Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Predicate Logic

Predicate Logic

Date: March 9, 2016
Course: UiS DAT911 - Foundations of Computer Science (fall 2016)

Please cite, link to or credit this presentation when using it or part of it in your work.

#ComputerScience #CS #PredicateLogic

Darío Garigliotti

March 09, 2016
Tweet

More Decks by Darío Garigliotti

Other Decks in Programming

Transcript

  1. Predicate Logic DAT911 - Foundations of Computer Science Dario Garigliotti

    March 9, 2016 Dario Garigliotti Predicate Logic
  2. Predicate Logic In Propositional Logic (P.L.) we could have: r

    = It is snowing in Stavanger s = It is snowing in Oslo t = It is snowing in Trondheim Dario Garigliotti Predicate Logic
  3. Predicate Logic In Propositional Logic (P.L.) we could have: r

    = It is snowing in Stavanger s = It is snowing in Oslo t = It is snowing in Trondheim A predicate is a generalization of a propositional variable: r(X) = It is snowing in X Dario Garigliotti Predicate Logic
  4. Predicate Logic In Propositional Logic (P.L.) we could have: r

    = It is snowing in Stavanger s = It is snowing in Oslo t = It is snowing in Trondheim A predicate is a generalization of a propositional variable: r(X) = It is snowing in X Atomic formula: a predicate with 0+ arguments (variables or constants) ”variables” vs ”propositional variables” 0 args: m = It is Wednesday Ground atomic formula: all arguments are constants r(Stavanger) = It is snowing in Stavanger Dario Garigliotti Predicate Logic
  5. Predicates and Logical Expressions A predicate is a generalization of

    a propositional variable: r(X) = It is snowing in X Atomic formula: a predicate with 0+ arguments (variables or constants) Logical expressions Literals: an atomic formula or its negation p(X, a), ¬p(a, b) Dario Garigliotti Predicate Logic
  6. Predicates and Logical Expressions A predicate is a generalization of

    a propositional variable: r(X) = It is snowing in X Atomic formula: a predicate with 0+ arguments (variables or constants) Logical expressions Literals: an atomic formula or its negation p(X, a), ¬p(a, b) Expressions: by using logical operators ¬, ∨, ∧, =⇒ , ≡ quantifiers ∀, ∃ Dario Garigliotti Predicate Logic
  7. Quantifiers For our predicate r(X) = It is snowing in

    X if we want to express: It is snowing in at least one city r(Berlin) ∨ r(London) ∨ r(Paris) ∨ r(Rome) ∨ ... we do it by the existential quantifier: (∃X)r(X) In the case of expressing For all the cities..., we use the universal quantifier: (∀X)r(X) Dario Garigliotti Predicate Logic
  8. Quantifiers Recursive definition of logical expressions Basis: every atomic formula

    is an expression Induction: E, F logical expressions, then so are ¬E, E ∧ F, E ∨ F, E =⇒ F, E ≡ F (∀X)E, (∃X)E, for any variable X Dario Garigliotti Predicate Logic
  9. Quantifiers Recursive definition of logical expressions Basis: every atomic formula

    is an expression Induction: E, F logical expressions, then so are ¬E, E ∧ F, E ∨ F, E =⇒ F, E ≡ F (∀X)E, (∃X)E, for any variable X A little more about quantifiers Precedence of operators: ∀, ∃ have highest precedence, then as in P.L.: ¬, ∧, ∨, =⇒ , ≡ Importance of order: (∀X)(∃Y ) vs (∃X)(∀Y ) Bound and free variables Dario Garigliotti Predicate Logic
  10. Quantifiers: Bound and Free Variables A quantifier ”declares” a variable

    within a ”scope” E.g. (∀X)r(X) ∨ (∀X)s(X) Let’s think on its expression tree ∨ − − − (∀X) − − − r(X) \ \ − − − (∀X) − − − s(X) An occurrence of a variable X in an expression E is bound by a quantifier (QX) if in its expression tree, (QX) is the lowest ancestor involving X Otherwise, that occurrence is free Dario Garigliotti Predicate Logic
  11. Quantifiers: Bound and Free Occurrences of Variables An occurrence of

    a variable X in an expression E is bound by a quantifier (QX) if in its expression tree, (QX) is the lowest ancestor involving X Otherwise, that occurrence is free Another example: r(X) ∨ (∃X)s(X) ∨ − − − r(X) \ \ − − − (∃X) − − − s(X) Then we mean: bound and free occurrences of variables Dario Garigliotti Predicate Logic
  12. Interpretations An example: E ≡ p(X, Y ) =⇒ (∃Z)(p(X,

    Z) ∧ p(Z, Y )) An interpretation for E is defined by: Dario Garigliotti Predicate Logic
  13. Interpretations An example: E ≡ p(X, Y ) =⇒ (∃Z)(p(X,

    Z) ∧ p(Z, Y )) An interpretation for E is defined by: an interpretation I for the predicate based on the assignment of values in D to its arguments, e.g. I1 : p(U, V ) ≡ U < V Dario Garigliotti Predicate Logic
  14. Interpretations An example: E ≡ p(X, Y ) =⇒ (∃Z)(p(X,

    Z) ∧ p(Z, Y )) An interpretation for E is defined by: an interpretation I for the predicate based on the assignment of values in D to its arguments, e.g. I1 : p(U, V ) ≡ U < V a domain D from which to select values for the variables, e.g. D = R Dario Garigliotti Predicate Logic
  15. Interpretations An example: E ≡ p(X, Y ) =⇒ (∃Z)(p(X,

    Z) ∧ p(Z, Y )) An interpretation for E is defined by: an interpretation I for the predicate based on the assignment of values in D to its arguments, e.g. I1 : p(U, V ) ≡ U < V a domain D from which to select values for the variables, e.g. D = R a value in D for each free occurrences of variables Dario Garigliotti Predicate Logic
  16. Interpretations An example: E ≡ p(X, Y ) =⇒ (∃Z)(p(X,

    Z) ∧ p(Z, Y )) An interpretation for E is defined by: an interpretation I for the predicate based on the assignment of values in D to its arguments, e.g. I1 : p(U, V ) ≡ U < V a domain D from which to select values for the variables, e.g. D = R a value in D for each free occurrences of variables given I1 with D, we can define infinite interpretations such that E is true Dario Garigliotti Predicate Logic
  17. Interpretations An example: E ≡ p(X, Y ) =⇒ (∃Z)(p(X,

    Z) ∧ p(Z, Y )) An interpretation for E is defined by: an interpretation I for the predicate based on the assignment of values in D to its arguments, e.g. I1 : p(U, V ) ≡ U < V a domain D from which to select values for the variables, e.g. D = R a value in D for each free occurrences of variables given I1 with D, we can define infinite interpretations such that E is true what if we use I2 by defining D = Z? Dario Garigliotti Predicate Logic
  18. Interpretations An example: E ≡ p(X, Y ) =⇒ (∃Z)(p(X,

    Z) ∧ p(Z, Y )) An interpretation for E is defined by: an interpretation I for the predicate based on the assignment of values in D to its arguments, e.g. I1 : p(U, V ) ≡ U < V a domain D from which to select values for the variables, e.g. D = R a value in D for each free occurrences of variables given I1 with D, we can define infinite interpretations such that E is true what if we use I2 by defining D = Z? E always true except for those in which Y = X + 1 Dario Garigliotti Predicate Logic
  19. Interpretations We can give a definition of the interpretation of

    an expression E, by induction in its expression tree E ≡ p(X1, ..., Xn) E ≡ E1 ∧ E2 E ≡ E1 ∨ E2 E ≡ ¬E1 E ≡ (∃X)E1 E ≡ (∀X)E1 Dario Garigliotti Predicate Logic
  20. Tautologies - Substitutions and Equivalences E is a tautology if

    its value is true for every interpretation of E The previous example is not: E ≡ p(X, Y ) =⇒ (∃Z)(p(X, Z) ∧ p(Z, Y )) E.g. of a tautology: q(X) ∨ ¬q(X) Dario Garigliotti Predicate Logic
  21. Tautologies - Substitutions and Equivalences E is a tautology if

    its value is true for every interpretation of E The previous example is not: E ≡ p(X, Y ) =⇒ (∃Z)(p(X, Z) ∧ p(Z, Y )) E.g. of a tautology: q(X) ∨ ¬q(X) The substitution principle allows to obtain tautologies in predicate logic from propositional tautologies E.g. the latter, after replacing in p ∨ ¬p Dario Garigliotti Predicate Logic
  22. Tautologies - Substitutions and Equivalences E is a tautology if

    its value is true for every interpretation of E The previous example is not: E ≡ p(X, Y ) =⇒ (∃Z)(p(X, Z) ∧ p(Z, Y )) E.g. of a tautology: q(X) ∨ ¬q(X) The substitution principle allows to obtain tautologies in predicate logic from propositional tautologies E.g. the latter, after replacing in p ∨ ¬p We can say that E and F are equivalent if E ≡ F is a tautology Then, by substitution, if E1 ≡ E2, and we replace in F1 one by another, we obtain an expression F2 such that F1 ≡ F2 Dario Garigliotti Predicate Logic
  23. Tautologies Involving Quantifiers Let’s describe two techniques for tautologies with

    quantifiers 1 Rectifying expressions Variable renaming: (QX)E ≡ (QX)E , where E is obtained from E by replacing all occurrences of bound X for a fresh (not free in E) Y Rectified expression by renaming it without repeating variables Dario Garigliotti Predicate Logic
  24. Tautologies Involving Quantifiers Let’s describe two techniques for tautologies with

    quantifiers 1 Rectifying expressions Variable renaming: (QX)E ≡ (QX)E , where E is obtained from E by replacing all occurrences of bound X for a fresh (not free in E) Y Rectified expression by renaming it without repeating variables 2 Moving quantifiers outside ¬((∀X)E) ≡ (∃X)(¬E) ¬((∃X)E) ≡ (∀X)(¬E) (E ∧ (QX)F) ≡ (QX)(E ∧ F) (X not free in E) (E ∨ (QX)F) ≡ (QX)(E ∨ F) (X not free in E) Dario Garigliotti Predicate Logic
  25. Tautologies Involving Quantifiers With those two steps, we can get

    an equivalent quantifier-free expression (or prenex-form expression) of the shape (Q1X1)(Q2X2)...(QkXk)E E.g. from E ≡ (∀X)p(X) ∨ ¬(∀X)p(X) Dario Garigliotti Predicate Logic
  26. Tautologies Involving Quantifiers With those two steps, we can get

    an equivalent quantifier-free expression (or prenex-form expression) of the shape (Q1X1)(Q2X2)...(QkXk)E E.g. from E ≡ (∀X)p(X) ∨ ¬(∀X)p(X) Rectifying expression: (∀X)p(X) ∨ ¬(∀Y )p(Y ) Dario Garigliotti Predicate Logic
  27. Tautologies Involving Quantifiers With those two steps, we can get

    an equivalent quantifier-free expression (or prenex-form expression) of the shape (Q1X1)(Q2X2)...(QkXk)E E.g. from E ≡ (∀X)p(X) ∨ ¬(∀X)p(X) Rectifying expression: (∀X)p(X) ∨ ¬(∀Y )p(Y ) Moving Qs outside: (∀X)p(X) ∨ (∃Y )¬p(Y ) Dario Garigliotti Predicate Logic
  28. Tautologies Involving Quantifiers With those two steps, we can get

    an equivalent quantifier-free expression (or prenex-form expression) of the shape (Q1X1)(Q2X2)...(QkXk)E E.g. from E ≡ (∀X)p(X) ∨ ¬(∀X)p(X) Rectifying expression: (∀X)p(X) ∨ ¬(∀Y )p(Y ) Moving Qs outside: (∀X)p(X) ∨ (∃Y )¬p(Y ) Moving Qs outside: (∀X)(∃Y )(p(X) ∨ ¬p(Y )) Dario Garigliotti Predicate Logic
  29. Proofs in Predicate Logic: Basics Given some hypotheses E1, E2,

    ..., Ek, a proof is a sequence of expressions such that each of them either is one if the Ei ’s or follows from 0+ previous expressions by some rule of inference A rule of inference is of the shape (F1 ∧ F2 ∧ ... ∧ Fn) =⇒ F Then, the law of variable substitution: given E asserted, E =⇒ sub(E) is a tautology E.g. p(X, Y ) =⇒ p(U, V ) E.g. p(X, Y ) =⇒ p(1, 2) Dario Garigliotti Predicate Logic
  30. Proofs in Predicate Logic: From Rules and Facts Two main

    kind of hypotheses: Facts: ground atomic formulas, e.g. p(1) Rules: ”if-then” expressions, with a body of subgoals and a head, e.g. p(X) ∧ q(Y ) =⇒ r(X) Dario Garigliotti Predicate Logic
  31. Proofs in Predicate Logic: From Rules and Facts Two main

    kind of hypotheses: Facts: ground atomic formulas, e.g. p(1) Rules: ”if-then” expressions, with a body of subgoals and a head, e.g. p(X) ∧ q(Y ) =⇒ r(X) Then, a proof can be build in this way, e.g. 1 p(X) ∧ q(Y ) =⇒ r(X) (Hypothesis: rule) 2 p(1) (Hypothesis: fact) 3 q(3) (Hypothesis: fact) Dario Garigliotti Predicate Logic
  32. Proofs in Predicate Logic: From Rules and Facts Two main

    kind of hypotheses: Facts: ground atomic formulas, e.g. p(1) Rules: ”if-then” expressions, with a body of subgoals and a head, e.g. p(X) ∧ q(Y ) =⇒ r(X) Then, a proof can be build in this way, e.g. 1 p(X) ∧ q(Y ) =⇒ r(X) (Hypothesis: rule) 2 p(1) (Hypothesis: fact) 3 q(3) (Hypothesis: fact) 4 p(1) ∧ q(3) Dario Garigliotti Predicate Logic
  33. Proofs in Predicate Logic: From Rules and Facts Two main

    kind of hypotheses: Facts: ground atomic formulas, e.g. p(1) Rules: ”if-then” expressions, with a body of subgoals and a head, e.g. p(X) ∧ q(Y ) =⇒ r(X) Then, a proof can be build in this way, e.g. 1 p(X) ∧ q(Y ) =⇒ r(X) (Hypothesis: rule) 2 p(1) (Hypothesis: fact) 3 q(3) (Hypothesis: fact) 4 p(1) ∧ q(3) 5 p(1) ∧ q(3) =⇒ r(1) Dario Garigliotti Predicate Logic
  34. Proofs in Predicate Logic: From Rules and Facts Two main

    kind of hypotheses: Facts: ground atomic formulas, e.g. p(1) Rules: ”if-then” expressions, with a body of subgoals and a head, e.g. p(X) ∧ q(Y ) =⇒ r(X) Then, a proof can be build in this way, e.g. 1 p(X) ∧ q(Y ) =⇒ r(X) (Hypothesis: rule) 2 p(1) (Hypothesis: fact) 3 q(3) (Hypothesis: fact) 4 p(1) ∧ q(3) 5 p(1) ∧ q(3) =⇒ r(1) 6 r(1) Dario Garigliotti Predicate Logic
  35. Provability and Truth Idea of model: an interpretation which makes

    an expression true Similarly, a model of a collection of expressions {E1, E2, ..., En} Entailment or satisfaction: E1, E2, ..., En |= E if every model for the collection is also a model for E Provability: E1, E2, ..., En E Consistency of a proof system: provability =⇒ entailment Completeness of a proof system: entailment =⇒ provability Dario Garigliotti Predicate Logic