Documentation

Complexity.Computability.Ram.Execution.Block.Basic

Straight-line instruction blocks #

execBlock is a convenient state transformer, not a second cost model. execBlock_exec connects it to exactly one real machine transition per instruction whenever a linear block is present at the current program counter.

Instructions that always advance to the next address without changing running status. Input reads are excluded because exhausted input faults.

Equations
Instances For
    theorem Ram.execInstr_pc_of_linear {w : Nat} {i : Instr} (s : State w) (h : i.Linear) :
    (execInstr i s).pc = s.pc + 1
    theorem Ram.execInstr_status_of_linear {w : Nat} {i : Instr} (s : State w) (h : i.Linear) :
    def Ram.execBlock {w : Nat} (block : Code) (s : State w) :

    Fold instruction bodies in their program order. This transformer is used only through the machine-execution theorem when assigning a transition count.

    Equations
    Instances For
      @[simp]
      theorem Ram.execBlock_nil {w : Nat} (s : State w) :
      @[simp]
      theorem Ram.execBlock_cons {w : Nat} (i : Instr) (block : Code) (s : State w) :
      execBlock (i :: block) s = execBlock block (execInstr i s)
      @[simp]
      theorem Ram.execBlock_append {w : Nat} (a b : Code) (s : State w) :
      execBlock (a ++ b) s = execBlock b (execBlock a s)
      theorem Ram.execBlock_pc {w : Nat} (block : Code) (s : State w) (hlinear : ∀ (i : Instr), i ∈ block → i.Linear) :
      (execBlock block s).pc = s.pc + List.length block
      theorem Ram.execBlock_status {w : Nat} (block : Code) (s : State w) (hlinear : ∀ (i : Instr), i ∈ block → i.Linear) :
      (execBlock block s).status = s.status
      def Ram.CodeAt (code : Code) (pc : Nat) (block : Code) :

      A block occupies a contiguous interval of the surrounding machine code.

      Equations
      Instances For
        @[simp]
        theorem Ram.CodeAt.nil (code : Code) (pc : Nat) :
        CodeAt code pc []
        theorem Ram.CodeAt.refl (block : Code) :
        CodeAt block 0 block
        theorem Ram.CodeAt.prefix_append (pre block suffix : Code) :
        CodeAt (pre ++ block ++ suffix) (List.length pre) block
        theorem Ram.CodeAt.head {code : Code} {pc : Nat} {i : Instr} {block : Code} (h : CodeAt code pc (i :: block)) :
        code[pc]? = some i
        theorem Ram.CodeAt.tail {code : Code} {pc : Nat} {i : Instr} {block : Code} (h : CodeAt code pc (i :: block)) :
        CodeAt code (pc + 1) block
        theorem Ram.CodeAt.cons {code : Code} {pc : Nat} {i : Instr} {block : Code} (hhead : code[pc]? = some i) (htail : CodeAt code (pc + 1) block) :
        CodeAt code pc (i :: block)
        theorem Ram.CodeAt.append_left {code a b : Code} {pc : Nat} (h : CodeAt code pc (a ++ b)) :
        CodeAt code pc a
        theorem Ram.CodeAt.append_right {code a b : Code} {pc : Nat} (h : CodeAt code pc (a ++ b)) :
        CodeAt code (pc + List.length a) b
        theorem Ram.CodeAt.append {code a b : Code} {pc : Nat} (ha : CodeAt code pc a) (hb : CodeAt code (pc + List.length a) b) :
        CodeAt code pc (a ++ b)
        theorem Ram.CodeAt.append_iff {code a b : Code} {pc : Nat} :
        CodeAt code pc (a ++ b) ↔ CodeAt code pc a ∧ CodeAt code (pc + List.length a) b
        theorem Ram.execBlock_exec {w : Nat} {code block : Code} {s : State w} (hAt : CodeAt code s.pc block) (hlinear : ∀ (i : Instr), i ∈ block → i.Linear) (hrun : s.status = Status.running) :
        Exec code (List.length block) s (execBlock block s)

        A linear block executes in exactly its length many transitions of the machine's real step, starting from any running state at its first instruction.