fix(library/equations_compiler/elim_match): whnf_pattern
This commit is contained in:
parent
b1e417805e
commit
d3298d518c
2 changed files with 25 additions and 0 deletions
|
|
@ -331,7 +331,15 @@ struct elim_match_fn {
|
|||
expr whnf_pattern(type_context & ctx, expr const & e) {
|
||||
if (is_inaccessible(e)) {
|
||||
return e;
|
||||
} else if (is_value(ctx, e)) {
|
||||
return e;
|
||||
} else {
|
||||
/* The case is_value(ctx, e) above is needed because whnf_head_pred does not check the given predicate
|
||||
before unfolding projections. Moreover, some values are projections applications.
|
||||
Example:
|
||||
(@has_zero.zero nat nat.has_zero)
|
||||
(@has_one.one nat nat.has_one)
|
||||
*/
|
||||
return ctx.whnf_head_pred(e, [&](expr const & e) {
|
||||
return !is_constructor_app(ctx, e) && !is_value(ctx, e) && !is_transport_app(e);
|
||||
});
|
||||
|
|
|
|||
17
tests/lean/run/eqn_value_issue.lean
Normal file
17
tests/lean/run/eqn_value_issue.lean
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
def f : nat -> nat
|
||||
| 1 := 1
|
||||
| 2000 := 2
|
||||
| _ := 3
|
||||
|
||||
#check f.equations._eqn_1
|
||||
#check f.equations._eqn_2
|
||||
#check f.equations._eqn_3
|
||||
|
||||
def g : nat -> nat
|
||||
| 0 := 1
|
||||
| 2000 := 2
|
||||
| _ := 3
|
||||
|
||||
#check g.equations._eqn_1
|
||||
#check g.equations._eqn_2
|
||||
#check g.equations._eqn_3
|
||||
Loading…
Add table
Reference in a new issue