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
    @[implicit_reducible]
    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]
    theorem Cslib.URM.Instr.T_nonJump (m n : ) :
    ¬(T m n).IsJump

    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
      @[implicit_reducible]
      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 #

      Cap a jump target to be at most len. Non-jump instructions are unchanged.

      Equations
      Instances For
        @[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.