Skip to content

Restructure venom/ into defs/proofs/props, simplify equiv API#168

Merged
charles-cooper merged 14 commits intomainfrom
refactor-venom-structure
Mar 4, 2026
Merged

Restructure venom/ into defs/proofs/props, simplify equiv API#168
charles-cooper merged 14 commits intomainfrom
refactor-venom-structure

Conversation

@charles-cooper
Copy link
Contributor

co-authored by claude opus 4.6

Restructure venom/ into defs/proofs/props pattern and simplify the equivalence API. All theories build clean with 0 cheats.

Changes

Directory restructure

  • venom/ split into venom/defs/, venom/proofs/, venom/props/ with proper Holmakefiles
  • Theory renames: venomSemvenomExecSemantics, venomProofsvenomExecProofs, venomPropsvenomExecProps
  • stateEquiv split into defs (in defs/) + proofs (in proofs/) + props API (in props/)
  • Props re-export via ACCEPT_TAC wrappers — clean public API

step_inst refactoring

  • Factor step_inst_def into category helpers: exec_pure{1,2,3}, exec_read{0,1}, exec_write2
  • Per-category equiv theorems enable compositional proofs
  • step_inst_result_equiv proven via MEM bridge dispatch (no cheats)

Equivalence API simplification

  • Rename: state_equiv_except varsstate_equiv vars, execution_equiv_exceptexecution_equiv, result_equiv_exceptresult_equiv
  • Delete var_equiv and old binary versions
  • General versions get short names (design principle: state_equiv {} for full equivalence)
  • Props API trimmed: stateEquivProps 74→20 theorems, execEquivProps 6→3

Downstream passes updated

  • revert_to_assert: all 4 theories build clean
  • phi_elimination: all 3 theories build clean (phiTransform, phiBlock, phiFunction)
  • lookup_block/lookup_function migrated from custom recursion to FIND

Stats

  • 61 files changed, 1880 insertions, 3962 deletions (net -2082 LOC)
  • 0 cheats across all theories

Directory structure:
  defs/   - venomState, venomInst, venomWf(new), venomEffects,
            venomExecSemantics(was venomSem), stateEquiv(defs only)
  proofs/ - stateEquivProofs, venomProofs, execEquivProofs
  props/  - stateEquivProps, venomProps, execEquivProps (ACCEPT_TAC API)

Theory renames:
  venomSem -> venomExecSemantics
  venomSemProps -> venomProofs/venomProps
  execEquiv -> execEquivProofs/execEquivProps

Other changes:
  - venomWf extracted from venomInst (well-formedness predicates)
  - stateEquiv split: definitions in defs/, 74 theorems in proofs/
  - lookup_block/lookup_function refactored to use FIND (stdlib)
  - exec_binop/unop/modop -> exec_pure2/pure1/pure3
  - Downstream Ancestors updated in passes/ (phi_elimination, revert_to_assert)
  - Internal proof helpers marked Triviality

Known issues (to fix in follow-up):
  - venomProofs: lookup_block_MEM etc need FIND-based reproof
  - execEquivProofs: step_inst_{state,result}_equiv cheated
Consistent naming chain:
  defs:   venomExecSemantics
  proofs: venomExecProofs
  props:  venomExecProps
stateEquivProps: 74 -> 33 (40 demoted to [local] in proofs)
execEquivProps: 6 -> 2 (4 step-level demoted, keep run_block only)
venomExecProps: 15 -> 13 (4 dead removed)

result_equiv_{ok,halt,revert,error,error_any,mismatch} kept as
exported [simp] rules since execEquivProofs depends on them.
- state_equiv_except vars s1 s2 -> state_equiv vars s1 s2
- execution_equiv_except -> execution_equiv
- result_equiv_except -> result_equiv
- Delete old binary state_equiv, result_equiv, var_equiv
- state_equiv {} s1 s2 replaces old state_equiv s1 s2
…ith vars

stateEquivProps:
- All predicates now parameterized by vars (no {} specializations)
- Drop _except suffix from all theorem names
- Delete crossing theorems (halt/revert_state_from_state_except)
- Delete state_equiv_implies_except (identity after rename)

execEquivProps:
- Add step_inst_result_equiv (general, with operand precondition)
- Generalize run_block_{state,result}_equiv with vars + operand precondition
- 2 -> 3 exported theorems
stateEquivProofs:
- All theorems use state_equiv/execution_equiv (no _except suffix)
- Drop var_equiv references, use execution_equiv_def directly
- Merge {} specializations into general versions
- Delete crossing theorems, observable_equiv extras
- 74 -> ~45 theorems (many internals consolidated)

execEquivProofs:
- Generalize step_inst_result_equiv with vars + operand precondition
- Absorb RTA pattern: per-opcode dispatch with category helpers
- step_inst_result_equiv now canonical (was duplicated in RTA)
- run_block_{state,result}_equiv cheated pending induction proof

venomExecProofs:
- Fix 3 FIND-based lookup cheats via FIND_MEM/FIND_P/FIND_NONE
- Simplify lookup_block_MEM proof
- execEquivProofs: prove step_inst_result_equiv, run_block_{state,result}_equiv
  with operand condition (vars parameter)
- venomExecProofs: update for new exec helpers (exec_read0/1, exec_write2)
- revert_to_assert: migrate binary->ternary equiv (state_equiv {}, result_equiv {})
- phiTransform: add stateEquiv ancestor for result_equiv_def access

All 0 cheats. All theories build clean.
- phiBlock: state_equiv/result_equiv {} for all theorem statements and proofs
  - Add stateEquiv ancestor for def access
  - Add exec_read0/1, exec_write2 to step_inst_preserves_prev_bb
  - Fix Halt/Revert cases: execution_equiv_refl instead of state_equiv_refl
  - Remove dead trailing tactics
- phiFunction: same binary->ternary migration
  - Fix run_function_state_equiv halted case with state_equiv_def unfolding
  - Fix result_equiv symmetry with execution_equiv_def

All 0 cheats. All theories build clean.
@charles-cooper charles-cooper requested a review from xrchz March 4, 2026 17:56
…t comments

- Add result_equiv_trans to stateEquivProofs/Props (used by phi+rta)
- Remove duplicate result_equiv_trans from phiBlock and rtaProofHelpers
- Remove dead resolve_phi_MEM from rtaProofHelpers (was unused)
- Add placement comment for step_inst_preserves_inst_idx in defs file
- Mark FIND lemmas as stdlib-gap candidates
…oofs

lookup_function_mem, lookup_function_not_mem, lookup_function_MEM were
either local or in venomExecProofs, invisible to analysis consumers.
Move to venomInstScript.sml where lookup_function is defined.

Fix liveness proofs that assumed pattern-matching lookup_block_def
(now FIND-based): add FIND_thm to induction proofs.
@charles-cooper charles-cooper merged commit 11fab49 into main Mar 4, 2026
12 checks passed
@charles-cooper charles-cooper deleted the refactor-venom-structure branch March 4, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant