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

predicate logic syntax
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Predicate Logic: Syntax

Alice Gao

Lecture 12

CS 245 Logic and Computation Fall 2019 1 / 30

slide-2
SLIDE 2

Outline

Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 2 / 30

slide-3
SLIDE 3

Learning goals

By the end of this lecture, you should be able to

▶ 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

induction.

▶ Draw the parse tree of a formula.

CS 245 Logic and Computation Fall 2019 3 / 30

slide-4
SLIDE 4

The Language of Predicate Logic

▶ 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

returns an object of the domain.

▶ Relations: takes objects in the domain as arguments and

returns true or false. They describe properties of objects or relationships between objects.

▶ Quantifjers: for how many objects in the domain is the

statement true?

CS 245 Logic and Computation Fall 2019 4 / 30

slide-5
SLIDE 5

Outline

Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 5 / 30

slide-6
SLIDE 6

Predicate Language 𝑀

Eight classes of symbols:

▶ Individual symbols: 𝑏, 𝑐, 𝑑. ▶ Relation symbols: 𝐺, 𝐻, 𝐼.

A special equality symbol ≈

▶ Function symbols: 𝑔, 𝑕, ℎ. ▶ Free variable symbols: 𝑣, 𝑤, 𝑥. ▶ Bound variable symbols: 𝑦, 𝑧, 𝑨. ▶ Connective symbols: ¬, ∧, ∨, →, ↔. ▶ Quantifjer symbol: ∀, ∃. ▶ Punctuation symbols: ‘(’, ‘)’, and ‘,’

CS 245 Logic and Computation Fall 2019 6 / 30

slide-7
SLIDE 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

▶ is bound if it lies in the scope of some quantifjer of the same

variable.

▶ is free, otherwise.

CS 245 Logic and Computation Fall 2019 7 / 30

slide-8
SLIDE 8

Outline

Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 8 / 30

slide-9
SLIDE 9

Two Kinds of Expressions

Two kinds of expressions:

▶ A term refers to an object in the domain. ▶ A formula evaluates to 1 or 0.

CS 245 Logic and Computation Fall 2019 9 / 30

slide-10
SLIDE 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.
  • 3. If 𝑢1, … , 𝑢𝑜 are terms and 𝑔 is an 𝑜-ary function symbol,

then 𝑔(𝑢1, … , 𝑢𝑜) is a term.

  • 4. Nothing else is a term.

CS 245 Logic and Computation Fall 2019 10 / 30

slide-11
SLIDE 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

slide-12
SLIDE 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

slide-13
SLIDE 13

Defjning the set of terms inductively

The set of terms can be inductively defjned as follows:

▶ The domain set 𝑌:

The set of fjnite sequences of symbols of 𝑀

▶ The core set 𝐷:

The set of all individual symbols and free variable symbols

▶ The set of operations 𝑄:

The set of all function symbols

CS 245 Logic and Computation Fall 2019 13 / 30

slide-14
SLIDE 14

Structural induction on terms

Theorem: Every term has a property 𝑄. Proof by structural induction:

▶ Base cases:

The term is an individual symbol. The term is a free variable symbol.

▶ Inductive cases:

The term is 𝑔(𝑢1, … , 𝑢𝑜) where 𝑔 is an n-ary function and 𝑢1, ..., 𝑢𝑜 are terms. Induction hypotheses: Assume that 𝑢1, … , 𝑢𝑜 all have the property 𝑄. We need to show that 𝑔(𝑢1, … , 𝑢𝑜) has the property 𝑄.

CS 245 Logic and Computation Fall 2019 14 / 30

slide-15
SLIDE 15

Outline

Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 15 / 30

slide-16
SLIDE 16

Atomic Formulas

The set of atomic formulas Atom(𝑀) is defjned below:

▶ If 𝐺 is an n-ary relation symbol and 𝑢1, … , 𝑢𝑜 (𝑜 ≥ 1) are

terms, then 𝐺(𝑢1, … , 𝑢𝑜) is an atomic formula.

▶ If 𝑢1, 𝑢2 are terms, then ≈ (𝑢1, 𝑢2) is an atomic formula. ▶ Nothing else is an atomic formula.

CS 245 Logic and Computation Fall 2019 16 / 30

slide-17
SLIDE 17

Examples of Atomic Formulas

Terms:

▶ 𝑏, 𝑐, 𝑑, 𝑣, 𝑤, 𝑥 ▶ 𝑔(𝑐), 𝑕(𝑏, 𝑔(𝑐)), 𝑕(𝑣, 𝑐), 𝑔(𝑕(𝑔(𝑣), 𝑐))

Atomic formulas:

▶ 𝐺(𝑏, 𝑣, 𝑔(𝑐), 𝑔(𝑥), 𝑕(𝑤, 𝑔(𝑏))) ▶ ≈ (𝑐, 𝑥)

CS 245 Logic and Computation Fall 2019 17 / 30

slide-18
SLIDE 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

slide-19
SLIDE 19

Explaining Case 4 of Formulas

If 𝐵(𝑣) is a well-formed formula and 𝑦 does not occur in 𝐵(𝑣), then ∀𝑦 𝐵(𝑦) and ∃𝑦 𝐵(𝑦) are well-formed formulas.

▶ 𝐵(𝑣) is a well-formed formula where 𝑣 is a free variable in the

  • formula. We want to quantify 𝑣.

▶ In order to do so, we need to choose a symbol for a bound

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

slide-20
SLIDE 20

Examples for Case 4

▶ We are allowed to generate the formula ∀𝑧𝐺(𝑧, 𝑧).

Start with 𝐺(𝑣, 𝑣). If we quantify 𝑣 by replacing it with 𝑧, we get ∀𝑧𝐺(𝑧, 𝑧).

▶ We are not allowed to generate the formula ∃𝑧∀𝑧𝐺(𝑧, 𝑧).

Start with ∀𝑧𝐺(𝑧, 𝑧). If we want to add the ∃ quantifjer, we will need to choose a bound variable symbol that is not 𝑧 because 𝑧 already appears in ∀𝑧 𝐺(𝑧, 𝑧). So, there is no way for us to generate ∃𝑧∀𝑧𝐺(𝑧, 𝑧).

▶ We are allowed to generate the formula ∃𝑦𝐻(𝑦) ∨ ∀𝑦𝐼(𝑦).

Start with 𝐻(𝑣) and 𝐼(𝑤) separately. We can quantify 𝑣 by replacing it with 𝑦 since 𝑦 does not appear in 𝐻(𝑣)). We get ∃𝑦𝐻(𝑦). We can quantify 𝑤 by replacing it with 𝑦 since 𝑦 does not appear in 𝐼(𝑤). We get ∀𝑦𝐼(𝑦). Connecting the two formulas using ∨, we get ∃𝑦𝐻(𝑦) ∨ ∀𝑦𝐼(𝑦).

CS 245 Logic and Computation Fall 2019 20 / 30

slide-21
SLIDE 21

Examples of Formulas

Well-Formed Formulas:

▶ 𝐺(𝑏, 𝑐), ∀𝑧 𝐺(𝑏, 𝑧), ∃𝑦∀𝑧 𝐺(𝑦, 𝑧) ▶ 𝐺(𝑣, 𝑤), ∃𝑧 𝐺(𝑣, 𝑧)

A formula with no free variable symbols is called a closed formula

  • r a sentence.

Which formulas above are closed formulas?

CS 245 Logic and Computation Fall 2019 21 / 30

slide-22
SLIDE 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

slide-23
SLIDE 23

Defjning the set of formulas inductively

The set of formulas can be inductively defjned as follows:

▶ The domain set 𝑌:

The set of fjnite sequences of symbols of 𝑀

▶ The core set 𝐷:

The set of all atomic formulas.

▶ The set of operations 𝑄:

𝑔1(𝑦) = (¬𝑦) 𝑔2(𝑦, 𝑧) = (𝑦 ∗ 𝑧) where ∗ is one of ∧, ∨, →, and ↔. 𝑔3(𝐵(𝑣)) = ∀𝑦 𝐵(𝑦), 𝑔4(𝐵(𝑣)) = ∃𝑦 𝐵(𝑦) where 𝑦 does not

  • ccur in 𝐵(𝑣).

CS 245 Logic and Computation Fall 2019 23 / 30

slide-24
SLIDE 24

Structural induction on formulas

Theorem: Every formula has a property 𝑄. Proof by structural induction:

▶ Base cases:

The formula is an atomic formula.

▶ Inductive cases:

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

slide-25
SLIDE 25

Comparing the Defjnitions of Well-Formed Formulas

Let’s compare the set of predicate formulas to the set of propositional formulas. Questions to think about:

▶ Which parts of the two defjnitions are the same?

The cases for negation and binary connectives are the same.

▶ Which parts of the two defjnitions are difgerent?

Atomic formulas are difgerent.

▶ Atomic propositional formulas are propositional variables. ▶ Atomic predicate formulas are relations applied to terms.

Predicate formulas have one additional case for quantifjers.

CS 245 Logic and Computation Fall 2019 25 / 30

slide-26
SLIDE 26

Outline

Learning goals Symbols Terms Formulas Parse Trees Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 26 / 30

slide-27
SLIDE 27

Parse Trees of Predicate Formulas

▶ The leaves are atomic formulas. ▶ Every quantifjer has exactly one child

(namely the formula which is its scope). Example: ∀𝑦(𝐺(𝑐) → ∃𝑧(∀𝑨 𝐻(𝑧, 𝑨) ∨ 𝐼(𝑔(𝑣), 𝑦, 𝑧)))

CS 245 Logic and Computation Fall 2019 27 / 30

slide-28
SLIDE 28

Parse tree

Example: ∀𝑦(𝐺(𝑐) → ∃𝑧(∀𝑨 𝐻(𝑧, 𝑨) ∨ 𝐼(𝑔(𝑣), 𝑦, 𝑧))) Parse tree: ∀𝑦(𝐺(𝑐) → ∃𝑧(∀𝑨 𝐻(𝑧, 𝑨) ∨ 𝐼(𝑔(𝑣), 𝑦, 𝑧))) 𝐺(𝑐) → ∃𝑧(∀𝑨 𝐻(𝑧, 𝑨) ∨ 𝐼(𝑔(𝑣), 𝑤, 𝑧)) 𝐺(𝑐) ∃𝑧(∀𝑨 𝐻(𝑧, 𝑨) ∨ 𝐼(𝑔(𝑣), 𝑤, 𝑧)) ∀𝑨 𝐻(𝑥, 𝑨) ∨ 𝐼(𝑔(𝑣), 𝑤, 𝑥) ∀𝑨 𝐻(𝑥, 𝑨) 𝐻(𝑥, 𝑣1) 𝐼(𝑔(𝑣), 𝑤, 𝑥)

CS 245 Logic and Computation Fall 2019 28 / 30

slide-29
SLIDE 29

A few notes on parse trees

  • 1. While constructing the parse tree, when removing a quantifjer,

we change the bound variable symbol to one of the free variable symbols that hasn’t appeared in the parse tree. For example, When removing ∀𝑦, we changed 𝑦 to 𝑤. When removing ∃𝑧, we changed 𝑧 to 𝑥.

  • 2. Th quantifjers have higher precedence than any other
  • connective. Each quantifjer modifjes the formula that is

immediately after it. For example, ∀𝑨 modifjes 𝐻(𝑥, 𝑨) instead of 𝐻(𝑥, 𝑨) ∨ 𝐼(𝑔(𝑣), 𝑤, 𝑥).

CS 245 Logic and Computation Fall 2019 29 / 30

slide-30
SLIDE 30

Revisiting the learning goals

By the end of this lecture, you should be able to

▶ 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

induction.

▶ Draw the parse tree of a formula.

CS 245 Logic and Computation Fall 2019 30 / 30