Documentation

MasterThesis.SCORE.Language

SCORE language #

This file defines SCORE, a minimal reversible programming language designed as a reversible adaptation of LOOP. SCORE can be understood as an extension of SRL [Mat03] that operates on variables represented by stacks of integers.

Notations #

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

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

Equations
Instances For

    An empty Store maps every identifier to the empty list.

    Equations
    Instances For

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

      Equations
      • (σ[x l]) y = if x = y then l 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 SCORE.Store.update_same {σ : SCORE.Store} {x : Ident} {y : Ident} {l : List } :
            x = y(σ[x l]) y = l

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

            @[simp]
            theorem SCORE.Store.update_other {σ : SCORE.Store} {x : Ident} {y : Ident} {l : List } :
            x y(σ[x l]) y = σ y

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

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

            Updating a variable to its current value produces no change.

            @[simp]
            theorem SCORE.Store.update_shrink {σ : SCORE.Store} {x : Ident} {l₁ : List } {l₂ : List } :
            σ[x l₁][x l₂] = σ[x l₂]

            Two consecutive updates to the same variable can be compressed into a single update.

            theorem SCORE.Store.update_no_update_cons {σ : SCORE.Store} {x : Ident} {v : } :
            (σ x).head? = some vσ[x v :: (σ x).tail] = σ

            Alternative version of update_no_update that considers the structure of the list.

            theorem SCORE.Store.update_swap {σ : SCORE.Store} {x : Ident} {y : Ident} {l₁ : List } {l₂ : List } :
            x yσ[x l₁][y l₂] = σ[y l₂][x l₁]

            The order in which two different variables are updated is not significant.

            @[reducible, inline]

            A State can be a Store or a failure.

            Equations
            Instances For
              inductive SCORE.Com :

              A SCORE program is a sequence of commands chosen from skip, extending a stack, decreasing a stack, incrementing the top of a stack, decrementing the top of a stack, composing two commands, and iterating over a finite number of steps.

              Instances For

                The inverse of the inverse program of P is P itself.

                Interpreter #

                Interpreter for SCORE. 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

                  Reverse interpreter for SCORE. The interpreter takes as input a Com and an evaluation State and outputs the resulting State obtained by applying the inverse of the command to the initial state.

                  Instances For

                    Invertibility #

                    theorem SCORE.invertible_SEQ {s : SCORE.State} {t : SCORE.State} {P : SCORE.Com} {Q : SCORE.Com} (ih₁ : ∀ {s t : SCORE.State}, SCORE.eval P s = t t none SCORE.eval P⁻¹ t = s s none) (ih₂ : ∀ {s t : SCORE.State}, SCORE.eval Q s = t t none SCORE.eval Q⁻¹ t = s s none) :
                    SCORE.eval (P;;Q) s = t t none SCORE.eval (P;;Q)⁻¹ t = s s none
                    theorem SCORE.invertible {s : SCORE.State} {t : SCORE.State} {P : SCORE.Com} :
                    SCORE.eval P s = t t none SCORE.eval P⁻¹ t = s s none