Documentation

MasterThesis.LOOP.Language

LOOP language #

This file defines LOOP, a simple imperative nonreversible programming language that precisely captures all the primitive recursive functions.

Notations #

Consecutive updates can be concatenated as σ[x ↦ v₁][x ↦ v₂].

Implementation notes #

A LOOP State is defined as an Option Store to provide a uniform structure for both LOOP and SCORE states, simplifying the management of the notion of equivalence. The term none can be interpreted as the failure state, even though this is not defined in the language specifications, nor is meaningful.

References #

See [MR67] for the original account on LOOP language.

A Store provides an abstract representation of memory in the form of a total function from Ident to Nat.

Equations
Instances For

    An empty Store maps every identifier to zero.

    Equations
    Instances For

      Updates a Store by mapping the register identified by x to a new value v.

      Equations
      • (σ[x v]) y = if x = y then v else σ y
      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[simp]
            theorem LOOP.Store.update_same {σ : LOOP.Store} {x : Ident} {y : Ident} {v : } :
            x = y(σ[x v]) y = v

            If x = y then the current value of y in σ[x ↦ v] is v.

            @[simp]
            theorem LOOP.Store.update_other {σ : LOOP.Store} {x : Ident} {y : Ident} {v : } :
            x y(σ[x v]) y = σ y

            If x ≠ y then the current value of y in σ[x ↦ v] is σ y.

            @[simp]
            theorem LOOP.Store.update_no_update {σ : LOOP.Store} {x : Ident} :
            σ[x σ x] = σ

            Updating a variable to its current value produces no change.

            @[reducible, inline]

            A State can be a Store or a failure.

            Equations
            Instances For
              inductive LOOP.Com :

              A LOOP program is a sequence of commands chosen from skip, clearing a register, incrementing a register, copying one register to another, composing two commands, and iterating over a finite number of steps.

              Instances For

                Computes the set of identifiers that appear in a LOOP command.

                Equations
                Instances For

                  Computes the string representation of a LOOP command.

                  Equations
                  Instances For

                    Interpreter for LOOP. The interpreter takes as input a Com and an evaluation State and outputs the resulting State obtained by applying the command to the initial state.

                    Equations
                    Instances For