Created
July 27, 2025 00:38
-
-
Save gahrae/ef23cc2577148949bf7c2e5d4c1d8746 to your computer and use it in GitHub Desktop.
solve the riverside murder with prolog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Read article at | |
| % https://medium.com/@gareth.stretton/the-riverside-diner-murder-a-logic-programming-investigation-b8ea0f54bae6 | |
| % Original facts remain the same | |
| missing_knife(elena). | |
| missing_knife(david). | |
| matching_tires(james). | |
| matching_tires(lisa). | |
| matching_tires(david). | |
| blue_uniform(elena). | |
| blue_uniform(tom). | |
| person(elena). | |
| person(david). | |
| person(james). | |
| person(lisa). | |
| person(tom). | |
| % New evidence facts | |
| borrowed_car(david, elena). % David borrowed Elena's car | |
| wore_jacket(david, elena). % David wore Elena's chef jacket | |
| fingerprints_on_knife(david, elena). % David's prints on Elena's knife roll | |
| % Updated tire tracks - now we know David used Elena's car | |
| % We need to account for who was actually driving which car | |
| actual_driver_tires(X) :- | |
| matching_tires(X), | |
| \+ borrowed_car(_, X). % Person drove their own car | |
| actual_driver_tires(X) :- | |
| borrowed_car(X, Y), | |
| matching_tires(Y). % Person borrowed a car with matching tires | |
| % Updated uniform facts - account for borrowed clothing | |
| actual_uniform(X) :- | |
| blue_uniform(X), | |
| \+ wore_jacket(_, X). % Person wore their own uniform | |
| actual_uniform(X) :- | |
| wore_jacket(X, Y), | |
| blue_uniform(Y). % Person wore someone else's uniform | |
| % The final murder solution | |
| murderer(X) :- | |
| (missing_knife(X); fingerprints_on_knife(X, _)), % Had access to murder weapon | |
| actual_driver_tires(X), % Was at scene (tire evidence) | |
| actual_uniform(X), % Matches witness description | |
| person(X). | |
| % Additional supporting evidence: | |
| motive(david, job_insecurity). % Feared being fired | |
| motive(david, financial_pressure). % Needed money, thought he'd inherit position | |
| opportunity(david, has_keys). % Had keys to diner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment