Documentation

Complexity.Computability.Machines.Turing.MultiTape.Universal.Basic

Simulating multi-tape machines on numbers #

The universal machine simulates a multi-tape Turing machine over the states and symbols ℕ from a description (Turing.MultiTapeTM.Universal.Desc): the number of work tapes, the initial state and a transition table. A transition maps a key (Turing.MultiTapeTM.Universal.Key) — the state and the symbols under the heads, as the arguments of Turing.MultiTapeTM.tr — to an action (Turing.MultiTapeTM.Universal.Act), which mirrors Turing.Action with the work tapes in a list. A missing transition halts the machine.

The configurations (Turing.MultiTapeTM.Universal.SCfg) mirror Turing.Cfg without the output: a step returns the symbol it emits, if any, and it is up to the caller to collect, use or discard it. A work tape (Turing.MultiTapeTM.Universal.Tape) is a zipper: the position of its head, the cells left of the head, nearest first, and the cells from the head on. It holds no more cells than the head has visited, so a configuration takes space linear in the space of the simulated machine. The input head is a number, encoded in binary by the universal machine.

Main definitions #

The key of a transition: the state and the symbols under the input head and the work-tape heads.

  • state : ℕ

    The state.

  • input : Option ℕ

    The symbol under the input head.

  • work : List (Option ℕ)

    The symbols under the work-tape heads.

Instances For
    Instances For

      An action, as Turing.Action with the work tapes in a list.

      Instances For

        A description of a machine: the number of work tapes, the initial state and the transitions.

        • tapes : ℕ

          The number of work tapes.

        • q₀ : ℕ

          The initial state.

        • table : List (Key × Act)

          The transitions.

        Instances For

          A simulated work tape, as a zipper.

          • head : ℤ

            The position of the head.

          • left : List (Option ℕ)

            The cells left of the head, nearest first.

          • right : List (Option ℕ)

            The cells from the head on.

          Instances For

            A configuration of the simulation, as Turing.Cfg with the work tapes in a list and without the output.

            • state : Option ℕ

              The state, or none once halted.

            • inputPos : ℕ

              The position of the input head.

            • workTapes : List Tape

              The work tapes.

            Instances For

              The symbol under the head.

              Instances For

                Writes o under the head.

                Instances For

                  Moves the head by m.

                  Instances For

                    Applies the action on a work tape: write, then move.

                    Instances For

                      The symbol at position p of the input x, with blanks at position 0 and after the input.

                      Instances For

                        Moves the input head at position p, reading a, by m: right moves stop at the blank after the input, which is the only blank right of position 0.

                        Instances For

                          Applies the actions to the work tapes, in order; a tape without an action is unchanged.

                          Instances For

                            The effect of an action on a configuration on the input x, as Turing.Action.apply, without the output.

                            Instances For

                              The key of the transition to take in c, on the input x, in the state q.

                              Instances For

                                One step of the machine described by d with the input head reading a, and the symbol it emits: the step without the input.

                                Instances For

                                  One step of the machine described by d on the input x, and the symbol it emits.

                                  Instances For

                                    A step reads the input only at the input head.

                                    The initial configuration: the initial state, the input head on the first symbol and blank work tapes.

                                    Instances For

                                      A step that collects the emitted symbol.

                                      Instances For

                                        The output of the machine described by d on the input x after t steps, and whether it has halted by then.

                                        Instances For