The oldest example in logic, with the reasoning written down.
socrates.py · output · proof · check · try it in the playground
Socrates is human. Every human is mortal.
Is Socrates mortal? And, just as important: can the computer show why?
Two facts and one rule, written in Python:
fact(type('socrates', 'human')) # Socrates is a human
fact(subclass_of('human', 'mortal')) # every human is a mortal
implies(type(S, A) & subclass_of(A, B), type(S, B))
The rule reads: if S is an A, and every A is a B, then S is a B.
implies(premise, conclusion) is N3’s =>: whenever the premise holds,
conclude the conclusion, and keep applying it until nothing new follows.
Names in quotes, like 'socrates', are plain values; capitalized names like
S, A and B are variables, and type and subclass_of are the
predicates. None of them has to be declared.
type('socrates', 'mortal')
type('socrates', 'human')
The first line is new: nobody typed it in. The second is the fact we gave,
reported back because the program asks for every type it knows.
peye does not just print the answer; it records how it got there:
Each step names the exact line of the program it used, and the values it filled in.
The proof is a document of its own, and a separate checker reads it against the program. It confirms, among other things, that:
Verdict: checked. All 3 steps verified, and nothing taken on trust.
python -m peye examples/socrates.py # the answers
python -m peye --proof examples/socrates.py # answers with their proof
Or open it in the playground.
Add fact(type('plato', 'human')) and run again: Plato becomes mortal too, with his
own proof.
A conclusion you can follow step by step, and that a machine has checked, is one you can explain, question and build on — not just believe.