rocq/theories/ValidFast.v
The validator with its single definitions found through a name map, and the proof that it answers as Validate.v's valid does.
single_definitions asks, for each definition of a function, how many definitions share its name, and answers by walking the list of all of them: time that grows with the square of their number. Three functions of SQLite have 6,000 to 14,800 definitions, and that walk was 7 of the 18 seconds valid took on its module. single_definitions_fast counts every name once, in a name map, and then keeps the definitions whose name counts one.
valid stays the specification: the proofs of the reuse forms read single_definitions, and nothing in them changes. valid_fast is what an extracted program runs, and valid_fast_eq says the two are one function. The definitions from stage_sources_fast down to valid_fast repeat Validate.v's with the one name replaced; each equality is proved by unfolding both sides, so a change to one side that the other lacks stops the build here.
Counting definitions
How many of the definitions ds define the name n: the length single_definitions compares with one.
The map from each name the definitions ds define to how many of them define it, built in one pass over ds.
As single_definitions: the temporaries of the function f with exactly one definition, each with it, in the same order.
Counting the definitions ds into a map m adds, to what m held for the name n, the number of them that define n.
Explore proof 14 tactics
Initial goal
intros n ds
induction ds as | d ds IH ; intros m
2 openfocused goal
–simpl
2 opendeferred goal
destruct nm_findn m ; rewrite Nat.add_0_r | ; reflexivity
deferred goal
–cbn [ fold_left ]
rewrite IH , nm_find_add
unfold def_count
cbn [ filter ]
destruct name_eqbn fstd eqn: E
2 open+apply term_eqb_eq in E
2 opensubst n
2 opencbn [ length ]
2 opendestruct nm_findfstd m ; simpl ; f_equal ; lia
+reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The map of counts answers, for a name n, the number of definitions of n when there is one, and nothing otherwise.
Explore proof 4 tactics
Initial goal
intros n ds
unfold def_counts
rewrite def_counts_fold , nm_find_empty
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The single definitions found through the map are those single_definitions finds, as one list.
Explore proof 7 tactics
Initial goal
intros f
unfold single_definitions_fast , single_definitions
apply filter_ext
intros d
rewrite def_counts_find
fold def_countfstd all_defsf
destruct def_countfstd all_defsf as | c ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The validator over them
As stage_sources, with single_definitions_fast.
As stage_func, with stage_sources_fast.
As valid_func, with stage_func_fast.
As valid_items, with valid_func_fast.
As valid, with valid_items_fast: what an extracted program runs.
They are the validator
Explore proof 4 tactics
Initial goal
intros md f doms
unfold stage_sources_fast , stage_sources
rewrite single_definitions_fast_eq
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 4 tactics
Initial goal
intros md f doms
unfold stage_func_fast , stage_func
rewrite stage_sources_fast_eq
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
One function is judged alike.
Explore proof 6 tactics
Initial goal
intros md f
unfold valid_func_fast , valid_func
destruct fn_blocksf as | entry bs ; reflexivity |
destruct block_intervalsentry :: bs as doms | ; | reflexivity
rewrite stage_func_fast_eq
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 9 tactics
Initial goal
intros md
unfold valid_items_fast , valid_items
f_equal
assert H : ∀its, forallbλit ⇒ match it with IFuncf ⇒ valid_func_fastmd f IDatan lk al its ⇒ valid_datamd n lk al its IAliasn lk t ⇒ valid_aliasmd n lk t IOutside_ _ ⇒ true end its = forallbλit ⇒ match it with IFuncf ⇒ valid_funcmd f IDatan lk al its ⇒ valid_datamd n lk al its IAliasn lk t ⇒ valid_aliasmd n lk t IOutside_ _ ⇒ true end its
2 openfocused goal
{induction its as | it its IH ; reflexivity |
2 opendeferred goal
cbn [ forallb ]
2 opendeferred goal
rewrite IH
2 opendeferred goal
destruct it ; try rewrite valid_func_fast_eq ; reflexivity
deferred goal
apply H
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
valid_fast accepts, refuses and declines to judge exactly the modules valid does.
Explore proof 4 tactics
Initial goal
intros md
unfold valid_fast , valid
rewrite valid_items_fast_eq
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.