Documentation

Cslib.Computability.URM.Basic

URM Basic Lemmas #

This file contains basic lemmas and helper operations for URM types.

Main definitions #

Main results #

Register Lemmas #

@[simp]
theorem Cslib.URM.Regs.write_read_self (σ : Regs) (n v : ā„•) :
(σ.write n v).read n = v
@[simp]
theorem Cslib.URM.Regs.write_read_of_ne (σ : Regs) (m n v : ā„•) (h : m ≠ n) :
(σ.write n v).read m = σ.read m

State Lemmas #

theorem Cslib.URM.State.ext {s₁ sā‚‚ : State} (hpc : s₁.pc = sā‚‚.pc) (hregs : s₁.regs = sā‚‚.regs) :
s₁ = sā‚‚

Extensionality for State: two states are equal iff their components are equal.

theorem Cslib.URM.State.ext_iff {s₁ sā‚‚ : State} :
s₁ = sā‚‚ ↔ s₁.pc = sā‚‚.pc ∧ s₁.regs = sā‚‚.regs

Instruction Lemmas #

Jump Instructions #

An instruction is a jump instruction.

Equations
Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    @[simp]

    Z instruction is not a jump.

    @[simp]

    S instruction is not a jump.

    @[simp]

    T instruction is not a jump.

    @[simp]
    theorem Cslib.URM.Instr.J_IsJump (m n q : ā„•) :
    (J m n q).IsJump

    J instruction is a jump.

    theorem Cslib.URM.Instr.shiftJumps_of_nonJump {instr : Instr} (h : ¬instr.IsJump) (offset : ā„•) :
    shiftJumps offset instr = instr

    shiftJumps is identity for non-jumping instructions.

    Bounded Jump Targets #

    An instruction's jump target is bounded by a given length. Non-jump instructions trivially satisfy this.

    Equations
    Instances For
      Equations
      • One or more equations did not get rendered due to their size.
      theorem Cslib.URM.Instr.jumpsBoundedBy_of_nonJump {instr : Instr} (h : ¬instr.IsJump) (len : ā„•) :
      JumpsBoundedBy len instr

      Non-jumping instructions have bounded jumps for any length.

      theorem Cslib.URM.Instr.JumpsBoundedBy.mono {instr : Instr} {len1 len2 : ā„•} (h : JumpsBoundedBy len1 instr) (hle : len1 ≤ len2) :
      JumpsBoundedBy len2 instr

      JumpsBoundedBy is monotonic: if bounded for len1, then bounded for any len2 ≄ len1.

      theorem Cslib.URM.Instr.JumpsBoundedBy.shiftJumps {instr : Instr} {len offset : ā„•} (h : JumpsBoundedBy len instr) :
      JumpsBoundedBy (offset + len) (Instr.shiftJumps offset instr)

      shiftJumps preserves bounded jumps with adjusted bound.

      Jump Target Capping #

      @[simp]
      theorem Cslib.URM.Instr.capJump_Z (len n : ā„•) :
      capJump len (Z n) = Z n
      @[simp]
      theorem Cslib.URM.Instr.capJump_S (len n : ā„•) :
      capJump len (S n) = S n
      @[simp]
      theorem Cslib.URM.Instr.capJump_T (len m n : ā„•) :
      capJump len (T m n) = T m n
      @[simp]
      theorem Cslib.URM.Instr.capJump_J (len m n q : ā„•) :
      capJump len (J m n q) = J m n (min q len)

      capJump always produces an instruction with bounded jump.

      @[simp]
      theorem Cslib.URM.Instr.capJump_idempotent (len : ā„•) (instr : Instr) :
      capJump len (capJump len instr) = capJump len instr

      capJump is idempotent: capping twice is the same as capping once.

      theorem Cslib.URM.Program.mem_maxRegister {p : Program} {instr : Instr} (h : instr ∈ p) :

      Any instruction in a program has maxRegister at most the program's maxRegister.