feat(frontends/lean): make the 'expression template' argument in Subst implicit because higher-order matching can infer it.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
bc92671ae4
commit
032f5cd7b3
7 changed files with 33 additions and 5 deletions
|
@ -11,6 +11,11 @@ Author: Leonardo de Moura
|
|||
#include "frontends/lean/frontend.h"
|
||||
|
||||
namespace lean {
|
||||
void add_alias(frontend & f, name const & n, name const & m) {
|
||||
object const & obj = f.get_object(n);
|
||||
f.add_definition(m, obj.get_type(), mk_constant(n));
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Initialize builtin notation.
|
||||
*/
|
||||
|
@ -80,7 +85,9 @@ void init_builtin_notation(frontend & f) {
|
|||
f.mark_implicit_arguments(mk_mp_fn(), {true, true, false, false});
|
||||
f.mark_implicit_arguments(mk_discharge_fn(), {true, true, false});
|
||||
f.mark_implicit_arguments(mk_refl_fn(), {true, false});
|
||||
f.mark_implicit_arguments(mk_subst_fn(), {true, true, true, false, false, false});
|
||||
f.mark_implicit_arguments(mk_subst_fn(), {true, true, true, true, false, false});
|
||||
add_alias(f, "Subst", "SubstP");
|
||||
f.mark_implicit_arguments("SubstP", {true, true, true, false, false, false});
|
||||
f.mark_implicit_arguments(mk_trans_ext_fn(), {true, true, true, true, true, true, false, false});
|
||||
f.mark_implicit_arguments(mk_eta_fn(), {true, true, false});
|
||||
f.mark_implicit_arguments(mk_imp_antisym_fn(), {true, true, false, false});
|
||||
|
|
|
@ -3,5 +3,5 @@ Variable a : Int
|
|||
Variable b : Int
|
||||
Axiom H1 : a = b
|
||||
Axiom H2 : (g a) > 0
|
||||
Theorem T1 : (g b) > 0 := Subst (λ x, (g x) > 0) H2 H1
|
||||
Theorem T1 : (g b) > 0 := SubstP (λ x, (g x) > 0) H2 H1
|
||||
Show Environment 2
|
||||
|
|
|
@ -7,4 +7,4 @@
|
|||
Assumed: H2
|
||||
Proved: T1
|
||||
Axiom H2 : (g a) > 0
|
||||
Theorem T1 : (g b) > 0 := Subst (λ x : ℤ, (g x) > 0) H2 H1
|
||||
Theorem T1 : (g b) > 0 := SubstP (λ x : ℤ, (g x) > 0) H2 H1
|
||||
|
|
|
@ -3,5 +3,5 @@ Variable a : Int
|
|||
Variable b : Int
|
||||
Axiom H1 : a = b
|
||||
Axiom H2 : (g a) > 0
|
||||
Theorem T1 : (g b) > 0 := Subst _ H2 H1
|
||||
Theorem T1 : (g b) > 0 := Subst H2 H1
|
||||
Show Environment 2
|
||||
|
|
|
@ -7,4 +7,4 @@
|
|||
Assumed: H2
|
||||
Proved: T1
|
||||
Axiom H2 : (g a) > 0
|
||||
Theorem T1 : (g b) > 0 := Subst (λ x : ℤ, if ((g x) ≤ 0) ⊥ ⊤) H2 H1
|
||||
Theorem T1 : (g b) > 0 := Subst H2 H1
|
||||
|
|
9
tests/lean/subst.lean
Normal file
9
tests/lean/subst.lean
Normal file
|
@ -0,0 +1,9 @@
|
|||
Variable a : Int
|
||||
Variable n : Nat
|
||||
Axiom H1 : a + a + a = 10
|
||||
Axiom H2 : a = n
|
||||
Theorem T : a + n + a = 10 := Subst H1 H2
|
||||
Set pp::coercion true
|
||||
Set pp::notation false
|
||||
Set pp::implicit true
|
||||
Show Environment 1.
|
12
tests/lean/subst.lean.expected.out
Normal file
12
tests/lean/subst.lean.expected.out
Normal file
|
@ -0,0 +1,12 @@
|
|||
Set: pp::colors
|
||||
Set: pp::unicode
|
||||
Assumed: a
|
||||
Assumed: n
|
||||
Assumed: H1
|
||||
Assumed: H2
|
||||
Proved: T
|
||||
Set: lean::pp::coercion
|
||||
Set: lean::pp::notation
|
||||
Set: lean::pp::implicit
|
||||
Theorem T : eq::explicit ℤ (Int::add (Int::add a (nat_to_int n)) a) (nat_to_int 10) :=
|
||||
Subst::explicit ℤ a (nat_to_int n) (λ x : ℤ, Int::add (Int::add a x) a == 10) H1 H2
|
Loading…
Reference in a new issue