Hoare-style specifications for Turing machines #
This file defines Hoare triples for reasoning about TM behavior in terms of tape preconditions and postconditions. This provides a compositional framework for building and verifying complex machines from simpler components.
Main definitions #
TapePred— a predicate on the tape configuration (input, work, output)TM.HoareTime— time-bounded Hoare triple:{pre} tm {post} [≤ bound]TM.Hoare— unbounded Hoare triple:{pre} tm {post}
Design notes #
Hoare triples abstract away the internal state Q, reasoning purely about
tape contents and head positions. This makes them ideal for compositional
reasoning: the pre/postconditions of composed machines can be stated without
reference to the internal state types of the components.
The precondition must imply that the starting configuration has the machine's
qstart state. The postcondition holds at halting.
A predicate on the tape configuration: input tape, work tapes, output tape.
Equations
- Complexity.TapePred n = (Complexity.Tape → (Fin n → Complexity.Tape) → Complexity.Tape → Prop)
Instances For
A predicate on the tape configuration: input tape, work tapes, output tape.
Equations
Instances For
Time-bounded Hoare triple: for any tapes satisfying pre, starting
from qstart, the machine halts within bound steps with tapes satisfying
post.
This is the core specification type for compositional TM reasoning. Captures both correctness (pre/post) and efficiency (time bound).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Consequence rule: weaken the precondition and strengthen the postcondition.
Precondition weakening: if pre' implies pre, lift the Hoare triple.
Postcondition strengthening: if post implies post', lift the triple.
DecidesInTime implies a family of Hoare triples, one per input.
A predicate on the tape configuration: input tape, work tapes, output tape.
Equations
Instances For
Time-bounded Hoare triple for nondeterministic machines: every choice
sequence of the given length reaches a halted configuration satisfying
post. NTM.trace already keeps halted configurations fixed, so this
also covers machines that halt earlier than the bound.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Consequence rule for NTM Hoare triples.
Postcondition strengthening for NTM Hoare triples.
Time monotonicity for NTM Hoare triples. Since NTM.trace is fixed after
halting, a proof for b steps also gives a proof for any larger bound.
Consequence rule plus time-bound weakening for NTM Hoare triples.
If a finite NTM trace is halted at time T, then it has a least halted
prefix time. This is useful for phase-composed machines: Hoare-time facts
give halting by a fixed bound, while phase exits need the first local halt
time.
Hoare-time corollary of exists_first_halt_time_of_trace_halted: every
all-path halting proof yields a least halting prefix for each fixed choice
sequence.
Hoare-time first-halt extraction, preserving the Hoare postcondition at the first halted prefix.