-
Notifications
You must be signed in to change notification settings - Fork 225
Simplifier Features
Here we list some suggestions / possible features for Lean's simplifier.
-
Add pre- and/or post-processing methods to the simpset (called
simprocin Isabelle). The idea is to install methods which are called when the current term matches certain patterns (see the section about Isabelle's simplifier for applications) -
Support the
auto_paramin the simplifier. Applications: (1) solve assumption in conditional rewrite rules, and (2) synthesize parts of the right-hand side. -
Preprocess hypothesis (either provided by the user, or by congruence rules) Isabelle's simplifier rewrites hypothesis and then adds them to the simpset. For congruence rules there is a special implication
H =simp=> Gwhich forces the simplifier to rewriteHbefore adding it to the context. -
Isabelle has the marker
ASSUMPTION(p): it forces the simplifier to solve a condition of a simp-rule to be solved by an assumption and not be touched by rewriting. I guess in Lean this would be done by anauto_param:(H : p . assumption). -
Often users want to enforce the application of a conditional rule: if the simplifier cannot solve the conditions it should be added as new goals to the interactive state. This would require quite some additions to the state in which the pre- and post-processing methods work: they need to return informations (new mvars are introduced), and the methods might also get some information (maybe an enforced rule should be only applied once)
Simprocs in Isabelle's simplifer are activated when the current term matches certain pattern. But the pattern can be very generic ?x : ?t.
The simplifier is also parameterized by loopers and solvers, they are not explaind here.
-
NO_MATCH(x, t)Fails if the patternxmatchest. OtherwiseNO_MATCHis definitionally true. Allows more control over the simplifcation process. For example it can be used to always rewritet : unitto(). -
Diverse cancellation procedures. Try to cancel common terms from (in)equalities. For example when a term
a * b >= c * bis reached it is tried to derive0 <= bfrom the assumptions and simplified toa >= c. -
Fast linear arithmetic
-
supandinfcancellation. Example: Reducesup a (sup b (-a))totop. -
Collect_mem: simplify{(x1, ..., xn) | (x1, ..., xn) \in S}toS -
Let_simp: reducelet x := t in t'under cetrain conditions: eithertis small (variable or constant) orxappears only once int' -
list_eq/list_neq: cancel common terms at start or end of both sides of an equation -
unit_eq: Rewritet : unitto()(could be done now myNO_MATCH) -
prove
(y = x) = falsefrom~ (y = x) -
recordevaluation / updates normalization. I guess this is done by Lean's elaborator / kernel -
Remove equality from quantifiers. Example:
forall x, p x --> x = t --> q xreduces top t --> q t
-
Setup by the datatype package
case_*(in Leantype.case_on): provide the simplifier with additional assumption about the new variables in each case. For examplematch xs with [] := t | (x :: xs') := t' end, by congruence we getxs = [] -> t = ?tandforall x xs', xs = x :: xs' -> t' x xs' = ?t x xs'. -
=simp=>: One often wants to rewrite the additional hypothesis introduced by introduction rules this is done by
=simp=>:(forall x, x \in s =simp=> p x) --> (forall x \in s, p x). Here=simp=>allows thatx \in scan be rewritten -
Expected rules for:
-->,if _ then _ else, bounded all, and bounded ex
Split up if and case (i.e. match) statements. The splitter is parameterized by rules like
C (if p then a else b) <-> (p -> C a) /\ (~ p -> C b).
Then it will replace an occurrences of if _ then _ else _ by its logical representation. The hope is that with the additional hypothesis C can be rewritten in both cases, and that C a and C b can be further reduced.
This is not restricted to constructs like if, another possible rule is
C (a - b) <-> (a <= b --> C 0) /\ (forall c > 0, b = a + c --> C c)
where a and b are natural numbers.