Presentation is loading. Please wait.

Presentation is loading. Please wait.

Predicate Logic Colin Campbell. A Formal Language Predicate Logic provides a way to formalize natural language so that ambiguity is removed. Mathematical.

Similar presentations

Presentation on theme: "Predicate Logic Colin Campbell. A Formal Language Predicate Logic provides a way to formalize natural language so that ambiguity is removed. Mathematical."— Presentation transcript:

1 Predicate Logic Colin Campbell

2 A Formal Language Predicate Logic provides a way to formalize natural language so that ambiguity is removed. Mathematical arguments (proofs) are usually written in pseudo logic. Many programming languages involve elements of predicate logic. e.g. if..then

3 Predicate vs Propositional Logic Predicate logic uses the same connectives as propositional logic but allows you to refer to different elements of the universe. It also introduces quantifiers…so you can say things like.. It always rains in England. Sometimes it is sunny in Bristol.

4 Propositional Logic Revised Propositional Logic is a formal approach to reasoning with or about declarative sentences. If David likes Mary then Mary likes David David likes Mary Mary likes David

5 Semantics vs Proof Theory There are two approaches to reasoning in propositional logic. Semantics = truth tables and valuations Proof theory = formal notion of proof from axioms and inference rule

6 Truth-Tables The truth value of compound sentences can then be determined by application of truth tables defined for each connective A A tftf ftft AB A B tftftftf ttffttff tffftfff AB tftftftf ttffttff ttftttft etc A sentence B truth-functionally follows from sentence A if for every row of the truth-table in which A is true B is also true. Denoted A|=B

7 Formal Proof T=set of assumptions (sentences) then T|-A if we can generate a sequence of sentences S 1,S 2,…,S i-1,S i,…,S n =A Where either Si=axiom = a sentence in T (an assumption) or S 1,…,S i-1 (inference rule) S i Axioms for propositional logic 1.A (B A) 2.(A (B C)) ((A B) (A C)) 3.( B A) (( B A) B) Inference Rule: Modus Ponens From A,A B infer B

8 Relating Semantics and Proof Soundness Proof theory Semantics Completeness Semantics Proof theory Propositional logic is sound and complete Semantics = Proof theory

9 Decidability A formal logic is decidable if there is a mechanical (algorithmic) way of determining whether A follows from T. T|=A ? yes No Propositional logic is decidable: at worst we need only consider every row of the truth- table for which T is true, and there are only finitely many.

10 Predicate Logic: Introducing Quantifiers Predicate logic allows for quantified statements by introducing the quantifiers for all and there exists. Why do we need quantifiers ? Consider All birds have wings Tweety is a bird Therefore, Tweety has wings Propositional logic: All birds have wings= (Robins have wings) (Crows have wings) (Eagles have wings)..........etc. This is impractical.

11 Quantifiers 2: In predicate logic this translates to B(x)= x is a Bird, W(x)=x has wings, x (B(x) W(x)) = For all x, if x is a bird then x has wings B(Tweety)=Tweety is a bird. W(Tweety)=Tweety has wings Unlike propositional logic, predicate logic has variables- in this case x. It also has constants – in this case Tweety Tweety is an instantiation of the predicates B and W.

12 Functions It is also desirable to be able to represent functional relationships in predicate logic. Consider Blue eyed people have blue eyed fathers Some people have blue eyes Therefore, some peoples fathers have blue eyes Translates to x is a variable ranging across all people BE(x) -means person x has blue eyes F is a function mapping from one person x to another person F(x), where F(x) is the father of x

13 Syntax: Building Blocks for Predicate Logic Formula in predicate are built up from the following elements (1) Predicates: PL is a set of n-ary predicates. e.g. B(x)=x is a bird –unary M(x,y)=x is married to y –binary BT(x,y,z)=y is between x and z –tertiary

14 Syntax (2) (2) Functions: FNL is a set of n-ary functions. F(x)=Father of x, D(x,y,z)=Day of the weeks falling on the date x/y/z. (3) Constants: CL is a set of constants e.g. Tweety, numbers, Aunty Ethel (4) Variables: a set of variables, x,y,z etc (5) Connectives, Quantifiers and Brackets:,,,,, (,),[,]

15 Terms Terms are possible instantiations of predicates. The set of terms TL is defined recursively in the following way: (i) All variables and constants are terms (ii) If f is an n - ary function symbols and t 1....t n are terms then f(t 1....t n ) is a term. FNL={father, mother, first-child}, CL={bill}, VL={x} - ranging across parents x, bill, father(x), mother(x), first-child(x), father(bill), mother(bill), first-child(bill), father(father(x)), father(mother(x)), first-child(father(x)) father(father(bill)), father(mother(bill)),.......etc

16 Formula in Predicate Logic Atomic Formula: The atomic formula ATL, have the form P(t 1,...., t n ) where P is an n-ary relation in PL and ti are terms for i=1,...,n E.g. PNL={Rich,Happy}, FNL={father,mother},CL={jim, fred, mary}, VL={x,y} Atomic formula include…Rich(x), Happy(y), Rich(bill), Happy(father(y)), Rich(mother(mary)), Happy(father(mother(x))) etc

17 Formula 2 Well-Formed Formula: The set of well-formed formula WFL is defined recursively as follows: (i) all atomic formula are well-formed formula (ii) If F and G are well-formed formula so are ( F), (F G), (F G), (F G), (F G) (iii) If F is a well-formed formula and x VL then ( x F ) and ( x F ) are well-formed formula. E.g. Rich(x) Happy(x), Rich(x) Happy(y), Rich(bill) Happy(father(fred)), ( x Happy(x)) yRich(y)), x(Rich(x) Happy(x))

18 Translating from Logic to English Example: PL ={married, younger-than, equal} all binary VL={x,y,z} ranging over all parents CL={bill, john, george, mary} FNL={father, mother, first-child} -all unary Connectives,,,, Quantifiers,, Brackets married(mary,john) translates to Mary is married to John equal(father(bill),george) translates to George is the father of Bill equal(mother(mother(bill)),mary) translates to Mary is the maternal grandmother of Bill (equal(mother(x),y) equal(father(x),y)) translates to y is a parent of x x y(married(x,y) married(y,x)) translates to for any parents x and y if x is married to y then y is married to x x y(equal(mother(x),y) translates to everyone has a mother

19 Translating from English to Logic Anyone who is persistent can learn logic translates to x(persistent(x) learn(x, logic)) All blocks which are on top of or attached to blocks which have been moved, have also been moved translates to x y((block(x) block(y) (ontop(x,y) attached(x,y)) moved(y)) moved(x)) You can fool some of the people all of the time, and you can fool all the people some of the time, but you cant fool all the people all the time translates to x y(person(x) time(y) fool-at(y,x)) y x(person(x) time(y) fool-at(y,x)) ( x y (person(x) time(y) fool-at(y,x)))

20 Removing Ambiguity Bertrand Russell gave the following example of how translating to logic can remove ambiguity. Consider the sentence The current king of France is bald. Is this sentence true? Translating to logic gives: x(KF(x) B(x)) KF(x)= x is the current king of France. B(x)= x is bald. This is clearly false! Why?

21 Whoops-Missed a bit Its only me! So the correct translation is xKF(x) x(KF(x) y(KF(y) equals(x,y))) x(KF(x) B(x)) Still false though! What about the current king of France is not bald – is it true or false?

22 Declarative Formula Some formula have a truth-value while others dont. x y(equal(mother(x),y) has a truth-value So does x(Rich(x) Happy(x)) But neither Rich(x) nor married(x,y) married(y,x) have truth values. In predicate logic declarative formula are closed. Non-declarative form are open.

23 Open and Closed Formula Scope of a Quantifier: The scope of x (resp. x) in x F (resp x F) is F E.g. In x(Rich(x) Happy(x)) the scope of x is (Rich(x) Happy(x)) In x y(equal(mother(x),y) the scope of x is y(equal(mother(x),y) and the scope of y is (equal(mother(x),y) Free and Bound Occurrence of a Variable: A bound occurrence of a variable in a formula is an occurrence immediately following a quantifier or an occurrence within the scope of a quantifier, which has the same variable immediately after the quantifier. Any other variable is free.

24 Open and Closed:2 Example: In the formula ( xP(x,y)) Q(x) the occurrence of x in P(x,y) is bound but the occurrence of x in Q(x) is free. All occurrences of x in x(P(x,y) Q(x)) are bound. Open and Closed Formula: A closed formula is a well-formed formula with no free occurrences of any variable. An open formula is a formula that is not closed Example: x y(equal(mother(x),y) is closed since all occurrences of x fall within the cope of x and all occurrences of y fall within the sope of y.

25 Interpretations Really a language of predicate logic is only a set of symbols which can be interpreted in different ways. Consider the formula: y xP(x,y) Quantification over natural numbers, P(x,y) means x y then interpretation is `for all natural numbers x there is some natural y for which x y Quantification over people, P(x,y) means `y is the father of x then interpretation is `there is some who is the father of everyone

26 Interpretations:2 Formal Logic PL={P,Q,R,..} FL={f,g,h,..} CL={a,b,c,..} U1U1 U2U2 I PL I ={P I,Q I,R I,..} FL I ={f I,g I,h I,..} CL I ={a I,b I,c I,..} J PL J ={P J,Q J,R J,..} FL J ={f J,g J,h J,..} CL J ={a J,b J,c J,..}

27 Theories and Models Theory: A theory of a language of predicate logic L is any finite set of closed well-formed formula of L. Model: A model of a theory T is an interpretation of L under which all the formula in T are true.

28 Satisfiability A theory of L, is satisfiable if it has at least one model. Any theory that is not satisfiable is said to be inconsistent. Any theory for which every possible interpretation is a model is said to be valid.

29 Satisfiability: 2 The theory consisting of the single formula x(P(x) P(x)) is inconsistent. The theory { x (P(x) P(x))} is valid.

30 Example Consider the following theories: Also consider the following two interpretations Interpretation I: Let U 1 be the set of all integers, c I =0, f I is the successor function, P I is > Interpretation J: Let U 2 be the set of all integers, c J =0, f J is the predecessor function, P I is

31 Example: 2 Under I T 1 means If for every integer x there is some integer y such that x>y then 0>0+1 Clearly this is false since the antecedent is true and the consequence is false - I is not a model of T 1 T 2 means If for every integer x x>x+1 then there exists an integer y such that 0>y This is true since the antecedent is false - I is a model of T 2

32 Example: 3 Under J T 1 means If for every integer x there is some integer y such that x y then 0 0-1 Clearly this is true since both the antecedent and consequence are true - J is a model of T 1 T 2 means If for every integer x, x x-1 then there exists an integer y such that 0 y This is true since, again, both antecedent and consequence are true - J is a model of T 2

33 Example: 4 We see that T 1 is not a valid theory since I is not a model of T 1. Both I and J are models of T 2. Is T 2 valid? Let K be any interpretation of L then T 2 means If for every element x U P K (x, f K (x)) then there exists some element y U such that P K (c K, y ).

34 Example: 5 Two possibilities Antecedent false -in this case the conditional is automatically true. Antecedent true -in this case since c K U we have PK (c K, f K (c K )) and hence the consequence of the conditional must also be true since we can select y to be f K (c K ).

35 Semantic Entailment A theory T is said to entail a closed formula F if F is true in every model of T. models of F models of T models of F models of T models of F models of T

36 Decidability Proof Procedure Query: does F follow from T Proof Procedure Query: does F follow from T Predicate logic is only semi-decidable Algorithm terminate and answers yes Algorithm may or may not terminate and answers no

Download ppt "Predicate Logic Colin Campbell. A Formal Language Predicate Logic provides a way to formalize natural language so that ambiguity is removed. Mathematical."

Similar presentations

Ads by Google