Skip to content

Instantly share code, notes, and snippets.

@elliott-beach
Created November 11, 2017 20:30
Show Gist options
  • Save elliott-beach/0b920cc93393221c40ca615db599d51c to your computer and use it in GitHub Desktop.
Save elliott-beach/0b920cc93393221c40ca615db599d51c to your computer and use it in GitHub Desktop.
import logic
# Write problem 3 into a logic base.
prob3 = logic.PropKB()
A, B, C, D, E = logic.expr('A, B, C, D, E')
prob3.tell(A)
prob3.tell(~A | C)
prob3.tell(C | ~D)
prob3.tell(D | C)
prob3.tell(~B | ~D | E)
# Use the knowledge to find the answers to (3.1) and (3.2)
print(prob3.ask_if_true(C)) # True
print(prob3.ask_if_true(E)) # False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment