Syntax of Predicate Logic Syntax of Predicate Logic 1/25 The - - PowerPoint PPT Presentation

syntax of predicate logic
SMART_READER_LITE
LIVE PREVIEW

Syntax of Predicate Logic Syntax of Predicate Logic 1/25 The - - PowerPoint PPT Presentation

Syntax of Predicate Logic Syntax of Predicate Logic 1/25 The Language of Predicate Logic object of the domain. or false. They describe properties of objects or relationships between objects. true? Syntax of Predicate Logic 2/25 Domain:


slide-1
SLIDE 1

Syntax of Predicate Logic

Syntax of Predicate Logic 1/25

slide-2
SLIDE 2

The Language of Predicate Logic

  • Domain: a non-empty set of objects
  • Constants: concrete objects in the domain
  • Variables: placeholders for concrete objects in the domain
  • Functions: takes objects in the domain as arguments and returns an
  • bject of the domain.
  • Predicates: takes objects in the domain as arguments and returns true
  • r false. They describe properties of objects or relationships between
  • bjects.
  • Quantifjers: for how many objects in the domain is the statement

true?

Syntax of Predicate Logic 2/25

slide-3
SLIDE 3

A question on functions

Consider two translations of the sentence “every child is younger than its mother.”

  • 1. (∀𝑦 (∀𝑧 ((𝐷ℎ𝑗𝑚𝑒(𝑦) ∧ 𝑁𝑝𝑢ℎ𝑓𝑠(𝑧, 𝑦)) → 𝑍 𝑝𝑣𝑜𝑕𝑓𝑠(𝑦, 𝑧))))
  • 2. (∀𝑦 (𝐷ℎ𝑗𝑚𝑒(𝑦) → 𝑍 𝑝𝑣𝑜𝑕𝑓𝑠(𝑦, 𝑛𝑝𝑢ℎ𝑓𝑠(𝑦))))

Which of the following is the best answer?

  • a. Both are wrong.
  • b. 1 is correct and 2 is wrong.
  • c. 2 is correct and 1 is wrong.
  • d. Both are correct. 1 is better.
  • e. Both are correct. 2 is better.

The domain is the set of people. 𝐷ℎ𝑗𝑚𝑒(𝑦) means 𝑦 is a child. 𝑁𝑝𝑢ℎ𝑓𝑠(𝑦, 𝑧) means 𝑦 is 𝑧’s mother. 𝑍 𝑝𝑣𝑜𝑕𝑓𝑠(𝑦, 𝑧) means 𝑦 is younger than 𝑧. 𝑛𝑝𝑢ℎ𝑓𝑠(𝑦) returns 𝑦’s mother.

Syntax of Predicate Logic 3/25

slide-4
SLIDE 4

Functions

Using functions allows us to avoid ugly/inelegant predicate logic formulas. Try translating the following sentence with and without functions. “Andy and Paul have the same maternal grandmother.”

Syntax of Predicate Logic 4/25

slide-5
SLIDE 5

The Language of Predicate Logic

The seven kinds of symbols: 1. Constant symbols. Usually 𝑑, 𝑒, 𝑑1, 𝑑2, … , 𝑒1, 𝑒2 … 2. Variables. Usually 𝑦, 𝑧, 𝑨, … 𝑦1, 𝑦2, … , 𝑧1, 𝑧2 … 3. Function symbols. Usually 𝑔, 𝑕, ℎ, … 𝑔1, 𝑔2, … , 𝑕1, 𝑕2, … 4. Predicate symbols. 𝑄, 𝑅, …𝑄1, 𝑄2, …, 𝑅1, 𝑅2, … 5. Connectives: ¬, ∧, ∨, →, and ↔ 6. Quantifjers: ∀ and ∃ 7. Punctuation: ‘(’, ‘)’, and ‘,’ Function symbols and predicate symbols have an assigned arity—the number of arguments required. For example,

  • 𝑔(1): 𝑔 is a unary function.
  • 𝑄 (2): 𝑄 is a binary predicate.

Syntax of Predicate Logic Symbols 5/25

slide-6
SLIDE 6

Two kinds of expressions

In predicate logic, we need to consider two kinds of expressions:

  • those that refer to an object of the domain, called terms, and
  • those that can have a truth value, called formulas.

Syntax of Predicate Logic Terms and Formulas 6/25

slide-7
SLIDE 7

Terms

Each term refers to an object of the domain. We defjne the set of terms inductively as follows.

  • 1. Each constant symbol is an atomic term.
  • 2. Each variable is an atomic term.
  • 3. 𝑔(𝑢1, … , 𝑢𝑜) is a term if 𝑢1, … , 𝑢𝑜 are terms and 𝑔 is an 𝑜-ary function
  • symbol. (If 𝑔 is a binary function symbol, then we may write (𝑢1 𝑔 𝑢2)

instead of 𝑔(𝑢1, 𝑢2).)

  • 4. Nothing else is a term.

Syntax of Predicate Logic Terms and Formulas 7/25

slide-8
SLIDE 8

Which expressions are terms?

A term refers to an object of the domain. Which of the following expressions is a term?

  • a. 𝑕(𝑒, 𝑒)
  • b. 𝑄(𝑔(𝑦, 𝑧), 𝑒)
  • c. 𝑔(𝑦, 𝑕(𝑧, 𝑨), 𝑒)
  • d. 𝑕(𝑦, 𝑔(𝑧, 𝑨), 𝑒)

Let 𝑒 be a constant symbol. Let 𝑄 be a predicate symbol with 2

  • arguments. Let 𝑔 be a function symbol with 2 arguments and 𝑕 be a

function symbol with 3 arguments. Let 𝑦, 𝑧, and 𝑨 be variable symbols.

Syntax of Predicate Logic Terms and Formulas 8/25

slide-9
SLIDE 9

Is this a term?

True or False: The expression (2 − 𝑔(𝑦)) + (𝑧 ∗ 𝑦) is a term.

  • a. True
  • b. False
  • c. Not enough information to tell

The domain is the set of integers. +, − and ∗ are binary functions. 𝑔 is a unary function. 𝑦 and 𝑧 are variables and 2 is a constant.

Syntax of Predicate Logic Terms and Formulas 9/25

slide-10
SLIDE 10

Well-Formed Predicate Logic Formulas

We defjne the set of well-formed formulas of predicate logic inductively as follows.

  • 1. 𝑄(𝑢1, … , 𝑢𝑜) is an atomic formula if 𝑄 is an 𝑜-ary predicate symbol

and each 𝑢𝑗 is a term (1 ≤ 𝑗 ≤ 𝑜).

  • 2. (¬𝛽) is a formula if 𝛽 is a formula.
  • 3. (𝛽 ⋆ 𝛾) is a formula if 𝛽 and 𝛾 are formulas and ⋆ is a binary

connective symbol.

  • 4. Each of (∀𝑦 𝛽) and (∃𝑦 𝛽) is a formula if 𝛽 is a formula and 𝑦 is a

variable.

  • 5. Nothing else is a formula.

Syntax of Predicate Logic Terms and Formulas 10/25

slide-11
SLIDE 11

Determine whether a formula is well-formed

𝑛 is a constant and 𝑦 and 𝑧 are variables. 𝑄 (2) and 𝑅(2) are binary

  • predicates. 𝑔(1) is a unary function.

Which of the following is a well-formed predicate logic formula?

  • a. (𝑔(𝑦) → 𝑄(𝑦, 𝑧))
  • b. ∀𝑧 𝑄(𝑛, 𝑔(𝑧))
  • c. 𝑄(𝑦, 𝑧) → 𝑅(𝑅(𝑦))
  • d. 𝑅(𝑛, 𝑔(𝑛))
  • e. 𝑄(𝑛, 𝑔(𝑅(𝑦, 𝑧)))

Syntax of Predicate Logic Terms and Formulas 11/25

slide-12
SLIDE 12

Determine whether a formula is well-formed

Things to consider:

  • Are there enough brackets? Are the brackets in the right places?
  • Is each unary/binary connective applied to the right number of

predicates?

  • Does every function have the right number and type of arguments?
  • Does every predicate have the right number and type of arguments?

Syntax of Predicate Logic Terms and Formulas 12/25

slide-13
SLIDE 13

Comparing the Defjnitions of WFFs

Let’s compare and contrast the defjnitions of WFFs for propositional and predicate logic.

  • Which parts of the two defjnitions are the same?
  • The defjnition of WFF for propositional logic says that a propositional

variable is an atomic WFF. Is this still the case for predicate logic?

  • What is new in the defjnition of WFF for predicate logic compared to

the defjnition of WFF for propositional logic?

  • If we were to prove that every WFF for predicate logic has a property

P by structural induction, what does the proof look like? What are the base case(s) and what are the cases in the induction step?

Syntax of Predicate Logic Terms and Formulas 13/25

slide-14
SLIDE 14

Parse Trees of Predicate Logic Formulas

New elements in the parse tree:

  • Quantifjers ∀𝑦 and ∃𝑧 has one subtree, similar to the unary

connective negation.

  • A predicate 𝑄(𝑢1, 𝑢2, … , 𝑢𝑜) has a node labelled 𝑄 with a sub-tree for

each of the terms 𝑢1, 𝑢2, … , 𝑢𝑜.

  • A function 𝑔(𝑢1, 𝑢2, … , 𝑢𝑜) has a node labelled 𝑔 with a sub-tree for

each of the terms 𝑢1, 𝑢2, … , 𝑢𝑜. Example 1: (∀𝑦 (𝑄(𝑦) ∧ 𝑅(𝑦))) → (¬(𝑄(𝑔(𝑦, 𝑧)) ∨ 𝑅(𝑧))) Example 2: (∀𝑦 ((𝑄(𝑦) ∧ 𝑅(𝑦)) → (¬(𝑄(𝑔(𝑦, 𝑧)) ∨ 𝑅(𝑧)))))

Syntax of Predicate Logic Terms and Formulas 14/25

slide-15
SLIDE 15

Evaluating a Formula

To evaluate the truth value of a formula, we need to replace the variables by concrete objects in the domain. However, we don’t necessarily have to perform this substitution for every variable. There are two types of variables in a formula:

  • A variable may be free. To evaluate the formula, we need to replace a

free variable by an object in the domain.

  • A variable may be bound by a quantifjer. The quantifjer tells us how

to evaluate the formula. We need to understand how to determine whether a variable is free/bound and how to replace a free variable with an object in the domain.

Syntax of Predicate Logic Free and Bound Variables 15/25

slide-16
SLIDE 16

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. Otherwise the occurrence of this variable is free.

  • If a variable occurs multiple times, we need to consider each
  • ccurrence of the variable separately.
  • The variable symbol immediately after ∃ or ∀ is neither free nor

bound. A formula with no free variables is called a closed formula or sentence.

Syntax of Predicate Logic Free and Bound Variables 16/25

slide-17
SLIDE 17

Determine whether a variable is free or bound

Determine whether a variable is free or bound using a parse tree.

  • 1. Draw the parse tree for the formula.
  • 2. Choose the leaf node for an occurrence of a variable.
  • 3. Walk up the tree. Stop as soon as we encounter a quantifjer for this

variable or we reach the root of the tree.

  • 4. If we encountered a quantifjer for the variable, this occurrence of the

variable is bound.

  • 5. If we reached the root of the tree which is not a quantifjer for the

variable, this occurrence of the variable is free. Example 1: (∀𝑦 (𝑄(𝑦) ∧ 𝑅(𝑦))) → (¬(𝑄(𝑔(𝑦, 𝑧)) ∨ 𝑅(𝑧))) Example 2: (∀𝑦 ((𝑄(𝑦) ∧ 𝑅(𝑦)) → (¬(𝑄(𝑔(𝑦, 𝑧)) ∨ 𝑅(𝑧)))))

Syntax of Predicate Logic Free and Bound Variables 17/25

slide-18
SLIDE 18

Substitution

When writing natural deduction proofs in predicate logic, it is often useful to replace a variable in a formula with a term. Suppose that the following sentences are true: (∀𝑦 (Fish(𝑦) → Swim(𝑦))) (1) Fish(Nemo) (2) To conclude that Nemo can swim, we need to replace every occurence of the variable x in the implication Fish(𝑦) → Swim(𝑦) by the term Nemo. This gives us (Fish(Nemo) → Swim(Nemo)) (3) By modus ponens on (2) and (3), we conclude that Swim(Nemo). Formally, we use substitution to refer to the process of replacing 𝑦 by Nemo in the formula ∀𝑦 Fish(𝑦) → Swim(𝑦).

Syntax of Predicate Logic Substitution 18/25

slide-19
SLIDE 19

Substitution

Intuitively, 𝛽[𝑢/𝑦] answers the question, “What happens to 𝛽 if 𝑦 has the value specifjed by term 𝑢?” For a variable 𝑦, a term 𝑢, and a formula 𝛽, 𝛽[𝑢/𝑦] denotes the resulting formula by replacing each free occurrence of 𝑦 in 𝛽 with 𝑢. In other words, substitution does NOT afgect bound occurrences of the variable.

Syntax of Predicate Logic Substitution 19/25

slide-20
SLIDE 20

Examles of Substitution

Examples.

  • If 𝛽 is the formula 𝐹(𝑔(𝑦)), then 𝛽[(𝑧 + 𝑧)/𝑦] is 𝐹(𝑔(𝑧 + 𝑧)).
  • 𝛽[𝑔(𝑦)/𝑦] is 𝐹(𝑔(𝑔(𝑦))).
  • 𝐹(𝑔(𝑦 + 𝑧))[𝑧/𝑦] is 𝐹(𝑔(𝑧 + 𝑧)).
  • If 𝛾 is (∀𝑦 (𝐹(𝑔(𝑦)) ∧ 𝑇(𝑦, 𝑧))), then 𝛾[𝑕(𝑦, 𝑧)/𝑦] is 𝛾,

because 𝛾 has no free occurrence of 𝑦.

Syntax of Predicate Logic Substitution 20/25

slide-21
SLIDE 21

Examples: Substitution

Example. Let 𝛾 be (𝑄(𝑦) ∧ (∃𝑦 𝑅(𝑦))). What is 𝛾[𝑧/𝑦]? 𝛾[𝑧/𝑦] is (𝑄(𝑧) ∧ (∃𝑦 𝑅(𝑦))). Only the free 𝑦 gets substituted. Example. What about 𝛾[(𝑧 − 1)/𝑨], where 𝛾 is (∀𝑦 (∃𝑧 ((𝑦 + 𝑧) = 𝑨))))? At fjrst thought, we might say (∀𝑦 (∃𝑧 ((𝑦 + 𝑧) = (𝑧 − 1)))). But there’s a problem—the free variable 𝑧 in the term (𝑧 − 1) got “captured” by the quantifjer ∃𝑧. We want to avoid this capture.

Syntax of Predicate Logic Substitution 21/25

slide-22
SLIDE 22

Preventing Capture

Example. Formula 𝛽 = 𝑇(𝑦) ∧ ∀𝑧 (𝑄(𝑦) → 𝑅(𝑧)); term 𝑢 = 𝑔(𝑧, 𝑧). The leftmost 𝑦 can be substituted by 𝑢 since it is not in the scope of any quantifjer, but substituting in 𝑄(𝑦) puts the variable 𝑧 into the scope

  • f ∀𝑧.

We can prevent capture of variables by a difgerent choice of variable. (Above, we might be able to substitute 𝑔(𝑨, 𝑨) instead of 𝑔(𝑧, 𝑧). Or alter 𝛽 to quantify some other variable.)

Syntax of Predicate Logic Substitution 22/25

slide-23
SLIDE 23

Substitution—Formal Defjnition

Let 𝑦 be a variable and 𝑢 a term. For a term 𝑣, the term 𝑣[𝑢/𝑦] is 𝑣 with each occurrence of the variable 𝑦 replaced by the term 𝑢. For a formula 𝛽,

  • 1. If 𝛽 is 𝑄(𝑢1, … , 𝑢𝑙), then 𝛽[𝑢/𝑦] is 𝑄(𝑢1[𝑢/𝑦], … , 𝑢𝑙[𝑢/𝑦]).
  • 2. If 𝛽 is (¬𝛾), then 𝛽[𝑢/𝑦] is (¬𝛾[𝑢/𝑦]).
  • 3. If 𝛽 is (𝛾 ⋆ 𝛿), then 𝛽[𝑢/𝑦] is (𝛾[𝑢/𝑦] ⋆ 𝛿[𝑢/𝑦]).

4. … (Continued next page…)

Syntax of Predicate Logic Substitution 23/25

slide-24
SLIDE 24

Substitution—Formal Defjnition (2)

For variable 𝑦, term 𝑢 and formula 𝛽: ⋮

  • 4. If 𝛽 is (𝑅𝑦 𝛾), then 𝛽[𝑢/𝑦] is 𝛽.
  • 5. If 𝛽 is (𝑅𝑧 𝛾) for some other variable 𝑧, then

(a) If 𝑧 does not occur in 𝑢, then 𝛽[𝑢/𝑦] is (𝑅𝑧 𝛾[𝑢/𝑦]). (b) Otherwise, select a variable 𝑨 that occurs in neither 𝛽 nor 𝑢; then 𝛽[𝑢/𝑦] is (𝑅𝑨 (𝛾[𝑨/𝑧])[𝑢/𝑦]).

The last case prevents capture by renaming the quantifjed variable to something harmless.

Syntax of Predicate Logic Substitution 24/25

slide-25
SLIDE 25

Example, Revisited

Example. If 𝛽 is (∀𝑦 (∃𝑧 (𝑦 + 𝑧 = 𝑨))), what is 𝛽[(𝑧 − 1)/𝑨]? This falls under case 5(b): the term to be substituted, namely 𝑧 − 1, contains a variable 𝑧 quantifjed in formula 𝛽. Let 𝛾 be (𝑦 + 𝑧 = 𝑨); thus 𝛽 is (∀𝑦 (∃𝑧 𝛾)). Select a new variable, say 𝑥. Then 𝛾[𝑥/𝑧] is 𝑦 + 𝑥 = 𝑨, and 𝛾[𝑥/𝑧][(𝑧 − 1)/𝑨] is (𝑦 + 𝑥) = (𝑧 − 1) . Thus the required formula 𝛽[(𝑧 − 1)/𝑨] is (∀𝑦 ∃𝑥((𝑦 + 𝑥) = (𝑧 − 1))) .

Syntax of Predicate Logic Substitution 25/25