2. First-Order Logic (FOL)

2. First-Order Logic (FOL)

The Calculus of Computation: Decision Procedures with Applications to Verification 2. First-Order Logic (FOL) by Aaron Bradley Zohar Manna Springer 2007 2- 1 2- 2 First-Order Logic (FOL) quantifiers existential quantifier ∃x.F [x] Also called Predicate Logic or Predicate Calculus “there exists an x such that F [x]” FOL Syntax universal quantifier ∀x.F [x] “for all x, F [x]” variables x, y, z, · · · a b c constants , , , · · · FOL formula literal, application of logical connectives f g h functions , , , · · · (¬, ∨ , ∧ , → , ↔ ) to formulae, terms variables, constants or or application of a quantifier to a formula n-ary function applied to n terms as arguments a, x, f (a), g(x, b), f (g(x, g(b))) predicates p, q, r, · · · atom ⊤, ⊥, or an n-ary predicate applied to n terms literal atom or its negation p(f (x), g(x, f (x))), ¬p(f (x), g(x, f (x))) Note: 0-ary functions: constant 0-ary predicates: P, Q, R,... 2- 3 2- 4 Example: FOL formula Translations of English Sentences into FOL ◮ ∀x. p(f (x), x) → (∃y. p(f (g(x, y)), g(x, y))) ∧ q(x, f (x)) The length of one side of a triangle is less than the sum of the | {z } lengths of the other two sides G | {z } F ∀x, y, z. triangle(x, y, z) → length(x) < length(y)+length(z) The scope of ∀x is F . ◮ Fermat’s Last Theorem. The scope of ∃y is G. The formula reads: ∀n. integer(n) ∧ n > 2 “for all x, → ∀x, y, z. if p(f (x), x) integer(x) ∧ integer(y) ∧ integer(z) then there exists a y such that ∧ x > 0 ∧ y > 0 ∧ z > 0 n n n p(f (g(x, y)), g(x, y)) and q(x, f (x))” → x + y 6= z 2- 5 2- 6 FOL Semantics Example: F : p(f (x, y), z) → p(y, g(z, x)) An interpretation I : (DI , αI ) consists of: Interpretation I : (DI , αI ) ◮ Domain DI DI = Z = {· · · , −2, −1, 0, 1, 2, ···} integers non-empty set of values or objects αI : {f 7→ +, g 7→ −, p 7→>} cardinality |DI | finite (eg, 52 cards), Therefore, we can write countably infinite (eg, integers), or uncountably infinite (eg, reals) FI : x + y > z → y > z − x ◮ Assignment αI (This is the way we’ll write it in the future!) ◮ each variable x assigned value xI ∈ DI Also ◮ each n-ary function f assigned αI : {x 7→ 13, y 7→ 42, z 7→ 1} n fI : DI → DI Thus In particular, each constant a (0-ary function) assigned value FI : 13 + 42 > 1 → 42 > 1 − 13 aI ∈ DI Compute the truth value of F under I ◮ each n-ary predicate p assigned 1. I |= x + y > z since 13 + 42 > 1 n pI : DI →{true, false} 2. I |= y > z − x since 42 > 1 − 13 In particular, each propositional variable P (0-ary predicate) 3. I |= F by 1, 2, and → assigned truth value (true, false) F is true under I 2- 7 2- 8 Semantics: Quantifiers Example For Q, the set of rational numbers, consider x variable. x-variant of interpretation I is an interpretation J : (DJ , αJ ) such FI : ∀x. ∃y. 2 × y = x that ◮ DI = DJ Compute the value of FI (F under I ): ◮ αI [y]= αJ [y] for all symbols y, except possibly x Let v J1 : I ⊳ {x 7→ v} J2 : J1 ⊳ {y 7→ } That is, I and J agree on everything except possibly the value of x 2 x-variant of I y-variant of J1 Denote J : I ⊳ {x 7→ v} the x-variant of I in which αJ [x] = v for for v ∈ Q. some v ∈ DI . Then Then ◮ I |= ∀x. F iff for all v ∈ DI , I ⊳ {x 7→ v} |= F v ◮ I |= ∃x. F iff there exists v ∈ DI s.t. I ⊳ {x 7→ v} |= F 1. J2 |= 2 × y = x since 2 × 2 = v 2. J1 |= ∃y. 2 × y = x 3. I |= ∀x. ∃y. 2 × y = x since v ∈ Q is arbitrary 2- 9 2- 10 Satisfiability and Validity Second case F is satisfiable iff there exists I s.t. I |= F 1. I 6|= ∀x. p(x) assumption F is valid iff for all I , I |= F 2. I |= ¬∃x. ¬p(x) assumption 3. I ⊳ {x 7→ v} 6|= p(x) 1and ∀, for some v ∈ DI F is valid iff ¬F is unsatisfiable 4. I 6|= ∃x. ¬p(x) 2and ¬ 5. I ⊳ {x 7→ v} 6|= ¬p(x) 4and ∃ 6. I ⊳ {x 7→ v} |= p(x) 5and ¬ Example: F : (∀x. p(x)) ↔ (¬∃x. ¬p(x)) valid? Suppose not. Then there is I s.t. 3 and 6 are contradictory. 0. I 6|= (∀x. p(x)) ↔ (¬∃x. ¬p(x)) Both cases end in contradictions for arbitrary I ⇒ F is valid. First case 1. I |= ∀x. p(x) assumption 2. I 6|= ¬∃x. ¬p(x) assumption 3. I |= ∃x. ¬p(x) 2and ¬ 4. I ⊳ {x 7→ v} |= ¬p(x) 3and ∃, for some v ∈ DI 5. I ⊳ {x 7→ v} |= p(x) 1and ∀ 4 and 5 are contradictory. 2- 11 2- 12 Example: Prove Example: Show F : p(a) → ∃x. p(x) isvalid. F : (∀x. p(x, x)) → (∃x. ∀y. p(x, y)) is invalid. Assume otherwise. Find interpretation I such that 1. I 6|= F assumption I |= ¬[(∀x. p(x, x)) → (∃x. ∀y. p(x, y))] 2. I |= p(a) 1and → 3. I 6|= ∃x. p(x) 1and → i.e. 4. I ⊳ {x 7→ αI [a]} 6|= p(x) 3and ∃ I |= (∀x. p(x, x)) ∧ ¬(∃x. ∀y. p(x, y)) 2 and 4 are contradictory. Thus, F is valid. Choose DI = {0, 1} pI = {(0, 0), (1, 1)} i.e. pI (0, 0) and pI (1, 1) are true pI (1, 0) and pI (1, 0) are false I falsifying interpretation ⇒ F is invalid. 2- 13 2- 14 Safe Substitution F σ Rename x by x′: ′ ′ Example: replace x in ∀x by x and all free x in the scope of ∀x by x . ′ ′ scope of ∀x ∀x. G[x] ⇔ ∀x . G[x ] z }| { F : (∀x. p(x, y) ) → q(f (y), x) Same for ∃x ր տ ր տ bound by ∀x free free free ∃x. G[x] ⇔ ∃x′. G[x′] free(F )= {x, y} where x′ is a fresh variable substitution Proposition (Substitution of Equivalent Formulae) σ : {x 7→ g(x), y 7→ f (x), q(f (y), x) 7→ ∃x. h(x, y)} σ : {F1 7→ G1, · · · , Fn 7→ Gn} F σ? 1. Rename s.t. for each i, Fi ⇔ Gi F ′ : ∀x′. p(x′, y) → q(f (y), x) ↑ ↑ If F σ a safe substitution, then F ⇔ F σ where x′ is a fresh variable 2. F ′σ : ∀x′. p(x′, f (x)) → ∃x. h(x, y) 2- 15 2- 16 Formula Schema Substitution σ of H Formula σ : {F1 7→ ,..., Fn 7→ } (∀x. p(x)) ↔ (¬∃x. ¬p(x)) mapping place holders Fi of H to FOL formulae, Formula Schema (obeying the side conditions of H) H1 : (∀x. F ) ↔ (¬∃x. ¬F ) Proposition (Formula Schema) ↑ place holder If H is valid formula schema and Formula Schema (with side condition) σ is a substitution obeying H’s side conditions H2 : (∀x. F ) ↔ F provided x ∈/ free(F ) then Hσ is also valid. Valid Formula Schema Example: H is valid iff valid for any FOL formula Fi obeying the side H : (∀x. F ) ↔ F provided x ∈/ free(F ) isvalid conditions σ : {F 7→ p(y)} obeys the side condition Example: H1 and H2 are valid. Therefore Hσ : ∀x. p(y) ↔ p(y) isvalid 2- 17 2- 18 Proving Validity of Formula Schema Normal Forms Example: Prove validity of 1. Negation Normal Forms (NNF) H : (∀x. F ) ↔ F provided x ∈/ free(F ) Augment the equivalence with (left-to-right) Proof by contradiction. Consider the two directions of ↔ . ¬∀x. F [x] ⇔ ∃x. ¬F [x] First case: ¬∃x. F [x] ⇔ ∀x. ¬F [x] 1. I |= ∀x. F assumption 2. I 6|= F assumption Example 3. I |= F 1, ∀, since x 6∈ free(F ) 4. I |= ⊥ 2, 3 G : ∀x. (∃y. p(x, y) ∧ p(x, z)) → ∃w.p(x, w) . Second Case: 1. ∀x. (∃y. p(x, y) ∧ p(x, z)) → ∃w. p(x, w) 1. I 6|= ∀x. F assumption 2. ∀x. ¬(∃y. p(x, y) ∧ p(x, z)) ∨ ∃w. p(x, w) 2. I |= F assumption F1 → F2 ⇔ ¬F1 ∨ F2 3. I |= ∃x. ¬F 1 and ¬ 4. I |= ¬F 3, ∃, since x 6∈ free(F ) 3. ∀x. (∀y. ¬(p(x, y) ∧ p(x, z))) ∨ ∃w. p(x, w) 5. I |= ⊥ 2, 4 ¬∃x. F [x] ⇔ ∀x. ¬F [x] 4. ∀x. (∀y. ¬p(x, y) ∨ ¬p(x, z)) ∨ ∃w. p(x, w) H Hence, is a valid formula schema. 2- 19 2- 20 2. Prenex Normal Form (PNF) 2. Rename quantified variables to fresh names All quantifiers appear at the beginning of the formula F2 : ∀x. (∀y. ¬p(x, y) ∨ ¬p(x, z)) ∨ ∃w. p(x, w) ↑ in the scope of ∀x Q1x1 · · · Qnxn. F [x1, · · · , xn] 3. Remove all quantifiers to produce quantifier-free formula where Qi ∈ {∀, ∃} and F is quantifier-free. F3 : ¬p(x, y) ∨ ¬p(x, z) ∨ p(x, w) Every FOL formula F can be transformed to formula F ′ in PNF 4. Add the quantifiers before F3 s.t. F ′ ⇔ F . F4 : ∀x. ∀y. ∃w. ¬p(x, y) ∨ ¬p(x, z) ∨ p(x, w) Example: Find equivalent PNF of Alternately, ′ F : ∀x. ¬(∃y. p(x, y) ∧ p(x, z)) ∨ ∃y. p(x, y) F4 : ∀x. ∃w. ∀y. ¬p(x, y) ∨ ¬p(x, z) ∨ p(x, w) ↑ to the end of the formula Note: In F2, ∀y is in the scope of ∀x, therefore the order of quantifiers must be ···∀x ···∀y · · · 1.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us