feat: Add fine grained control over mem_omega rewriting [7/?] #238
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
We increase the ITPness of
simp_mem
by making it less of a proof hammer, and more of a user-controllable rewrite engine. Description of the new design follows:The simp_mem tactic allows simplifying expressions of the form
Memory.read_bytes rbase rn (mem')
.simp_mem
attempts to discover the result of the expression by various heuristics,which can be controlled by the end user:
mem' = Memory.write_bytes wbase wn mem
and we know that(rbase, rn) ⟂ (wbase, wn)
, then we simplify tomem.read (rbase, rn)
.mem' = Memory.write_bytes wbase wn wval mem
and we kow that(rbase, rn) ⊆ (wbase, wn)
, then we simplify towval.extract (rbase, rn) (wbase, wn)
.hr' : mem'.read_bytes rbase' rn' = rval
, and we know that(rbase, rn) ⊆ (rbase', rn')
, then we simplify torval.extract (rbase, rn) (rbase', rn')
.These simplifications are performed by reducing the problem to a problem that can be solved by a decision procedure (
omega
) to establishwhich hypotheses are at play.
simp_mem
can be controlled along multiple axes:simp_mem
will pass along to the decision procedure to discover overlapping reads (likehr'
),and hypotheses to establish memory (non-)interference, such as
(rbase, rn) ⟂ (wbase, wn)
.The kind of rewrite that simp_mem should apply. By default, it explores all possible choices, which might be expensive due to repeated calls to the decision
procedure. The user can describe which of (a), (b), (c) above happen:
simp_mem ⟂
: Only simplify when read is disjoint from write.simp_mem ⊂w
: Only simplify when read overlaps the write.simp_mem ⊂r hr
: Simplify when read overlaps with a known readhr : mem.read_bytes baseaddr' n' = val
.This is useful for static information such as lookup tables that are at a fixed location and never modified.
simp_mem ⊂r
: Simplify when read overlaps with known read from hypothesis list.The targets where the rewrite must be applied. (This needs some thought: does this even make sense?)
simp_mem at ⊢
simp_mem at h₁, h₂, ⊢
simp_mem using []
simp_mem ⟂/⊂w/⊂r hr/⊂r
Stacked on top of #237
@shilgoel the branch shows appreciable speedups, by controlling the lemmas we pass to mem_omega: In total, it goes from 34s to 13s
Batch mode use, measured by
lake build
:Individual breakdown during Interactive use, measured by #time
MemCpyVCG:
I feel that this, plus if we get the instantiateMVars fix, will help quite a bit with scaling 🙂
Testing:
What tests have been run? Did
make all
succeed for your changes? Wasconformance testing successful on an Aarch64 machine?
No semantics were changed, conformance succeeds.
License:
By submitting this pull request, I confirm that my contribution is
made under the terms of the Apache 2.0 license.