feat(frontends/lean/parser): combine Echo and Show commands into the 'print' command

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-01-05 11:03:35 -08:00
parent ce1213a020
commit 9f08156a73
104 changed files with 306 additions and 316 deletions

View file

@ -59,13 +59,13 @@ Theorem OddPlusOne {a : Nat} (H : odd a) : even (a + 1)
-- The following command displays the proof object produced by Lean after -- The following command displays the proof object produced by Lean after
-- expanding macros, and infering implicit/missing arguments. -- expanding macros, and infering implicit/missing arguments.
Show Environment 2. print Environment 2.
-- By default, Lean does not display implicit arguments. -- By default, Lean does not display implicit arguments.
-- The following command will force it to display them. -- The following command will force it to display them.
SetOption pp::implicit true. SetOption pp::implicit true.
Show Environment 2. print Environment 2.
-- As an exercise, prove that the sum of two odd numbers is even, -- As an exercise, prove that the sum of two odd numbers is even,
-- and other similar theorems. -- and other similar theorems.

View file

@ -27,9 +27,9 @@ Theorem T2 : (h a (h a b)) = (h a (h c e)) :=
CongrH (Refl a) T1 CongrH (Refl a) T1
-- Display the last two objects (i.e., theorems) added to the environment -- Display the last two objects (i.e., theorems) added to the environment
Show Environment 2 print Environment 2
-- Show implicit arguments -- print implicit arguments
SetOption lean::pp::implicit true SetOption lean::pp::implicit true
SetOption pp::width 150 SetOption pp::width 150
Show Environment 2 print Environment 2

View file

@ -8,7 +8,7 @@ Theorem simple (p q r : Bool) : (p ⇒ q) ∧ (q ⇒ r) ⇒ p ⇒ r
in MP P_qr P_q. in MP P_qr P_q.
SetOption pp::implicit true. SetOption pp::implicit true.
Show Environment 1. print Environment 1.
Theorem simple2 (a b c : Bool) : (a ⇒ b ⇒ c) ⇒ (a ⇒ b) ⇒ a ⇒ c Theorem simple2 (a b c : Bool) : (a ⇒ b ⇒ c) ⇒ (a ⇒ b) ⇒ a ⇒ c
:= Assume H_abc H_ab H_a, := Assume H_abc H_ab H_a,
@ -16,4 +16,4 @@ Theorem simple2 (a b c : Bool) : (a ⇒ b ⇒ c) ⇒ (a ⇒ b) ⇒ a ⇒ c
P_bc := (MP H_abc H_a) P_bc := (MP H_abc H_a)
in MP P_bc P_b. in MP P_bc P_b.
Show Environment 1. print Environment 1.

View file

@ -25,4 +25,4 @@ Theorem pierce (a b : Bool) : ((a ⇒ b) ⇒ a) ⇒ a
(λ H_a, H_a) (λ H_a, H_a)
(λ H_na, NotImp1 (MT H H_na)). (λ H_na, NotImp1 (MT H H_na)).
Show Environment 3. print Environment 3.

View file

@ -45,7 +45,7 @@ Push
let L1 : R w x := Symmetry ! x ! w << H let L1 : R w x := Symmetry ! x ! w << H
in Transitivity ! x ! w ! x << H << L1)) in Transitivity ! x ! w ! x << H << L1))
Show Environment 1 print Environment 1
Pop Pop
Scope Scope
@ -70,4 +70,4 @@ Scope
EndScope EndScope
-- Display the last two theorems -- Display the last two theorems
Show Environment 2 print Environment 2

View file

@ -24,7 +24,7 @@ Theorem T1 (A B : Bool) : A /\ B -> B /\ A :=
lemma2 : B := (by auto) lemma2 : B := (by auto)
in (show B /\ A by auto) in (show B /\ A by auto)
Show Environment 1. -- Show proof for the previous theorem print Environment 1. -- print proof for the previous theorem
-- When hints are not provided, the user must fill the (remaining) holes using tactic command sequences. -- When hints are not provided, the user must fill the (remaining) holes using tactic command sequences.
-- Each hole must be filled with a tactic command sequence that terminates with the command 'done' and -- Each hole must be filled with a tactic command sequence that terminates with the command 'done' and

View file

@ -68,5 +68,5 @@ Theorem T (a b : Bool) : a => b => a /\ b := _.
(* Then(Repeat(OrElse(imp_tac(), conj_in_lua)), assumption_tac()) *) (* Then(Repeat(OrElse(imp_tac(), conj_in_lua)), assumption_tac()) *)
done done
-- Show proof created using our script -- print proof created using our script
Show Environment 1. print Environment 1.

View file

@ -32,21 +32,20 @@ static name g_theorem_kwd("Theorem");
static name g_axiom_kwd("Axiom"); static name g_axiom_kwd("Axiom");
static name g_universe_kwd("Universe"); static name g_universe_kwd("Universe");
static name g_eval_kwd("Eval"); static name g_eval_kwd("Eval");
static name g_show_kwd("Show");
static name g_check_kwd("Check"); static name g_check_kwd("Check");
static name g_infix_kwd("Infix"); static name g_infix_kwd("Infix");
static name g_infixl_kwd("Infixl"); static name g_infixl_kwd("Infixl");
static name g_infixr_kwd("Infixr"); static name g_infixr_kwd("Infixr");
static name g_notation_kwd("Notation"); static name g_notation_kwd("Notation");
static name g_echo_kwd("Echo");
static name g_set_option_kwd("SetOption"); static name g_set_option_kwd("SetOption");
static name g_set_opaque_kwd("SetOpaque"); static name g_set_opaque_kwd("SetOpaque");
static name g_options_kwd("Options"); static name g_options_kwd("Options");
static name g_env_kwd("Environment"); static name g_env_kwd("Environment");
static name g_import_kwd("Import"); static name g_import_kwd("Import");
static name g_help_kwd("Help"); static name g_help_kwd("help");
static name g_coercion_kwd("Coercion"); static name g_coercion_kwd("Coercion");
static name g_exit_kwd("Exit"); static name g_exit_kwd("Exit");
static name g_print_kwd("print");
static name g_push_kwd("Push"); static name g_push_kwd("Push");
static name g_pop_kwd("Pop"); static name g_pop_kwd("Pop");
static name g_scope_kwd("Scope"); static name g_scope_kwd("Scope");
@ -56,9 +55,9 @@ static name g_namespace_kwd("Namespace");
static name g_end_namespace_kwd("EndNamespace"); static name g_end_namespace_kwd("EndNamespace");
/** \brief Table/List with all builtin command keywords */ /** \brief Table/List with all builtin command keywords */
static list<name> g_command_keywords = {g_definition_kwd, g_variable_kwd, g_variables_kwd, g_theorem_kwd, g_axiom_kwd, g_universe_kwd, g_eval_kwd, static list<name> g_command_keywords = {g_definition_kwd, g_variable_kwd, g_variables_kwd, g_theorem_kwd, g_axiom_kwd, g_universe_kwd, g_eval_kwd,
g_show_kwd, g_check_kwd, g_infix_kwd, g_infixl_kwd, g_infixr_kwd, g_notation_kwd, g_echo_kwd, g_check_kwd, g_infix_kwd, g_infixl_kwd, g_infixr_kwd, g_notation_kwd,
g_set_option_kwd, g_set_opaque_kwd, g_env_kwd, g_options_kwd, g_import_kwd, g_help_kwd, g_coercion_kwd, g_set_option_kwd, g_set_opaque_kwd, g_env_kwd, g_options_kwd, g_import_kwd, g_help_kwd, g_coercion_kwd,
g_exit_kwd, g_push_kwd, g_pop_kwd, g_scope_kwd, g_end_scope_kwd, g_alias_kwd, g_builtin_kwd, g_exit_kwd, g_print_kwd, g_push_kwd, g_pop_kwd, g_scope_kwd, g_end_scope_kwd, g_alias_kwd, g_builtin_kwd,
g_namespace_kwd, g_end_namespace_kwd}; g_namespace_kwd, g_end_namespace_kwd};
// ========================================== // ==========================================
@ -278,12 +277,13 @@ bool parser_imp::is_hidden_object(object const & obj) const {
} }
/** \brief Parse /** \brief Parse
'Show' expr 'print' expr
'Show' Environment [num] 'print' Environment [num]
'Show' Environment all 'print' Environment all
'Show' Options 'print' Options
'print' [string]
*/ */
void parser_imp::parse_show() { void parser_imp::parse_print() {
next(); next();
if (curr() == scanner::token::CommandId) { if (curr() == scanner::token::CommandId) {
name opt_id = curr_name(); name opt_id = curr_name();
@ -337,6 +337,10 @@ void parser_imp::parse_show() {
} else { } else {
throw parser_error("invalid Show command, expression, 'Options' or 'Environment' expected", m_last_cmd_pos); throw parser_error("invalid Show command, expression, 'Options' or 'Environment' expected", m_last_cmd_pos);
} }
} else if (curr() == scanner::token::StringVal) {
std::string msg = curr_string();
next();
regular(m_io_state) << msg << endl;
} else { } else {
expr v = m_elaborator(parse_expr()).first; expr v = m_elaborator(parse_expr()).first;
regular(m_io_state) << v << endl; regular(m_io_state) << v << endl;
@ -469,13 +473,6 @@ void parser_imp::parse_notation_decl() {
} }
} }
/** Parse 'Echo' [string] */
void parser_imp::parse_echo() {
next();
std::string msg = check_string_next("invalid echo command, string expected");
regular(m_io_state) << msg << endl;
}
/** Parse 'SetOption' [id] [value] */ /** Parse 'SetOption' [id] [value] */
void parser_imp::parse_set_option() { void parser_imp::parse_set_option() {
next(); next();
@ -615,12 +612,13 @@ void parser_imp::parse_help() {
<< " Import [string] load the given file" << endl << " Import [string] load the given file" << endl
<< " Push create a scope (it is just an alias for the command Scope)" << endl << " Push create a scope (it is just an alias for the command Scope)" << endl
<< " Pop discard the current scope" << endl << " Pop discard the current scope" << endl
<< " print [expr] pretty print the given expression" << endl
<< " print Options print current the set of assigned options" << endl
<< " print [string] print the given string" << endl
<< " print Environment print objects in the environment, if [Num] provided, then show only the last [Num] objects" << endl
<< " print Environment [num] show the last num objects in the environment" << endl
<< " Scope create a scope" << endl << " Scope create a scope" << endl
<< " SetOption [id] [value] set option [id] with value [value]" << endl << " SetOption [id] [value] set option [id] with value [value]" << endl
<< " Show [expr] pretty print the given expression" << endl
<< " Show Options show current the set of assigned options" << endl
<< " Show Environment show objects in the environment, if [Num] provided, then show only the last [Num] objects" << endl
<< " Show Environment [num] show the last num objects in the environment" << endl
<< " Theorem [id] : [type] := [expr] define a new theorem" << endl << " Theorem [id] : [type] := [expr] define a new theorem" << endl
<< " Variable [id] : [type] declare/postulate an element of the given type" << endl << " Variable [id] : [type] declare/postulate an element of the given type" << endl
<< " Universe [id] [level] declare a new universe variable that is >= the given level" << endl; << " Universe [id] [level] declare a new universe variable that is >= the given level" << endl;
@ -766,8 +764,8 @@ bool parser_imp::parse_command() {
parse_axiom(); parse_axiom();
} else if (cmd_id == g_eval_kwd) { } else if (cmd_id == g_eval_kwd) {
parse_eval(); parse_eval();
} else if (cmd_id == g_show_kwd) { } else if (cmd_id == g_print_kwd) {
parse_show(); parse_print();
} else if (cmd_id == g_check_kwd) { } else if (cmd_id == g_check_kwd) {
parse_check(); parse_check();
} else if (cmd_id == g_infix_kwd) { } else if (cmd_id == g_infix_kwd) {
@ -778,8 +776,6 @@ bool parser_imp::parse_command() {
parse_op(fixity::Infixr); parse_op(fixity::Infixr);
} else if (cmd_id == g_notation_kwd) { } else if (cmd_id == g_notation_kwd) {
parse_notation_decl(); parse_notation_decl();
} else if (cmd_id == g_echo_kwd) {
parse_echo();
} else if (cmd_id == g_set_option_kwd) { } else if (cmd_id == g_set_option_kwd) {
parse_set_option(); parse_set_option();
} else if (cmd_id == g_set_opaque_kwd) { } else if (cmd_id == g_set_opaque_kwd) {

View file

@ -394,13 +394,12 @@ private:
void parse_axiom(); void parse_axiom();
void parse_eval(); void parse_eval();
bool is_hidden_object(object const & obj) const; bool is_hidden_object(object const & obj) const;
void parse_show(); void parse_print();
void parse_check(); void parse_check();
unsigned parse_precedence(); unsigned parse_precedence();
name parse_op_id(); name parse_op_id();
void parse_op(fixity fx); void parse_op(fixity fx);
void parse_notation_decl(); void parse_notation_decl();
void parse_echo();
void parse_set_option(); void parse_set_option();
void parse_set_opaque(); void parse_set_opaque();
optional<std::string> find_lua_file(std::string const & fname); optional<std::string> find_lua_file(std::string const & fname);

View file

@ -46,10 +46,10 @@ static void tst1() {
environment env; io_state ios = init_test_frontend(env); environment env; io_state ios = init_test_frontend(env);
parse(env, ios, "Variable x : Bool Variable y : Bool Axiom H : x && y || x => x"); parse(env, ios, "Variable x : Bool Variable y : Bool Axiom H : x && y || x => x");
parse(env, ios, "Eval true && true"); parse(env, ios, "Eval true && true");
parse(env, ios, "Show true && false Eval true && false"); parse(env, ios, "print true && false Eval true && false");
parse(env, ios, "Infixl 35 & : and Show true & false & false Eval true & false"); parse(env, ios, "Infixl 35 & : and print true & false & false Eval true & false");
parse(env, ios, "Notation 100 if _ then _ fi : implies Show if true then false fi"); parse(env, ios, "Notation 100 if _ then _ fi : implies print if true then false fi");
parse(env, ios, "Show Pi (A : Type), A -> A"); parse(env, ios, "print Pi (A : Type), A -> A");
parse(env, ios, "Check Pi (A : Type), A -> A"); parse(env, ios, "Check Pi (A : Type), A -> A");
} }
@ -82,9 +82,9 @@ static void tst2() {
static void tst3() { static void tst3() {
environment env; io_state ios = init_test_frontend(env); environment env; io_state ios = init_test_frontend(env);
parse(env, ios, "Help"); parse(env, ios, "help");
parse(env, ios, "Help Options"); parse(env, ios, "help Options");
parse_error(env, ios, "Help Echo"); parse_error(env, ios, "help print");
check(env, ios, "10.3", mk_real_value(mpq(103, 10))); check(env, ios, "10.3", mk_real_value(mpq(103, 10)));
parse(env, ios, "Variable f : Real -> Real. Check f 10.3."); parse(env, ios, "Variable f : Real -> Real. Check f 10.3.");
parse(env, ios, "Variable g : (Type 1) -> Type. Check g Type"); parse(env, ios, "Variable g : (Type 1) -> Type. Check g Type");

View file

@ -1,3 +1,3 @@
Alias BB : Bool. Alias BB : Bool.
Variable x : BB. Variable x : BB.
Show Environment 1. print Environment 1.

View file

@ -2,15 +2,15 @@ Push
Variable Natural : Type. Variable Natural : Type.
Alias : Natural. Alias : Natural.
Variable x : Natural. Variable x : Natural.
Show Environment 1. print Environment 1.
SetOption pp::unicode false. SetOption pp::unicode false.
Show Environment 1. print Environment 1.
SetOption pp::unicode true. SetOption pp::unicode true.
Show Environment 1. print Environment 1.
Alias NN : Natural. Alias NN : Natural.
Show Environment 2. print Environment 2.
Alias : Natural. Alias : Natural.
Show Environment 3. print Environment 3.
SetOption pp::unicode false. SetOption pp::unicode false.
Show Environment 3. print Environment 3.
Pop Pop

View file

@ -22,4 +22,4 @@ Theorem T3 (a : Int) : (P a a) => (f a a).
Repeat (OrElse (apply Discharge) exact (apply Ax2) (apply Ax1)). Repeat (OrElse (apply Discharge) exact (apply Ax2) (apply Ax1)).
done. done.
Show Environment 2. print Environment 2.

View file

@ -8,11 +8,11 @@ Check 15 + 10 - 20
Variable x : Int Variable x : Int
Variable n : Nat Variable n : Nat
Variable m : Nat Variable m : Nat
Show n + m print n + m
Show n + x + m print n + x + m
SetOption lean::pp::coercion true SetOption lean::pp::coercion true
Show n + x + m + 10 print n + x + m + 10
Show x + n + m + 10 print x + n + m + 10
Show n + m + 10 + x print n + m + 10 + x
SetOption lean::pp::notation false SetOption lean::pp::notation false
Show n + m + 10 + x print n + m + 10 + x

View file

@ -1,16 +1,16 @@
Import Int. Import Int.
Import Real. Import Real.
Show 1/2 print 1/2
Eval 4/6 Eval 4/6
Show 3 div 2 print 3 div 2
Variable x : Real Variable x : Real
Variable i : Int Variable i : Int
Variable n : Nat Variable n : Nat
Show x + i + 1 + n print x + i + 1 + n
SetOption lean::pp::coercion true SetOption lean::pp::coercion true
Show x + i + 1 + n print x + i + 1 + n
Show x * i + x print x * i + x
Show x - i + x - x >= 0 print x - i + x - x >= 0
Show x < x print x < x
Show x <= x print x <= x
Show x > x print x > x

View file

@ -3,8 +3,8 @@ Eval 8 mod 3
Eval 8 div 4 Eval 8 div 4
Eval 7 div 3 Eval 7 div 3
Eval 7 mod 3 Eval 7 mod 3
Show -8 mod 3 print -8 mod 3
SetOption lean::pp::notation false SetOption lean::pp::notation false
Show -8 mod 3 print -8 mod 3
Eval -8 mod 3 Eval -8 mod 3
Eval (-8 div 3)*3 + (-8 mod 3) Eval (-8 div 3)*3 + (-8 mod 3)

View file

@ -1,6 +1,6 @@
Import Int. Import Int.
SetOption pp::unicode false SetOption pp::unicode false
Show 3 | 6 print 3 | 6
Eval 3 | 6 Eval 3 | 6
Eval 3 | 7 Eval 3 | 7
Eval 2 | 6 Eval 2 | 6
@ -10,4 +10,4 @@ Eval x | 3
Eval 3 | x Eval 3 | x
Eval 6 | 3 Eval 6 | 3
SetOption pp::notation false SetOption pp::notation false
Show 3 | x print 3 | x

View file

@ -10,7 +10,7 @@ Eval |x + 1|
Eval |x + 1| > 0 Eval |x + 1| > 0
Variable y : Int Variable y : Int
Eval |x + y| Eval |x + y|
Show |x + y| > x print |x + y| > x
SetOption pp::notation false SetOption pp::notation false
Show |x + y| > x print |x + y| > x
Show |x + y| + |y + x| > x print |x + y| + |y + x| > x

View file

@ -1,5 +1,5 @@
Import Int. Import Int.
Show (Int -> Int) -> Int print (Int -> Int) -> Int
Show Int -> Int -> Int print Int -> Int -> Int
Show Int -> (Int -> Int) print Int -> (Int -> Int)
Show (Int -> Int) -> (Int -> Int) -> Int print (Int -> Int) -> (Int -> Int) -> Int

View file

@ -5,4 +5,4 @@ Variable N : Type.
Definition T (a : N) (f : _ -> _) (H : f a == a) : f (f _) == f _ := Definition T (a : N) (f : _ -> _) (H : f a == a) : f (f _) == f _ :=
SubstP (fun x : N, f (f a) == _) (Refl (f (f _))) H. SubstP (fun x : N, f (f a) == _) (Refl (f (f _))) H.
Show Environment 1. print Environment 1.

View file

@ -10,4 +10,4 @@ Definition n5 : _ := cons 10 nil
SetOption pp::coercion true SetOption pp::coercion true
SetOption pp::implicit true SetOption pp::implicit true
Show Environment 1. print Environment 1.

View file

@ -5,4 +5,4 @@ Variable b : Int
Axiom H1 : a = b Axiom H1 : a = b
Axiom H2 : (g a) > 0 Axiom H2 : (g a) > 0
Theorem T1 : (g b) > 0 := SubstP (λ x, (g x) > 0) H2 H1 Theorem T1 : (g b) > 0 := SubstP (λ x, (g x) > 0) H2 H1
Show Environment 2 print Environment 2

View file

@ -3,4 +3,4 @@ Variable f {A : Type} (a b : A) : Bool
Variable a : Int Variable a : Int
Variable b : Real Variable b : Real
Definition tst : Bool := (fun x y, f x y) a b Definition tst : Bool := (fun x y, f x y) a b
Show Environment 1 print Environment 1

View file

@ -8,5 +8,5 @@ Variable a : A
Check DomInj H Check DomInj H
Theorem BeqB' : B = B' := RanInj H a Theorem BeqB' : B = B' := RanInj H a
SetOption pp::implicit true SetOption pp::implicit true
Show DomInj H print DomInj H
Show RanInj H a print RanInj H a

View file

@ -2,7 +2,7 @@ Variable T : Type
Variable R : Type Variable R : Type
Variable f : T -> R Variable f : T -> R
Coercion f Coercion f
Show Environment 2 print Environment 2
Variable g : T -> R Variable g : T -> R
Coercion g Coercion g
Variable h : Pi (x : Type), x Variable h : Pi (x : Type), x

View file

@ -4,14 +4,14 @@ Variable t2r : T -> R
Coercion t2r Coercion t2r
Variable g : R -> R -> R Variable g : R -> R -> R
Variable a : T Variable a : T
Show g a a print g a a
Variable b : R Variable b : R
Show g a b print g a b
Show g b a print g b a
SetOption lean::pp::coercion true SetOption lean::pp::coercion true
Show g a a print g a a
Show g a b print g a b
Show g b a print g b a
SetOption lean::pp::coercion false SetOption lean::pp::coercion false
Variable S : Type Variable S : Type
Variable s : S Variable s : S
@ -20,13 +20,13 @@ Variable h : S -> S -> S
Infixl 10 ++ : g Infixl 10 ++ : g
Infixl 10 ++ : h Infixl 10 ++ : h
SetOption lean::pp::notation false SetOption lean::pp::notation false
Show a ++ b ++ a print a ++ b ++ a
Show r ++ s ++ r print r ++ s ++ r
Check a ++ b ++ a Check a ++ b ++ a
Check r ++ s ++ r Check r ++ s ++ r
SetOption lean::pp::coercion true SetOption lean::pp::coercion true
Show a ++ b ++ a print a ++ b ++ a
Show r ++ s ++ r print r ++ s ++ r
SetOption lean::pp::notation true SetOption lean::pp::notation true
Show a ++ b ++ a print a ++ b ++ a
Show r ++ s ++ r print r ++ s ++ r

View file

@ -2,4 +2,4 @@ Import specialfn.
Definition f x y := x + y Definition f x y := x + y
Definition g x y := sin x + y Definition g x y := sin x + y
Definition h x y := x * sin (x + y) Definition h x y := x * sin (x + y)
Show Environment 3 print Environment 3

View file

@ -18,4 +18,4 @@ Theorem T2 (a b : Bool) : a \/ b => b \/ a.
simple_tac. simple_tac.
done. done.
Show Environment 1. print Environment 1.

View file

@ -1,4 +1,3 @@
Variable C : Pi (A B : Type) (H : A = B) (a : A), B Variable C : Pi (A B : Type) (H : A = B) (a : A), B
Variable D : Pi (A A' : Type) (B : A -> Type) (B' : A' -> Type) (H : (Pi x : A, B x) = (Pi x : A', B' x)), A = A' Variable D : Pi (A A' : Type) (B : A -> Type) (B' : A' -> Type) (H : (Pi x : A, B x) = (Pi x : A', B' x)), A = A'
@ -8,7 +7,7 @@ Variable R : Pi (A A' : Type) (B : A -> Type) (B' : A' -> Type) (H : (Pi x : A,
Theorem R2 (A A' B B' : Type) (H : (A -> B) = (A' -> B')) (a : A) : B = B' := R _ _ _ _ H a Theorem R2 (A A' B B' : Type) (H : (A -> B) = (A' -> B')) (a : A) : B = B' := R _ _ _ _ H a
Show Environment 1 print Environment 1
Theorem R3 : Pi (A1 A2 B1 B2 : Type) (H : (A1 -> B1) = (A2 -> B2)) (a : A1), B1 = B2 := Theorem R3 : Pi (A1 A2 B1 B2 : Type) (H : (A1 -> B1) = (A2 -> B2)) (a : A1), B1 = B2 :=
fun (A1 A2 B1 B2 : Type) (H : (A1 -> B1) = (A2 -> B2)) (a : A1), fun (A1 A2 B1 B2 : Type) (H : (A1 -> B1) = (A2 -> B2)) (a : A1),
@ -22,4 +21,4 @@ Theorem R5 : Pi (A1 A2 B1 B2 : Type) (H : (A1 -> B1) = (A2 -> B2)) (a : A1), B1
fun (A1 A2 B1 B2 : Type) (H : _) (a : _), fun (A1 A2 B1 B2 : Type) (H : _) (a : _),
R _ _ _ _ H a R _ _ _ _ H a
Show Environment 1 print Environment 1

View file

@ -9,4 +9,4 @@ Theorem R2 : Pi (A1 A2 B1 B2 : Type) (H : (A1 -> B1) = (A2 -> B2)) (a : A1), B1
fun A1 A2 B1 B2 H a, fun A1 A2 B1 B2 H a,
R _ _ _ _ H a R _ _ _ _ H a
Show Environment 1. print Environment 1.

View file

@ -9,4 +9,4 @@ Theorem R2 : Pi (A1 A2 B1 B2 : Type) (H : (A1 -> B1) = (A2 -> B2)) (a : A1), B1
fun A1 A2 B1 B2 H a, R H a fun A1 A2 B1 B2 H a, R H a
SetOption pp::implicit true SetOption pp::implicit true
Show Environment 7. print Environment 7.

View file

@ -9,4 +9,4 @@ Theorem R2 : Pi (A1 A2 B1 B2 : Type), ((A1 -> B1) = (A2 -> B2)) -> A1 -> (B1 = B
fun A1 A2 B1 B2 H a, R H a fun A1 A2 B1 B2 H a, R H a
SetOption pp::implicit true SetOption pp::implicit true
Show Environment 7. print Environment 7.

View file

@ -16,6 +16,6 @@ Theorem T1 : F1 = F2 := Abst (fun a, (Abst (fun b, H a b)))
Theorem T2 : (fun (x1 : A) (x2 : B), F1 x1 x2) = F2 := Abst (fun a, (Abst (fun b, H a b))) Theorem T2 : (fun (x1 : A) (x2 : B), F1 x1 x2) = F2 := Abst (fun a, (Abst (fun b, H a b)))
Theorem T3 : F1 = (fun (x1 : A) (x2 : B), F2 x1 x2) := Abst (fun a, (Abst (fun b, H a b))) Theorem T3 : F1 = (fun (x1 : A) (x2 : B), F2 x1 x2) := Abst (fun a, (Abst (fun b, H a b)))
Theorem T4 : (fun (x1 : A) (x2 : B), F1 x1 x2) = (fun (x1 : A) (x2 : B), F2 x1 x2) := Abst (fun a, (Abst (fun b, H a b))) Theorem T4 : (fun (x1 : A) (x2 : B), F1 x1 x2) = (fun (x1 : A) (x2 : B), F2 x1 x2) := Abst (fun a, (Abst (fun b, H a b)))
Show Environment 4 print Environment 4
SetOption pp::implicit true SetOption pp::implicit true
Show Environment 4 print Environment 4

View file

@ -1,5 +1,5 @@
Eval fun x, x Eval fun x, x
Show fun x, x print fun x, x
Check fun x, x Check fun x, x
Theorem T (A : Type) (x : A) : Pi (y : A), A Theorem T (A : Type) (x : A) : Pi (y : A), A

View file

@ -1 +1 @@
Echo "test" print "test"

View file

@ -1,18 +1,18 @@
-- comment -- comment
Show true print true
SetOption lean::pp::notation false SetOption lean::pp::notation false
Show true && false print true && false
SetOption pp::unicode false SetOption pp::unicode false
Show true && false print true && false
Variable a : Bool Variable a : Bool
Variable a : Bool Variable a : Bool
Variable b : Bool Variable b : Bool
Show a && b print a && b
Variable A : Type Variable A : Type
Check a && A Check a && A
Show Environment 1 print Environment 1
Show Options print Options
SetOption lean::p::notation true SetOption lean::p::notation true
SetOption lean::pp::notation 10 SetOption lean::pp::notation 10
SetOption lean::pp::notation true SetOption lean::pp::notation true
Show a && b print a && b

View file

@ -1,5 +1,5 @@
Variable myeq : Pi (A : Type), A -> A -> Bool Variable myeq : Pi (A : Type), A -> A -> Bool
Show myeq _ true false print myeq _ true false
Variable T : Type Variable T : Type
Variable a : T Variable a : T
Check myeq _ true a Check myeq _ true a

View file

@ -3,4 +3,4 @@ Variable a : Int
Variable P : Int -> Int -> Bool Variable P : Int -> Int -> Bool
Axiom H : P a a Axiom H : P a a
Theorem T : exists x : Int, P a a := ExistsIntro a H. Theorem T : exists x : Int, P a a := ExistsIntro a H.
Show Environment 1. print Environment 1.

View file

@ -15,4 +15,4 @@ 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 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) Theorem T8 : exists x y : Int, P (f x x) y := ExistsIntro _ (ExistsIntro _ H3)
Show Environment 8. print Environment 8.

View file

@ -13,4 +13,4 @@ Theorem T3 : exists x y z : N, P x y z := ExistsIntro _ (ExistsIntro _ (ExistsIn
Theorem T4 (H : P a a b) : exists x y z, P x y z := ExistsIntro _ (ExistsIntro _ (ExistsIntro _ H)) Theorem T4 (H : P a a b) : exists x y z, P x y z := ExistsIntro _ (ExistsIntro _ (ExistsIntro _ H))
Show Environment 4 print Environment 4

View file

@ -4,4 +4,4 @@ Variables P : N -> N -> N -> Bool
Theorem T1 (f : N -> N) (H : P (f a) b (f (f c))) : exists x y z, P x y z := ExistsIntro _ (ExistsIntro _ (ExistsIntro _ H)) Theorem T1 (f : N -> N) (H : P (f a) b (f (f c))) : exists x y z, P x y z := ExistsIntro _ (ExistsIntro _ (ExistsIntro _ H))
Show Environment 1. print Environment 1.

View file

@ -9,4 +9,4 @@ SetOpaque not false.
Theorem T1 (f : N -> N) (H : P (f a) b (f (f c))) : exists x y z, P x y z := ExistsIntro _ (ExistsIntro _ (ExistsIntro _ H)) Theorem T1 (f : N -> N) (H : P (f a) b (f (f c))) : exists x y z, P x y z := ExistsIntro _ (ExistsIntro _ (ExistsIntro _ H))
Show Environment 1. print Environment 1.

View file

@ -1,2 +1,2 @@
Exit Exit
Show "FAILED" print "FAILED"

View file

@ -5,4 +5,4 @@ Variable b : Int
Axiom H1 : a = b Axiom H1 : a = b
Axiom H2 : (g a) > 0 Axiom H2 : (g a) > 0
Theorem T1 : (g b) > 0 := Subst H2 H1 Theorem T1 : (g b) > 0 := Subst H2 H1
Show Environment 2 print Environment 2

View file

@ -1,20 +1,20 @@
Import Int. Import Int.
Import Real. Import Real.
Variable f : Int -> Int -> Int Variable f : Int -> Int -> Int
Show forall a, f a a > 0 print forall a, f a a > 0
Show forall a b, f a b > 0 print forall a b, f a b > 0
Variable g : Int -> Real -> Int Variable g : Int -> Real -> Int
Show forall a b, g a b > 0 print forall a b, g a b > 0
Show forall a b, g a (f a b) > 0 print forall a b, g a (f a b) > 0
SetOption pp::coercion true SetOption pp::coercion true
Show forall a b, g a (f a b) > 0 print forall a b, g a (f a b) > 0
Show fun a, a + 1 print fun a, a + 1
Show fun a b, a + b print fun a b, a + b
Show fun (a b) (c : Int), a + c + b print fun (a b) (c : Int), a + c + b
-- The next example shows a limitation of the current elaborator. -- The next example shows a limitation of the current elaborator.
-- The current elaborator resolves overloads before solving the implicit argument constraints. -- The current elaborator resolves overloads before solving the implicit argument constraints.
-- So, it does not have enough information for deciding which overload to use. -- So, it does not have enough information for deciding which overload to use.
Show (fun a b, a + b) 10 20. print (fun a b, a + b) 10 20.
Variable x : Int Variable x : Int
-- The following one works because the type of x is used to decide which + should be used -- The following one works because the type of x is used to decide which + should be used
Show fun a b, a + x + b print fun a b, a + x + b

View file

@ -1,11 +1,11 @@
Import Int. Import Int.
Show 10 = 20 print 10 = 20
Variable f : Int -> Int -> Int Variable f : Int -> Int -> Int
Variable g : Int -> Int -> Int -> Int Variable g : Int -> Int -> Int -> Int
Notation 10 _ ++ _ : f Notation 10 _ ++ _ : f
Notation 10 _ ++ _ : g Notation 10 _ ++ _ : g
SetOption pp::implicit true SetOption pp::implicit true
SetOption pp::notation false SetOption pp::notation false
Show (10 ++ 20) print (10 ++ 20)
Show (10 ++ 20) 10 print (10 ++ 20) 10

View file

@ -1,11 +1,11 @@
Import Int. Import Int.
Variable f {A : Type} : A -> A -> A Variable f {A : Type} : A -> A -> A
Infixl 65 + : f Infixl 65 + : f
Show true + false print true + false
Show 10 + 20 print 10 + 20
Show 10 + (- 20) print 10 + (- 20)
SetOption pp::notation false SetOption pp::notation false
SetOption pp::coercion true SetOption pp::coercion true
Show true + false print true + false
Show 10 + 20 print 10 + 20
Show 10 + (- 20) print 10 + (- 20)

View file

@ -12,4 +12,4 @@ Theorem T2 (A B : Bool) : A /\ B => B /\ A :=
simple2_tac. done. simple2_tac. done.
simple_tac. done. simple_tac. done.
Echo "echo command after failure" print "echo command after failure"

View file

@ -10,7 +10,7 @@ Theorem T1 (A B : Bool) : A /\ B -> B /\ A :=
lemma2 : B := (by auto) lemma2 : B := (by auto)
in (show B /\ A by auto) in (show B /\ A by auto)
Show Environment 1. -- Show proof for the previous theorem print Environment 1. -- print proof for the previous theorem
Theorem T2 (A B : Bool) : A /\ B -> B /\ A := Theorem T2 (A B : Bool) : A /\ B -> B /\ A :=
fun assumption : A /\ B, fun assumption : A /\ B,

View file

@ -9,4 +9,4 @@ Theorem T1 (A B : Bool) : A /\ B -> B /\ A :=
lemma2 := (show B by auto) lemma2 := (show B by auto)
in (show B /\ A by auto) in (show B /\ A by auto)
Show Environment 1. print Environment 1.

View file

@ -6,4 +6,4 @@ foo.
abort. abort.
Variables a b : Bool. Variables a b : Bool.
Show Environment 2. print Environment 2.

View file

@ -8,4 +8,4 @@ back.
exact. exact.
done. done.
Show Environment 1. print Environment 1.

View file

@ -1,2 +1,2 @@
Theorem (a : Bool) : a. Theorem (a : Bool) : a.
Echo "done". print "done".

View file

@ -5,4 +5,4 @@ Theorem T (a : Bool) : a.
apply magic. apply magic.
done. done.
Show Environment 1. print Environment 1.

View file

@ -1,12 +1,10 @@
Import Int. Import Int.
Show let a : Nat := 10, b : Nat := 20, c : Nat := 30, d : Nat := 10 in a + b + c + d print let a : Nat := 10, b : Nat := 20, c : Nat := 30, d : Nat := 10 in a + b + c + d
Show let a : Nat := 1000000000000000000, b : Nat := 20000000000000000000, c : Nat := 3000000000000000000, d : Nat := 4000000000000000000 in a + b + c + d print let a : Nat := 1000000000000000000, b : Nat := 20000000000000000000, c : Nat := 3000000000000000000, d : Nat := 4000000000000000000 in a + b + c + d
Check let a : Nat := 10 in a + 1 Check let a : Nat := 10 in a + 1
Eval let a : Nat := 20 in a + 10 Eval let a : Nat := 20 in a + 10
Eval let a := 20 in a + 10 Eval let a := 20 in a + 10
Check let a : Int := 20 in a + 10 Check let a : Int := 20 in a + 10
SetOption pp::coercion true SetOption pp::coercion true
Show let a : Int := 20 in a + 10 print let a : Int := 20 in a + 10

View file

@ -7,4 +7,4 @@ Theorem simple (p q r : Bool) : (p ⇒ q) ∧ (q ⇒ r) ⇒ p ⇒ r :=
P_q : q := MP P_pq H_p P_q : q := MP P_pq H_p
in MP P_qr P_q)) in MP P_qr P_q))
Show Environment 1 print Environment 1

View file

@ -4,6 +4,6 @@ Variable magic : Pi (H : Bool), H
SetOption pp::notation false SetOption pp::notation false
SetOption pp::coercion true SetOption pp::coercion true
Show let a : Int := 1, print let a : Int := 1,
H : a > 0 := magic (a > 0) H : a > 0 := magic (a > 0)
in H in H

View file

@ -1,6 +1,6 @@
Import Int. Import Int.
Show print
let b := true, let b := true,
a : Int := b a : Int := b
in a in a
@ -14,7 +14,7 @@ let a := 10,
v2 := v1 v2 := v1
in v2 in v2
Show print
let a := 10, let a := 10,
v1 : vector Bool a := const a true, v1 : vector Bool a := const a true,
v2 : vector Bool a := v1 v2 : vector Bool a := v1
@ -43,10 +43,8 @@ in v2
SetOption pp::coercion true SetOption pp::coercion true
Show print
let a := 10, let a := 10,
v1 : vector Bool a := const a true, v1 : vector Bool a := const a true,
v2 : vector Int a := v1 v2 : vector Int a := v1
in v2 in v2

View file

@ -1,6 +1,6 @@
Import Int. Import Int.
Variables a b : Int Variables a b : Int
Show Options print Options
(* (*
local ios = io_state() local ios = io_state()
@ -10,5 +10,5 @@ Show Options
print(parse_lean("fun x, a + x")) print(parse_lean("fun x, a + x"))
print(get_options()) print(get_options())
*) *)
Show Options print Options
Show Environment 2 print Environment 2

View file

@ -18,8 +18,8 @@ macro("Sum", { macro_arg.Exprs },
end) end)
*) *)
Show (MyMacro 10, 20) + 20 print (MyMacro 10, 20) + 20
Show (Sum) print (Sum)
Show Sum 10 20 30 40 print Sum 10 20 30 40
Show fun x, Sum x 10 x 20 print fun x, Sum x 10 x 20
Eval (fun x, Sum x 10 x 20) 100 Eval (fun x, Sum x 10 x 20) 100

View file

@ -11,5 +11,5 @@ for i = 1, N do
end end
*) *)
Show Environment 101 print Environment 101
Check x + y_1 + y_2 Check x + y_1 + y_2

View file

@ -33,6 +33,6 @@ Variable x : Bool
env:add_definition("sum1", s) env:add_definition("sum1", s)
*) *)
Show Environment 1 print Environment 1
Eval sum1 Eval sum1
Variable y : Bool Variable y : Bool

View file

@ -7,7 +7,7 @@ Variable vector (A : Type) (sz : Nat) : Type
Variable read {A : Type} {sz : Nat} (v : vector A sz) (i : Nat) (H : i < sz) : A Variable read {A : Type} {sz : Nat} (v : vector A sz) (i : Nat) (H : i < sz) : A
Variable V1 : vector Int 10 Variable V1 : vector Int 10
Definition D := read V1 1 (by trivial) Definition D := read V1 1 (by trivial)
Show Environment 1 print Environment 1
Variable b : Bool Variable b : Bool
Definition a := b Definition a := b
Theorem T : b => a := (by (* imp_tac() .. normalize_tac() .. assumption_tac() *)) Theorem T : b => a := (by (* imp_tac() .. normalize_tac() .. assumption_tac() *))

View file

@ -3,10 +3,10 @@ Variable f : Bool -> Bool -> Bool
Variable g : N -> N -> N Variable g : N -> N -> N
Infixl 10 ++ : f Infixl 10 ++ : f
Infixl 10 ++ : g Infixl 10 ++ : g
Show true ++ false ++ true print true ++ false ++ true
SetOption lean::pp::notation false SetOption lean::pp::notation false
Show true ++ false ++ true print true ++ false ++ true
Variable a : N Variable a : N
Variable b : N Variable b : N
Show a ++ b ++ a print a ++ b ++ a
Show true ++ false ++ false print true ++ false ++ false

View file

@ -1,6 +1,6 @@
Import Int Import Int
Import Real Import Real
Show 1 + true print 1 + true
Variable R : Type Variable R : Type
Variable T : Type Variable T : Type
Variable r2t : R -> T Variable r2t : R -> T
@ -12,10 +12,10 @@ Variable a : T
Variable b : R Variable b : R
SetOption lean::pp::coercion true SetOption lean::pp::coercion true
SetOption lean::pp::notation false SetOption lean::pp::notation false
Show f a b print f a b
Show f b a print f b a
Variable g : R -> T -> R Variable g : R -> T -> R
Infix 10 ++ : f Infix 10 ++ : f
Infix 10 ++ : g Infix 10 ++ : g
Show a ++ b print a ++ b
Show b ++ a print b ++ a

View file

@ -4,25 +4,25 @@
Imported 'Real' Imported 'Real'
Failed to solve Failed to solve
⊢ (?M::0 ≈ Nat::add) ⊕ (?M::0 ≈ Int::add) ⊕ (?M::0 ≈ Real::add) ⊢ (?M::0 ≈ Nat::add) ⊕ (?M::0 ≈ Int::add) ⊕ (?M::0 ≈ Real::add)
(line: 3: pos: 9) Overloading at (line: 3: pos: 10) Overloading at
(Real::add | Int::add | Nat::add) 1 (Real::add | Int::add | Nat::add) 1
Failed to solve Failed to solve
⊢ Bool ≺ ⊢ Bool ≺
(line: 3: pos: 9) Type of argument 2 must be convertible to the expected type in the application of (line: 3: pos: 10) Type of argument 2 must be convertible to the expected type in the application of
Nat::add Nat::add
with arguments: with arguments:
1 1
Failed to solve Failed to solve
⊢ Bool ≺ ⊢ Bool ≺
(line: 3: pos: 9) Type of argument 2 must be convertible to the expected type in the application of (line: 3: pos: 10) Type of argument 2 must be convertible to the expected type in the application of
Int::add Int::add
with arguments: with arguments:
1 1
Failed to solve Failed to solve
⊢ Bool ≺ ⊢ Bool ≺
(line: 3: pos: 9) Type of argument 2 must be convertible to the expected type in the application of (line: 3: pos: 10) Type of argument 2 must be convertible to the expected type in the application of
Real::add Real::add
with arguments: with arguments:
1 1

View file

@ -3,4 +3,4 @@ Theorem T (C A B : Bool) : C -> A -> B -> A.
exact. exact.
done. done.
Show Environment 1. print Environment 1.

View file

@ -10,7 +10,7 @@ Pop
Eval f a -- should produce an error Eval f a -- should produce an error
Show Environment 1 print Environment 1
Push Push
Infixl 100 ++ : Int::add Infixl 100 ++ : Int::add

View file

@ -23,5 +23,5 @@ Scope
in Trans L5 L3. in Trans L5 L3.
EndScope EndScope
Show Environment 3. print Environment 3.
Eval g Int Int::sub 10 20 Eval g Int Int::sub 10 20

View file

@ -1,3 +1,3 @@
SetOption pp::colors false SetOption pp::colors false
Echo "===BEGIN ENVIRONMENT===" print "===BEGIN ENVIRONMENT==="
Show Environment print Environment

View file

@ -1,6 +1,6 @@
Import Int. Import Int.
Variables a b c : Int. Variables a b c : Int.
Show a + b + c. print a + b + c.
Check a + b. Check a + b.
Exit. Exit.
-- the following line should be executed -- the following line should be executed

View file

@ -7,4 +7,4 @@ Theorem T : a + n + a = 10 := Subst H1 H2
SetOption pp::coercion true SetOption pp::coercion true
SetOption pp::notation false SetOption pp::notation false
SetOption pp::implicit true SetOption pp::implicit true
Show Environment 1. print Environment 1.

View file

@ -12,4 +12,4 @@ Theorem T (A : Type) (p : A -> Bool) (f : A -> A -> A) : forall x y z, p (f x x)
apply (Subst (Subst H H::1) H::2) apply (Subst (Subst H H::1) H::2)
done. done.
Show Environment 1. print Environment 1.

View file

@ -4,4 +4,4 @@ Theorem T (A : Type) (p : A -> Bool) (f : A -> A -> A) : forall x y z, p (f x x)
For x y z, Assume (H1 : p (f x x)) (H2 : x = y) (H3 : x = z), For x y z, Assume (H1 : p (f x x)) (H2 : x = y) (H3 : x = z),
Subst' H1 H2 H3. Subst' H1 H2 H3.
Show Environment 1. print Environment 1.

View file

@ -8,4 +8,4 @@ Variables p q r : Bool
env:add_theorem("T1", conjecture, proof) env:add_theorem("T1", conjecture, proof)
*) *)
Show Environment 1. print Environment 1.

View file

@ -21,4 +21,4 @@ Theorem T2 (a b : Bool) : (h a b) => (f b) => a := _.
simple_tac simple_tac
done. done.
Show Environment 1. print Environment 1.

View file

@ -19,4 +19,4 @@ Theorem T2 (a b c : Int) (H1 : a = b) (H2 : a = c) : (f (f a c)) = (f (f b a)).
auto. auto.
done. done.
Show Environment 2. print Environment 2.

View file

@ -10,4 +10,4 @@ Theorem T1 (a b : Int) (f : Int -> Int) : a = b -> (f (f a)) = (f (f b)) :=
fun assumption : a = b, fun assumption : a = b,
show (f (f a)) = (f (f b)) by congr_tac show (f (f a)) = (f (f b)) by congr_tac
Show Environment 1. print Environment 1.

View file

@ -21,18 +21,18 @@ Theorem T2 : p => q => p /\ q /\ p := _.
simple_tac simple_tac
done done
Show Environment 1 print Environment 1
Theorem T3 : p => p /\ q => r => q /\ r /\ p := _. Theorem T3 : p => p /\ q => r => q /\ r /\ p := _.
(* Repeat(OrElse(imp_tac(), conj_tac(), conj_hyp_tac(), assumption_tac())) *) (* Repeat(OrElse(imp_tac(), conj_tac(), conj_hyp_tac(), assumption_tac())) *)
done done
-- Display proof term generated by previous tac -- Display proof term generated by previous tac
Show Environment 1 print Environment 1
Theorem T4 : p => p /\ q => r => q /\ r /\ p := _. Theorem T4 : p => p /\ q => r => q /\ r /\ p := _.
Repeat (OrElse (apply Discharge) (apply Conj) conj_hyp exact) Repeat (OrElse (apply Discharge) (apply Conj) conj_hyp exact)
done done
-- Display proof term generated by previous tac -- -- Display proof term generated by previous tac --
Show Environment 1 print Environment 1

View file

@ -6,4 +6,4 @@ Theorem T1 : p => p /\ q => r => q /\ r /\ p := _.
done done
-- Display proof term generated by previous tactic -- Display proof term generated by previous tactic
Show Environment 1 print Environment 1

View file

@ -6,4 +6,4 @@ Theorem T4 (a b : Bool) : a => b => a /\ b := _.
simple_tac simple_tac
done done
Show Environment 1. print Environment 1.

View file

@ -6,4 +6,4 @@ Theorem T4 (a b : Bool) : a => b => a /\ b /\ a := _.
simple_tac simple_tac
done done
Show Environment 1. print Environment 1.

View file

@ -6,4 +6,4 @@ Theorem T (a b : Bool) : a \/ b => (not b) => a := _.
exact exact
absurd absurd
done done
Show Environment 1. print Environment 1.

View file

@ -10,4 +10,4 @@ Theorem T (a b : Bool) : a \/ b => (f b) => a := _.
absurd absurd
done done
Show Environment 1. print Environment 1.

View file

@ -12,15 +12,15 @@ Definition const {A : Type} (n : N) (d : A) : vector A n := fun (i : N) (H : i <
Definition update {A : Type} {n : N} (v : vector A n) (i : N) (d : A) : vector A n := fun (j : N) (H : j < n), if (j = i) d (v j H) Definition update {A : Type} {n : N} (v : vector A n) (i : N) (d : A) : vector A n := fun (j : N) (H : j < n), if (j = i) d (v j H)
Definition select {A : Type} {n : N} (v : vector A n) (i : N) (H : i < n) : A := v i H Definition select {A : Type} {n : N} (v : vector A n) (i : N) (H : i < n) : A := v i H
Definition map {A B C : Type} {n : N} (f : A -> B -> C) (v1 : vector A n) (v2 : vector B n) : vector C n := fun (i : N) (H : i < n), f (v1 i H) (v2 i H) Definition map {A B C : Type} {n : N} (f : A -> B -> C) (v1 : vector A n) (v2 : vector B n) : vector C n := fun (i : N) (H : i < n), f (v1 i H) (v2 i H)
Show Environment 10 print Environment 10
Check select (update (const three false) two true) two two_lt_three Check select (update (const three false) two true) two two_lt_three
Eval select (update (const three false) two true) two two_lt_three Eval select (update (const three false) two true) two two_lt_three
Check update (const three false) two true Check update (const three false) two true
Echo "\n--------" print "\n--------"
Check @select Check @select
Echo "\nmap type ---> " print "\nmap type ---> "
Check @map Check @map
Echo "\nmap normal form --> " print "\nmap normal form --> "
Eval @map Eval @map
Echo "\nupdate normal form --> " print "\nupdate normal form --> "
Eval @update Eval @update

View file

@ -1,20 +1,20 @@
Variable a : Bool Variable a : Bool
Variable b : Bool Variable b : Bool
-- Conjunctions -- Conjunctions
Show a && b print a && b
Show a && b && a print a && b && a
Show a /\ b print a /\ b
Show a ∧ b print a ∧ b
Show (and a b) print (and a b)
Show and a b print and a b
-- Disjunctions -- Disjunctions
Show a || b print a || b
Show a \/ b print a \/ b
Show a b print a b
Show (or a b) print (or a b)
Show or a (or a b) print or a (or a b)
-- Simple Formulas -- Simple Formulas
Show a => b => a print a => b => a
Check a => b Check a => b
Eval a => a Eval a => a
Eval true => a Eval true => a
@ -22,5 +22,5 @@ Eval true => a
Axiom H1 : a Axiom H1 : a
Axiom H2 : a => b Axiom H2 : a => b
Check @MP Check @MP
Show MP H2 H1 print MP H2 H1
Check MP H2 H1 Check MP H2 H1

View file

@ -1,10 +1,10 @@
Definition xor (x y : Bool) : Bool := (not x) = y Definition xor (x y : Bool) : Bool := (not x) = y
Infixr 50 ⊕ : xor Infixr 50 ⊕ : xor
Show xor true false print xor true false
Eval xor true true Eval xor true true
Eval xor true false Eval xor true false
Variable a : Bool Variable a : Bool
Show a ⊕ a ⊕ a print a ⊕ a ⊕ a
Check @Subst Check @Subst
Theorem EM2 (a : Bool) : a \/ (not a) := Theorem EM2 (a : Bool) : a \/ (not a) :=
Case (fun x : Bool, x \/ (not x)) Trivial Trivial a Case (fun x : Bool, x \/ (not x)) Trivial Trivial a

View file

@ -1,5 +1,5 @@
Show (fun x : Bool, (fun y : Bool, x /\ y)) print (fun x : Bool, (fun y : Bool, x /\ y))
Show let x := true, print let x := true,
y := true y := true
in (let z := x /\ y, in (let z := x /\ y,
f := (fun arg1 arg2 : Bool, arg1 /\ arg2 <=> f := (fun arg1 arg2 : Bool, arg1 /\ arg2 <=>

View file

@ -1,5 +1,5 @@
Show fun x : Bool, (fun x : Bool, x). print fun x : Bool, (fun x : Bool, x).
Show let x := true, print let x := true,
y := true y := true
in (let z := x /\ y, in (let z := x /\ y,
f := (fun x y : Bool, x /\ y <=> f := (fun x y : Bool, x /\ y <=>

View file

@ -1,5 +1,5 @@
Import Int. Import Int.
Show Int -> Int -> Int print Int -> Int -> Int
Variable f : Int -> Int -> Int Variable f : Int -> Int -> Int
Eval f 0 Eval f 0
Check f 0 Check f 0

View file

@ -6,15 +6,15 @@ Check f x
Check (Type 4) Check (Type 4)
Check x Check x
Check (Type max U M) Check (Type max U M)
Show (Type U+3) print (Type U+3)
Check (Type U+3) Check (Type U+3)
Check (Type U ⊔ M) Check (Type U ⊔ M)
Check (Type U ⊔ M ⊔ 3) Check (Type U ⊔ M ⊔ 3)
Show (Type U+1 ⊔ M ⊔ 3) print (Type U+1 ⊔ M ⊔ 3)
Check (Type U+1 ⊔ M ⊔ 3) Check (Type U+1 ⊔ M ⊔ 3)
Show (Type U) -> (Type 5) print (Type U) -> (Type 5)
Check (Type U) -> (Type 5) Check (Type U) -> (Type 5)
Check (Type M ⊔ 3) -> (Type U+5) Check (Type M ⊔ 3) -> (Type U+5)
Show (Type M ⊔ 3) -> (Type U) -> (Type 5) print (Type M ⊔ 3) -> (Type U) -> (Type 5)
Check (Type M ⊔ 3) -> (Type U) -> (Type 5) Check (Type M ⊔ 3) -> (Type U) -> (Type 5)
Show (Type U) print (Type U)

View file

@ -1,15 +1,15 @@
Variable f : Type -> Bool Variable f : Type -> Bool
Show forall a b : Type, (f a) = (f b) print forall a b : Type, (f a) = (f b)
Variable g : Bool -> Bool -> Bool Variable g : Bool -> Bool -> Bool
Show forall (a b : Type) (c : Bool), g c ((f a) = (f b)) print forall (a b : Type) (c : Bool), g c ((f a) = (f b))
Show exists (a b : Type) (c : Bool), g c ((f a) = (f b)) print exists (a b : Type) (c : Bool), g c ((f a) = (f b))
Show forall (a b : Type) (c : Bool), (g c (f a) = (f b)) ⇒ (f a) print forall (a b : Type) (c : Bool), (g c (f a) = (f b)) ⇒ (f a)
Check forall (a b : Type) (c : Bool), g c ((f a) = (f b)) Check forall (a b : Type) (c : Bool), g c ((f a) = (f b))
Show ∀ (a b : Type) (c : Bool), g c ((f a) = (f b)) print ∀ (a b : Type) (c : Bool), g c ((f a) = (f b))
Show ∀ a b : Type, (f a) = (f b) print ∀ a b : Type, (f a) = (f b)
Show ∃ a b : Type, (f a) = (f b) ∧ (f a) print ∃ a b : Type, (f a) = (f b) ∧ (f a)
Show ∃ a b : Type, (f a) = (f b) (f b) print ∃ a b : Type, (f a) = (f b) (f b)
Variable a : Bool Variable a : Bool
Show (f a) (f a) print (f a) (f a)
Show (f a) = a (f a) print (f a) = a (f a)
Show (f a) = a ∧ (f a) print (f a) = a ∧ (f a)

View file

@ -1,5 +1,5 @@
Variable f : Type -> Bool Variable f : Type -> Bool
Variable g : Type -> Type -> Bool Variable g : Type -> Type -> Bool
Show forall (a b : Type), exists (c : Type), (g a b) = (f c) print forall (a b : Type), exists (c : Type), (g a b) = (f c)
Check forall (a b : Type), exists (c : Type), (g a b) = (f c) Check forall (a b : Type), exists (c : Type), (g a b) = (f c)
Eval forall (a b : Type), exists (c : Type), (g a b) = (f c) Eval forall (a b : Type), exists (c : Type), (g a b) = (f c)

View file

@ -1,11 +1,11 @@
Show Options print Options
Variable a : Bool Variable a : Bool
Variable b : Bool Variable b : Bool
Show a/\b print a/\b
SetOption lean::pp::notation false SetOption lean::pp::notation false
Show Options print Options
Show a/\b print a/\b
Show Environment 2 print Environment 2
SetOption lean::pp::notation true SetOption lean::pp::notation true
Show Options print Options
Show a/\b print a/\b

View file

@ -1,58 +1,58 @@
SetOption lean::parser::verbose false. SetOption lean::parser::verbose false.
Notation 10 if _ then _ : implies. Notation 10 if _ then _ : implies.
Show Environment 1. print Environment 1.
Show if true then false. print if true then false.
Variable a : Bool. Variable a : Bool.
Show if true then if a then false. print if true then if a then false.
SetOption lean::pp::notation false. SetOption lean::pp::notation false.
Show if true then if a then false. print if true then if a then false.
Variable A : Type. Variable A : Type.
Variable f : A -> A -> A -> Bool. Variable f : A -> A -> A -> Bool.
Notation 100 _ |- _ ; _ : f. Notation 100 _ |- _ ; _ : f.
Show Environment 1. print Environment 1.
Variable c : A. Variable c : A.
Variable d : A. Variable d : A.
Variable e : A. Variable e : A.
Show c |- d ; e. print c |- d ; e.
SetOption lean::pp::notation true. SetOption lean::pp::notation true.
Show c |- d ; e. print c |- d ; e.
Variable fact : A -> A. Variable fact : A -> A.
Notation 20 _ ! : fact. Notation 20 _ ! : fact.
Show c! !. print c! !.
SetOption lean::pp::notation false. SetOption lean::pp::notation false.
Show c! !. print c! !.
SetOption lean::pp::notation true. SetOption lean::pp::notation true.
Variable g : A -> A -> A. Variable g : A -> A -> A.
Notation 30 [ _ ; _ ] : g Notation 30 [ _ ; _ ] : g
Show [c;d]. print [c;d].
Show [c ; [d;e] ]. print [c ; [d;e] ].
SetOption lean::pp::notation false. SetOption lean::pp::notation false.
Show [c ; [d;e] ]. print [c ; [d;e] ].
SetOption lean::pp::notation true. SetOption lean::pp::notation true.
Variable h : A -> A -> A. Variable h : A -> A -> A.
Notation 40 _ << _ end : h. Notation 40 _ << _ end : h.
Show Environment 1. print Environment 1.
Show d << e end. print d << e end.
Show [c ; d << e end ]. print [c ; d << e end ].
SetOption lean::pp::notation false. SetOption lean::pp::notation false.
Show [c ; d << e end ]. print [c ; d << e end ].
SetOption lean::pp::notation true. SetOption lean::pp::notation true.
Variable r : A -> A -> A. Variable r : A -> A -> A.
Infixl 30 ++ : r. Infixl 30 ++ : r.
Variable s : A -> A -> A. Variable s : A -> A -> A.
Infixl 40 ** : s. Infixl 40 ** : s.
Show c ** d ++ e ** c. print c ** d ++ e ** c.
Variable p1 : Bool. Variable p1 : Bool.
Variable p2 : Bool. Variable p2 : Bool.
Variable p3 : Bool. Variable p3 : Bool.
Show p1 || p2 && p3. print p1 || p2 && p3.
SetOption lean::pp::notation false. SetOption lean::pp::notation false.
Show c ** d ++ e ** c. print c ** d ++ e ** c.
Show p1 || p2 && p3. print p1 || p2 && p3.
SetOption lean::pp::notation true. SetOption lean::pp::notation true.
Show c = d || d = c. print c = d || d = c.
Show not p1 || p2. print not p1 || p2.
Show p1 && p3 || p2 && p3. print p1 && p3 || p2 && p3.
SetOption lean::pp::notation false. SetOption lean::pp::notation false.
Show not p1 || p2. print not p1 || p2.
Show p1 && p3 || p2 && p3. print p1 && p3 || p2 && p3.

View file

@ -3,14 +3,14 @@ Variable N : Type
Variable n1 : N Variable n1 : N
Variable n2 : N Variable n2 : N
SetOption lean::pp::implicit true SetOption lean::pp::implicit true
Show f n1 n2 print f n1 n2
Show f (fun x : N -> N, x) (fun y : _, y) print f (fun x : N -> N, x) (fun y : _, y)
Variable EqNice {A : Type} (lhs rhs : A) : Bool Variable EqNice {A : Type} (lhs rhs : A) : Bool
Infix 50 === : EqNice Infix 50 === : EqNice
Show n1 === n2 print n1 === n2
Check f n1 n2 Check f n1 n2
Check @Congr Check @Congr
Show f n1 n2 print f n1 n2
Variable a : N Variable a : N
Variable b : N Variable b : N
Variable c : N Variable c : N
@ -18,4 +18,4 @@ Variable g : N -> N
Axiom H1 : a = b && b = c Axiom H1 : a = b && b = c
Theorem Pr : (g a) = (g c) := Theorem Pr : (g a) = (g c) :=
Congr (Refl g) (Trans (Conjunct1 H1) (Conjunct2 H1)) Congr (Refl g) (Trans (Conjunct1 H1) (Conjunct2 H1))
Show Environment 2 print Environment 2

View file

@ -1,9 +1,9 @@
Variable N : Type Variable N : Type
Variable a : N Variable a : N
Variable b : N Variable b : N
Show a = b print a = b
Check a = b Check a = b
SetOption lean::pp::implicit true SetOption lean::pp::implicit true
Show a = b print a = b
Show (Type 1) = (Type 1) print (Type 1) = (Type 1)
Show true = false print true = false

View file

@ -6,11 +6,11 @@ Theorem CongrH {a1 a2 b1 b2 : N} (H1 : a1 = b1) (H2 : a2 = b2) : (h a1 a2) = (h
-- Display the theorem showing implicit arguments -- Display the theorem showing implicit arguments
SetOption lean::pp::implicit true SetOption lean::pp::implicit true
Show Environment 2 print Environment 2
-- Display the theorem hiding implicit arguments -- Display the theorem hiding implicit arguments
SetOption lean::pp::implicit false SetOption lean::pp::implicit false
Show Environment 2 print Environment 2
Theorem Example1 (a b c d : N) (H: (a = b ∧ b = c) (a = d ∧ d = c)) : (h a b) = (h c b) := Theorem Example1 (a b c d : N) (H: (a = b ∧ b = c) (a = d ∧ d = c)) : (h a b) = (h c b) :=
DisjCases H DisjCases H
@ -19,9 +19,9 @@ Theorem Example1 (a b c d : N) (H: (a = b ∧ b = c) (a = d ∧ d = c)) : (h
(fun H1 : a = d ∧ d = c, (fun H1 : a = d ∧ d = c,
CongrH (Trans (Conjunct1 H1) (Conjunct2 H1)) (Refl b)) CongrH (Trans (Conjunct1 H1) (Conjunct2 H1)) (Refl b))
-- Show proof of the last theorem with all implicit arguments -- print proof of the last theorem with all implicit arguments
SetOption lean::pp::implicit true SetOption lean::pp::implicit true
Show Environment 1 print Environment 1
-- Using placeholders to hide the type of H1 -- Using placeholders to hide the type of H1
Theorem Example2 (a b c d : N) (H: (a = b ∧ b = c) (a = d ∧ d = c)) : (h a b) = (h c b) := Theorem Example2 (a b c d : N) (H: (a = b ∧ b = c) (a = d ∧ d = c)) : (h a b) = (h c b) :=
@ -32,7 +32,7 @@ Theorem Example2 (a b c d : N) (H: (a = b ∧ b = c) (a = d ∧ d = c)) : (h
CongrH (Trans (Conjunct1 H1) (Conjunct2 H1)) (Refl b)) CongrH (Trans (Conjunct1 H1) (Conjunct2 H1)) (Refl b))
SetOption lean::pp::implicit true SetOption lean::pp::implicit true
Show Environment 1 print Environment 1
-- Same example but the first conjuct has unnecessary stuff -- Same example but the first conjuct has unnecessary stuff
Theorem Example3 (a b c d e : N) (H: (a = b ∧ b = e ∧ b = c) (a = d ∧ d = c)) : (h a b) = (h c b) := Theorem Example3 (a b c d e : N) (H: (a = b ∧ b = e ∧ b = c) (a = d ∧ d = c)) : (h a b) = (h c b) :=
@ -43,7 +43,7 @@ Theorem Example3 (a b c d e : N) (H: (a = b ∧ b = e ∧ b = c) (a = d ∧
CongrH (Trans (Conjunct1 H1) (Conjunct2 H1)) (Refl b)) CongrH (Trans (Conjunct1 H1) (Conjunct2 H1)) (Refl b))
SetOption lean::pp::implicit false SetOption lean::pp::implicit false
Show Environment 1 print Environment 1
Theorem Example4 (a b c d e : N) (H: (a = b ∧ b = e ∧ b = c) (a = d ∧ d = c)) : (h a c) = (h c a) := Theorem Example4 (a b c d e : N) (H: (a = b ∧ b = e ∧ b = c) (a = d ∧ d = c)) : (h a c) = (h c a) :=
DisjCases H DisjCases H
@ -55,4 +55,4 @@ Theorem Example4 (a b c d e : N) (H: (a = b ∧ b = e ∧ b = c) (a = d ∧
in CongrH AeqC (Symm AeqC)) in CongrH AeqC (Symm AeqC))
SetOption lean::pp::implicit false SetOption lean::pp::implicit false
Show Environment 1 print Environment 1

View file

@ -1,10 +1,10 @@
Variable f : Pi (A : Type), A -> Bool Variable f : Pi (A : Type), A -> Bool
Show fun (A B : Type) (a : _), f B a print fun (A B : Type) (a : _), f B a
-- The following one should produce an error -- The following one should produce an error
Show fun (A : Type) (a : _) (B : Type), f B a print fun (A : Type) (a : _) (B : Type), f B a
Variable myeq : Pi A : (Type U), A -> A -> Bool Variable myeq : Pi A : (Type U), A -> A -> Bool
Show myeq _ (fun (A : Type) (a : _), a) (fun (B : Type) (b : B), b) print myeq _ (fun (A : Type) (a : _), a) (fun (B : Type) (b : B), b)
Check myeq _ (fun (A : Type) (a : _), a) (fun (B : Type) (b : B), b) Check myeq _ (fun (A : Type) (a : _), a) (fun (B : Type) (b : B), b)

View file

@ -4,7 +4,7 @@
λ (A B : Type) (a : B), f B a λ (A B : Type) (a : B), f B a
Failed to solve Failed to solve
A : Type, a : ?M::0, B : Type ⊢ ?M::0[lift:0:2] ≺ B A : Type, a : ?M::0, B : Type ⊢ ?M::0[lift:0:2] ≺ B
(line: 4: pos: 41) Type of argument 2 must be convertible to the expected type in the application of (line: 4: pos: 42) Type of argument 2 must be convertible to the expected type in the application of
f f
with arguments: with arguments:
B B

Some files were not shown because too many files have changed in this diff Show more