Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
RMDEC/DEPT OF CSE
A Knowledge-Based Agent A knowledge-based agent consists of a knowledge base (KB) and an inference engine (IE). A knowledge-base is a set of representations of what one knows about the world (objects and classes of objects, the fact about objects, relationships among objects, etc.) Each individual representation is called a sentence. The sentences are expressed in a knowledge representation language. Examples of sentences The moon is made of green cheese If A is true then B is true A is false All humans are mortal Confucius is a human
1
B.GAYATHRI DEVI, Asst. Prof/CSE
RMDEC/DEPT OF CSE
The Inference engine derives new sentences from the input and KB The inference mechanism depends on representation in KB The agent operates as follows:
1. It receives percepts from environment 2. It computes what action it should perform (by IE and KB) 3. It performs the chosen action (some actions are simply inserting inferred new facts into KB). KB can be viewed at different levels Knowledge Level. The most abstract level -- describe agent by saying what it knows. Example: A taxi agent might know that the Golden Gate Bridge connects San Francisco with the Marin County. Logical Level. The level at which the knowledge is encoded into sentences. Example: Links(GoldenGateBridge, SanFrancisco, MarinCounty).
Implementation Level. The physical representation of the sentences in the logical level. Example: (Links GoldenGateBridge, SanFrancisco, MarinCounty)
Representation, Reasoning, and Logic The objective of knowledge representation is to express knowledge in a computertractable form, so that agents can perform well. A knowledge representation language is defined by: Its syntax which defines all possible sequences of symbols that constitute sentences of the language (grammar to form sentences) Its semantics determines the facts in the world to which the sentences refer (meaning of sentences) Each sentence makes a claim about the world.
RMDEC/DEPT OF CSE
Semantics maps sentences in logic to facts in the world. The property of one fact following from another is mirrored by the property of one sentence being entailed by (inferred from) another
Logic as a KR language
Modal
Temporal
Non-monotonic Logic
AGENT PROGRAM
Like all our agents, it takes a percept as input and returns an action. The agent maintains a knowledge base, KB, KNOWLEDGE which may initially contain some background
3
B.GAYATHRI DEVI, Asst. Prof/CSE
RMDEC/DEPT OF CSE
knowledge. Each time the agent program is called, it does three things. First, it TELLS the knowledge base what it perceives. Second, it ASKS the knowledge base what action it should perform. In the process of answering this query, extensive reasoning may be done about the current state of the world, about the outcomes of possible action sequences, and so on. Third, the agent records its choice with TELL and executes the action. The second TELL is necessary to let the knowledge base know that the hypothetical action has actually been executed. MAKE-PERCEPT-SENTENCE constructs a sentence asserting that the agent perceived the given percept at the given time. MAKE-ACTION-QUERY constructs a sentence that asks what action should be done at the current time. Finally, MAKE-ACTION-SENTENCE constructs a sentence asserting that the chosen action was executed. Propositional Logic : Syntax Symbols: Logical constants: true (T), false (F) Propositional symbols: P, Q, S, ... logical connectives:
~ <=>
=>
Wrapping parentheses: ( ) A proposition (denoted by a proposition symbol) is a declarative statement which can be either true or false but not both or neither. The moon is made of green cheese (F)
RMDEC/DEPT OF CSE
2. Individual proposition symbols P, Q, ... are sentences 3. If S is a sentence, so is (S) 4. If S1 and S2 are sentences, so are S1 S2, S1 S2, S1 => S2, S1 <=> S2, ~ S1 1. Nothing else is a sentence Order of precedence of logical connectors ~ , , , => , <=> Minimum set of logical connectors (~ , ), or (~ , ) Atomic sentences: T, F, P, Q, ...
Examples of PL sentences P means "It is hot" Q means "It is humid" R means "It is raining" P ^ Q => R
"If it is hot and humid, then it is raining" Q => P "If it is humid, then it is hot"Q "It is humid."
RMDEC/DEPT OF CSE
Propositional Logic (PL): Semantics Need an interpretation of symbols for a given set of sentences Proposition symbols do not have meaning by themselves An interpretation connects proposition symbols to a statement about the world (which may be true or false in that world) An interpretation in PL can be defined as an assignment of truth values to all proposition symbols involved There are many interpretations for a given set of sentences (2^n if they involve n distinct proposition symbols) Example:
1: P: it is humid (T) Q: it is hot (T) P ^ Q is true 2: P: moon is made of green cheese (F) Q: I am happy (T) P ^ Q is false
Give a meaning to each logical connectives A connective is a function (boolean), It does not depend on any particular interpretations (universal to all PL sentences It can best be defined by a truth table
The truth table for may seem puzzling at first, because it might not quite fit one's intuitive understanding of "P implies Q" or "if P then Q." For one thing, propositional logic does not require any relation of causation or relevance between P and Q. This seems bizarre, but it makes sense if you think of "P Q" as saying, "If P is true, then I am claiming that Q is true. Otherwise I am making no claim." The only way for this sentence to be false is if P is true but Q is false.
6
B.GAYATHRI DEVI, Asst. Prof/CSE
RMDEC/DEPT OF CSE
Implication Approximating causal relationships Many logic theoreticians are not happy about the current definition for P = F
P => Q ~P v Q P <=> Q (P => Q) ^ (Q => P) Distribution law P ^ (Q v R) => P ^ Q v P ^ R P v (Q ^ R) => (P v Q) ^ (P v R) De Morgans law ~(P v Q v R) => ~P ^ ~Q ^ ~R ~(P ^ Q ^ R) => ~P v ~Q v ~R
RMDEC/DEPT OF CSE
A simple Knowledge Base(KB) Now that we have defined the semantics for propositional logic, we can construct a knowledge base for the wumpus world. For simplicity, we will deal only with pits
FORMULAS
RMDEC/DEPT OF CSE
Some terms A model is an interpretation of a set of sentences such that every sentence is True. A model is just a formal mathematical structure that "stands in" for the world. A sentence is satisfiable if it is True under some interpretation(s) A valid sentence or tautology is a sentence that is True under all possible interpretations, no matter what the world is actually like or what the semantics is, e.g., An inconsistent sentence or contradiction is a sentence that is False under all interpretations. The world is never like what it describes, e.g., P entails Q (Q is a logical consequence of P, Q logically follows P), written P |= Q, means that whenever P is True, so is Q. In other words, all models of P are also models of Q
Models of Complex Sentences (Venn diagrams)
16
RMDEC/DEPT OF CSE
Inference Rule Logical Inference is used to create new sentences X that logically follow from a given set of sentences S (in KB and from input), i.e., S |= X This kind of inference is also known as deduction Use truth table: Whether S |= X holds can be determined by whether S => X is a tautology S |= X holds iff every interpretation I that makes S true also makes X true
S => X is a tautology iff every interpretation I that makes S true also makes X true Example: P, P => Q |= Q because (P, P => Q) => Q is true under any interpretation Huge truth tables for inference involving large number of sentences
Use inference rules: generate new sentences X from a one or more existing sentences S. S is called the premise and X the conclusion of the rule. Proof procedure: a set of inference rules and a procedure of how to use these rules If X can be generated from S by proof procedure i, we say X is derived from S by i, denoted S |i X, or S | X. Soundness. An inference procedure is sound if every sentence X it produces from a set of sentences S logically follows from S. (No contradiction is created). if S | X then S |= X
Completeness. A inference procedure is complete, if it is able to produce every sentence that logically follows from any give S. if S |= X then S | X
Sound Inference Rules (deductive rules) Here are some examples of sound rules of inference. Each can be shown to be sound using a truth table -- a rule is sound if its conclusion is true whenever the premise is true.
10
RMDEC/DEPT OF CSE
RULES
Bi Conditional Elimination
11
RMDEC/DEPT OF CSE
RULE Modus Ponens Modus Tollens And Introduction And Elimination Or Introduction Double Negation Chaining Resolution rule Unit Resolution Resolution
PREMISE
A v B, ~A B A v B, ~B v C
AvC
Operates on two disjunctions of literals The pair of two opposite literals cancel each other, all other literals from the two disjunctions are combined to form a new disjunction as the inferred sentence Resolution rule can replace all other inference rules A, ~A v B ~B, ~A v B ~A v B, ~B v C B ~A ~A v C
21
12
RMDEC/DEPT OF CSE
Proving things A proof is a sequence of sentences, where each sentence is either a premise (also called an axiom) or a sentence derived from earlier sentences in the proof by one of the rules of inference. 1 2 3 4 5 6 The last sentence is the theorem (also called goal or query) that we want to prove. Complete proof procedure for PL has time complexity exponential to the number of premises Example for the "weather problem" given before. Q Q=>P P (P^Q)=>R P^Q R Premise Premise Modus Ponens(1,2) Premise And Introduction(1) Modus Ponens(4,5) It is humid if it is humid, it is hot It is hot If its hot & humid, its raining It is hot and humid It is raining
Proof by resolution
Q P
~Q v P
~P v ~Q v R
premises
~Q v R R
theorem
13
RMDEC/DEPT OF CSE
Theorem proving as search Start node: the set of given premises/axioms (KB + Input) Operator: inference rule (add a new sentence into parent node) Goal: a state that contains the theorem asked to prove Solution: a path from start node to a goal
Normal forms of PL sentences Disjunctive normal form (DNF) Any sentence can be written as a disjunction of conjunctions of literals. Examples: P ^ Q ^ ~R; A^B v C^D v P^Q^R; P
Conjunctive normal form (CNF) Any sentence can be written as a conjunction of disjunctions of literals. Examples: P v Q v ~R; (A v B) ^ (C v D) ^ (P v Q v R); P
Normal forms can be obtained by applying equivalence laws [(A v B) => (C v D)] => P ~[~(A v B) v (C v D)] v P [~~(A v B) ^ ~(C v D)] v P [(A v B)^(~C ^ ~D)] v P (A v B v P)^(~C^~D v P) (A v B v P)^(~C v P)^(~D v P) a CNF
Horn Sentences A Horn sentences is a disjunction of literals with at most one of these literals being nonnegated (positive). ~P1 v ~P2 v ~P3 ... v ~Pn v Q; or alternatively P1 ^ P2 ^ P3 ... ^ Pn => Q; (an implication or if-then rule)
RMDEC/DEPT OF CSE
P => Q ^ R P v Q => R
We will expand Horn sentences to Horn clauses in first order predicate logic later and give it more discussion then As we will see later, Horn clauses make automating logical inference easier.
PL is Too Weak a Representational Language Consider the problem of representing the following information: Every person is mortal. (S1) Confucius is a person. Confucius is mortal. (S2) (S3)
S3 is clearly a logical consequence of S1 and S2. But how can these sentences be represented using PL so that we can infer the third sentence from the first two? We can use symbols P, Q, and R to denote the three propositions, but this leads us to nowhere because knowledge important to infer R from P and Q (i.e., relationship between being a human and mortality, and the membership relation between Confucius and human class) is not expressed in a way that can be used by inference rules
Alternatively, we can use symbols for parts of each sentence P = "person; M = "mortal; C = "Confucius" The above 3 sentences can be roughly represented as:
S2: C => P; S1: P => M; S3: C => M. Then S3 is entailed by S1 and S2 by the chaining rule. Confucius (and person and mortal) are not PL sentences (not a declarative statement) and cannot have a truth value. What does P => M mean?
Bad semantics
We need infinite distinct symbols X for individual persons, and infinite implications to connect these X with P (person) and M (mortal) because we need a unique symbol for each individual.
15
RMDEC/DEPT OF CSE
Person_n => P; person_n => M Weakness of PL Hard to identify "individuals." E.g., Mary, 3 Individuals cannot be PL sentences themselves.
Difficult to directly and clearly talk about properties of individuals or relations between individuals (hard to connect individuals to class properties). E.g., property of being a human implies property of being mortal
Generalizations, patterns, regularities can't easily be represented. All members of a class have this property Some member of a class have this property
A better representation is needed to capture the relationship (and distinction) between objects and classes, including properties belonging to classes and individuals First-Order Logic (abbreviated FOL or FOPC) is expressive enough to concisely represent this kind of situation by separating classes and individuals Explicit representation of individuals and classes, x, Mary, 3, persons. Adds relations, variables, and quantifiers, e.g., Every person is mortal Forall X: person(X) => mortal(X) There is a white alligator There exists some X: Alligator(X) ^ white(X)
16
RMDEC/DEPT OF CSE
classes of objects (often defined by properties) e.g., human, mammal, machine, ... relations that hold among objects e.g., brother of, bigger than, outside, part of, has color, occurs after, owns, a functions which are a subset of the relations in which there is only one ``value'' for any given ``input''. e.g., father of, best friend, second half, one more than
Introduction:
17
RMDEC/DEPT OF CSE
RMDEC/DEPT OF CSE
The objects in the model may be related in various ways. In the figure, Richard and John are brothers. Formally speaking, a relation is just the set of tuples of objects that are related. (A tuple is a collection of objects arranged in ,a fixed order and is written with angle brackets surrounding the objects.) Thus, the brotherhood relation in this model is the set
A model containing five objects, two binary relations,three unary relations (indicated by labels on the objects), and one unary function, left-leg.
The crown is on King John's head, so the "on head relation contains just one tuple, (the crown, King John). The "brother" and "on head" relations are binary relations-that is, they relate pairs of objects. The model also contains unary relations, or properties: the "person" property is true of both Richard and John; the "king" property is true only of John (presumably because Richard is dead at this point); and the "crown" property is true only of the crown. Certain kinds of relationships are best considered as functions, in that a given object must be related to exactly one object in this way. For example, each person has one left leg, so the model has a unary "left leg" function that includes the following mappings:
19
RMDEC/DEPT OF CSE
Symbols and Interpretations The basic syntactic elements of first-order logic are the symbols that stand for objects, relations, and functions. The symbols, therefore, come in three kinds: constant symbols, which stand for objects; predicate symbols, which stand for relations; and function symbols, which stand for functions. We adopt the convention that these symbols will begin with uppercase letters. For example, we might use the constant symbols Richard and John; the predicate symbols Brother, OnHead, Person, King, and Crown; and the function symbol LeftLeg. As with proposition symbols, the choice of names is entirely up to the user. Each predicate and function symbol comes with an arity that fixes the number of arguments. The semantics must relate sentences to models in order to determine truth. For this to happen, we need an interpretation that specifies exactly which objects, relations and functions are referred to by the constant, predicate, and function symbols. One possible interpretation for our examplewhich we will call the intended interpretation-is as follows: Richard refers to Richard the Lionheart and John refers to the evil king John. Brother refers to the brotherhood relation, LeftLeg refers to the "left leg" function
Terms A term is a logical expression that refers to an object. Constant symbols are therefore terms, but it is not always convenient to have a distinct symbol to name every object. For example, in English we might use the expression "King John's left leg" rather than giving a name to his leg. This is what function symbols are for: instead of using a constant symbol, we use LeftLeg(John). Atomic sentences Now that we have both terms for referring to objects and predicate symbols for referring to relations, we can put them together to make atomic sentences that state facts. An atomic sentence is formed from a predicate symbol followed by a parenthesized list of terms:
20
RMDEC/DEPT OF CSE
Complex sentences We can use logical connectives to construct more complex sentences, just as in propositional calculus. The semantics of sentences formed with logical connectives is identical to that in the propositional case.
Quantifiers Once we have a logic that allows objects, it is only natural to want to express properties of entire collections of objects, instead of enumerating the objects by name. Quantifiers let us do this. First-order logic contains two standard quantifiers, called universal and existential.
21
RMDEC/DEPT OF CSE
The second rule, "All kings are persons,'' is written in first-order logic as
22
RMDEC/DEPT OF CSE
says that the object referred to by Father(John) and the object referred to by Henry are the same. Because an interpretation fixes the referent of any term, determining the truth of an equality sentence is simply a matter of seeing that the referents of the two terms are the same object.
23
RMDEC/DEPT OF CSE
24
RMDEC/DEPT OF CSE
25
RMDEC/DEPT OF CSE
1. Identify the task. The knowledge engineer must delineate the range of questions that the knowledge base will support and the kinds of facts that will be available for each specific problem instance. For example, does the wumpus knowledge base need to be able to choose actions or is it required to answer questions only about the contents of the
26
RMDEC/DEPT OF CSE
environment? Will the sensor facts include the current location? The task will determine what knowledge must be represented in order to connect problem instances to answers.
2. Assemble the relevant knowledge. The knowledge engineer might already be an expert in the domain, or might need to work with real experts to extract what they know-a process called knowledge acquisition. At this stage, the knowledge is not represented formally. The idea is to understand the scope of the knowledge base, as determined by the task, and to understand how the domain actually works.
3. Decide on a vocabulary of predicates, functions, and (constants. That is, translate the important domain-level concepts into logic-level names. This involves many questions of knowledge engineering style. Like programming style, this can have a significant impact on the eventual success of the project. For example, should pits be represented by objects or by a unary predicate on squares? Should the agent's orientation be a function or a predicate? Should the wumpus's location depend on time?
4. Encode general /knowledge about the domain. The knowledge engineer writes down the axioms for all the vocabulary terms. This pins down (to the extent possible) the meaning of the terms, enabling the expert to check the content. Often, this step reveals misconceptions or gaps in the vocabulary that must be fixed by returning to step 3 and iterating through the process. 5. Encode a description of the specific problem instance. If the ontology is well thought out, this step will be easy. It will involve writing simple atomic sentences about instances of concepts that are already part of the ontology. For a logical agent, problem instances are supplied by the sensors, whereas a "disembodied" knowledge base is supplied with additional sentences in the same way that traditional programs are supplied with input data.
6. Pose queries to the inference procedure and get answers. This is where the reward is: we can let the inference procedure operate on the axioms and problem-specific facts to derive the facts we are interested in knowing.
7. Debug the knowledge base. Alas, the answers to queries will seldom be correct on the first try. More precisely, the answers will be correct for the knowledge base as written, assuming that
27
B.GAYATHRI DEVI, Asst. Prof/CSE
RMDEC/DEPT OF CSE
the inference procedure is sound, but they will not be the ones that the user is expecting. For example, if an axiom is missing, some queries will not be answerable from the knowledge base. A considerable debugging process could ensue.
INFERENCE IN FIRST-ORDER LOGIC
Inference rules for quantifiers Let us begin with universal quantifiers. Suppose our knowledge base contains the standard folkloric axiom stating that all greedy kings are evil:
The rule of Universal Instantiation (UI for short) salys that we can infer any sentence obtained by substituting a ground term (a term without varialbles) for the variable.
For example, once we have added the sentence Kill(Murderer, Victim), we no longer need the sentence
28
B.GAYATHRI DEVI, Asst. Prof/CSE
RMDEC/DEPT OF CSE
Kill(x, Victim). Strictly speaking, the new knowledge base is not logically equivalent to the old, but it can be shown to be inferentially equivalent in the sense that it is satisfiable exactly when the original knowledge base is satisfiable. Reduction to propositional inference Once we have rules for inferring nonquantified sentences from quantified sentences, it becomes possible to reduce first-order inference to propositional inference.
This technique of propositionalization can be made completely general, that is, every firstorder knowledge base and query can be propositionalized in such a way that entailment is preserved.
29
RMDEC/DEPT OF CSE
EXAMPLES
Syntax of FOL Predicates: P(x[1], ..., x[n]) P: predicate name; (x[1], ..., x[n]): argument list
A special function with range = {T, F}; Examples: human(x), /* x is a human */ /* x is the father of y */
father(x, y)
When all arguments of a predicate is assigned values (said to be instantiated), the predicate becomes either true or false, i.e., it becomes a proposition. Father(Fred, Joe) Ex.
A predicate, like a membership function, defines a set (or a class) of objects Constants are terms (e.g., Fred, a, Z, red, etc.) Variables are terms (e.g., x, y, z, etc.), a variable is instantiated when it is assigned a constant as its value Functions of terms are terms (e.g., f(x, y, z), f(x, g(a)), etc.) A term is called a ground term if it does not involve variables Predicates, though special functions, are not terms in FOL
Quantifiers
Universal quantification (or forall) (x)P(x) means that P holds for all values of x in the domain associated with that variable. E.g., (x) dolphin(x) => mammal(x) (x) human(x) => mortal(x)
30
RMDEC/DEPT OF CSE
Universal quantifiers often used with "implication (=>)" to form "rules" about properties of a class (x) student(x) => smart(x) (All students are smart)
Often associated with English words all, everyone, always, etc. You rarely use universal quantification to make blanket statements about every individual in the world (because such statement is hardly true) (x)student(x)^smart(x) means everyone in the world is a student and is smart.
Existential quantification (x)P(x) means that P holds for some value(s) of x in the domain associated with that variable. E.g., (x) mammal(x) ^ lays-eggs(x) (x) taller(x, Fred) (x) UMBC-Student (x) ^ taller(x, Fred) Existential quantifiers usually used with ^ (and)" to specify a list of properties about an individual. (x) student(x) ^ smart(x) (there is a student who is smart.) A common mistake is to represent this English sentence as the FOL sentence: (x) student(x) => smart(x) It also holds if there no student exists in the domain because student(x) => smart(x) holds for any individual who is not a student. Often associated with English words someone, sometimes, etc.
Scopes of quantifiers Each quantified variable has its scope (x)[human(x) => (y) [human(y) ^ father(y, x)] All occurrences of x within the scope of the quantified x refer to the same thing.
31
B.GAYATHRI DEVI, Asst. Prof/CSE
RMDEC/DEPT OF CSE
Switching the order of universal quantifiers does not change the meaning: (x)(y)P(x,y) <=> (y)(x)P(x,y), can write as (x,y)P(x,y)
Similarly, you can switch the order of existential quantifiers. (x)(y)P(x,y) <=> (y)(x)P(x,y)
Switching the order of universals and existential does change meaning: Everyone likes someone: (x)(y)likes(x,y) Someone is liked by everyone: (y)(x) likes(x,y)
Sentences are built from terms and atoms A term (denoting a individual in the world) is a constant symbol, a variable symbol, or a function of terms. An atom (atomic sentence) is a predicate P(x[1], ..., x[n]) Ground atom: all terms in its arguments are ground terms (does not involve variables) A ground atom has value true or false (like a proposition in PL)
A literal is either an atom or a negation of an atom A sentence is an atom, or, ~P, P v Q, P ^ Q, P => Q, P <=> Q, (P) where P and Q are sentences If P is a sentence and x is a variable, then (x)P and (x)P are sentences
A well-formed formula (wff) is a sentence containing no "free" variables. i.e., all variables are "bound" by universal or existential quantifiers.
(x)P(x,y) has x bound as a universally quantified variable, but y is free. Translating English to FOL Every gardener likes the sun. (x) gardener(x) => likes(x,Sun) Not Every gardener likes the sun. ~((x) gardener(x) => likes(x,Sun))
32
RMDEC/DEPT OF CSE
You can fool some of the people all of the time. (x)(t) person(x) ^ time(t) => can-be-fooled(x,t)
You can fool all of the people some of the time. (x)(t) person(x) ^ time(t) => can-be-fooled(x,t) (the time people are fooled may be different)
You can fool all of the people at some time. (t)(x) person(x) ^ time(t) => can-be-fooled(x,t) (all people are fooled at the same time)
You can not fool all of the people all of the time. ~((x)(t) person(x) ^ time(t) => can-be-fooled(x,t))
Everyone is younger than his father (x) person(x) => younger(x, father(x))
All purple mushrooms are poisonous. (x) (mushroom(x) ^ purple(x)) => poisonous(x)
No purple mushroom is poisonous. ~(x) purple(x) ^ mushroom(x) ^ poisonous(x) (x) (mushroom(x) ^ purple(x)) => ~poisonous(x)
There are exactly two purple mushrooms. (x)(Ey) mushroom(x) ^ purple(x) ^ mushroom(y) ^ purple(y) ^ ~(x=y) ^ (z) (mushroom(z) ^ purple(z)) => ((x=z) v (y=z))
X is above Y if X is directly on top of Y or there is a pile of one or more other objects directly on top of one another starting with X and ending with Y. (x)(y) above(x,y) <=> (on(x,y) v (z) (on(x,z) ^ above(z,y)))
33
B.GAYATHRI DEVI, Asst. Prof/CSE
RMDEC/DEPT OF CSE
Example: A simple genealogy KB by FOL Build a small genealogy knowledge base by FOL that Facts: husband(Joe, Mary), son(Fred, Joe) spouse(John, Nancy), male(John), son(Mark, Nancy) father(Jack, Nancy), daughter(Linda, Jack) daughter(Liz, Linda) etc. contains facts of immediate family relations (spouses, parents, etc.) contains definitions of more complex relations (ancestors, relatives) is able to answer queries about relationships between people
Predicates: parent(x, y), child (x, y), father(x, y), daughter(x, y), etc. spouse(x, y), husband(x, y), wife(x,y) ancestor(x, y), descendent(x, y) relative(x, y)
Rules for genealogical relations (x,y) parent(x, y) <=> child (y, x) (x,y) father(x, y) <=> parent(x, y) ^ male(x) (similarly for mother(x, y)) (x,y) daughter(x, y) <=> child(x, y) ^ female(x) (similarly for son(x, y)) (x,y) husband(x, y) <=> spouse(x, y) ^ male(x) (similarly for wife(x, y)) (x,y) spouse(x, y) <=> spouse(y, x) (spouse relation is symmetric) (x,y) parent(x, y) => ancestor(x, y) (x,y)(z) parent(x, z) ^ ancestor(z, y) => ancestor(x, y) (x,y) descendent(x, y) <=> ancestor(y, x) (x,y)(z) ancestor(z, x) ^ ancestor(z, y) => relative(x, y) (related by common ancestry) (x,y) spouse(x, y) => relative(x, y) (related by marriage)
34
B.GAYATHRI DEVI, Asst. Prof/CSE
RMDEC/DEPT OF CSE
(x,y)(z) relative(z, x) ^ relative(z, y) => relative(x, y) (transitive) (x,y) relative(x, y) => relative(y, x) (symmetric) Queries ancestor(Jack, Fred) /* the answer is yes */ relative(Liz, Joe) /* the answer is yes */
relative(Nancy, Mathews)
/* no answer in general, no if under closed world assumption */ Connections between Forall and Exists It is not the case that everyone is ... is logically equivalent to There is someone who is NOT ... No one is ... is logically equivalent to All people are NOT ... We can relate sentences involving forall and exists using De Morgans laws:
~(x)P(x) <=> (x) ~P(x) ~(x) P(x) <=> (x) ~P(x) (x) P(x) <=> ~(x) ~P(x) (x) P(x) <=> ~ (x) ~P(x) Example: no one likes everyone ~ (x)(y)likes(x,y) (x)(y)~likes(x,y)
Semantics of FOL Domain M: the set of all objects in the world (of interest) Interpretation I: includes Assign each constant to an object in M Define each function of n arguments as a mapping M^n => M Define each predicate of n arguments as a mapping M^n => {T, F} Therefore, every ground predicate with any instantiation will have a truth value In general there are infinite number of interpretations because |M| is infinite
35
B.GAYATHRI DEVI, Asst. Prof/CSE
RMDEC/DEPT OF CSE
Define of logical connectives: ~, ^, v, =>, <=> as in PL Define semantics of (x) and (x) (x) P(x) is true iff P(x) is true under all interpretations (x) P(x) is true iff P(x) is true under some interpretation
Model: an interpretation of a set of sentences such that every sentence is True A sentence is satisfiable if it is true under some interpretation valid if it is true under all possible interpretations inconsistent if there does not exist any interpretation under which the sentence is true
Axioms, definitions and theorems Axioms are facts and rules which are known (or assumed) to be true facts and concepts about a domain. Mathematicians don't want any unnecessary (dependent) axioms -- ones that can be derived from other axioms. Dependent axioms can make reasoning faster, however. Choosing a good set of axioms for a domain is a kind of design problem.
A definition of a predicate is of the form P(x) <=> S(x) (define P(x) by S(x)) and can be decomposed into two parts Necessary description: P(x) => S(x) (only if) Sufficient description P(x) <= S(x) (if) Some concepts dont have complete definitions (e.g. person(x))
36