Top Banner
Predicate logic www.tudorgirba.com
112

03 - Predicate logic

May 10, 2015

Download

Technology

Tudor Girba

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.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 03 - Predicate logic

Predicatelogic

www.tudorgirba.com

Page 2: 03 - Predicate logic

Boolean algebra Propositional logic0, 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)

Page 3: 03 - Predicate logic

Boolean algebra Propositional logic0, 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)

Page 4: 03 - Predicate logic

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.

Page 5: 03 - Predicate logic

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.

Page 6: 03 - Predicate logic

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 SpyRS : Stirlitz is Russian

Page 7: 03 - Predicate logic

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.

Page 8: 03 - Predicate logic

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.

Page 9: 03 - Predicate logic

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.

Page 10: 03 - Predicate logic

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.

Page 11: 03 - Predicate logic

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.

Page 12: 03 - Predicate logic

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.

Page 13: 03 - Predicate logic

computerinformation information

computation

Page 14: 03 - Predicate logic

2 is greater than 5

Page 15: 03 - Predicate logic

2 is greater than 5 False

Page 16: 03 - Predicate logic

2 is greater than 5

6 is greater than 5

False

Page 17: 03 - Predicate logic

2 is greater than 5

6 is greater than 5

False

True

Page 18: 03 - Predicate logic

2 is greater than 5

6 is greater than 5

False

True

x is greater than 5

Page 19: 03 - Predicate logic

2 is greater than 5

6 is greater than 5

False

True

x is greater than 5 ?

Page 20: 03 - Predicate logic

2 is greater than 5

6 is greater than 5

False

True

x is greater than 5 ?predicate

Page 21: 03 - Predicate logic

x is greater than 5

2 is greater than 5

6 is greater than 5

False

True

predicate

Page 22: 03 - Predicate logic

x is greater than 5F(x) =

2 is greater than 5

6 is greater than 5

False

True

predicate

Page 23: 03 - Predicate logic

x is greater than 5F(x) =

2 is greater than 5

6 is greater than 5F(6) =

F(2) = False

True

predicate

Page 24: 03 - Predicate logic

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

Page 25: 03 - Predicate logic

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

Page 26: 03 - Predicate logic

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

Page 27: 03 - Predicate logic

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

Page 28: 03 - Predicate logic

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

quantifier

Page 29: 03 - Predicate logic

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

quantifier

quantifier

Page 30: 03 - Predicate logic

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

quantifier

quantifier

universe

Page 31: 03 - Predicate logic

Existential quantifiers ∃ :Universal quantifier ∀ :

∀x: U(x): F(x) ∃x: U(x): F(x)

∀x:x∈N:x>5 ∃x:x∈N:x>5for all natural numbers x,x is greater than 5

for some natural numbers x,x is greater than 5

Page 32: 03 - Predicate logic

Gottlob Frege1848—1925

no appeal to intuition

Page 33: 03 - Predicate logic

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))

Page 34: 03 - Predicate logic

Examples

Page 35: 03 - Predicate logic

∀ i: 0≤i<N: ai=0

Examples

Page 36: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

Examples

Page 37: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ ai

Examples

Page 38: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

Examples

Page 39: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ aj

Examples

Page 40: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

Examples

Page 41: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = aj

Examples

Page 42: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

Examples

Page 43: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0

Examples

Page 44: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

Examples

Page 45: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0

Examples

Page 46: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

Examples

Page 47: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

∃ i: 1≤i<N: ai-1 > ai

Examples

Page 48: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

∃ i: 1≤i<N: ai-1 > aielements of array a are not monotonically increasing

Examples

Page 49: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

∃ i: 1≤i<N: ai-1 > aielements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai > aj

Examples

Page 50: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

∃ i: 1≤i<N: ai-1 > aielements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai > ajelements of array a are not monotonically increasing

Examples

Page 51: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

∃ i: 1≤i<N: ai-1 > aielements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai > ajelements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai ≠ aj

Examples

Page 52: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

∃ i: 1≤i<N: ai-1 > aielements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai > ajelements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai ≠ ajnot all elements of array a are equal

Examples

Page 53: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

∃ i: 1≤i<N: ai-1 > aielements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai > ajelements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai ≠ ajnot all elements of array a are equal

∃ i: 0<i<N: ai > a0

Examples

Page 54: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

∃ i: 1≤i<N: ai-1 > aielements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai > ajelements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai ≠ ajnot all elements of array a are equal

∃ i: 0<i<N: ai > a0a0 is not the greatest element of array a

Examples

Page 55: 03 - Predicate logic

∀ i: 0≤i<N: ai=0all elements ai of array a (of length N) are zero

∀ i: 1≤i<N: ai-1 ≤ aielements of array a are monotonically increasing

∀ i,j: 0≤i<j<N: ai ≤ ajelements of array a are monotonically increasing

∀ i,j: 0≤i,j<N: ai = ajall elements of array a are equal

∀ i: 0<i<N: ai ≤ a0a0 is the greatest element of array a

∃ i: 0≤i<N: ai ≠ 0at least one element of array a (of length N) is not zero

∃ i: 1≤i<N: ai-1 > aielements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai > ajelements of array a are not monotonically increasing

∃ i,j: 0≤i<j<N: ai ≠ ajnot all elements of array a are equal

∃ i: 0<i<N: ai > a0a0 is not the greatest element of array a

Examples

Page 56: 03 - Predicate logic

¬(∃ 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 ¬∀ :

Page 57: 03 - Predicate logic

Example

What is the negation of the statement“Always, when he drives then he is sober.”

Page 58: 03 - Predicate logic

Example

What is the negation of the statement“Always, when he drives then he is sober.”

D(t): He drives at moment t.

Page 59: 03 - Predicate logic

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.

Page 60: 03 - Predicate logic

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)

Page 61: 03 - Predicate logic

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)) ⇔

Page 62: 03 - Predicate logic

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)) ⇔

Page 63: 03 - Predicate logic

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)) ⇔

Page 64: 03 - Predicate logic

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))

Page 65: 03 - Predicate logic

computerinformation information

computation

Page 66: 03 - Predicate logic

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)

Page 67: 03 - Predicate logic

Bounded variables

(∃j: 0<j<N: P(i,j) ∨ Q(i,j))

Free variablesIf a variable is not bound in a WFF thenit is free.

An appearance of variable is bound in a WFF ifa specific value is assigned to it, or it is quantified.

∃i: 0<i<N: (

∃i,j: 0<i,j<N: P(i,j) ∨ Q(i,j)

Page 68: 03 - Predicate logic

Bounded variables

(∃j: 0<j<N: P(i,j) ∨ Q(i,j))

Free variablesIf a variable is not bound in a WFF thenit is free.

An appearance of variable is bound in a WFF ifa specific value is assigned to it, or it is quantified.

∃i: 0<i<N: ( )

∃i,j: 0<i,j<N: P(i,j) ∨ Q(i,j)

Page 69: 03 - Predicate logic

∃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

Page 70: 03 - Predicate logic

∃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

Page 71: 03 - Predicate logic

Example

Every boy loves some girl does not imply thatsome 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))

Page 72: 03 - Predicate logic

∀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

Page 73: 03 - Predicate logic

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.

Page 74: 03 - Predicate logic

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) )

Page 75: 03 - Predicate logic

Example

All elements of an array a of length N are either zero or one

Page 76: 03 - Predicate logic

Example

All elements of an array a of length N are either zero or one

∀i: 0≤i<N: ( ai=0 ∨ ai=1 )

Page 77: 03 - Predicate logic

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)

Page 78: 03 - Predicate logic

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

Page 79: 03 - Predicate logic

Example

The elements of arrays a and b are the same (both arrays of length N).

Page 80: 03 - Predicate logic

Example

The elements of arrays a and b are the same (both arrays of length N).

∀i: 0≤i<N: (ai=bi)(1)

Page 81: 03 - Predicate logic

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)

Page 82: 03 - Predicate logic

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)

Page 83: 03 - Predicate logic

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)

Page 84: 03 - Predicate logic

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)

Page 85: 03 - Predicate logic

Example

Page 86: 03 - Predicate logic

They drank two cups of tea because they were warm.

Example

Page 87: 03 - Predicate logic

They drank two cups of tea because they were warm.

They drank two cups of tea because they were cold.

Example

Page 88: 03 - Predicate logic

Go to the shop and buy bread.If they have eggs, buy 10.

Example

Page 89: 03 - Predicate logic

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

Page 90: 03 - Predicate logic

Min x: U(x): T(x)gives the “smallest value of terms T(x)for all objects x from the universe U“

Page 91: 03 - Predicate logic

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 +∞.

Page 92: 03 - Predicate logic

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]) ) ⇔

Page 93: 03 - Predicate logic

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]))

Page 94: 03 - Predicate logic

Max x: U(x): T(x)gives the “greatest value of terms T(x)for all objects x from the universe U“

Page 95: 03 - Predicate logic

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 -∞.

Page 96: 03 - Predicate logic

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))

Page 97: 03 - Predicate logic

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))

Page 98: 03 - Predicate logic

Anz x: U(x): F(x)gives the “number of all those objects xfrom the universe U for which F(x) holds“

Page 99: 03 - Predicate logic

Anz x: U(x): F(x)gives the “number of all those objects xfrom the universe U for which F(x) holds“

Anz x: False: F(x) is 0.

Page 100: 03 - Predicate logic

Anz x: U(x): F(x)gives the “number of all those objects xfrom 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)

Page 101: 03 - Predicate logic

Anz x: U(x): F(x)gives the “number of all those objects xfrom 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)

Page 102: 03 - Predicate logic

Given arrays a and b.Both arrays are of length N.The elements of both arrays are natural numbers.

Example

Page 103: 03 - Predicate logic

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

Page 104: 03 - Predicate logic

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) = 0all elements ai of a are different than 0

Example

Page 105: 03 - Predicate logic

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) = 0all elements ai of a are different than 0

(Anz i: 0≤i<N: ai=x) > 0

Example

Page 106: 03 - Predicate logic

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) = 0all elements ai of a are different than 0

(Anz i: 0≤i<N: ai=x) > 0at least one element ai has the value x (x∈N)

Example

Page 107: 03 - Predicate logic

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) = 0all elements ai of a are different than 0

(Anz i: 0≤i<N: ai=x) > 0at 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

Page 108: 03 - Predicate logic

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) = 0all elements ai of a are different than 0

(Anz i: 0≤i<N: ai=x) > 0at 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

Page 109: 03 - Predicate logic

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) = 0all elements ai of a are different than 0

(Anz i: 0≤i<N: ai=x) > 0at 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

Page 110: 03 - Predicate logic

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) = 0all elements ai of a are different than 0

(Anz i: 0≤i<N: ai=x) > 0at 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

Page 111: 03 - Predicate logic

computerinformation information

computation