Exercises on Propositional Logic

Exercises on Propositional Logic
Models
Artificial Intelligence I — LCA 12/13
Models
1
Exercise 1
T ell(KB, α) is the function used to query the knowledge base KB when
we want to prove that α is logically entailed by it.
Artificial Intelligence I — LCA 12/13
Models
2
Solution 1
T ell(KB, α) is the function used to query the knowledge base KB when
we want to prove that α is logically entailed by it.
FALSE: T ell is used to update KB by adding α to it; the function that
queries a knowledge base is Ask.
Artificial Intelligence I — LCA 12/13
Models
3
Exercise 2
Both T ell(KB, α) and Ask(KB, α) modify the knowledge base KB.
Artificial Intelligence I — LCA 12/13
Models
4
Solution 2
Both T ell(KB, α) and Ask(KB, α) modify the knowledge base KB.
FALSE: T ell updates KB by adding α to it; Ask in principles doesn’t
modify it.
Artificial Intelligence I — LCA 12/13
Models
5
Exercise 3
Two syntactically distinct propositional formulas can never have exactly the
same models.
Artificial Intelligence I — LCA 12/13
Models
6
Solution 3
Two syntactically distinct propositional formulas can never have exactly the
same models.
FALSE: A and A ∨ A are syntactically distinct and have the same models.
Find other examples.
Artificial Intelligence I — LCA 12/13
Models
7
Exercise 4
Let α, β, γ be three propositional formulas such that α ∧ β entails γ; then
α entails γ or β entails γ.
Artificial Intelligence I — LCA 12/13
Models
8
Solution 4
Let α, β, γ be three propositional formulas such that α ∧ β entails γ; then
α entails γ or β entails γ.
Which is the correct interpretation of the above question??
1) If α ∧ β |= γ then either α |= γ or β |= γ.
2) Tell wether or not (α ∧ β)→γ |= (α→γ) ∨ (β→γ).
Are they equivalent??
Artificial Intelligence I — LCA 12/13
Models
9
Solution 4-1
Let α, β, γ be three propositional formulas such that α ∧ β |= γ;
then α |= γ or β |= γ.
Case a) we assume α ∧ β |= γ; we want to check wether or not α |= γ
Case b) we assume α ∧ β |= γ; we want to check wether or not β |= γ.
Both are false, in fact: Consider the propositional symbols A, B and let
α = A, β = B, γ = A∧B; then (A∧B) |= (A∧B) but neither A |= (A∧B)
nor B |= (A ∧ B).
Artificial Intelligence I — LCA 12/13
Models
10
Exercise 4-2
Let α, β, γ be three propositional formulas, tell wether or not
(α ∧ β)→γ |= (α→γ) ∨ (β→γ)
The entailment is true: build the truth table.
Artificial Intelligence I — LCA 12/13
Models
11
Exercise 5
In propositional logic if a formula α is satisfiable, then the formula ¬α is
contradictory.
Artificial Intelligence I — LCA 12/13
Models
12
Solution 5
In propositional logic if a formula α is satisfiable, then the formula ¬α is
contradictory.
FALSE: In order for ¬α to be contradictory it has to have no model, so all
interpretations must be models of α, hence α is valid, and not just satisfiable.
Artificial Intelligence I — LCA 12/13
Models
13
Exercise 6
In propositional logic if a formula ¬α is contradictory, then the formula α is
valid.
Artificial Intelligence I — LCA 12/13
Models
14
Solution 6
In propositional logic if a formula ¬α is contradictory, then the formula α is
valid.
TRUE: ¬α contradictory means it has no model, so all interpretations are
models of α, hence α is valid.
Artificial Intelligence I — LCA 12/13
Models
15
Exercise 7
The propositional formula (A ∧ B) ∨ (¬A ∧ ¬B) is valid.
Artificial Intelligence I — LCA 12/13
Models
16
Solution 7
The propositional formula (A ∧ B) ∨ (¬A ∧ ¬B) is valid.
FALSE: Its truth value depends on A and B (the formula is true only if both
A and B are tue or both are false).
Artificial Intelligence I — LCA 12/13
Models
17
Exercise 8
If α and β are propositional formulas and α→β is valid, then the models of
β are all and only the models of α.
Artificial Intelligence I — LCA 12/13
Models
18
Solution 8
If α and β are propositional formulas and α→β is valid, then the models of
β are all and only the models of α.
FALSE: If α→β is valid, all the models of α are also models of β, the
contrary is not necessarily true.
Artificial Intelligence I — LCA 12/13
Models
19
Exercise Three weird implications
Consider a knowledge base consisting of the conjunction of the following
propositions:
¬A→B
B→A
A→(C ∧ D)
1. Tell wether the knowledge base is consistent. In the positive case exhibit
a model.
Artificial Intelligence I — LCA 12/13
Models
20
Exercise
Consider a knowledge base consisting of the conjunction of the following
propositions:
¬A→B
B→A
A→(C ∧ D)
1. Tell wether the knowledge base is consistent. In the positive case exhibit
a model.
It is consistent: A model is {A, B, C, D}
Is this the only model??
Artificial Intelligence I — LCA 12/13
Models
21
Exercise
Consider a knowledge base consisting of the conjunction of the following
propositions:
¬A→B
B→A
A→(C ∧ D)
1. Tell wether the knowledge base is consistent. In the positive case exhibit
a model.
It is consistent: A model is {A, B, C, D}
Is this the only model??
The only other model is {A, C, D}
Artificial Intelligence I — LCA 12/13
Models
22
Exercise
¬A→B
B→A
A→(C ∧ D)
2. Compile the above propositions into a new knowledge base written in
disjunctive form.
Artificial Intelligence I — LCA 12/13
Models
23
Exercise
¬A→B
B→A
A→(C ∧ D)
2. Compile the above propositions into a new knowledge base written in
disjunctive form.
1.
2.
3.
4.
A∨B
¬B ∨ A
¬A ∨ C
¬A ∨ D
Artificial Intelligence I — LCA 12/13
Models
24
Exercise
1.
2.
3.
4.
A∨B
¬B ∨ A
¬A ∨ C
¬A ∨ D
3. Which of the clauses in your knowledge base (if any) are not Horn clauses?
Justify your answer.
Artificial Intelligence I — LCA 12/13
Models
25
Exercise
1.
2.
3.
4.
A∨B
¬B ∨ A
¬A ∨ C
¬A ∨ D
3. Which of the clauses in your knowledge base (if any) are not Horn clauses?
Justify your answer.
A ∨ B is not a Horn clause, because it has more than one positive literal.
Artificial Intelligence I — LCA 12/13
Models
26
Exercise
The propositional formula (A ∨ B)→(A ∧ B) has more models then A→B
Artificial Intelligence I — LCA 12/13
Models
27
Exercise
The propositional formula (A ∨ B)→(A ∧ B) has more models then A→B
FALSE: The contrary is true.
Artificial Intelligence I — LCA 12/13
Models
28
Exercise
Consider the formula:
[(¬Q ∨ R) ∧ (¬P ∨ ¬R) ∧ (P ∨ Q ∨ R)]
Tell which one among these sets is a model for it
{P, Q, R}
{P, Q}
{R}
{}
Does it have other models?
Artificial Intelligence I — LCA 12/13
Models
29
Exercise
Consider the formula:
[(¬Q ∨ R) ∧ (¬P ∨ ¬R) ∧ (P ∨ Q ∨ R)]
Tell which one among these sets is a model for it
{P, Q, R} NO
{P, Q} NO
{R} YES
{} NO
Does it have other models?
YES, e.g. {P}. The formula is consistent
Artificial Intelligence I — LCA 12/13
Models
30
Exercise
Consider the formula:
[((A ∨ B)→C)] ∨ [A ∧ B ∧ D]
Tell which one among these sets is a model for it
{}
{A}
{C}
{A, B}
{A, C}
{A, B, C, D}
Tell wether the formula has other models, in case show one.
Artificial Intelligence I — LCA 12/13
Models
31
Exercise
Consider the formula:
[((A ∨ B)→C)] ∨ [A ∧ B ∧ D]
Tell which one among these sets is a model for it
{} YES
{A} NO
{C} YES
{A, B} NO
{A, C} YES
{A, B, C, D} YES
Tell wether the formula has other models, in case show one.
Yes, the formula has other models, e.g., {A, B, D}
Artificial Intelligence I — LCA 12/13
Models
32
Exercise
Tell which one among the following formulas is a good representation of the
sentence
If John studies and his father works, then his grandfather is happy
(1)
(2)
(3)
(4)
(Study ∧ W ork)→Happy
Study ∧ W ork ∧ Happy
¬Study ∨ (¬W ork ∨ Happy)
(Study ∨ W ork)→Happy
Artificial Intelligence I — LCA 12/13
Models
33
Exercise
Tell which one among the following formulas is a good representation of the
sentence
If John studies and his father works, then his grandfather is Happy
(1) (Study ∧ W ork)→Happy
correct
(2) Study ∧ W ork ∧ Happy
incorrect
(3) ¬Study ∨ (¬W ork ∨ Happy)
correct, logically equivalent to 1
(4) (Study ∨ W ork)→Happy
incorrect
Artificial Intelligence I — LCA 12/13
Models
34
Exercise
Consider the following propositional formulas:
P →(Q↔R)
Q→(P ∨ R)
R→(Q ∧ ¬P )
1- Convert them into Conjunctive Normal Form.
2- Tell wether or not the resulting set of clauses is Horn.
3- Tell wether or not the resulting set of clauses is satisfiable, in the positive
case show a model.
Artificial Intelligence I — LCA 12/13
Models
35
Exercise
Consider the following propositional formulas:
P →(Q↔R)
Q→(P ∨ R)
R→(Q ∧ ¬P )
1-Convert them into Conjunctive Normal Form.
2-Tell wether or not the resulting set of clauses is Horn.
3- Tell wether or not the resulting set of clauses is satisfiable, in the positive
case show a model.
1- {¬P, ¬Q, R}{¬P, Q, ¬R}{P, ¬Q, R}{Q, ¬R}{¬P, ¬R}
2- The set is not Horn, because of the third clause, which has two positive
literals.
3- The set is satisfiable, e.g., {} is a model
Artificial Intelligence I — LCA 12/13
Models
36
Exercise
Given three propositional symbols A, B, C write a formula φ that contains
all the symbols (one or more times) and that has exactly two models.
Show a model in a domain of your choice: interpret the symbols and provide
an intuitive reading of the formula φ.
Artificial Intelligence I — LCA 12/13
Models
37
Exercise
Given three propositional symbols A, B, C write a formula φ that contains
all the symbols (one or more times) and that has exactly two models.
Show a model in a domain of your choice: interpret the symbols and provide
an intuitive reading of the formula φ.
A possible formula φ is :
(A ∧ B ∧ ¬C) ∨ (A ∧ C ∧ ¬B)
Its only two models are: {A, B} e {A, C}.
Consider methereology, le A be “the sun is shining,” B “it rains,” and C
“it snows.” φ reads as “Either there is sunshine and it rains, but it doesn’t
snow, or there is the sunshine and it snows, but it doesn’t rain” i.e., sun is
present with snow or rain, but snow and rain are not present together.
Artificial Intelligence I — LCA 12/13
Models
38
Exercise
I am at the Cinema, I am without a ticket, but I have money.
Let: C =I am at the Cinema, B = I have a ticket, M =I have money
Tell the models among these sets: {C, T, S}
{C, T }
{C, M }
{T, M }
{C}
{T }
{M }
{}
Artificial Intelligence I — LCA 12/13
Models
39
Solution
I am at the Cinema, I am without a ticket, but I have money.
C ∧ ¬B ∧ S
{C, T, M } N O
{C, T } N O
{C, M } Y ES
{T, M } N O
{C} N O
{T } N O
{M } N O
{} NO
Artificial Intelligence I — LCA 12/13
Models
40
Exercise
Check whether or not
{(C ∧ ¬B)→S, C, S} |= B
using semantics, i.e. reasoning on models and not performing inferences.
Answer is NO.
Artificial Intelligence I — LCA 12/13
Models
41
Exercise
Given the formula:
((A ∨ B)→C) ∨ (A ∧ B ∧ D)
Tell which one among the following sets of literals is a model:
{}
{A}
{C}
{A, B}
{A, C}
{A, B, C, D}
Tell whether or not the formula has other models, in the positive case show
at least one.
Artificial Intelligence I — LCA 12/13
Models
42
Exercise
((A ∨ B)→C) ∨ (A ∧ B ∧ D)
{} Y ES
{A} N O
{C} Y ES
{A, B} N O
{A, C} Y ES
{A, B, C, D} Y ES
The formula has other models, e.g. {A, C, D}, {B, C, D}, {B, C}, {D}.
Artificial Intelligence I — LCA 12/13
Models
43
Exercise
Given the following propositional symbols:
ST stands for Giorgio studies
SP stands for Giorgio likes sports
SM indicates that Giorgio smiles
HS stands for Giorgio has success with girls.
It is evident that if Giorgio studies but he does not smile he has no success
with girls. Conversely, if Giorgio smiles and likes sports he has success with
girls.
(1) express the above sentences in propositional calculus
(2) tell which one among the following sets are models:
{ST, SP, HS}; {SM, HS}; {}; {SM, SP, HS}.
(3) tell whether the formula has other models or not, in the positive case
indicate at least one.
Artificial Intelligence I — LCA 12/13
Models
44
Solution
(1)
(ST ∧ ¬SM )→¬HS
(SM ∧ SP )→HS
(2)
{ST, SP, HS} N O
{SM, HS} Y ES
{} Y ES
{SM, SP, HS}Y ES
(3) Yes, e.g. {ST, SP }.
Artificial Intelligence I — LCA 12/13
Models
45
Exercise
Convert into Horn form the formula
(P ∧ ¬R)→(Q→R)
Artificial Intelligence I — LCA 12/13
Models
46
Solution
Convert into Horn form the formula
(P ∧ ¬R)→(Q→R)
(1)
(2)
(3)
(4)
(5)
(6)
(P ∧ ¬R)→(Q→R)
¬(P ∧ ¬R) ∨ (¬Q ∨ R) (α→β ≡ ¬α ∨ β)
¬P ∨ R ∨ ¬Q ∨ R (DoubleNegation+DeMorgan+Associativity)
¬P ∨ ¬Q ∨ R (Associtivity + Idempotence)
¬(P ∧ Q) ∨ R
(De Morgan)
(P ∧ Q)→R (¬α ∨ β ≡ α→β)
Artificial Intelligence I — LCA 12/13
Models
47
Exercise
Prove that the following KB implies the formula R:
{P ∧ Q→R, A ∧ B→R, C→A, C, P, S→Q, S→B, P ∧ A ∧ C→B}
Use GMP (Generalized Modus Ponens) with both forward and backward
chaining. Build the And-Or graph.
Artificial Intelligence I — LCA 12/13
Models
48