Professional Documents
Culture Documents
Assignment 2
Assignment 2
Hedgehog adventures.
As the player you are required to navigate your hedgehog character through a forest, eating mush-
rooms and avoiding the fox who is chasing you through the forest. Mushrooms the hedgehog eats
can be of two types: normal or powered. Thus, your hedgehog can avenge the pursuer by eating a
“powered” mushroom, which enables him to enter into the “prickly ball” mode and chase down the
fox instead. When this occurs, the fox’s behavior changes, and instead of chasing the hedgehog it
tries to run from him. When your hedgehog meets the fox in this special mode, then the unlucky
predator gets beaten up badly. To win your hedgehog needs to eat all the mushroom. However if
it meets the fox while not in “prickly ball” mode, then it gets eaten and loses.
Q1. Specify each of the rules below using propositional logic. The current titles of the rules are
hinting at what their logical formulation should be about. Follow the procedure from the lab,
and try to arrive at a minimal set of logical literals necessary to specify the rules.
Game rules.
Original statement:
"Mushrooms the hedgehog eats can be of two types: normal or powered."
Literals:
enm - "Hedgehog eats a normal mushroom"
epm - "Hedgehog eats a powered mushroom"
Rule:
enm ∨ epm
1
F. Win condition.
G. Loss condition.
Q2. Specify each of the properties below using propositional logic. The properties are quite close
to what their formulation in logic should be.
Properties to verify.
A. If the fox is chasing the hedgehog, then he is not in “prickly ball” mode.
B. The fox cannot be both running away and chasing.
C. If the fox is beaten up, then the hedgehog met it in the “prickly ball” mode.
D. If the hedgehog met the fox and it is not beaten up, then he could have only eaten a normal
mushroom.
E. The hedgehog cannot lose while in “prickly ball” mode.
F. The hedgehog cannot both win and lose.
(Example): p ∧ (p ∨ q)
p q (p ∨ q) p ∧ (p ∨ q)
T T T T
T F T T
F T T F
F F F F
Q4. Is the expression from question above a tautology, contradiction or contingent statement?
Explain why.
Q5. Produce two variations of the expression that differ from the original by only one operator, so
that as a result you will have three statements: the original and two variations. One of them
has to be a tautology, another a contradiction, and the third one a contingent statement.
Q6. Deduce linearly the following two entailments using Propositional Calculus:
Q7. Implement all of the game rules in Z3 and check if their combination is satisfiable.
(Example):
2
(declare-const p Bool)
(declare-const q Bool)
(define-fun conjecture () Bool
(and p (or p q)))
(assert conjecture)
(check-sat)
Q8. Explain briefly what it would mean if the combination were unsatisfiable.
Q9. Check if the combination of all rules guarantees Property C using Z3.
Q10. Check if the combination guarantees Property F. If not, suggest a modification to guarantee
it.