Upcoming SlideShare
×

03 - Predicate logic

2,755 views

Published on

I used this set of slides for the lecture on Predicate Logic I gave at the University of Zurich for the 1st year students following the course of Formale Grundlagen der Informatik.

Published in: Technology
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
2,755
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
107
0
Likes
1
Embeds 0
No embeds

No notes for slide

03 - Predicate logic

1. 1. Predicate logic www.tudorgirba.com
2. 2. Boolean algebra Propositional logic 0, 1 True, False boolean variables: a∈{0, 1} atomic formulas: p∈{True,False} boolean operators: ¬ ∧ ∨ logical connectives: ¬ ∧ ∨ boolean functions: 0, 1 boolean variables if a is a boolean function, then ¬a is a boolean function if a and b are boolean functions, then a∧b, a∨b, a b, a b are boolean functions propositional formulas (propositions): True and False atomic formulas if a is a propositional formula, then ¬a is a propositional formula if a and b are propositional formulas, then a∧b, a∨b, a b, a b are propositional formulas truth value of a boolean function (truth tables) truth value of a propositional formula (truth tables)
3. 3. Boolean algebra Propositional logic 0, 1 True, False boolean variables: a∈{0, 1} atomic formulas: p∈{True,False} boolean operators: ¬ ∧ ∨ logical connectives: ¬ ∧ ∨ boolean functions: 0, 1 boolean variables if a is a boolean function, then ¬a is a boolean function if a and b are boolean functions, then a∧b, a∨b, a b, a b are boolean functions propositional formulas (propositions): True and False atomic formulas if a is a propositional formula, then ¬a is a propositional formula if a and b are propositional formulas, then a∧b, a∨b, a b, a b are propositional formulas truth value of a boolean function (truth tables) truth value of a propositional formula (truth tables)
4. 4. The Russian spy problem There are three persons: Stirlitz, Mueller, and Eismann. It is known that exactly one of them is Russian, while the other two are Germans. Moreover, every Russian must be a spy. When Stirlitz meets Mueller in a corridor, he makes the following joke: “you know, Mueller, you are as German as I am Russian”. It is known that Stirlitz always says the truth when he is joking. Establish that Eismann is not a Russian spy.
5. 5. There are three persons: Stirlitz, Mueller, and Eismann. It is known that exactly one of them is Russian, while the other two are Germans. Moreover, every Russian must be a spy. When Stirlitz meets Mueller in a corridor, he makes the following joke: “you know, Mueller, you are as German as I am Russian”. It is known that Stirlitz always says the truth when he is joking. Establish that Eismann is not a Russian spy.
6. 6. There are three persons: Stirlitz, Mueller, and Eismann. It is known that exactly one of them is Russian, while the other two are Germans. Moreover, every Russian must be a spy. When Stirlitz meets Mueller in a corridor, he makes the following joke: “you know, Mueller, you are as German as I am Russian”. It is known that Stirlitz always says the truth when he is joking. Establish that Eismann is not a Russian spy. X ∈ {R, G, S} (denoting Russian, German, Spy) Y ∈ {S,M,E} (denoting Stirlitz, Müller, Eismann) SE : Eismann is a Spy RS : Stirlitz is Russian
7. 7. There are three persons: Stirlitz, Mueller, and Eismann. It is known that exactly one of them is Russian, while the other two are Germans. (RS ∧ GM ∧ GE) ∨ (GS ∧ RM ∧ GE) ∨ (GS ∧ GM ∧ RE). (RS ¬GS) ∧ (RM ¬GM) ∧ (RE ¬GE). Moreover, every Russian must be a spy. (RS SS) ∧ (RM SM) ∧ (RE SE). When Stirlitz meets Mueller in a corridor, he makes the following joke: “you know, Mueller, you are as German as I am Russian”. It is known that Stirlitz always says the truth when he is joking. RS GM. Establish that Eismann is not a Russian spy. RE ∧ SE.
8. 8. There are three persons: Stirlitz, Mueller, and Eismann. It is known that exactly one of them is Russian, while the other two are Germans. (RS ∧ GM ∧ GE) ∨ (GS ∧ RM ∧ GE) ∨ (GS ∧ GM ∧ RE). (RS ¬GS) ∧ (RM ¬GM) ∧ (RE ¬GE). Moreover, every Russian must be a spy. (RS SS) ∧ (RM SM) ∧ (RE SE). When Stirlitz meets Mueller in a corridor, he makes the following joke: “you know, Mueller, you are as German as I am Russian”. It is known that Stirlitz always says the truth when he is joking. RS GM. Establish that Eismann is not a Russian spy. RE ∧ SE.
9. 9. There are three persons: Stirlitz, Mueller, and Eismann. It is known that exactly one of them is Russian, while the other two are Germans. (RS ∧ GM ∧ GE) ∨ (GS ∧ RM ∧ GE) ∨ (GS ∧ GM ∧ RE). (RS ¬GS) ∧ (RM ¬GM) ∧ (RE ¬GE). Moreover, every Russian must be a spy. (RS SS) ∧ (RM SM) ∧ (RE SE). When Stirlitz meets Mueller in a corridor, he makes the following joke: “you know, Mueller, you are as German as I am Russian”. It is known that Stirlitz always says the truth when he is joking. RS GM. Establish that Eismann is not a Russian spy. RE ∧ SE.
10. 10. There are three persons: Stirlitz, Mueller, and Eismann. It is known that exactly one of them is Russian, while the other two are Germans. (RS ∧ GM ∧ GE) ∨ (GS ∧ RM ∧ GE) ∨ (GS ∧ GM ∧ RE). (RS ¬GS) ∧ (RM ¬GM) ∧ (RE ¬GE). Moreover, every Russian must be a spy. (RS SS) ∧ (RM SM) ∧ (RE SE). When Stirlitz meets Mueller in a corridor, he makes the following joke: “you know, Mueller, you are as German as I am Russian”. It is known that Stirlitz always says the truth when he is joking. RS GM. Establish that Eismann is not a Russian spy. RE ∧ SE.
11. 11. There are three persons: Stirlitz, Mueller, and Eismann. It is known that exactly one of them is Russian, while the other two are Germans. (RS ∧ GM ∧ GE) ∨ (GS ∧ RM ∧ GE) ∨ (GS ∧ GM ∧ RE). (RS ¬GS) ∧ (RM ¬GM) ∧ (RE ¬GE). Moreover, every Russian must be a spy. (RS SS) ∧ (RM SM) ∧ (RE SE). When Stirlitz meets Mueller in a corridor, he makes the following joke: “you know, Mueller, you are as German as I am Russian”. It is known that Stirlitz always says the truth when he is joking. RS GM. Establish that Eismann is not a Russian spy. RE ∧ SE.
12. 12. There are three persons: Stirlitz, Mueller, and Eismann. It is known that exactly one of them is Russian, while the other two are Germans. (RS ∧ GM ∧ GE) ∨ (GS ∧ RM ∧ GE) ∨ (GS ∧ GM ∧ RE). (RS ¬GS) ∧ (RM ¬GM) ∧ (RE ¬GE). Moreover, every Russian must be a spy. (RS SS) ∧ (RM SM) ∧ (RE SE). When Stirlitz meets Mueller in a corridor, he makes the following joke: “you know, Mueller, you are as German as I am Russian”. It is known that Stirlitz always says the truth when he is joking. RS GM. Establish that Eismann is not a Russian spy. RE ∧ SE.
13. 13. computer information information computation
14. 14. 2 is greater than 5
15. 15. 2 is greater than 5 False
16. 16. 2 is greater than 5 6 is greater than 5 False
17. 17. 2 is greater than 5 6 is greater than 5 False True
18. 18. 2 is greater than 5 6 is greater than 5 False True x is greater than 5
19. 19. 2 is greater than 5 6 is greater than 5 False True x is greater than 5 ?
20. 20. 2 is greater than 5 6 is greater than 5 False True x is greater than 5 ? predicate
21. 21. x is greater than 5 2 is greater than 5 6 is greater than 5 False True predicate
22. 22. x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5 False True predicate
23. 23. x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5F(6) = F(2) = False True predicate
24. 24. x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5F(6) = F(2) = False True for all natural numbers x, x is greater than 5 predicate
25. 25. x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5F(6) = F(2) = False True for all natural numbers x, x is greater than 5 False predicate
26. 26. x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5F(6) = F(2) = False True for all natural numbers x, x is greater than 5 False for some natural numbers x, x is greater than 5 predicate
27. 27. True x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5F(6) = F(2) = False True for all natural numbers x, x is greater than 5 False for some natural numbers x, x is greater than 5 predicate
28. 28. True x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5F(6) = F(2) = False True for all natural numbers x, x is greater than 5 False for some natural numbers x, x is greater than 5 predicate quantiﬁer
29. 29. True x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5F(6) = F(2) = False True for all natural numbers x, x is greater than 5 False for some natural numbers x, x is greater than 5 predicate quantiﬁer quantiﬁer
30. 30. True x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5F(6) = F(2) = False True for all natural numbers x, x is greater than 5 False for some natural numbers x, x is greater than 5 predicate quantiﬁer quantiﬁer universe
31. 31. Existential quantiﬁers ∃ :Universal quantiﬁer ∀ : ∀x: U(x): F(x) ∃x: U(x): F(x) ∀x:x∈N:x>5 ∃x:x∈N:x>5 for all natural numbers x, x is greater than 5 for some natural numbers x, x is greater than 5
32. 32. Gottlob Frege 1848—1925 no appeal to intuition
33. 33. Distributivity of ∀ ∧ ∀x: U(x): (P(x) ∧ Q(x)) Distributivity of ∃ ∨ ∃x: U(x): (P(x) ∨ Q(x)) Non-distributivity of ∀ ∨ (∀x: U(x): P(x)) ∨ (∀x: U(x): Q(x)) Non-distributivity of ∃ ∧ ∃x: U(x): (P(x) ∧ Q(x)) (∀x: U(x): P(x)) ∧ (∀ x: U(x): Q(x)) (∃x: U(x): P(x)) ∨ (∃ x: U(x): Q(x)) ∀x: U(x): (P(x) ∨ Q(x)) (∃x: U(x): P(x)) ∧ (∃x: U(x): Q(x))
34. 34. Examples
35. 35. ∀ i: 0≤i<N: ai=0 Examples
36. 36. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero Examples
37. 37. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai Examples
38. 38. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing Examples
39. 39. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj Examples
40. 40. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing Examples
41. 41. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj Examples
42. 42. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal Examples
43. 43. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 Examples
44. 44. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a Examples
45. 45. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 Examples
46. 46. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero Examples
47. 47. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero ∃ i: 1≤i<N: ai-1 > ai Examples
48. 48. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero ∃ i: 1≤i<N: ai-1 > ai elements of array a are not monotonically increasing Examples
49. 49. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero ∃ i: 1≤i<N: ai-1 > ai elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai > aj Examples
50. 50. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero ∃ i: 1≤i<N: ai-1 > ai elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai > aj elements of array a are not monotonically increasing Examples
51. 51. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero ∃ i: 1≤i<N: ai-1 > ai elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai > aj elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai ≠ aj Examples
52. 52. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero ∃ i: 1≤i<N: ai-1 > ai elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai > aj elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai ≠ aj not all elements of array a are equal Examples
53. 53. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero ∃ i: 1≤i<N: ai-1 > ai elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai > aj elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai ≠ aj not all elements of array a are equal ∃ i: 0<i<N: ai > a0 Examples
54. 54. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero ∃ i: 1≤i<N: ai-1 > ai elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai > aj elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai ≠ aj not all elements of array a are equal ∃ i: 0<i<N: ai > a0 a0 is not the greatest element of array a Examples
55. 55. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero ∀ i: 1≤i<N: ai-1 ≤ ai elements of array a are monotonically increasing ∀ i,j: 0≤i<j<N: ai ≤ aj elements of array a are monotonically increasing ∀ i,j: 0≤i,j<N: ai = aj all elements of array a are equal ∀ i: 0<i<N: ai ≤ a0 a0 is the greatest element of array a ∃ i: 0≤i<N: ai ≠ 0 at least one element of array a (of length N) is not zero ∃ i: 1≤i<N: ai-1 > ai elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai > aj elements of array a are not monotonically increasing ∃ i,j: 0≤i<j<N: ai ≠ aj not all elements of array a are equal ∃ i: 0<i<N: ai > a0 a0 is not the greatest element of array a Examples
56. 56. ¬(∃ x: U(x): F(x)) ∀ x: U(x): ¬ F(x) ¬(∀ x: U(x): F(x)) ∃ x: U(x): ¬ F(x) De Morgan’s Axiom ¬∃ : De Morgan’s Axiom ¬∀ :
57. 57. Example What is the negation of the statement “Always, when he drives then he is sober.”
58. 58. Example What is the negation of the statement “Always, when he drives then he is sober.” D(t): He drives at moment t.
59. 59. Example What is the negation of the statement “Always, when he drives then he is sober.” D(t): He drives at moment t. S(t): He is sober at moment t.
60. 60. Example What is the negation of the statement “Always, when he drives then he is sober.” D(t): He drives at moment t. S(t): He is sober at moment t. ∀t : D(t)->S(t)
61. 61. Example What is the negation of the statement “Always, when he drives then he is sober.” D(t): He drives at moment t. S(t): He is sober at moment t. ∀t : D(t)->S(t) ¬(∀t :: D(t)->S(t))
62. 62. Example What is the negation of the statement “Always, when he drives then he is sober.” D(t): He drives at moment t. S(t): He is sober at moment t. ∀t : D(t)->S(t) ¬(∀t :: D(t)->S(t)) ¬(∀t :: ¬D(t)∨S(t))
63. 63. Example What is the negation of the statement “Always, when he drives then he is sober.” D(t): He drives at moment t. S(t): He is sober at moment t. ∀t : D(t)->S(t) ¬(∀t :: D(t)->S(t)) ¬(∀t :: ¬D(t)∨S(t)) ∃t :: ¬(¬D(t)∨S(t))
64. 64. Example What is the negation of the statement “Always, when he drives then he is sober.” D(t): He drives at moment t. S(t): He is sober at moment t. ∀t : D(t)->S(t) ¬(∀t :: D(t)->S(t)) ¬(∀t :: ¬D(t)∨S(t)) ∃t :: ¬(¬D(t)∨S(t)) ∃t :: D(t)∧¬S(t))
65. 65. computer information information computation
66. 66. True, False are WFFs. Propositional variables are WFFs. Predicates with variables are WFFs. If A and B are WFFs, then ¬A, A∧B, A∨B, A B, A B are also WFFs. If x is a variable in universe U and A is a WFF, then ∀x:U(x):A(x) and ∃x:U(x):A(x) are also WFFs. Well formed formulas (WFF)
67. 67. Bounded variables (∃j: 0<j<N: P(i,j) ∨ Q(i,j)) Free variables If a variable is not bound in a WFF then it is free. An appearance of variable is bound in a WFF if a speciﬁc value is assigned to it, or it is quantiﬁed. ∃i: 0<i<N: ( ∃i,j: 0<i,j<N: P(i,j) ∨ Q(i,j)
68. 68. Bounded variables (∃j: 0<j<N: P(i,j) ∨ Q(i,j)) Free variables If a variable is not bound in a WFF then it is free. An appearance of variable is bound in a WFF if a speciﬁc value is assigned to it, or it is quantiﬁed. ∃i: 0<i<N: ( ) ∃i,j: 0<i,j<N: P(i,j) ∨ Q(i,j)
69. 69. ∃x: U1(x): (∀y: U2(y): Q(x,y)) ∀y: U2(y): (∃x: U1(x): Q(x,y)) ∃x: U1(x): (∀y: U2(y): Q(x,y)) ∀y: U2(y): (∃x: U1(x): Q(x,y)) ∀y: U2(y): (∃x: U1(x): Q(x,y)) ∃x: U1(y): (∀y: U2(y): Q(x,y)) Swapping ∀ and ∃ ∀x: U1(x): (∀y: U2(y): Q(x,y)) ∀y: U2(y): (∀x: U1(x): Q(x,y)) ∃x: U1(x): (∃y: U2(y): Q(x,y)) ∃y: U2(y): (∃x: U1(x): Q(x,y)) However
70. 70. ∃x: U1(x): (∀y: U2(y): Q(x,y)) ∀y: U2(y): (∃x: U1(x): Q(x,y)) ∃x: U1(x): (∀y: U2(y): Q(x,y)) ∀y: U2(y): (∃x: U1(x): Q(x,y)) ∀y: U2(y): (∃x: U1(x): Q(x,y)) ∃x: U1(y): (∀y: U2(y): Q(x,y)) Swapping ∀ and ∃ ∀x: U1(x): (∀y: U2(y): Q(x,y)) ∀y: U2(y): (∀x: U1(x): Q(x,y)) ∃x: U1(x): (∃y: U2(y): Q(x,y)) ∃y: U2(y): (∃x: U1(x): Q(x,y)) However
71. 71. Example Every boy loves some girl does not imply that some girl is loved by every boy. U1 - the universe of boys. U2 - the universe of girls. Q(x,y) - boy x loves girl y. ∀y: U2(y): (∃x: U1(x): Q(x,y)) ∃x: U1(y): (∀y: U2(y): Q(x,y))
72. 72. ∀x: U(x): (Q(x) ∨ P) (∀x: U(x): Q(x)) ∨ P ∀x: U(x): (Q(x) ∧ P) (∀x: U(x): Q(x)) ∧ P ∃x: U(x): (Q(x) ∨ P) (∃x: U(x): Q(x)) ∨ P ∃x: U(x): (Q(x) ∧ P) (∃x: U(x): Q(x)) ∧ P If P does not contain x as a free variable
73. 73. Example Given: an array a[0..N-1] of length N≥3 Find: i, j, k such that: i is the index of the greatest element of a; j is the index of the 2nd greatest element of a; k is the index of the 3rd greatest element of a.
74. 74. Example Given: an array a[0..N-1] of length N≥3 Find: i, j, k such that: i is the index of the greatest element of a; j is the index of the 2nd greatest element of a; k is the index of the 3rd greatest element of a. ∃ i,j,k: (0≤i,j,k<N)∧(i≠j)∧(i≠k)∧(j≠k): ( (ai≥aj≥ak) ∧ (∀m: (0≤m<N)∧(m≠i)∧(m≠j)∧(m≠k): ak≥am) )
75. 75. Example All elements of an array a of length N are either zero or one
76. 76. Example All elements of an array a of length N are either zero or one ∀i: 0≤i<N: ( ai=0 ∨ ai=1 )
77. 77. Example All elements of an array a of length N are either zero or one ∀i: 0≤i<N: ( ai=0 ∨ ai=1 ) (∀i: 0≤i<N: ai=0) ∨ (∀i: 0≤i<N: ai=1) (1) (2)
78. 78. Example All elements of an array a of length N are either zero or one ∀i: 0≤i<N: ( ai=0 ∨ ai=1 ) (∀i: 0≤i<N: ai=0) ∨ (∀i: 0≤i<N: ai=1) (1) (2) ambiguous
79. 79. Example The elements of arrays a and b are the same (both arrays of length N).
80. 80. Example The elements of arrays a and b are the same (both arrays of length N). ∀i: 0≤i<N: (ai=bi)(1)
81. 81. Example The elements of arrays a and b are the same (both arrays of length N). ∀i: 0≤i<N: (ai=bi) ∀i: 1≤i<N: ((ai=ai-1) ∧ (bi=bi-1)) (1) (2)
82. 82. Example The elements of arrays a and b are the same (both arrays of length N). ∀i: 0≤i<N: (ai=bi) ∀i: 1≤i<N: ((ai=ai-1) ∧ (bi=bi-1)) (1) (2) (∀i: 1≤i<N: (ai=ai-1)) ∧ (∀i: 0≤i<N: (ai=bi))(3)
83. 83. Example The elements of arrays a and b are the same (both arrays of length N). ∀i: 0≤i<N: (ai=bi) ∀i: 1≤i<N: ((ai=ai-1) ∧ (bi=bi-1)) (1) (2) (∀i: 1≤i<N: (ai=ai-1)) ∧ (∀i: 0≤i<N: (ai=bi))(3) ∀i: 0≤i<N: (∃ j: 0≤j<N: (ai=bi) )(4)
84. 84. Example The elements of arrays a and b are the same (both arrays of length N). ∀i: 0≤i<N: (ai=bi) ∀i: 1≤i<N: ((ai=ai-1) ∧ (bi=bi-1)) (1) (2) ambiguous (∀i: 1≤i<N: (ai=ai-1)) ∧ (∀i: 0≤i<N: (ai=bi))(3) ∀i: 0≤i<N: (∃ j: 0≤j<N: (ai=bi) )(4)
85. 85. Example
86. 86. They drank two cups of tea because they were warm. Example
87. 87. They drank two cups of tea because they were warm. They drank two cups of tea because they were cold. Example
89. 89. Go to the shop and buy bread. If they have eggs, buy 10. ... Do you have eggs? Yes. Then give me 10 pieces of bread. Example
90. 90. Min x: U(x): T(x) gives the “smallest value of terms T(x) for all objects x from the universe U“
91. 91. Min x: U(x): T(x) gives the “smallest value of terms T(x) for all objects x from the universe U“ Min x: False: T(x) is +∞.
92. 92. Min x: U(x): T(x) gives the “smallest value of terms T(x) for all objects x from the universe U“ Min x: False: T(x) is +∞. ( m = (Min i: 0≤i<N: a[i]) )
93. 93. Min x: U(x): T(x) gives the “smallest value of terms T(x) for all objects x from the universe U“ Min x: False: T(x) is +∞. ( m = (Min i: 0≤i<N: a[i]) ) ((∃ i: 0≤i<N: m=a[i]) ∧ (∀ i: 0≤i<N: m≤a[i]))
94. 94. Max x: U(x): T(x) gives the “greatest value of terms T(x) for all objects x from the universe U“
95. 95. Max x: U(x): T(x) gives the “greatest value of terms T(x) for all objects x from the universe U“ Max x: False: T(x) is -∞.
96. 96. Max x: U(x): T(x) gives the “greatest value of terms T(x) for all objects x from the universe U“ Max x: False: T(x) is -∞. Max x: U(x): T(x) = - (Min x: U(x): - T(x))
97. 97. Max x: U(x): T(x) gives the “greatest value of terms T(x) for all objects x from the universe U“ Max x: False: T(x) is -∞. Max x: U(x): T(x) = - (Min x: U(x): - T(x)) Min x: U(x): T(x) = - (Max x: U(x): - T(x))
98. 98. Anz x: U(x): F(x) gives the “number of all those objects x from the universe U for which F(x) holds“
99. 99. Anz x: U(x): F(x) gives the “number of all those objects x from the universe U for which F(x) holds“ Anz x: False: F(x) is 0.
100. 100. Anz x: U(x): F(x) gives the “number of all those objects x from the universe U for which F(x) holds“ Anz x: False: F(x) is 0. ((Anz x: U(x): F(x)) = 0) ∀x: U(x):¬F(x)
101. 101. Anz x: U(x): F(x) gives the “number of all those objects x from the universe U for which F(x) holds“ Anz x: False: F(x) is 0. ((Anz x: U(x): F(x)) = 0) ∀x: U(x):¬F(x) ((Anz x: U(x): F(x)) ≥ 0) ∃x: U(x): F(x)
102. 102. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. Example
103. 103. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. (Anz i: 0≤i<N: ai=0) = 0 Example
104. 104. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. (Anz i: 0≤i<N: ai=0) = 0 all elements ai of a are different than 0 Example
105. 105. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. (Anz i: 0≤i<N: ai=0) = 0 all elements ai of a are different than 0 (Anz i: 0≤i<N: ai=x) > 0 Example
106. 106. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. (Anz i: 0≤i<N: ai=0) = 0 all elements ai of a are different than 0 (Anz i: 0≤i<N: ai=x) > 0 at least one element ai has the value x (x∈N) Example
107. 107. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. (Anz i: 0≤i<N: ai=0) = 0 all elements ai of a are different than 0 (Anz i: 0≤i<N: ai=x) > 0 at least one element ai has the value x (x∈N) (Anz i: 0≤i<N: ai<x) = (Anz i: 0≤i<N: ai>x) Example
108. 108. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. (Anz i: 0≤i<N: ai=0) = 0 all elements ai of a are different than 0 (Anz i: 0≤i<N: ai=x) > 0 at least one element ai has the value x (x∈N) (Anz i: 0≤i<N: ai<x) = (Anz i: 0≤i<N: ai>x) x is the median value of a Example
109. 109. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. (Anz i: 0≤i<N: ai=0) = 0 all elements ai of a are different than 0 (Anz i: 0≤i<N: ai=x) > 0 at least one element ai has the value x (x∈N) (Anz i: 0≤i<N: ai<x) = (Anz i: 0≤i<N: ai>x) x is the median value of a ∀x:: ( (Anz i: 0≤i<N: ai=x) = (Anz i: 0≤i<N: bi=x) ) Example
110. 110. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. (Anz i: 0≤i<N: ai=0) = 0 all elements ai of a are different than 0 (Anz i: 0≤i<N: ai=x) > 0 at least one element ai has the value x (x∈N) (Anz i: 0≤i<N: ai<x) = (Anz i: 0≤i<N: ai>x) x is the median value of a ∀x:: ( (Anz i: 0≤i<N: ai=x) = (Anz i: 0≤i<N: bi=x) ) a is a permutation of b Example
111. 111. computer information information computation
112. 112. Tudor Gîrba www.tudorgirba.com creativecommons.org/licenses/by/3.0/