-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuzzle1.py
More file actions
37 lines (30 loc) · 882 Bytes
/
puzzle1.py
File metadata and controls
37 lines (30 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from logic import *
# Puzzle
# A says "I am both a knight and a knave."
# One character : A => A is a Knave
AKnight = Symbol("A is a Knight")
AKnave = Symbol("A is a Knave")
# Facts about our world: XOR
InitialKnowledge = And(
# Must be either a knight or a knave
Or(AKnight, AKnave),
# Can't be both a knight and a knave
Not(And(AKnight, AKnave)),
)
# What we're told by the character
InitialStatment = And(AKnight, AKnave)
knowledge = And(
InitialKnowledge,
# If A is a Knight than the initial statement must be true
Biconditional(AKnight, InitialStatment)
)
def main():
symbols = [AKnight, AKnave]
if len(knowledge.conjuncts) == 0:
print("Not yet implemented.")
else:
for symbol in symbols:
if model_check(knowledge, symbol):
print(f" {symbol}")
if __name__ == "__main__":
main()