# i dont know why i got error in the cs50 knight puzzle

from logic import *

AKnight = Symbol("A is a Knight") AKnave = Symbol("A is a Knave")

BKnight = Symbol("B is a Knight") BKnave = Symbol("B is a Knave")

CKnight = Symbol("C is a Knight") CKnave = Symbol("C is a Knave")

# A says "I am both a knight and a knave."

knowledge0 = And( Biconditional(AKnave,Not(AKnight)), Biconditional(BKnave,Not(BKnight)), Biconditional(CKnave,Not(CKnight)),

``````Implication(AKnight,And(AKnight,AKnight)) ,And(Implication(AKnave,Not(And(AKnave,AKnave))))
``````

)

# B says nothing.

knowledge1 = And(

Biconditional(AKnave,Not(AKnight)), Biconditional(BKnave,Not(BKnight)), Biconditional(CKnave,Not(CKnight)), Implication(AKnight,And(AKnave,BKnave)) ,And(Implication(AKnave,Not(And(AKnave,BKnave))))

)

# B says "We are of different kinds."

knowledge2 = And( Biconditional(AKnave,Not(AKnight)), Biconditional(BKnave,Not(BKnight)), Biconditional(CKnave,Not(CKnight)),

``````Implication(AKnight,Or(And(AKnight,BKnave),And(AKnight,BKnight))),And(Implication(AKnave,Not(Or(And(AKnight,BKnave),And(AKnight,BKnight))))),
Implication(BKnight,Or(And(AKnave,BKnight),And(BKnave,AKnight))),And(Implication(BKnave,Not(Or(And(AKnave,BKnight),And(BKnave,AKnight)))))
``````

)

# C says "A is a knight."

knowledge3 = And( Biconditional(AKnave,Not(AKnight)), Biconditional(BKnave,Not(BKnight)), Biconditional(CKnave,Not(CKnight)),

Implication(BKnight,(Implication(AKnight,AKnave),And(Implication(AKnave,Not(AKnave)))),And(Implication(BKnave,Not((Implication(AKnight,AKnave),And(Implication(AKnave,Not(AKnave)))))), Implication(BKnight,CKnave),And(BKnave,Not(CKnave)), Implication(CKnight,AKnave),And(CKnave,Not(AKnave))

)

def main(): symbols = [AKnight, AKnave, BKnight, BKnave, CKnight, CKnave] puzzles = [ ("Puzzle 0", knowledge0), ("Puzzle 1", knowledge1), ("Puzzle 2", knowledge2), ("Puzzle 3", knowledge3) ] for puzzle, knowledge in puzzles: print(puzzle) 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()

## I got the error##

Python38-32/python.exe" "c:/Users/Mzle.py" File "c:/Users/M Hasnain Sikander def main(): ^ SyntaxError: invalid syntax