ARM Machine State #
This file defines the ARM machine state used for verification.
Main Definitions #
Reg- ARM register names (X0-X30, PC, SP)Flags- ARM condition flags (N, Z, C, V)ArmState- Complete machine state (registers, flags, memory)read,write- Access registers and memory
References #
This corresponds to the ARM state in HOL Light's ARM model. Source: s2n-bignum/arm/proofs/arm.ml and instruction.ml
Equations
- Bignum.Arm.instDecidableEqReg.decEq (Bignum.Arm.Reg.X a) (Bignum.Arm.Reg.X b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Bignum.Arm.instDecidableEqReg.decEq (Bignum.Arm.Reg.X a) Bignum.Arm.Reg.PC = isFalse ⋯
- Bignum.Arm.instDecidableEqReg.decEq (Bignum.Arm.Reg.X a) Bignum.Arm.Reg.SP = isFalse ⋯
- Bignum.Arm.instDecidableEqReg.decEq Bignum.Arm.Reg.PC (Bignum.Arm.Reg.X a) = isFalse ⋯
- Bignum.Arm.instDecidableEqReg.decEq Bignum.Arm.Reg.PC Bignum.Arm.Reg.PC = isTrue ⋯
- Bignum.Arm.instDecidableEqReg.decEq Bignum.Arm.Reg.PC Bignum.Arm.Reg.SP = isFalse Bignum.Arm.instDecidableEqReg.decEq._proof_7
- Bignum.Arm.instDecidableEqReg.decEq Bignum.Arm.Reg.SP (Bignum.Arm.Reg.X a) = isFalse ⋯
- Bignum.Arm.instDecidableEqReg.decEq Bignum.Arm.Reg.SP Bignum.Arm.Reg.PC = isFalse Bignum.Arm.instDecidableEqReg.decEq._proof_9
- Bignum.Arm.instDecidableEqReg.decEq Bignum.Arm.Reg.SP Bignum.Arm.Reg.SP = isTrue ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Bignum.Arm.instReprReg.repr Bignum.Arm.Reg.PC prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Bignum.Arm.Reg.PC")).group prec✝
- Bignum.Arm.instReprReg.repr Bignum.Arm.Reg.SP prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Bignum.Arm.Reg.SP")).group prec✝
Instances For
Equations
- Bignum.Arm.instReprReg = { reprPrec := Bignum.Arm.instReprReg.repr }
Equations
- One or more equations did not get rendered due to their size.
ARM condition flag identifiers.
In HOL Light (s2n-bignum/arm/proofs/instruction.ml:186-192), flags are defined as sub-components of a 4-bit field:
let NF = define `NF = flags :> bitelement 3`;;
let ZF = define `ZF = flags :> bitelement 2`;;
let CF = define `CF = flags :> bitelement 1`;;
let VF = define `VF = flags :> bitelement 0`;;
Note: Named CFlag (Condition Flag) to avoid conflict with Mathlib's Flag.
Instances For
Equations
- Bignum.Arm.instReprFlag = { reprPrec := Bignum.Arm.instReprFlag.repr }
Equations
- Bignum.Arm.instReprFlag.repr Bignum.Arm.Flag.N prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Bignum.Arm.Flag.N")).group prec✝
- Bignum.Arm.instReprFlag.repr Bignum.Arm.Flag.Z prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Bignum.Arm.Flag.Z")).group prec✝
- Bignum.Arm.instReprFlag.repr Bignum.Arm.Flag.C prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Bignum.Arm.Flag.C")).group prec✝
- Bignum.Arm.instReprFlag.repr Bignum.Arm.Flag.V prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Bignum.Arm.Flag.V")).group prec✝
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
Equations
- Bignum.Arm.instReprFlags = { reprPrec := Bignum.Arm.instReprFlags.repr }
Read an individual flag by its identifier.
Equations
- f.read Bignum.Arm.Flag.N = f.N
- f.read Bignum.Arm.Flag.Z = f.Z
- f.read Bignum.Arm.Flag.C = f.C
- f.read Bignum.Arm.Flag.V = f.V
Instances For
Write an individual flag by its identifier.
Equations
Instances For
Write a value to a register.
Corresponds to HOL Light's state update for registers.
Equations
Instances For
Write a byte to memory.
Equations
- s.write_mem_byte addr byte = { regs := s.regs, flags := s.flags, mem := s.mem.write_byte addr byte }
Instances For
Read a 64-bit word from memory.
Equations
- s.read_mem_word64 addr = s.mem.read_word64 addr
Instances For
Write a 64-bit word to memory.
Equations
- s.write_mem_word64 addr w = { regs := s.regs, flags := s.flags, mem := s.mem.write_word64 addr w }
Instances For
Read a bignum from memory.
Corresponds to HOL Light's bignum_from_memory.
Example from bignum_add.ml:91-92:
bignum_from_memory (x,val m) s = a /\
bignum_from_memory (y,val n) s = b
Equations
- s.read_bignum addr n = s.mem.read_bignum addr n
Instances For
Write a bignum to memory.
Equations
- s.write_bignum addr n val = { regs := s.regs, flags := s.flags, mem := s.mem.write_bignum addr n val }
Instances For
Convenience notation for reading registers. Following HOL Light convention:
read PC s means read program counter from state s.
Equations
- Bignum.Arm.termRead__ = Lean.ParserDescr.node `Bignum.Arm.termRead__ 1022 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "read_") (Lean.ParserDescr.cat `term 1024))
Instances For
Simplification Lemmas for Register Read/Write #
These lemmas enable automatic simplification of register access patterns in proofs. They are essential for symbolic execution and proving correctness of instruction sequences.
Simplification Lemmas for Flag Read/Write #
Reading a flag immediately after writing to it returns the written value.
Reading a different flag is not affected by writing another flag.
Writing a flag does not affect registers.