Skip to content

Commit

Permalink
chore: stress test against binder nonsense
Browse files Browse the repository at this point in the history
  • Loading branch information
bollu committed Aug 19, 2024
1 parent ea43901 commit e9cd5df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Arm/Memory/SeparateAutomation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace SeparateAutomation

structure SimpMemConfig where
/-- number of times rewrites must be performed. -/
rewriteFuel : Nat := 100
rewriteFuel : Nat := 1000


/-- Context for the `SimpMemM` monad, containing the user configurable options. -/
Expand Down Expand Up @@ -776,11 +776,16 @@ partial def SimpMemM.improveExpr (e : Expr) (hyps : Array Hypothesis) : SimpMemM
Lean.Meta.forallTelescope e fun xs b => do
for x in xs do
improveExpr x hyps
-- we may have a hypothesis like
-- ∀ (x : read_mem (read_mem_bytes ...) ... = out).
-- we want to simplify the *type* of x.
improveExpr (← inferType x) hyps
improveExpr b hyps
else if e.isLambda then
Lean.Meta.lambdaTelescope e fun xs b => do
for x in xs do
improveExpr x hyps
improveExpr (← inferType x) hyps
improveExpr b hyps
else
-- check if we have expressions.
Expand Down
7 changes: 4 additions & 3 deletions Proofs/Experiments/MemoryAliasing.lean
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,16 @@ info: 'ExprVisitor.test_quantified_app_1' depends on axioms: [propext, Classical
#guard_msgs in #print axioms test_quantified_app_1

/--
Check that we correctly simplify hypotheses as well,
where the hypotheses are universally quantified variables
Check that we correctly simplify the *types* of binders as well.
Here, the bound variable `P` has *type* that involves a memory read.
We make sure that we simplify these as well.
-/
theorem test_quantified_app_2 {val : BitVec (16 * 8)}
(hlegal : ∀ (addr : Nat), mem_legal' addr 16)
(f : _ → Nat) :
f (∀ (P : Memory.read_bytes 16 0 (Memory.write_bytes 16 0 val mem) = irrelevant), Nat) =
f (∀ (P : val.extractLsBytes 0 16 = irrelevant), Nat) := by
simp_mem
simp
rfl

end ExprVisitor

0 comments on commit e9cd5df

Please sign in to comment.