Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Tactic.Step

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 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 cfg is rewritten to the action of the transition function when the state of cfg is some q by rfl. For a halted configuration, give the hypothesis cfg.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 of Fin n for a numeral n; with Fin.lastCases or Fin.addCases where that function, or Fin.append, is applied to i; into i = j and i ≠ j for Function.update f j v i; and on the condition of an if or the cases of a match that mentions i. Other conditions and matches are split on only when that closes the case.
  • Each case is closed with simp, using the simp set tm_step_simps and the arguments, and then omega; an input head position is also compared as an integer. When a case stays open, tm_step fails and shows the cases left, each simplified with tm_step_simps and 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