390 likes | 459 Views
Artificial Intelligence 605451. Chapter 3. Propositional calculus Predicate calculus. Dr.Hassan Al-Tarawneh. Propositional Calculus Symbols. They symbols of propositional calculus are the propsositional symbols P, Q, R, S ….. Truth symbols true, false Connectives
E N D
Artificial Intelligence 605451 Chapter 3 Propositional calculus Predicate calculus Dr.Hassan Al-Tarawneh
Propositional Calculus Symbols • They symbols of propositional calculus are the propsositional symbols • P, Q, R, S ….. • Truth symbols • true, false • Connectives • • An interpretation of a set of propositions is the assignment of truth value, either T or F • true is always assigned T • false is always assigned F
Propositional Calculus Semantics • Negation P,
Propositional Calculus Semantics • Conjunction,
Propositional Calculus Semantics • Disjunction,
Propositional Calculus Semantics • Implication, • P is the premise or antecedent • Q is the conclusion or consequent
Propositional Calculus Semantics • Equivalence,
Identities • (P ) P • (P Q) P Q • Contrapositive law (P Q) ( Q P) • De Morgan’s Law (P Q) ( P Q) (P Q) ( P Q)
Identities • The commutative laws (P Q) (Q P) (P Q) (Q P) • The associative law ((P Q) R) (P (Q R)) ((P Q) R) (P (Q R))
Identities • The Distributive law(it is wrong ) P (Q R) (P Q) (Q R)) P (Q R) (P Q) (Q R)) • P(Q R) = (P Q) (P R)
Predicate Calculus • In propositional calculus, • P would denote “it rained on Tuesday” • In predicate calculus • weather(tuesday, rain) • Using variables • weather(X, rain) • X is a day of the week
Predicate Calculus Symbols • The alphabet that makes up the symbols of the predicate calculus consists of • The set of letter, both upper- and lowercase • The set of digits, 0, 1, …, 9. • The underscore, _.
Predicate Calculus Symbols • Symbols in the predicate calculus begin with a letter and are followed by any sequence of these legal characters a R 6 9 p _ z • Example of characters not in the alphabet include : # % @ / & • Legitimate predicate calculus symbols include • George fire3 tom_and_jerry bill XXXX friend_of • Example of strings that are not legal symbols are • 3jack “no blacks allowed” ab%cd ***71 duck!!!
Predicate Calculus Symbols • likes(george, kate) • ( ) - parentheses • , - commas • . - period
Predicate Calculus Symbols • Truth symbols • true and false • Constants • Must be lower case • goerge, tree
Predicate Calculus Symbols • Variables • Represented by symbols • Begin with upper case • George, BILL, Kate (correct) • geORGE, bill (wrong) • Functions • Begin with lower case • Denoted mapping • Each function had an associated arity • father (jack) – one arity • plus(2,3) – two arity
Predicate Calculus Symbols • A predicate calculus term is either a constant, variable or function expression • Example cat constant times(2,3) function X variable blue constant mother(jane) function kate constant
Atomic sentences • An atomic sentence is a predicate constant of arity n, followed by n terms, t1, t2 … tn, enclosed in parentheses and separated by comas • The truth values, true and false are also atomic sentences • Example likes(george,kate) likes(X,george) likes(X,X) likes(george,sarah,tuesday) friends(bill,richard) friends(father_of(david),father_of(andrew))
Advantages of Predicate Calculus • Allows the access to individual components of a proposition • plays(ahmad,fooball) • Allows to determine the relationship between individuals or objects and their properties • Allows expressions to contain variable, enabling general assertions about classes of entities • plays(X, football) [X refer to humans that play football] • plays(ahmad, Y) [Y refer to class of games] • Through inference rules we can manipulate expression to infer new sentences • team_mates(X, Y) plays (X, football) plays (Y, football) • team_mates(ahmad, ali) plays (ahmad, football) plays (ali, football)
Predicate Calculus • We can combine atomic sentences using logical operators to from sentences in the predicate calculus. • Logical connectives are is the universal quantifier, indicating that the sentence is true for all values of the Is the existential quantifier indicating that the sentence is true for at least one value in the domain
Examples • Marcus was a man • man(marcus) • Marcus was a Pompeian • pompeian(marcus) • All pompeians were Romans • X pompeian(X) roman(X) • Caesar was a ruler • ruler(ceaser)
Examples • All romans were either loyal to Caesar or hated him • X roman(X) loyal_to(X, caeser) hate(X, caeser) • Everyone it loyal to someone • X Y loyal_to(X,Y) • People try to assassinate rulers that they are not loyal to • X Y person(X) ruler (Y) tryassassinate (X,Y) loyalto(X,Y) • Marcus tried to assassinate Caesar • tryassassinate(marcus,caesar)
Predicate Calculus Sentences • Every atomic sentence is a sentence • If s is a sentence, then also its negation, s. • If s1 and s2 is a sentence, then also their conjunctions, s1 s2. • If s1 and s2 is a sentence, then also their disjunctions, s1 s2. • If s1 and s2 is a sentence, then also their implication, s1 s2. • If s1 and s2 is a sentence, then also their equivalence, s1 s2. • If X is a variable and s is a sentence, then X is a sentence • If X is a variable and s is a sentence, then X is a sentence
Predicate Calculus Semantic • friends(george,susie) = T if true • friends(george,kate) = F if false • friends(george,X) • X is a place holder • Substitute X with katie or susie • X is for all constants • Can have any other name, Y or PEOPLE
Predicate Calculus Semantic • In predicate calculus variable must be quantified • universally • existentially • Free variables • If it is not within the scope of the universal or existential quantifier • Closed expression • If its variables are quantified • Ground expression • Has no variables at all • X (p(X) q (Y) r(X)) • X is universally quantified to p(X) and r(X)
Universal Quantification • Problem computing the truth table of a sentence • All possible values of a variable must be tested to see whether the expression remains true • X likes(george,X) • X is all humans
Universal Quantification • Propositional calculus does not use variables • Has finite no of possible truth assignment • Can test all assignments • Done with truth table
Existential Quantifier • Evaluating the truth expression is also not easy. • Determine the truth by trying substitution until one is found that makes the expression true. • If the domain is infinite, algorithm will not halt
Universal & Existential Quantification • Relationships X p(X) X p(X) X p(X) X p(X) X p(X) Y p(Y) X q(X) Y q(Y) X (p(X) q(X)) X p(X) Y p(Y) X (p(X) q(X)) X p(X) Y p(Y)
Clauses to Predicate Calculus • If it doesn’t rain on Monday, Tom will go to the mountains weather(rain,Monday) go(tom,mountains) • Emma is a Doberman and a good dog gooddog(emma) isa(emma,doberman) • All basketball players are tall X(basketball_player(X) tall(X)) • Some people like anchovies X (person(X) likes(X,anchovies)) • If wished were horses, beggars would ride equal(wishes,horses) ride(beggars) • Nobody likes taxes X likes(X, takes)
Inference Rules • Logical inference • Ability to infer correct expression from a set of true assertions • New expression consistent with all previous interpretation of the original expression
Inference Rules • A mechanical means of producing new predicate calculus sentences from other sentences • Example : modus ponens
Inference Rules • If the sentence P and P Q are know to be true, then modus ponens lets us infer Q • Under the inference rule modus tollens, if P Q is know to be true and Q is known to be false, we can infer P.
Inference Rules • Elimination allows us to infer the truth of either of the conjuncts from the truth of a conjunctive sentence. For instance, P Q lets us conclude P and Q are true. • Introduction allows us to infer the truth of conjunction from the truth of its conjuncts. For instance, if P and Q are true, then P Q is true
Inference Rules • Universal instantiation states that if any universally quantified variable in a true sentence is replaced by an appropriate term from the domain, the results is a true sentence • Thus, if a is from the domain of X, X p(X) lets us infer p(a)
Modus ponen • X (man(X) mortal (X)) • man(socrates) • (man(socrates) mortal (socrates))
Unification • Unification is an algorithm for determining the substitutions needed to make two predicate calculus expression match • foo(X,a,goo(Y)) • legal substitutes • foo(fred,a,goo(Z)) {fred/X, Z/Y} • foo(W,a,goo(jack)) {W/X, jack/Y} • foo(Z,a,goo(moo(Z))) {Z/X, moo(Z)/Y} • X/Y indicates X is substituted for the variable Y in the original expression
Unification Issues • Variable can be substituted by constant, but constant cannot be replaced with a constant • Not allowed p(p(p(…X))) • Must maintain consistency across all occurrence of the variable in the expression matched • X = socrates in man(X) and mortal(X)
Unification Issues • Once a variable is substituted, future unification and inference must take the value of this substitution into account • {X/Y, W/Z} {V/X} {a/V, f(b)/W} => {a/Y,f(b)/Z} • Use most general unification • p(X) p(Y) => {fred/X, fred/Y} • most general => {Z/X, Z/Y}