predicate logic syntax
play

Predicate Logic: Syntax Alice Gao Lecture 12 CS 245 Logic and - PowerPoint PPT Presentation

Predicate Logic: Syntax Alice Gao Lecture 12 CS 245 Logic and Computation Fall 2019 1 / 30 Outline Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals CS 245 Logic and Computation Fall 2019 2 / 30


  1. Predicate Logic: Syntax Alice Gao Lecture 12 CS 245 Logic and Computation Fall 2019 1 / 30

  2. Outline Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals CS 245 Logic and Computation Fall 2019 2 / 30

  3. Learning goals By the end of this lecture, you should be able to induction. CS 245 Logic and Computation Fall 2019 3 / 30 ▶ Defjne the set of terms inductively. ▶ Defjne the set of formulas inductively. ▶ Determine whether a variable in a formula is free or bound. ▶ Prove properties of terms and formulas by structural ▶ Draw the parse tree of a formula.

  4. The Language of Predicate Logic returns an object of the domain. returns true or false. They describe properties of objects or relationships between objects. statement true? CS 245 Logic and Computation Fall 2019 4 / 30 ▶ Domain: a non-empty set of objects. ▶ Individuals: concrete objects in the domain. ▶ Variables: placeholders for concrete objects in the domain. ▶ Functions: takes objects in the domain as arguments and ▶ Relations: takes objects in the domain as arguments and ▶ Quantifjers: for how many objects in the domain is the

  5. Outline Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals CS 245 Logic and Computation Fall 2019 5 / 30

  6. Predicate Language 𝑀 Eight classes of symbols: A special equality symbol ≈ CS 245 Logic and Computation Fall 2019 6 / 30 ▶ Individual symbols: 𝑏, 𝑐, 𝑑 . ▶ Relation symbols: 𝐺, 𝐻, 𝐼 . ▶ Function symbols: 𝑔, 𝑕, ℎ . ▶ Free variable symbols: 𝑣, 𝑤, 𝑥 . ▶ Bound variable symbols: 𝑦, 𝑧, 𝑨 . ▶ Connective symbols: ¬ , ∧ , ∨ , → , ↔ . ▶ Quantifjer symbol: ∀ , ∃ . ▶ Punctuation symbols: ‘(’, ‘)’, and ‘,’

  7. Free and Bound Variables In a formula ∀𝑦 𝐵(𝑦) or ∃𝑦 𝐵(𝑦) , the scope of a quantifjer is the formula 𝐵(𝑦) . A quantifjer binds its variable within its scope. An occurrence of a variable in a formula variable. CS 245 Logic and Computation Fall 2019 7 / 30 ▶ is bound if it lies in the scope of some quantifjer of the same ▶ is free, otherwise.

  8. Outline Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals CS 245 Logic and Computation Fall 2019 8 / 30

  9. Two Kinds of Expressions Two kinds of expressions: CS 245 Logic and Computation Fall 2019 9 / 30 ▶ A term refers to an object in the domain. ▶ A formula evaluates to 1 or 0 .

  10. Terms The set of terms Term (𝑀) is defjned below: 1. An individual symbol 𝑏 standing alone is a term. 2. A free variable symbol 𝑣 standing alone is a term. then 𝑔(𝑢 1 , … , 𝑢 𝑜 ) is a term. 4. Nothing else is a term. CS 245 Logic and Computation Fall 2019 10 / 30 3. If 𝑢 1 , … , 𝑢 𝑜 are terms and 𝑔 is an 𝑜 -ary function symbol,

  11. Examples of Terms Terms: A term with no free variable symbols is called a closed term. Which one(s) of the above are closed terms? CS 245 Logic and Computation Fall 2019 11 / 30 ▶ 𝑏, 𝑐, 𝑑 , 𝑣, 𝑤, 𝑥 ▶ 𝑔(𝑐) , 𝑕(𝑏, 𝑔(𝑐)) , 𝑕(𝑣, 𝑐) , 𝑔(𝑕(𝑔(𝑣), 𝑐))

  12. CQ: Which expressions are terms? Which of the following expressions is a term? If there are multiple correct answers, choose your favourite one. (A) 𝑥 (B) 𝑕(𝑏, 𝑣) (C) 𝐺(𝑔(𝑣, 𝑤), 𝑏) (D) 𝑔(𝑣, 𝑕(𝑤, 𝑥), 𝑏) (E) 𝑕(𝑣, 𝑔(𝑤, 𝑥), 𝑏) Individual symbols: 𝑏 Relation symbols: 𝐺 is a binary relation symbol. Function symbols: 𝑔 is a binary function symbol and 𝑕 is a 3-ary function symbol. Free variable symbols: 𝑣, 𝑤, 𝑥 . CS 245 Logic and Computation Fall 2019 12 / 30

  13. Defjning the set of terms inductively The set of terms can be inductively defjned as follows: The set of fjnite sequences of symbols of 𝑀 The set of all individual symbols and free variable symbols The set of all function symbols CS 245 Logic and Computation Fall 2019 13 / 30 ▶ The domain set 𝑌 : ▶ The core set 𝐷 : ▶ The set of operations 𝑄 :

  14. Structural induction on terms Theorem: Every term has a property 𝑄 . Proof by structural induction: The term is an individual symbol. The term is a free variable symbol. The term is 𝑔(𝑢 1 , … , 𝑢 𝑜 ) where 𝑔 is an n-ary function and property 𝑄 . We need to show that 𝑔(𝑢 1 , … , 𝑢 𝑜 ) has the property 𝑄 . CS 245 Logic and Computation Fall 2019 14 / 30 ▶ Base cases: ▶ Inductive cases: 𝑢 1 , ..., 𝑢 𝑜 are terms. Induction hypotheses: Assume that 𝑢 1 , … , 𝑢 𝑜 all have the

  15. Outline Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals CS 245 Logic and Computation Fall 2019 15 / 30

  16. Atomic Formulas The set of atomic formulas Atom (𝑀) is defjned below: terms, then 𝐺(𝑢 1 , … , 𝑢 𝑜 ) is an atomic formula. CS 245 Logic and Computation Fall 2019 16 / 30 ▶ If 𝐺 is an n-ary relation symbol and 𝑢 1 , … , 𝑢 𝑜 ( 𝑜 ≥ 1 ) are ▶ If 𝑢 1 , 𝑢 2 are terms, then ≈ (𝑢 1 , 𝑢 2 ) is an atomic formula. ▶ Nothing else is an atomic formula.

  17. Examples of Atomic Formulas Terms: Atomic formulas: CS 245 Logic and Computation Fall 2019 17 / 30 ▶ 𝑏, 𝑐, 𝑑 , 𝑣, 𝑤, 𝑥 ▶ 𝑔(𝑐) , 𝑕(𝑏, 𝑔(𝑐)) , 𝑕(𝑣, 𝑐) , 𝑔(𝑕(𝑔(𝑣), 𝑐)) ▶ 𝐺(𝑏, 𝑣, 𝑔(𝑐), 𝑔(𝑥), 𝑕(𝑤, 𝑔(𝑏))) ▶ ≈ (𝑐, 𝑥)

  18. Well-Formed Formulas The set of well-formed formulas Form (𝑀) is defjned below: 1. An atomic formula is a well-formed formula. 2. If 𝐵 is a well-formed formula, then (¬𝐵) is a well-formed formula. 3. If 𝐵 and 𝐶 are well-formed formulas and ⋆ is one of ∧ , ∨ , → , and ↔ , then (𝐵 ⋆ 𝐶) is a well-formed formula. 4. If 𝐵(𝑣) is a well-formed formula and 𝑦 does not occur in 𝐵(𝑣) , then ∀𝑦 𝐵(𝑦) and ∃𝑦 𝐵(𝑦) are well-formed formulas. 5. Nothing else is a well-formed formula. CS 245 Logic and Computation Fall 2019 18 / 30

  19. Explaining Case 4 of Formulas If 𝐵(𝑣) is a well-formed formula and 𝑦 does not occur in 𝐵(𝑣) , formula. We want to quantify 𝑣 . variable, e.g. 𝑦 . We need to make sure that our choice of the bound variable symbol does not already occur in 𝐵(𝑣) . CS 245 Logic and Computation Fall 2019 19 / 30 then ∀𝑦 𝐵(𝑦) and ∃𝑦 𝐵(𝑦) are well-formed formulas. ▶ 𝐵(𝑣) is a well-formed formula where 𝑣 is a free variable in the ▶ In order to do so, we need to choose a symbol for a bound

  20. Examples for Case 4 Start with 𝐻(𝑣) and 𝐼(𝑤) separately. We can quantify 𝑣 by Fall 2019 CS 245 Logic and Computation two formulas using ∨ , we get ∃𝑦𝐻(𝑦) ∨ ∀𝑦𝐼(𝑦) . does not appear in 𝐼(𝑤) . We get ∀𝑦𝐼(𝑦) . Connecting the ∃𝑦𝐻(𝑦) . We can quantify 𝑤 by replacing it with 𝑦 since 𝑦 replacing it with 𝑦 since 𝑦 does not appear in 𝐻(𝑣) ). We get 20 / 30 for us to generate ∃𝑧∀𝑧𝐺(𝑧, 𝑧) . will need to choose a bound variable symbol that is not 𝑧 Start with ∀𝑧𝐺(𝑧, 𝑧) . If we want to add the ∃ quantifjer, we get ∀𝑧𝐺(𝑧, 𝑧) . Start with 𝐺(𝑣, 𝑣) . If we quantify 𝑣 by replacing it with 𝑧 , we ▶ We are allowed to generate the formula ∀𝑧𝐺(𝑧, 𝑧) . ▶ We are not allowed to generate the formula ∃𝑧∀𝑧𝐺(𝑧, 𝑧) . because 𝑧 already appears in ∀𝑧 𝐺(𝑧, 𝑧) . So, there is no way ▶ We are allowed to generate the formula ∃𝑦𝐻(𝑦) ∨ ∀𝑦𝐼(𝑦) .

  21. Examples of Formulas Well-Formed Formulas: A formula with no free variable symbols is called a closed formula or a sentence. Which formulas above are closed formulas? CS 245 Logic and Computation Fall 2019 21 / 30 ▶ 𝐺(𝑏, 𝑐) , ∀𝑧 𝐺(𝑏, 𝑧) , ∃𝑦∀𝑧 𝐺(𝑦, 𝑧) ▶ 𝐺(𝑣, 𝑤) , ∃𝑧 𝐺(𝑣, 𝑧)

  22. Determine whether a formula is well-formed Which of the following is a well-formed formula? (A) 𝑔(𝑣) → 𝐺(𝑣, 𝑤) (B) ∀𝑦 𝐺(𝑛, 𝑔(𝑦)) (C) 𝐺(𝑣, 𝑤) → 𝐻(𝐻(𝑣)) (D) 𝐻(𝑛, 𝑔(𝑛)) (E) 𝐺(𝑛, 𝑔(𝐻(𝑣, 𝑤))) Individual symbols: 𝑛 . Free Variable Symbols: 𝑣, 𝑤 . Bound Variable symbols: 𝑦 . Relation symbols: 𝐺 and 𝐻 are binary relation symbols. Function symbols: 𝑔 is a unary function. CS 245 Logic and Computation Fall 2019 22 / 30

  23. Defjning the set of formulas inductively The set of formulas can be inductively defjned as follows: The set of fjnite sequences of symbols of 𝑀 The set of all atomic formulas. 𝑔 1 (𝑦) = (¬𝑦) 𝑔 2 (𝑦, 𝑧) = (𝑦 ∗ 𝑧) where ∗ is one of ∧ , ∨ , → , and ↔ . 𝑔 3 (𝐵(𝑣)) = ∀𝑦 𝐵(𝑦), 𝑔 4 (𝐵(𝑣)) = ∃𝑦 𝐵(𝑦) where 𝑦 does not occur in 𝐵(𝑣) . CS 245 Logic and Computation Fall 2019 23 / 30 ▶ The domain set 𝑌 : ▶ The core set 𝐷 : ▶ The set of operations 𝑄 :

  24. Structural induction on formulas Theorem: Every formula has a property 𝑄 . Proof by structural induction: The formula is an atomic formula. The formula is (¬𝐵) where 𝐵 is a formula. The formula is (𝐵 ∗ 𝐶) where 𝐵 and 𝐶 are formulas and ∗ is a binary connective. The formula is ∀𝑦 𝐵(𝑦) and ∃𝑦 𝐵(𝑦) where 𝐵(𝑣) is a formula and 𝑦 does not occur in 𝐵(𝑣) . CS 245 Logic and Computation Fall 2019 24 / 30 ▶ Base cases: ▶ Inductive cases:

Recommend


More recommend