Add named and local simplify hint databases#954
Conversation
|
Partially answers #918 by wrapping exponent simplification lemmas. |
3ae8c0e to
38c60c2
Compare
Introduce named simplify databases, proof-local control over the active
DBs and lemmas, head-symbol filtering, and proof-local defaults for the
`simplify`/`cbv` simplification machinery.
Global declarations:
hint simplify {lemma}+ . (* default database *)
hint simplify in {db} : {lemma}+ . (* named database *)
Selecting a database and filtering by head symbol on simplify/cbv:
simplify hint {db} (* use named database *)
cbv hint {db}
simplify with {sym}+ (* only rules headed by sym *)
simplify with - {sym}+ (* all rules except those *)
simplify with {sym}+ hint {db} (* filter + named database *)
Proof-local modifications of the active configuration:
hint +db simplify {db}+ . (* activate named DBs *)
hint -db simplify {db}+ . (* deactivate named DBs *)
hint +simplify [in {db}] {lemma}+ . (* add lemmas locally *)
hint -simplify [in {db}] {lemma}+ . (* remove lemmas locally *)
hint clear simplify [in {db}] . (* clear local add/remove *)
Proof-local defaults consulted by later bare simplify/cbv calls:
hint simplify hint {db} . (* default database *)
hint simplify with [-] {sym}+ . (* default head filter *)
hint simplify clear . (* clear local defaults *)
Scoped application around a tactic, restored on the resulting subgoals:
with hint {command} ( {tactic} ) .
Thread the local simplify context through proof goals so the active DB
set, lemma overrides, default database, and head filter propagate across
subgoals and are consulted by `simplify` and `cbv`. Update simplify-hint
printing and reduction storage to support named databases and head
filtering.
Document all syntax forms in doc/tactics/hint-simplify.rst and add
regression tests (tests/hint_simplify_db.ec, tests/local_hint_simplify.ec,
tests/simplify_head_filter.ec).
bgregoir
left a comment
There was a problem hiding this comment.
General comment:
I think the syntax is a little bit to verbose.
More importantly, if I have well understood only one database can be selected. I don't understand this restriction.
| | EcTheory.Th_reduction { red_base; _ } -> | ||
| (* FIXME: section we should add the lemma in the reduction *) | ||
| Format.fprintf fmt "hint simplify." | ||
| begin match red_base with |
There was a problem hiding this comment.
I think the printing info is partial here. Lemmas added or removed from the database are not printed
|
|
||
| | EcTheory.Th_reduction _ -> | ||
| | EcTheory.Th_reduction { red_base; _ } -> | ||
| (* FIXME: section we should add the lemma in the reduction *) |
There was a problem hiding this comment.
Maybe this comment explain what should be done
| val get : topsym -> env -> rule list | ||
| type base = symbol | ||
|
|
||
| val dname : symbol |
There was a problem hiding this comment.
dname is for "default name" ?
| val add1 : path * rule_option * rule option -> env -> env | ||
| val add : ?import:bool -> (path * rule_option * rule option) list -> env -> env | ||
| val get : topsym -> env -> rule list | ||
| type base = symbol |
There was a problem hiding this comment.
Why a database name is a symbol and not a path?
I don't claim that it should be, just asking the question.
|
|
||
| (* Name of the default simplify database. Must agree with | ||
| [EcEnv.Reduction.dname]. *) | ||
| let dname : symbol = "" |
There was a problem hiding this comment.
Why dname is defined here and also in ecEnv
| (* -------------------------------------------------------------------- *) | ||
| let normbase (base : symbol option) : symbol = | ||
| match base with | ||
| | Some "default" | None -> dname |
There was a problem hiding this comment.
Why do we have Some "default" ? I think either option should be remove or "default" should
| (* -------------------------------------------------------------------- *) | ||
| type simplify_context = { | ||
| ls_active : Ssym.t; | ||
| ls_default_db : symbol option option; |
There was a problem hiding this comment.
Some comment will be welcome on the meaning of symbol option option...
| : simplify_context | ||
| = | ||
| let hd = hd |> omap (fun (mode, paths) -> | ||
| let paths = List.fold_left (fun acc p -> Sp.add p acc) Sp.empty paths in |
There was a problem hiding this comment.
There is no Sp.of_list function ?
| logic : rlogic_info; (* perform logical simplification *) | ||
| modpath : bool; (* reduce module path *) | ||
| user : bool; (* reduce user defined rules *) | ||
| user_db : EcSymbols.symbol option; (* user reduction database *) |
There was a problem hiding this comment.
Does it means that only one user reduction database can be added?
| box (wrap_default x) = box (x + 1). | ||
| proof. | ||
| hint -db simplify default. | ||
| simplify. |
There was a problem hiding this comment.
Should make sure it is disabling, maybe add "fail trivial" after first simplify?
| proof. | ||
| hint +simplify wrap_localE. | ||
| hint -simplify wrap_localE. | ||
| simplify. |
There was a problem hiding this comment.
Same as above, should make sure that simplify is failing
| trivial. | ||
| qed. | ||
|
|
||
| lemma cbv_named_with_exclude (x : int) : |
There was a problem hiding this comment.
Does this actually test whether wrap1 hint is excluded?
Several databases should be selectable. I'll check and fix if needed. For the syntax, I agree. If you have a better proposition, I take it. |
Introduce named simplify databases, proof-local control over the active
DBs and lemmas, head-symbol filtering, and proof-local defaults for the
simplify/cbvsimplification machinery.Global declarations:
Selecting a database and filtering by head symbol on simplify/cbv:
Proof-local modifications of the active configuration:
Proof-local defaults consulted by later bare simplify/cbv calls:
Scoped application around a tactic, restored on the resulting subgoals:
Thread the local simplify context through proof goals so the active DB
set, lemma overrides, default database, and head filter propagate across
subgoals and are consulted by
simplifyandcbv. Update simplify-hintprinting and reduction storage to support named databases and head
filtering.
Document all syntax forms in doc/tactics/hint-simplify.rst and add
regression tests (tests/hint_simplify_db.ec, tests/local_hint_simplify.ec,
tests/simplify_head_filter.ec).