Sending a quantum state with two ordinary bits, checked for every case.
teleportation.py · output · proof · check · try it in the playground
In quantum teleportation, Alice wants to give Bob a qubit (a quantum bit) without sending the qubit itself. They share a linked pair of qubits in advance. Alice makes a measurement, phones Bob two ordinary bits (one of four outcomes, 0 to 3), and Bob applies a fix that depends on the outcome.
Does Bob always end up with exactly the state Alice had — for every state and every outcome?
The program uses discrete quantum theory: a toy version where amplitudes are just “there or not”, and two ways of reaching the same result cancel each other out. A result survives only if it can be reached an odd number of ways.
It keeps the strange parts — superposition, interference, entanglement —
small enough to check exhaustively. Three states are tested: zero, one,
and plus (both at once).
# … the shared pair, Alice's measurement and Bob's fixes
implied_by(received(S, M, Z), qubit(Z) & findall(Path, path(S, M, Z, Path), Paths) & odd(Paths))
# …
implies(name(S) & outcome(M) & findall(Z, received(S, M, Z), Received), teleported(S, M, Received))
# …
contradiction(teleported(S, _, Received), sent(S, Sent), not_identical(Received, Sent))
findall gathers all answers. The contradiction rule is a safety
alarm: if Bob’s state ever differs from Alice’s, the run stops with exit
code 65.
teleported('zero', 0, ['false'])
teleported('one', 0, ['true'])
teleported('plus', 0, ['false', 'true'])
teleported('plus', 3, ['false', 'true'])
…12 answers in all: 3 states × 4 outcomes. In every one, Bob holds exactly
what Alice sent (zero is ['false'], one is ['true'], plus is
both), and the alarm never fires.
For each of the 12 cases, the proof says:
Step 3 is where the quantum work happens, and it is a “find all” step.
Verdict: checked_with_obligations. 31 steps, 12 on trust. Honestly put: the counting of paths sits inside those 12 obligations.
python -m peye examples/teleportation.py # the answers
python -m peye --proof examples/teleportation.py # answers with their proof
Break Bob’s fix for outcome 0: in implied_by(bob(0, Y, Z), kg(Y, Z)) replace
kg(Y, Z) with id(Y, Z). Now Bob sometimes gets the wrong state, peye
prints 'false' and exits with code 65.
Even a quantum protocol can be checked case by case with a few rules. peye covers all 12 cases, and is upfront that the “all answers” lists are the part you are trusting.