Steps and equalities of multi-tape configurations #
A proof that follows a multi-tape machine shows again and again that two descriptions of a
configuration agree: tm.step cfg = cfg', action.apply cfg = cfg', or an initial or embedded
configuration written in two ways. By hand this is Turing.Cfg.ext, a funext on the work tapes,
and a case split on the tape index chosen to match the way the tapes were written. The tactic
tm_step takes these steps and reads the case split off the goal.
No step function or transition table is a simp lemma: tm_step unfolds the step itself and takes
the table among its arguments.
Main definitions #
tm_step,tm_step [defs, facts]: prove an equality of configurations (Turing.Cfg,Turing.MultiTapeMachine.Config), or fail showing the cases thatsimpdoes not close.tm_step_simps: the simp set with whichtm_stepcomputes the fields of a configuration after an action, and the values of a family of tapes at the indices it splits on. It is declared inCslibFrontier.Computability.Machines.Turing.MultiTape.Tactic.Step.Initand filled here.
tm_step proves an equality of multi-tape configurations (Turing.Cfg or
Turing.MultiTapeMachine.Config), such as tm.step cfg = cfg' or action.apply cfg = cfg'.
tm_step [defs, facts] also unfolds the definitions defs, among them the transition table of
the machine and the builders of the two configurations, and uses the facts, as simp does.
- A step
tm.step cfgis rewritten to the action of the transition function when the state ofcfgissome qbyrfl. For a halted configuration, give the hypothesiscfg.state = none. - The two configurations are compared field by field. A field of work tapes or of their heads is
compared at an index
i, which is split as the goal requires: into the values ofFin nfor a numeraln; withFin.lastCasesorFin.addCaseswhere that function, orFin.append, is applied toi; intoi = jandi ≠ jforFunction.update f j v i; and on the condition of anifor the cases of amatchthat mentionsi. Other conditions andmatches are split on only when that closes the case. - Each case is closed with
simp, using the simp settm_step_simpsand the arguments, and thenomega; an input head position is also compared as an integer. When a case stays open,tm_stepfails and shows the cases left, each simplified withtm_step_simpsand the arguments only and with the hypothesis of its case in context: the fact that closes a case goes among the arguments.
One field is split into at most eight cases; beyond that tm_step fails.
example (j : Fin k) (c : Cfg k Bool State input) (q : State) :
(⟨0, Function.update (fun _ => (none, 0)) j (some (some true), 1), none, some q⟩ :
Action k Bool State).apply c =
⟨some q, c.inputPos,
Function.update c.workTapes j (Function.update (c.workTapes j) (c.workTapePos j) true),
Function.update c.workTapePos j (c.workTapePos j + 1), c.output⟩ := by
tm_step