LibcHooks.lean
Libc and Allocator HookOk Witnesses
Provides HookOk witnesses for leaf and field-query external hooks (retHook, hookNoop, hookReturnZero, fieldHook, fieldHook64), stack-frame splitting combinators, standard memory operations (memset, memcpy, memmove), and single-slot or bump-pointer pool allocators (witnessAlloc, bumpAllocator, bumpAllocReg).
@[expose] public sectionnamespace ProofLibopen Arm64Leaf and field-query hooks
def retHook
Wrap a state transformer f as a leaf subroutine hook that returns to LR (X30).
13 declarations not shown (lines 40–125): theorems, which Lean checks, or definitions that no headline statement uses
ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib.
elab
Auto-parameter helper that unfolds concrete Spec. / Spec. projections so simp [ctype_simp] reduces lowered c_spec / c_type_spec handle query contracts.
elab "close_field_hook_entails" : tactic => do
Lean.Elab.Tactic.evalTactic (← `(tactic| intros))
let goal ← Lean.Elab.Tactic.getMainGoal
let ty ← Lean.instantiateMVars (← goal.getType)
let ty' ← Lean.Core.transform ty (pre := fun e => do
if e.isAppOfArity ``Spec.pre 4 || e.isAppOfArity ``Spec.post 5 then
let specExpr := (e.getAppArgs)[1]!
if let some specUnf ← Lean.Meta.unfoldDefinition? specExpr then
let args := e.getAppArgs.set! 1 specUnf
return .visit (← Lean.Meta.whnf (Lean.mkAppN e.getAppFn args))
return .continue)
let goal' ← goal.replaceTargetDefEq ty'
Lean.Elab.Tactic.replaceMainGoal [goal']
Lean.Elab.Tactic.evalTactic (← `(tactic|
(try dsimp only;
try simp only [ctype_simp, true_and, and_true, pure_true_sepConj, sepConj_pure_true,
sepConj_emp, emp_sepConj];
try rw [show _ = _ by ac_rfl];
exact Entails.refl _)))7 declarations not shown (lines 149–248): theorems, which Lean checks, or definitions that no headline statement uses
ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib.
def hookMemcpy
Functional hook for void *memcpy(void *dst, const void *src, size_t n) / void *memmove(void *dst, const void *src, size_t n): reads n bytes from X1, writes them to X0, and returns X0 at LR.
abbrev hookMemmove
abbrev hookMemmove : State → State := hookMemcpy27 declarations not shown (lines 262–675): theorems, which Lean checks, or definitions that no headline statement uses
ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib., ProofLib.
end ProofLib