#+title: Who's the criminal in 3MI3? #+options: :tangle tutorial.pl * Problem One of the following is the criminal, only one is speaking truthfully. Who is the criminal? A says: "It's not me" B says: "It's D" C says: "It's B" D says: "It's not me" Confident Guess: A is bad; D is good. * Let's Calculate! :2DM3: Let's write X to denote that X is honest, and so “X ≡ what-X-says” is an axiom. Here's what we know: 1. A ≡ ¬ A 2. B ≡ D ∧ ¬ B 3. C ≡ B ∧ ¬ C 4. D ≡ ¬ D 5. A ∨ B ∨ C ∨ D 6. ¬(A ∧ B ∧ C ∧ D) Let's start with (5) and see where we end up. true ={ by 5 } A ∨ B ∨ C ∨ D ={ by 3 } A ∨ B ∨ (B ∧ ¬ C) ∨ D ={ absorption: p ∨ (p ∧ q) ≡ p } A ∨ B ∨ D ={ by 2 } A ∨ (D ∧ ¬ B) ∨ D ={ absoprtion again } A ∨ D Whence we know that one of A or D is speaking the truth. Exercise: Calculate to find out the criminal. * Quick Intro to Prolog ---look at my terminal--- #+BEGIN_SRC prolog :tangle tutorial.pl % confident(X) ≡ X is a confident student confident(alice). confident(dan). confident(stefan). #+END_SRC #+BEGIN_SRC prolog :tangle tutorial.pl % cool (X) %≡ person(X) ∧ friend(X, Y) ∧ confident(Y) % % a cool person is someone with a confident friend person(jack). person(bobert). person(mikahel). person(jasim). person(mary). person(mariam). person(maryiam). person(X) :- confident(X). % inference rules, or computation rules friend(bobert, Y) :- person(Y). friend(mary, mariam). friend(mary, maryiam). friend(mary, jasim). friend(X, Y) :- friend(Y, X). friend(X, Z) :- person(Y) , friend(X, Y) , friend(Y, Z). % Exercise: Fix me, and above. cool(X) :- person(X) , person(Y) , friend(X, Y) , confident(Y). #+END_SRC * Solve the orignal pronblem [[https://stackoverflow.com/questions/1939054/solving-a-logic-puzzle-using-prolog][Here]] is a solution. * Thrusday's tutorial ↻ the overhead wasn't working, we used the blackboard. ↻ [[https://github.com/alhassy/PrologCheatSheet#declaration-ordering-matters][Here]] is essentially what we did: We wrote a path search algorithm.