SlideShare a Scribd company logo
Predicate
logic
www.tudorgirba.com
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)
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)
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.
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.
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
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.
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.
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.
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.
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.
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.
computer
information information
computation
2 is greater than 5
2 is greater than 5 False
2 is greater than 5
6 is greater than 5
False
2 is greater than 5
6 is greater than 5
False
True
2 is greater than 5
6 is greater than 5
False
True
x is greater than 5
2 is greater than 5
6 is greater than 5
False
True
x is greater than 5 ?
2 is greater than 5
6 is greater than 5
False
True
x is greater than 5 ?
predicate
x is greater than 5
2 is greater than 5
6 is greater than 5
False
True
predicate
x is greater than 5F(x) =
2 is greater than 5
6 is greater than 5
False
True
predicate
x is greater than 5F(x) =
2 is greater than 5
6 is greater than 5F(6) =
F(2) = False
True
predicate
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
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
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
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
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
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
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
Existential quantifiers ∃ :Universal quantifier ∀ :
∀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
Gottlob Frege
1848—1925
no appeal to intuition
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))
Examples
∀ i: 0≤i<N: ai=0
Examples
∀ i: 0≤i<N: ai=0
all elements ai of array a (of length N) are
zero
Examples
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
∀ 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
¬(∃ 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 ¬∀ :
Example
What is the negation of the statement
“Always, when he drives then he is sober.”
Example
What is the negation of the statement
“Always, when he drives then he is sober.”
D(t): He drives at moment t.
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.
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)
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))
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))
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))
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))
computer
information information
computation
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)
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 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)
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 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)
∃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
∃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
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))
∀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
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.
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) )
Example
All elements of an array a of length N are either zero or one
Example
All elements of an array a of length N are either zero or one
∀i: 0≤i<N: ( ai=0 ∨ ai=1 )
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)
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
Example
The elements of arrays a and b are the same (both arrays of length N).
Example
The elements of arrays a and b are the same (both arrays of length N).
∀i: 0≤i<N: (ai=bi)(1)
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)
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)
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)
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)
Example
They drank two cups of tea because they were warm.
Example
They drank two cups of tea because they were warm.
They drank two cups of tea because they were cold.
Example
Go to the shop and buy bread.
If they have eggs, buy 10.
Example
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
Min x: U(x): T(x)
gives the “smallest value of terms T(x)
for all objects x from the universe U“
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 +∞.
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]) )
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]))
Max x: U(x): T(x)
gives the “greatest value of terms T(x)
for all objects x from the universe U“
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)
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))
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))
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: 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)
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)
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)
Given arrays a and b.
Both arrays are of length N.
The elements of both arrays are natural numbers.
Example
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
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
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
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
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
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
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
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
computer
information information
computation
Tudor Gîrba
www.tudorgirba.com
creativecommons.org/licenses/by/3.0/

More Related Content

PPTX
Alphabets
PDF
わかる中級英文法 Grammar in Use Unit 26 could and could have
PPT
Predicate Logic
PPTX
Knowledge representation and Predicate logic
PPTX
Knowledge representation in AI
PPT
Knowledge Representation in Artificial intelligence
PPT
Propositional And First-Order Logic
PPTX
Propositional logic & inference
Alphabets
わかる中級英文法 Grammar in Use Unit 26 could and could have
Predicate Logic
Knowledge representation and Predicate logic
Knowledge representation in AI
Knowledge Representation in Artificial intelligence
Propositional And First-Order Logic
Propositional logic & inference

Viewers also liked (20)

PPTX
Issues in knowledge representation
PPTX
Propositional logic
DOC
Chapter 4 (final)
PPT
Syntax and semantics of propositional logic
PPT
Propositional logic
PPTX
Propositional logic
PPT
First order logic
PPT
Knowledge Representation & Reasoning
PPT
Artificial intelligence and knowledge representation
PPT
Predicate calculus
PPTX
#3 formal methods – propositional logic
PPTX
#4 formal methods – predicate logic
PPT
Translating English to Propositional Logic
PPT
Ch2 3-informed (heuristic) search
PPTX
Logic Ppt
PPT
Hill climbing
PPTX
Artificial Intelligence Presentation
PPT
artificial intelligence
PDF
Predicate Calculus
PPT
Propositional logic for Beginners
Issues in knowledge representation
Propositional logic
Chapter 4 (final)
Syntax and semantics of propositional logic
Propositional logic
Propositional logic
First order logic
Knowledge Representation & Reasoning
Artificial intelligence and knowledge representation
Predicate calculus
#3 formal methods – propositional logic
#4 formal methods – predicate logic
Translating English to Propositional Logic
Ch2 3-informed (heuristic) search
Logic Ppt
Hill climbing
Artificial Intelligence Presentation
artificial intelligence
Predicate Calculus
Propositional logic for Beginners
Ad

More from Tudor Girba (20)

PDF
Beyond software evolution: Software environmentalism
PDF
Software craftsmanship meetup (Zurich 2015) on solving real problems without ...
PDF
GT Spotter
PDF
Don't demo facts. Demo stories! (handouts)
PDF
Don't demo facts. Demo stories!
PDF
Humane assessment on cards
PDF
Underneath Scrum: Reflective Thinking
PDF
1800+ TED talks later
PDF
Software assessment by example (lecture at the University of Bern)
PDF
Humane assessment: Taming the elephant from the development room
PDF
Moose: how to solve real problems without reading code
PDF
Software Environmentalism (ECOOP 2014 Keynote)
PPTX
The emergent nature of software systems
PDF
Presenting is storytelling at Uni Zurich - slides (2014-03-05)
PDF
Presenting is storytelling at Uni Zurich - handouts (2014-03-05)
PDF
Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)
PDF
Demo-driven innovation teaser
PDF
Software assessment essentials (lecture at the University of Bern 2013)
PDF
Demo-driven innovation (University of Zurich, June 2013)
PDF
Humane assessment with Moose at GOTO Aarhus 2011
Beyond software evolution: Software environmentalism
Software craftsmanship meetup (Zurich 2015) on solving real problems without ...
GT Spotter
Don't demo facts. Demo stories! (handouts)
Don't demo facts. Demo stories!
Humane assessment on cards
Underneath Scrum: Reflective Thinking
1800+ TED talks later
Software assessment by example (lecture at the University of Bern)
Humane assessment: Taming the elephant from the development room
Moose: how to solve real problems without reading code
Software Environmentalism (ECOOP 2014 Keynote)
The emergent nature of software systems
Presenting is storytelling at Uni Zurich - slides (2014-03-05)
Presenting is storytelling at Uni Zurich - handouts (2014-03-05)
Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)
Demo-driven innovation teaser
Software assessment essentials (lecture at the University of Bern 2013)
Demo-driven innovation (University of Zurich, June 2013)
Humane assessment with Moose at GOTO Aarhus 2011
Ad

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Empathic Computing: Creating Shared Understanding
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Empathic Computing: Creating Shared Understanding
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
The Rise and Fall of 3GPP – Time for a Sabbatical?
Dropbox Q2 2025 Financial Results & Investor Presentation
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

03 - Predicate logic

  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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.
  • 14. 2 is greater than 5
  • 15. 2 is greater than 5 False
  • 16. 2 is greater than 5 6 is greater than 5 False
  • 17. 2 is greater than 5 6 is greater than 5 False True
  • 18. 2 is greater than 5 6 is greater than 5 False True x is greater than 5
  • 19. 2 is greater than 5 6 is greater than 5 False True x is greater than 5 ?
  • 20. 2 is greater than 5 6 is greater than 5 False True x is greater than 5 ? predicate
  • 21. x is greater than 5 2 is greater than 5 6 is greater than 5 False True predicate
  • 22. x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5 False True predicate
  • 23. x is greater than 5F(x) = 2 is greater than 5 6 is greater than 5F(6) = F(2) = False True predicate
  • 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. 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. 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. 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. 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
  • 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 quantifier quantifier
  • 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 quantifier quantifier universe
  • 31. Existential quantifiers ∃ :Universal quantifier ∀ : ∀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
  • 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))
  • 35. ∀ i: 0≤i<N: ai=0 Examples
  • 36. ∀ i: 0≤i<N: ai=0 all elements ai of array a (of length N) are zero Examples
  • 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ∀ 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. ¬(∃ 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. Example What is the negation of the statement “Always, when he drives then he is sober.”
  • 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. 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. 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. 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. 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. 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. 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))
  • 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. 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 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)
  • 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 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)
  • 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. ∃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. 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. ∀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. 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. 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. Example All elements of an array a of length N are either zero or one
  • 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. 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. 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. Example The elements of arrays a and b are the same (both arrays of length N).
  • 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. 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. 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. 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. 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)
  • 86. They drank two cups of tea because they were warm. Example
  • 87. They drank two cups of tea because they were warm. They drank two cups of tea because they were cold. Example
  • 88. Go to the shop and buy bread. If they have eggs, buy 10. Example
  • 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. Min x: U(x): T(x) gives the “smallest value of terms T(x) for all objects x from the universe U“
  • 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. 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. 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. Max x: U(x): T(x) gives the “greatest value of terms T(x) for all objects x from the universe U“
  • 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. 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. 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. Anz x: U(x): F(x) gives the “number of all those objects x from the universe U for which F(x) holds“
  • 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. 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. 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. Given arrays a and b. Both arrays are of length N. The elements of both arrays are natural numbers. Example
  • 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. 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. 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. 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. 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. 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. 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. 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