180 likes | 263 Views
Artificial Intelligence. Why predicate calculus. Provides the ability to access individual assertions. e.g. in Predicate calculus we may say: P denotes “It rained on Tuesday” but in predicate calculus we may have a relation called weather(tuesday,rain).
E N D
Why predicate calculus • Provides the ability to access individual assertions. e.g. in Predicate calculus we may say: P denotes “It rained on Tuesday” but in predicate calculus we may have a relation called weather(tuesday,rain). Also we can have variables such as weather(X,rain)
Predicate calculus symbols • The set of letters, both upper and lower case, of English alphabet • The set of digits: 0, 1, … 9 • The underscore ‘_’ • Symbols begin with a letter and followed by any sequence of legal letters
Symbols (cont.) • Constant symbols begin with “small” letters • Symbols true and false are reserved constants • Variables are used to designate general classes of objects or properties. • Variables begin with “capital” letters
Functions • They start with “small” letters • They have arity, e.g. father(?) has one arity while Plus(?,?) has 2 arity, …etc. • Examples: f(X,Y), father(david), price(house)
Atomic sentences • Is a predicate of arity n followed by n terms enclosed in parentheses and separated by commas. • Examlpes: likes(ahmed,Chocolate) likes(X,ahmed) likes(X,Y) friends(aly,ahmed) friends(father_of(ahmed),father_of(aly))
Logical connectives ¬ (universal quantifier) (existential quantifier) Examples: Y friends(Y,peter) X likes(X,ice_cream)
Examples • Assume time and plus are function symbols of arity 2 and assume equal and good be predicate symbols of arity 2 and 3, respectively. plus(two,three) is a function and thus not an atomic sentence equal(plus(two,three),five) is an atomic sentence equal(plus(2,3),seven) is a sentence (although seems wrong computationally) X good(X,two,plus(two,three)) equal(plus(two,three),five) is a sentence (good(two,two,plus(two,three))) (equal(plus(three,two),five) true ) is a sentence
Example application of predicate calculus • mother(amina,aly) • mother(amina,mahmoud) • father(hasan,aly) • father(hasan,mahmoud) • X Y (father(X,Y) mother(X,Y) parent(X,Y)) • X Y Z (parent(X,Y) parent(X,Z) brother(Y,Z))
Predicate calculus semantics (by example) on(c,a) on(b,d) ontable(a) ontable(d) clear(b) clear(c ) hand_empty Rule describing when a block is clear: X(¬ Y on(Y,X)) clear(X)) (i.e. for all X, X is clear if there does not exist a Y such that Y is on X) c b a d
Example (cont.) • To stack one block on top of another: Assume we want to stack X on Y: • Empty the hand • Clear X • Clear Y • pick_up X and put_down X on Y X Y ((hand_empty clear(X) clear(Y) pick_up(X) put_down(X,Y)) stack(X,Y))
Using Inference Rules to produce predicate calculus expressions • An interpretation that makes a sentence true is said to satisfy that sentence. • An interpretation that satisfies every member of a set of expressions is said to satisfy the set.
Proof Procedure • A proof procedure is a combination of an inference rule and an algorithm for applying that rule to a set of logical expressions to generate new sentences • Defn: a predicate calculus expression X logically follows from a set S of predicate calculus expressions if every interpretation and assignment that satisfies S also satisfies X.
Important definitions • Modus ponens: If P is true and PQ is known to be true then we can infer Q. • Modus tollens: If P Q is known to be true and Q is known to be false we can infer ¬P • And elimination If PQ is true the P is true and Q is true • And introduction: If P and Q are true then PQ is true • Universal Instantiation: If a is from the domain of X, X p(X) lets us infer p(a)
Example on modus ponens • “If it is raining then the ground will be wet” and we know “It is raining” then: • P denotes “It is raining” • Q denotes “The ground is wet” • i.e. PQ is true and P is true then we can infer Q (i.e. The ground is wet)
Another example • “All men are mortal and Socrates is a man” “Is Socrates mortal?” • This sentence can be represented as: X (man(X) mortal(X)) man(socrates) • If we substitute socrates for X we get: man(scorates) moral(socrates) Then we can now infer: mortal(socrates)
Unification • Unification is an algorithm for determining the substitutions needed to make two predicate calculus expressions match. • Unification+inference rules (e.g. modus ponens) allow us to make inferences on a set of logical assertions. • To do this, the logical database must be expressed in an appropriate form.
Replacing existentially quantified variables • This is done by replacing all existentially quantified variables by their corresponding constants: e.g. X parent(X,tom) is being replaced by parent(bob,tom) or parent(mary,tom). • Complication : X Y mother(X,Y) where the value of Y is dependent on X