fix(library/elaborator): tag meta_app constraints of the form 'ctx |- m?[inst:i v] t1 =:= t2' as expensive

This commits also adds a new unit test that demonstrates non-termination due to this kind of constraint.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-12-16 09:38:57 -08:00
parent 2972fb9d8c
commit 8f9405c8b3
3 changed files with 48 additions and 1 deletions

View file

@ -879,9 +879,12 @@ class elaborator::imp {
We perform a "case split" using "projection" or "imitation". See Huet&Lang's paper on higher order matching
for further details.
*/
bool process_meta_app(expr const & a, expr const & b, bool is_lhs, unification_constraint const & c, bool flex_flex = false) {
bool process_meta_app(expr const & a, expr const & b, bool is_lhs, unification_constraint const & c,
bool flex_flex = false, bool local_ctx = false) {
if (!is_meta_app(a))
return false;
if (!local_ctx && has_local_context(arg(a, 0)))
return false;
if (!flex_flex) {
if (is_meta_app(b))
return false;
@ -1498,6 +1501,8 @@ class elaborator::imp {
process_metavar_inst(b, a, false, c) ||
process_metavar_lift_abstraction(a, b, c) ||
process_metavar_lift_abstraction(b, a, c) ||
process_meta_app(a, b, true, c, false, true) ||
process_meta_app(b, a, false, c, false, true) ||
process_meta_app(a, b, true, c, true)) {
return true;
}

17
tests/lean/exists2.lean Normal file
View file

@ -0,0 +1,17 @@
Variable a : Int
Variable P : Int -> Int -> Bool
Variable f : Int -> Int -> Int
Variable g : Int -> Int
Axiom H1 : P (f a (g a)) (f a (g a))
Axiom H2 : P (f (g a) (g a)) (f (g a) (g a))
Axiom H3 : P (f (g a) (g a)) (g a)
Theorem T1 : exists x y : Int, P (f y x) (f y x) := ExistsIntro _ (ExistsIntro _ H1)
Theorem T2 : exists x : Int, P (f x (g x)) (f x (g x)) := ExistsIntro _ H1
Theorem T3 : exists x : Int, P (f x x) (f x x) := ExistsIntro _ H2
Theorem T4 : exists x : Int, P (f (g a) x) (f x x) := ExistsIntro _ H2
Theorem T5 : exists x : Int, P x x := ExistsIntro _ H2
Theorem T6 : exists x y : Int, P x y := ExistsIntro _ (ExistsIntro _ H3)
Theorem T7 : exists x : Int, P (f x x) x := ExistsIntro _ H3
Theorem T8 : exists x y : Int, P (f x x) y := ExistsIntro _ (ExistsIntro _ H3)
Show Environment 8.

View file

@ -0,0 +1,25 @@
Set: pp::colors
Set: pp::unicode
Assumed: a
Assumed: P
Assumed: f
Assumed: g
Assumed: H1
Assumed: H2
Assumed: H3
Proved: T1
Proved: T2
Proved: T3
Proved: T4
Proved: T5
Proved: T6
Proved: T7
Proved: T8
Theorem T1 : ∃ x y : , P (f y x) (f y x) := ExistsIntro (g a) (ExistsIntro a H1)
Theorem T2 : ∃ x : , P (f x (g x)) (f x (g x)) := ExistsIntro a H1
Theorem T3 : ∃ x : , P (f x x) (f x x) := ExistsIntro (g a) H2
Theorem T4 : ∃ x : , P (f (g a) x) (f x x) := ExistsIntro (g a) H2
Theorem T5 : ∃ x : , P x x := ExistsIntro (f (g a) (g a)) H2
Theorem T6 : ∃ x y : , P x y := ExistsIntro (f (g a) (g a)) (ExistsIntro (g a) H3)
Theorem T7 : ∃ x : , P (f x x) x := ExistsIntro (g a) H3
Theorem T8 : ∃ x y : , P (f x x) y := ExistsIntro (g a) (ExistsIntro (g a) H3)