feat(frontends/lean): relax compatible_denotation predicate

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-12-10 12:42:29 -08:00
parent abe2cf2fb5
commit 90f88acf42
5 changed files with 38 additions and 2 deletions

View file

@ -170,10 +170,15 @@ struct lean_extension : public environment::extension {
f : Pi {A : Type} (a : A) {B : Type} (b : B), A Pattern _ * _ *
g : Pi {A B : Type} (a : A) (b : B), A Pattern _ _ * *
TODO(Leo): not implemented yet
Remark: we remove the explicit suffix at mark_implicit_arguments.
*/
bool compatible_denotation(expr const & d1, expr const & d2) {
return get_implicit_arguments(d1) == get_implicit_arguments(d2);
auto imp1 = get_implicit_arguments(d1);
auto imp2 = get_implicit_arguments(d2);
auto it1 = std::find(imp1.begin(), imp1.end(), false);
auto it2 = std::find(imp2.begin(), imp2.end(), false);
for (; it1 != imp1.end() && it2 != imp2.end() && *it1 == *it2; ++it1, ++it2) {}
return it1 == imp1.end() && it2 == imp2.end();
}
/**

View file

@ -0,0 +1,8 @@
Variable f {A : Type} (a1 a2 : A) {B : Type} (b1 b2 : B) : A
Variable g {A1 A2 : Type} (a1 : A1) (a2 : A2) {B : Type} (b : B) : A1
Variable p (a1 a2 : Int) {B : Type} (b1 b2 b3 : B) : B
Variable h {A1 A2 : Type} (a1 : A1) (a2 : A2) (a3 : A2) : A1
Infix ++ : f
Infix ++ : g
Infix ++ : p
Infix ++ : h

View file

@ -0,0 +1,6 @@
Set: pp::colors
Set: pp::unicode
Assumed: f
Assumed: g
Assumed: p
Assumed: h

10
tests/lean/implicit5.lean Normal file
View file

@ -0,0 +1,10 @@
Variable f {A : Type} (a1 a2 : A) : A
Variable g : Int -> Int -> Int
Variable h : Int -> Int -> Real -> Int
Variable p {A B : Type} (a1 a2 : A) (b : B) : A
Infix ++ : f
Infix ++ : g
Infix ++ : h
Infix ++ : p
Variable p2 {A B : Type} (a1 a2 : A) (b : B) {C : Type} (c : C) : A
Infix ++ : p2

View file

@ -0,0 +1,7 @@
Set: pp::colors
Set: pp::unicode
Assumed: f
Assumed: g
Assumed: h
Assumed: p
Assumed: p2