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:
parent
ce1213a020
commit
9f08156a73
104 changed files with 306 additions and 316 deletions
|
@ -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
|
||||
-- expanding macros, and infering implicit/missing arguments.
|
||||
Show Environment 2.
|
||||
print Environment 2.
|
||||
|
||||
-- By default, Lean does not display implicit arguments.
|
||||
-- The following command will force it to display them.
|
||||
SetOption pp::implicit true.
|
||||
|
||||
Show Environment 2.
|
||||
print Environment 2.
|
||||
|
||||
-- As an exercise, prove that the sum of two odd numbers is even,
|
||||
-- and other similar theorems.
|
||||
|
|
|
@ -27,9 +27,9 @@ Theorem T2 : (h a (h a b)) = (h a (h c e)) :=
|
|||
CongrH (Refl a) T1
|
||||
|
||||
-- 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 pp::width 150
|
||||
Show Environment 2
|
||||
print Environment 2
|
||||
|
|
|
@ -8,7 +8,7 @@ Theorem simple (p q r : Bool) : (p ⇒ q) ∧ (q ⇒ r) ⇒ p ⇒ r
|
|||
in MP P_qr P_q.
|
||||
|
||||
SetOption pp::implicit true.
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
||||
Theorem simple2 (a b c : Bool) : (a ⇒ b ⇒ c) ⇒ (a ⇒ b) ⇒ a ⇒ c
|
||||
:= 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)
|
||||
in MP P_bc P_b.
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
|
|
@ -25,4 +25,4 @@ Theorem pierce (a b : Bool) : ((a ⇒ b) ⇒ a) ⇒ a
|
|||
(λ H_a, H_a)
|
||||
(λ H_na, NotImp1 (MT H H_na)).
|
||||
|
||||
Show Environment 3.
|
||||
print Environment 3.
|
|
@ -45,7 +45,7 @@ Push
|
|||
let L1 : R w x := Symmetry ! x ! w << H
|
||||
in Transitivity ! x ! w ! x << H << L1))
|
||||
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
Pop
|
||||
|
||||
Scope
|
||||
|
@ -70,4 +70,4 @@ Scope
|
|||
EndScope
|
||||
|
||||
-- Display the last two theorems
|
||||
Show Environment 2
|
||||
print Environment 2
|
|
@ -24,7 +24,7 @@ Theorem T1 (A B : Bool) : A /\ B -> B /\ A :=
|
|||
lemma2 : B := (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.
|
||||
-- Each hole must be filled with a tactic command sequence that terminates with the command 'done' and
|
||||
|
|
|
@ -68,5 +68,5 @@ Theorem T (a b : Bool) : a => b => a /\ b := _.
|
|||
(* Then(Repeat(OrElse(imp_tac(), conj_in_lua)), assumption_tac()) *)
|
||||
done
|
||||
|
||||
-- Show proof created using our script
|
||||
Show Environment 1.
|
||||
-- print proof created using our script
|
||||
print Environment 1.
|
||||
|
|
|
@ -32,21 +32,20 @@ static name g_theorem_kwd("Theorem");
|
|||
static name g_axiom_kwd("Axiom");
|
||||
static name g_universe_kwd("Universe");
|
||||
static name g_eval_kwd("Eval");
|
||||
static name g_show_kwd("Show");
|
||||
static name g_check_kwd("Check");
|
||||
static name g_infix_kwd("Infix");
|
||||
static name g_infixl_kwd("Infixl");
|
||||
static name g_infixr_kwd("Infixr");
|
||||
static name g_notation_kwd("Notation");
|
||||
static name g_echo_kwd("Echo");
|
||||
static name g_set_option_kwd("SetOption");
|
||||
static name g_set_opaque_kwd("SetOpaque");
|
||||
static name g_options_kwd("Options");
|
||||
static name g_env_kwd("Environment");
|
||||
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_exit_kwd("Exit");
|
||||
static name g_print_kwd("print");
|
||||
static name g_push_kwd("Push");
|
||||
static name g_pop_kwd("Pop");
|
||||
static name g_scope_kwd("Scope");
|
||||
|
@ -56,9 +55,9 @@ static name g_namespace_kwd("Namespace");
|
|||
static name g_end_namespace_kwd("EndNamespace");
|
||||
/** \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,
|
||||
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_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};
|
||||
// ==========================================
|
||||
|
||||
|
@ -278,12 +277,13 @@ bool parser_imp::is_hidden_object(object const & obj) const {
|
|||
}
|
||||
|
||||
/** \brief Parse
|
||||
'Show' expr
|
||||
'Show' Environment [num]
|
||||
'Show' Environment all
|
||||
'Show' Options
|
||||
'print' expr
|
||||
'print' Environment [num]
|
||||
'print' Environment all
|
||||
'print' Options
|
||||
'print' [string]
|
||||
*/
|
||||
void parser_imp::parse_show() {
|
||||
void parser_imp::parse_print() {
|
||||
next();
|
||||
if (curr() == scanner::token::CommandId) {
|
||||
name opt_id = curr_name();
|
||||
|
@ -337,6 +337,10 @@ void parser_imp::parse_show() {
|
|||
} else {
|
||||
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 {
|
||||
expr v = m_elaborator(parse_expr()).first;
|
||||
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] */
|
||||
void parser_imp::parse_set_option() {
|
||||
next();
|
||||
|
@ -615,12 +612,13 @@ void parser_imp::parse_help() {
|
|||
<< " Import [string] load the given file" << endl
|
||||
<< " Push create a scope (it is just an alias for the command 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
|
||||
<< " 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
|
||||
<< " 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;
|
||||
|
@ -766,8 +764,8 @@ bool parser_imp::parse_command() {
|
|||
parse_axiom();
|
||||
} else if (cmd_id == g_eval_kwd) {
|
||||
parse_eval();
|
||||
} else if (cmd_id == g_show_kwd) {
|
||||
parse_show();
|
||||
} else if (cmd_id == g_print_kwd) {
|
||||
parse_print();
|
||||
} else if (cmd_id == g_check_kwd) {
|
||||
parse_check();
|
||||
} else if (cmd_id == g_infix_kwd) {
|
||||
|
@ -778,8 +776,6 @@ bool parser_imp::parse_command() {
|
|||
parse_op(fixity::Infixr);
|
||||
} else if (cmd_id == g_notation_kwd) {
|
||||
parse_notation_decl();
|
||||
} else if (cmd_id == g_echo_kwd) {
|
||||
parse_echo();
|
||||
} else if (cmd_id == g_set_option_kwd) {
|
||||
parse_set_option();
|
||||
} else if (cmd_id == g_set_opaque_kwd) {
|
||||
|
|
|
@ -394,13 +394,12 @@ private:
|
|||
void parse_axiom();
|
||||
void parse_eval();
|
||||
bool is_hidden_object(object const & obj) const;
|
||||
void parse_show();
|
||||
void parse_print();
|
||||
void parse_check();
|
||||
unsigned parse_precedence();
|
||||
name parse_op_id();
|
||||
void parse_op(fixity fx);
|
||||
void parse_notation_decl();
|
||||
void parse_echo();
|
||||
void parse_set_option();
|
||||
void parse_set_opaque();
|
||||
optional<std::string> find_lua_file(std::string const & fname);
|
||||
|
|
|
@ -46,10 +46,10 @@ static void tst1() {
|
|||
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, "Eval true && true");
|
||||
parse(env, ios, "Show true && false Eval true && false");
|
||||
parse(env, ios, "Infixl 35 & : and Show true & false & false Eval true & false");
|
||||
parse(env, ios, "Notation 100 if _ then _ fi : implies Show if true then false fi");
|
||||
parse(env, ios, "Show Pi (A : Type), A -> A");
|
||||
parse(env, ios, "print true && 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 print if true then false fi");
|
||||
parse(env, ios, "print Pi (A : Type), A -> A");
|
||||
parse(env, ios, "Check Pi (A : Type), A -> A");
|
||||
}
|
||||
|
||||
|
@ -82,9 +82,9 @@ static void tst2() {
|
|||
|
||||
static void tst3() {
|
||||
environment env; io_state ios = init_test_frontend(env);
|
||||
parse(env, ios, "Help");
|
||||
parse(env, ios, "Help Options");
|
||||
parse_error(env, ios, "Help Echo");
|
||||
parse(env, ios, "help");
|
||||
parse(env, ios, "help Options");
|
||||
parse_error(env, ios, "help print");
|
||||
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 g : (Type 1) -> Type. Check g Type");
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
Alias BB : Bool.
|
||||
Variable x : BB.
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -2,15 +2,15 @@ Push
|
|||
Variable Natural : Type.
|
||||
Alias ℕℕ : Natural.
|
||||
Variable x : Natural.
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
SetOption pp::unicode false.
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
SetOption pp::unicode true.
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
Alias NN : Natural.
|
||||
Show Environment 2.
|
||||
print Environment 2.
|
||||
Alias ℕℕℕ : Natural.
|
||||
Show Environment 3.
|
||||
print Environment 3.
|
||||
SetOption pp::unicode false.
|
||||
Show Environment 3.
|
||||
print Environment 3.
|
||||
Pop
|
|
@ -22,4 +22,4 @@ Theorem T3 (a : Int) : (P a a) => (f a a).
|
|||
Repeat (OrElse (apply Discharge) exact (apply Ax2) (apply Ax1)).
|
||||
done.
|
||||
|
||||
Show Environment 2.
|
||||
print Environment 2.
|
|
@ -8,11 +8,11 @@ Check 15 + 10 - 20
|
|||
Variable x : Int
|
||||
Variable n : Nat
|
||||
Variable m : Nat
|
||||
Show n + m
|
||||
Show n + x + m
|
||||
print n + m
|
||||
print n + x + m
|
||||
SetOption lean::pp::coercion true
|
||||
Show n + x + m + 10
|
||||
Show x + n + m + 10
|
||||
Show n + m + 10 + x
|
||||
print n + x + m + 10
|
||||
print x + n + m + 10
|
||||
print n + m + 10 + x
|
||||
SetOption lean::pp::notation false
|
||||
Show n + m + 10 + x
|
||||
print n + m + 10 + x
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
Import Int.
|
||||
Import Real.
|
||||
Show 1/2
|
||||
print 1/2
|
||||
Eval 4/6
|
||||
Show 3 div 2
|
||||
print 3 div 2
|
||||
Variable x : Real
|
||||
Variable i : Int
|
||||
Variable n : Nat
|
||||
Show x + i + 1 + n
|
||||
print x + i + 1 + n
|
||||
SetOption lean::pp::coercion true
|
||||
Show x + i + 1 + n
|
||||
Show x * i + x
|
||||
Show x - i + x - x >= 0
|
||||
Show x < x
|
||||
Show x <= x
|
||||
Show x > x
|
||||
print x + i + 1 + n
|
||||
print x * i + x
|
||||
print x - i + x - x >= 0
|
||||
print x < x
|
||||
print x <= x
|
||||
print x > x
|
|
@ -3,8 +3,8 @@ Eval 8 mod 3
|
|||
Eval 8 div 4
|
||||
Eval 7 div 3
|
||||
Eval 7 mod 3
|
||||
Show -8 mod 3
|
||||
print -8 mod 3
|
||||
SetOption lean::pp::notation false
|
||||
Show -8 mod 3
|
||||
print -8 mod 3
|
||||
Eval -8 mod 3
|
||||
Eval (-8 div 3)*3 + (-8 mod 3)
|
|
@ -1,6 +1,6 @@
|
|||
Import Int.
|
||||
SetOption pp::unicode false
|
||||
Show 3 | 6
|
||||
print 3 | 6
|
||||
Eval 3 | 6
|
||||
Eval 3 | 7
|
||||
Eval 2 | 6
|
||||
|
@ -10,4 +10,4 @@ Eval x | 3
|
|||
Eval 3 | x
|
||||
Eval 6 | 3
|
||||
SetOption pp::notation false
|
||||
Show 3 | x
|
||||
print 3 | x
|
|
@ -10,7 +10,7 @@ Eval |x + 1|
|
|||
Eval |x + 1| > 0
|
||||
Variable y : Int
|
||||
Eval |x + y|
|
||||
Show |x + y| > x
|
||||
print |x + y| > x
|
||||
SetOption pp::notation false
|
||||
Show |x + y| > x
|
||||
Show |x + y| + |y + x| > x
|
||||
print |x + y| > x
|
||||
print |x + y| + |y + x| > x
|
|
@ -1,5 +1,5 @@
|
|||
Import Int.
|
||||
Show (Int -> Int) -> Int
|
||||
Show Int -> Int -> Int
|
||||
Show Int -> (Int -> Int)
|
||||
Show (Int -> Int) -> (Int -> Int) -> Int
|
||||
print (Int -> Int) -> Int
|
||||
print Int -> Int -> Int
|
||||
print Int -> (Int -> Int)
|
||||
print (Int -> Int) -> (Int -> Int) -> Int
|
||||
|
|
|
@ -5,4 +5,4 @@ Variable N : Type.
|
|||
Definition T (a : N) (f : _ -> _) (H : f a == a) : f (f _) == f _ :=
|
||||
SubstP (fun x : N, f (f a) == _) (Refl (f (f _))) H.
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
|
|
@ -10,4 +10,4 @@ Definition n5 : _ := cons 10 nil
|
|||
|
||||
SetOption pp::coercion true
|
||||
SetOption pp::implicit true
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -5,4 +5,4 @@ Variable b : Int
|
|||
Axiom H1 : a = b
|
||||
Axiom H2 : (g a) > 0
|
||||
Theorem T1 : (g b) > 0 := SubstP (λ x, (g x) > 0) H2 H1
|
||||
Show Environment 2
|
||||
print Environment 2
|
||||
|
|
|
@ -3,4 +3,4 @@ Variable f {A : Type} (a b : A) : Bool
|
|||
Variable a : Int
|
||||
Variable b : Real
|
||||
Definition tst : Bool := (fun x y, f x y) a b
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
|
|
|
@ -8,5 +8,5 @@ Variable a : A
|
|||
Check DomInj H
|
||||
Theorem BeqB' : B = B' := RanInj H a
|
||||
SetOption pp::implicit true
|
||||
Show DomInj H
|
||||
Show RanInj H a
|
||||
print DomInj H
|
||||
print RanInj H a
|
||||
|
|
|
@ -2,7 +2,7 @@ Variable T : Type
|
|||
Variable R : Type
|
||||
Variable f : T -> R
|
||||
Coercion f
|
||||
Show Environment 2
|
||||
print Environment 2
|
||||
Variable g : T -> R
|
||||
Coercion g
|
||||
Variable h : Pi (x : Type), x
|
||||
|
|
|
@ -4,14 +4,14 @@ Variable t2r : T -> R
|
|||
Coercion t2r
|
||||
Variable g : R -> R -> R
|
||||
Variable a : T
|
||||
Show g a a
|
||||
print g a a
|
||||
Variable b : R
|
||||
Show g a b
|
||||
Show g b a
|
||||
print g a b
|
||||
print g b a
|
||||
SetOption lean::pp::coercion true
|
||||
Show g a a
|
||||
Show g a b
|
||||
Show g b a
|
||||
print g a a
|
||||
print g a b
|
||||
print g b a
|
||||
SetOption lean::pp::coercion false
|
||||
Variable S : Type
|
||||
Variable s : S
|
||||
|
@ -20,13 +20,13 @@ Variable h : S -> S -> S
|
|||
Infixl 10 ++ : g
|
||||
Infixl 10 ++ : h
|
||||
SetOption lean::pp::notation false
|
||||
Show a ++ b ++ a
|
||||
Show r ++ s ++ r
|
||||
print a ++ b ++ a
|
||||
print r ++ s ++ r
|
||||
Check a ++ b ++ a
|
||||
Check r ++ s ++ r
|
||||
SetOption lean::pp::coercion true
|
||||
Show a ++ b ++ a
|
||||
Show r ++ s ++ r
|
||||
print a ++ b ++ a
|
||||
print r ++ s ++ r
|
||||
SetOption lean::pp::notation true
|
||||
Show a ++ b ++ a
|
||||
Show r ++ s ++ r
|
||||
print a ++ b ++ a
|
||||
print r ++ s ++ r
|
||||
|
|
|
@ -2,4 +2,4 @@ Import specialfn.
|
|||
Definition f x y := x + y
|
||||
Definition g x y := sin x + y
|
||||
Definition h x y := x * sin (x + y)
|
||||
Show Environment 3
|
||||
print Environment 3
|
|
@ -18,4 +18,4 @@ Theorem T2 (a b : Bool) : a \/ b => b \/ a.
|
|||
simple_tac.
|
||||
done.
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
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'
|
||||
|
@ -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
|
||||
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
|
||||
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),
|
||||
|
@ -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 : _),
|
||||
R _ _ _ _ H a
|
||||
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
|
|
|
@ -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
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -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
|
||||
|
||||
SetOption pp::implicit true
|
||||
Show Environment 7.
|
||||
print Environment 7.
|
||||
|
|
|
@ -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
|
||||
|
||||
SetOption pp::implicit true
|
||||
Show Environment 7.
|
||||
print Environment 7.
|
||||
|
|
|
@ -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 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)))
|
||||
Show Environment 4
|
||||
print Environment 4
|
||||
SetOption pp::implicit true
|
||||
Show Environment 4
|
||||
print Environment 4
|
|
@ -1,5 +1,5 @@
|
|||
Eval fun x, x
|
||||
Show fun x, x
|
||||
print fun x, x
|
||||
|
||||
Check fun x, x
|
||||
Theorem T (A : Type) (x : A) : Pi (y : A), A
|
||||
|
|
|
@ -1 +1 @@
|
|||
Echo "test"
|
||||
print "test"
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
-- comment
|
||||
Show true
|
||||
print true
|
||||
SetOption lean::pp::notation false
|
||||
Show true && false
|
||||
print true && false
|
||||
SetOption pp::unicode false
|
||||
Show true && false
|
||||
print true && false
|
||||
Variable a : Bool
|
||||
Variable a : Bool
|
||||
Variable b : Bool
|
||||
Show a && b
|
||||
print a && b
|
||||
Variable A : Type
|
||||
Check a && A
|
||||
Show Environment 1
|
||||
Show Options
|
||||
print Environment 1
|
||||
print Options
|
||||
SetOption lean::p::notation true
|
||||
SetOption lean::pp::notation 10
|
||||
SetOption lean::pp::notation true
|
||||
Show a && b
|
||||
print a && b
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Variable myeq : Pi (A : Type), A -> A -> Bool
|
||||
Show myeq _ true false
|
||||
print myeq _ true false
|
||||
Variable T : Type
|
||||
Variable a : T
|
||||
Check myeq _ true a
|
||||
|
|
|
@ -3,4 +3,4 @@ Variable a : Int
|
|||
Variable P : Int -> Int -> Bool
|
||||
Axiom H : P a a
|
||||
Theorem T : exists x : Int, P a a := ExistsIntro a H.
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -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 T8 : exists x y : Int, P (f x x) y := ExistsIntro _ (ExistsIntro _ H3)
|
||||
|
||||
Show Environment 8.
|
||||
print Environment 8.
|
|
@ -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))
|
||||
|
||||
Show Environment 4
|
||||
print Environment 4
|
|
@ -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))
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
|
|
@ -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))
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Exit
|
||||
Show "FAILED"
|
||||
print "FAILED"
|
||||
|
|
|
@ -5,4 +5,4 @@ Variable b : Int
|
|||
Axiom H1 : a = b
|
||||
Axiom H2 : (g a) > 0
|
||||
Theorem T1 : (g b) > 0 := Subst H2 H1
|
||||
Show Environment 2
|
||||
print Environment 2
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
Import Int.
|
||||
Import Real.
|
||||
Variable f : Int -> Int -> Int
|
||||
Show forall a, f a a > 0
|
||||
Show forall a b, f a b > 0
|
||||
print forall a, f a a > 0
|
||||
print forall a b, f a b > 0
|
||||
Variable g : Int -> Real -> Int
|
||||
Show forall a b, g a b > 0
|
||||
Show forall a b, g a (f a b) > 0
|
||||
print forall a b, g a b > 0
|
||||
print forall a b, g a (f a b) > 0
|
||||
SetOption pp::coercion true
|
||||
Show forall a b, g a (f a b) > 0
|
||||
Show fun a, a + 1
|
||||
Show fun a b, a + b
|
||||
Show fun (a b) (c : Int), a + c + b
|
||||
print forall a b, g a (f a b) > 0
|
||||
print fun a, a + 1
|
||||
print fun a b, a + b
|
||||
print fun (a b) (c : Int), a + c + b
|
||||
-- The next example shows a limitation of the current elaborator.
|
||||
-- The current elaborator resolves overloads before solving the implicit argument constraints.
|
||||
-- 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
|
||||
-- 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
|
|
@ -1,11 +1,11 @@
|
|||
Import Int.
|
||||
|
||||
Show 10 = 20
|
||||
print 10 = 20
|
||||
Variable f : Int -> Int -> Int
|
||||
Variable g : Int -> Int -> Int -> Int
|
||||
Notation 10 _ ++ _ : f
|
||||
Notation 10 _ ++ _ : g
|
||||
SetOption pp::implicit true
|
||||
SetOption pp::notation false
|
||||
Show (10 ++ 20)
|
||||
Show (10 ++ 20) 10
|
||||
print (10 ++ 20)
|
||||
print (10 ++ 20) 10
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
Import Int.
|
||||
Variable f {A : Type} : A -> A -> A
|
||||
Infixl 65 + : f
|
||||
Show true + false
|
||||
Show 10 + 20
|
||||
Show 10 + (- 20)
|
||||
print true + false
|
||||
print 10 + 20
|
||||
print 10 + (- 20)
|
||||
SetOption pp::notation false
|
||||
SetOption pp::coercion true
|
||||
Show true + false
|
||||
Show 10 + 20
|
||||
Show 10 + (- 20)
|
||||
print true + false
|
||||
print 10 + 20
|
||||
print 10 + (- 20)
|
||||
|
|
|
@ -12,4 +12,4 @@ Theorem T2 (A B : Bool) : A /\ B => B /\ A :=
|
|||
simple2_tac. done.
|
||||
simple_tac. done.
|
||||
|
||||
Echo "echo command after failure"
|
||||
print "echo command after failure"
|
|
@ -10,7 +10,7 @@ Theorem T1 (A B : Bool) : A /\ B -> B /\ A :=
|
|||
lemma2 : B := (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 :=
|
||||
fun assumption : A /\ B,
|
||||
|
|
|
@ -9,4 +9,4 @@ Theorem T1 (A B : Bool) : A /\ B -> B /\ A :=
|
|||
lemma2 := (show B by auto)
|
||||
in (show B /\ A by auto)
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
|
|
@ -6,4 +6,4 @@ foo.
|
|||
abort.
|
||||
|
||||
Variables a b : Bool.
|
||||
Show Environment 2.
|
||||
print Environment 2.
|
||||
|
|
|
@ -8,4 +8,4 @@ back.
|
|||
exact.
|
||||
done.
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -1,2 +1,2 @@
|
|||
Theorem (a : Bool) : a.
|
||||
Echo "done".
|
||||
print "done".
|
|
@ -5,4 +5,4 @@ Theorem T (a : Bool) : a.
|
|||
apply magic.
|
||||
done.
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -1,12 +1,10 @@
|
|||
Import Int.
|
||||
|
||||
Show 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 := 10, b : Nat := 20, c : Nat := 30, d : Nat := 10 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
|
||||
Eval let a : Nat := 20 in a + 10
|
||||
Eval let a := 20 in a + 10
|
||||
Check let a : Int := 20 in a + 10
|
||||
SetOption pp::coercion true
|
||||
Show let a : Int := 20 in a + 10
|
||||
|
||||
|
||||
print let a : Int := 20 in a + 10
|
||||
|
|
|
@ -7,4 +7,4 @@ Theorem simple (p q r : Bool) : (p ⇒ q) ∧ (q ⇒ r) ⇒ p ⇒ r :=
|
|||
P_q : q := MP P_pq H_p
|
||||
in MP P_qr P_q))
|
||||
|
||||
Show Environment 1
|
||||
print Environment 1
|
|
@ -4,6 +4,6 @@ Variable magic : Pi (H : Bool), H
|
|||
|
||||
SetOption pp::notation false
|
||||
SetOption pp::coercion true
|
||||
Show let a : Int := 1,
|
||||
print let a : Int := 1,
|
||||
H : a > 0 := magic (a > 0)
|
||||
in H
|
|
@ -1,6 +1,6 @@
|
|||
Import Int.
|
||||
|
||||
Show
|
||||
print
|
||||
let b := true,
|
||||
a : Int := b
|
||||
in a
|
||||
|
@ -14,7 +14,7 @@ let a := 10,
|
|||
v2 := v1
|
||||
in v2
|
||||
|
||||
Show
|
||||
print
|
||||
let a := 10,
|
||||
v1 : vector Bool a := const a true,
|
||||
v2 : vector Bool a := v1
|
||||
|
@ -43,10 +43,8 @@ in v2
|
|||
|
||||
SetOption pp::coercion true
|
||||
|
||||
Show
|
||||
print
|
||||
let a := 10,
|
||||
v1 : vector Bool a := const a true,
|
||||
v2 : vector Int a := v1
|
||||
in v2
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Import Int.
|
||||
Variables a b : Int
|
||||
Show Options
|
||||
print Options
|
||||
(*
|
||||
local ios = io_state()
|
||||
|
||||
|
@ -10,5 +10,5 @@ Show Options
|
|||
print(parse_lean("fun x, a + x"))
|
||||
print(get_options())
|
||||
*)
|
||||
Show Options
|
||||
Show Environment 2
|
||||
print Options
|
||||
print Environment 2
|
|
@ -18,8 +18,8 @@ macro("Sum", { macro_arg.Exprs },
|
|||
end)
|
||||
*)
|
||||
|
||||
Show (MyMacro 10, 20) + 20
|
||||
Show (Sum)
|
||||
Show Sum 10 20 30 40
|
||||
Show fun x, Sum x 10 x 20
|
||||
print (MyMacro 10, 20) + 20
|
||||
print (Sum)
|
||||
print Sum 10 20 30 40
|
||||
print fun x, Sum x 10 x 20
|
||||
Eval (fun x, Sum x 10 x 20) 100
|
||||
|
|
|
@ -11,5 +11,5 @@ for i = 1, N do
|
|||
end
|
||||
*)
|
||||
|
||||
Show Environment 101
|
||||
print Environment 101
|
||||
Check x + y_1 + y_2
|
|
@ -33,6 +33,6 @@ Variable x : Bool
|
|||
env:add_definition("sum1", s)
|
||||
*)
|
||||
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
Eval sum1
|
||||
Variable y : Bool
|
||||
|
|
|
@ -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 V1 : vector Int 10
|
||||
Definition D := read V1 1 (by trivial)
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
Variable b : Bool
|
||||
Definition a := b
|
||||
Theorem T : b => a := (by (* imp_tac() .. normalize_tac() .. assumption_tac() *))
|
||||
|
|
|
@ -3,10 +3,10 @@ Variable f : Bool -> Bool -> Bool
|
|||
Variable g : N -> N -> N
|
||||
Infixl 10 ++ : f
|
||||
Infixl 10 ++ : g
|
||||
Show true ++ false ++ true
|
||||
print true ++ false ++ true
|
||||
SetOption lean::pp::notation false
|
||||
Show true ++ false ++ true
|
||||
print true ++ false ++ true
|
||||
Variable a : N
|
||||
Variable b : N
|
||||
Show a ++ b ++ a
|
||||
Show true ++ false ++ false
|
||||
print a ++ b ++ a
|
||||
print true ++ false ++ false
|
|
@ -1,6 +1,6 @@
|
|||
Import Int
|
||||
Import Real
|
||||
Show 1 + true
|
||||
print 1 + true
|
||||
Variable R : Type
|
||||
Variable T : Type
|
||||
Variable r2t : R -> T
|
||||
|
@ -12,10 +12,10 @@ Variable a : T
|
|||
Variable b : R
|
||||
SetOption lean::pp::coercion true
|
||||
SetOption lean::pp::notation false
|
||||
Show f a b
|
||||
Show f b a
|
||||
print f a b
|
||||
print f b a
|
||||
Variable g : R -> T -> R
|
||||
Infix 10 ++ : f
|
||||
Infix 10 ++ : g
|
||||
Show a ++ b
|
||||
Show b ++ a
|
||||
print a ++ b
|
||||
print b ++ a
|
||||
|
|
|
@ -4,25 +4,25 @@
|
|||
Imported 'Real'
|
||||
Failed to solve
|
||||
⊢ (?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 ⊤
|
||||
Failed to solve
|
||||
⊢ 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
|
||||
with arguments:
|
||||
1
|
||||
⊤
|
||||
Failed to solve
|
||||
⊢ 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
|
||||
with arguments:
|
||||
1
|
||||
⊤
|
||||
Failed to solve
|
||||
⊢ 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
|
||||
with arguments:
|
||||
1
|
||||
|
|
|
@ -3,4 +3,4 @@ Theorem T (C A B : Bool) : C -> A -> B -> A.
|
|||
exact.
|
||||
done.
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -10,7 +10,7 @@ Pop
|
|||
|
||||
Eval f a -- should produce an error
|
||||
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
|
||||
Push
|
||||
Infixl 100 ++ : Int::add
|
||||
|
|
|
@ -23,5 +23,5 @@ Scope
|
|||
in Trans L5 L3.
|
||||
EndScope
|
||||
|
||||
Show Environment 3.
|
||||
print Environment 3.
|
||||
Eval g Int Int::sub 10 20
|
|
@ -1,3 +1,3 @@
|
|||
SetOption pp::colors false
|
||||
Echo "===BEGIN ENVIRONMENT==="
|
||||
Show Environment
|
||||
print "===BEGIN ENVIRONMENT==="
|
||||
print Environment
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Import Int.
|
||||
Variables a b c : Int.
|
||||
Show a + b + c.
|
||||
print a + b + c.
|
||||
Check a + b.
|
||||
Exit.
|
||||
-- the following line should be executed
|
||||
|
|
|
@ -7,4 +7,4 @@ Theorem T : a + n + a = 10 := Subst H1 H2
|
|||
SetOption pp::coercion true
|
||||
SetOption pp::notation false
|
||||
SetOption pp::implicit true
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
|
|
@ -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)
|
||||
done.
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -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),
|
||||
Subst' H1 H2 H3.
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -8,4 +8,4 @@ Variables p q r : Bool
|
|||
env:add_theorem("T1", conjecture, proof)
|
||||
*)
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
|
|
@ -21,4 +21,4 @@ Theorem T2 (a b : Bool) : (h a b) => (f b) => a := _.
|
|||
simple_tac
|
||||
done.
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
|
|
@ -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.
|
||||
done.
|
||||
|
||||
Show Environment 2.
|
||||
print Environment 2.
|
|
@ -10,4 +10,4 @@ Theorem T1 (a b : Int) (f : Int -> Int) : a = b -> (f (f a)) = (f (f b)) :=
|
|||
fun assumption : a = b,
|
||||
show (f (f a)) = (f (f b)) by congr_tac
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
|
|
|
@ -21,18 +21,18 @@ Theorem T2 : p => q => p /\ q /\ p := _.
|
|||
simple_tac
|
||||
done
|
||||
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
|
||||
Theorem T3 : p => p /\ q => r => q /\ r /\ p := _.
|
||||
(* Repeat(OrElse(imp_tac(), conj_tac(), conj_hyp_tac(), assumption_tac())) *)
|
||||
done
|
||||
|
||||
-- Display proof term generated by previous tac
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
|
||||
Theorem T4 : p => p /\ q => r => q /\ r /\ p := _.
|
||||
Repeat (OrElse (apply Discharge) (apply Conj) conj_hyp exact)
|
||||
done
|
||||
|
||||
-- Display proof term generated by previous tac --
|
||||
Show Environment 1
|
||||
print Environment 1
|
|
@ -6,4 +6,4 @@ Theorem T1 : p => p /\ q => r => q /\ r /\ p := _.
|
|||
done
|
||||
|
||||
-- Display proof term generated by previous tactic
|
||||
Show Environment 1
|
||||
print Environment 1
|
|
@ -6,4 +6,4 @@ Theorem T4 (a b : Bool) : a => b => a /\ b := _.
|
|||
simple_tac
|
||||
done
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -6,4 +6,4 @@ Theorem T4 (a b : Bool) : a => b => a /\ b /\ a := _.
|
|||
simple_tac
|
||||
done
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -6,4 +6,4 @@ Theorem T (a b : Bool) : a \/ b => (not b) => a := _.
|
|||
exact
|
||||
absurd
|
||||
done
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -10,4 +10,4 @@ Theorem T (a b : Bool) : a \/ b => (f b) => a := _.
|
|||
absurd
|
||||
done
|
||||
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
|
@ -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 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)
|
||||
Show Environment 10
|
||||
print Environment 10
|
||||
Check 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
|
||||
Echo "\n--------"
|
||||
print "\n--------"
|
||||
Check @select
|
||||
Echo "\nmap type ---> "
|
||||
print "\nmap type ---> "
|
||||
Check @map
|
||||
Echo "\nmap normal form --> "
|
||||
print "\nmap normal form --> "
|
||||
Eval @map
|
||||
Echo "\nupdate normal form --> "
|
||||
print "\nupdate normal form --> "
|
||||
Eval @update
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
Variable a : Bool
|
||||
Variable b : Bool
|
||||
-- Conjunctions
|
||||
Show a && b
|
||||
Show a && b && a
|
||||
Show a /\ b
|
||||
Show a ∧ b
|
||||
Show (and a b)
|
||||
Show and a b
|
||||
print a && b
|
||||
print a && b && a
|
||||
print a /\ b
|
||||
print a ∧ b
|
||||
print (and a b)
|
||||
print and a b
|
||||
-- Disjunctions
|
||||
Show a || b
|
||||
Show a \/ b
|
||||
Show a ∨ b
|
||||
Show (or a b)
|
||||
Show or a (or a b)
|
||||
print a || b
|
||||
print a \/ b
|
||||
print a ∨ b
|
||||
print (or a b)
|
||||
print or a (or a b)
|
||||
-- Simple Formulas
|
||||
Show a => b => a
|
||||
print a => b => a
|
||||
Check a => b
|
||||
Eval a => a
|
||||
Eval true => a
|
||||
|
@ -22,5 +22,5 @@ Eval true => a
|
|||
Axiom H1 : a
|
||||
Axiom H2 : a => b
|
||||
Check @MP
|
||||
Show MP H2 H1
|
||||
print MP H2 H1
|
||||
Check MP H2 H1
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
Definition xor (x y : Bool) : Bool := (not x) = y
|
||||
Infixr 50 ⊕ : xor
|
||||
Show xor true false
|
||||
print xor true false
|
||||
Eval xor true true
|
||||
Eval xor true false
|
||||
Variable a : Bool
|
||||
Show a ⊕ a ⊕ a
|
||||
print a ⊕ a ⊕ a
|
||||
Check @Subst
|
||||
Theorem EM2 (a : Bool) : a \/ (not a) :=
|
||||
Case (fun x : Bool, x \/ (not x)) Trivial Trivial a
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Show (fun x : Bool, (fun y : Bool, x /\ y))
|
||||
Show let x := true,
|
||||
print (fun x : Bool, (fun y : Bool, x /\ y))
|
||||
print let x := true,
|
||||
y := true
|
||||
in (let z := x /\ y,
|
||||
f := (fun arg1 arg2 : Bool, arg1 /\ arg2 <=>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Show fun x : Bool, (fun x : Bool, x).
|
||||
Show let x := true,
|
||||
print fun x : Bool, (fun x : Bool, x).
|
||||
print let x := true,
|
||||
y := true
|
||||
in (let z := x /\ y,
|
||||
f := (fun x y : Bool, x /\ y <=>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Import Int.
|
||||
Show Int -> Int -> Int
|
||||
print Int -> Int -> Int
|
||||
Variable f : Int -> Int -> Int
|
||||
Eval f 0
|
||||
Check f 0
|
||||
|
|
|
@ -6,15 +6,15 @@ Check f x
|
|||
Check (Type 4)
|
||||
Check x
|
||||
Check (Type max U M)
|
||||
Show (Type U+3)
|
||||
print (Type U+3)
|
||||
Check (Type U+3)
|
||||
Check (Type U ⊔ M)
|
||||
Check (Type U ⊔ M ⊔ 3)
|
||||
Show (Type U+1 ⊔ M ⊔ 3)
|
||||
print (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 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)
|
||||
Show (Type U)
|
||||
print (Type U)
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
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
|
||||
Show 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))
|
||||
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))
|
||||
print exists (a b : Type) (c : Bool), g c ((f a) = (f b))
|
||||
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))
|
||||
Show ∀ (a b : Type) (c : Bool), g c ((f a) = (f b))
|
||||
Show ∀ a b : Type, (f a) = (f b)
|
||||
Show ∃ a b : Type, (f a) = (f b) ∧ (f a)
|
||||
Show ∃ a b : Type, (f a) = (f b) ∨ (f b)
|
||||
print ∀ (a b : Type) (c : Bool), g c ((f a) = (f b))
|
||||
print ∀ a b : Type, (f a) = (f b)
|
||||
print ∃ a b : Type, (f a) = (f b) ∧ (f a)
|
||||
print ∃ a b : Type, (f a) = (f b) ∨ (f b)
|
||||
Variable a : Bool
|
||||
Show (f a) ∨ (f a)
|
||||
Show (f a) = a ∨ (f a)
|
||||
Show (f a) = a ∧ (f a)
|
||||
print (f a) ∨ (f a)
|
||||
print (f a) = a ∨ (f a)
|
||||
print (f a) = a ∧ (f a)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Variable f : 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)
|
||||
Eval forall (a b : Type), exists (c : Type), (g a b) = (f c)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
Show Options
|
||||
print Options
|
||||
Variable a : Bool
|
||||
Variable b : Bool
|
||||
Show a/\b
|
||||
print a/\b
|
||||
SetOption lean::pp::notation false
|
||||
Show Options
|
||||
Show a/\b
|
||||
Show Environment 2
|
||||
print Options
|
||||
print a/\b
|
||||
print Environment 2
|
||||
SetOption lean::pp::notation true
|
||||
Show Options
|
||||
Show a/\b
|
||||
print Options
|
||||
print a/\b
|
||||
|
|
|
@ -1,58 +1,58 @@
|
|||
SetOption lean::parser::verbose false.
|
||||
Notation 10 if _ then _ : implies.
|
||||
Show Environment 1.
|
||||
Show if true then false.
|
||||
print Environment 1.
|
||||
print if true then false.
|
||||
Variable a : Bool.
|
||||
Show if true then if a then false.
|
||||
print if true then if a then 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 f : A -> A -> A -> Bool.
|
||||
Notation 100 _ |- _ ; _ : f.
|
||||
Show Environment 1.
|
||||
print Environment 1.
|
||||
Variable c : A.
|
||||
Variable d : A.
|
||||
Variable e : A.
|
||||
Show c |- d ; e.
|
||||
print c |- d ; e.
|
||||
SetOption lean::pp::notation true.
|
||||
Show c |- d ; e.
|
||||
print c |- d ; e.
|
||||
Variable fact : A -> A.
|
||||
Notation 20 _ ! : fact.
|
||||
Show c! !.
|
||||
print c! !.
|
||||
SetOption lean::pp::notation false.
|
||||
Show c! !.
|
||||
print c! !.
|
||||
SetOption lean::pp::notation true.
|
||||
Variable g : A -> A -> A.
|
||||
Notation 30 [ _ ; _ ] : g
|
||||
Show [c;d].
|
||||
Show [c ; [d;e] ].
|
||||
print [c;d].
|
||||
print [c ; [d;e] ].
|
||||
SetOption lean::pp::notation false.
|
||||
Show [c ; [d;e] ].
|
||||
print [c ; [d;e] ].
|
||||
SetOption lean::pp::notation true.
|
||||
Variable h : A -> A -> A.
|
||||
Notation 40 _ << _ end : h.
|
||||
Show Environment 1.
|
||||
Show d << e end.
|
||||
Show [c ; d << e end ].
|
||||
print Environment 1.
|
||||
print d << e end.
|
||||
print [c ; d << e end ].
|
||||
SetOption lean::pp::notation false.
|
||||
Show [c ; d << e end ].
|
||||
print [c ; d << e end ].
|
||||
SetOption lean::pp::notation true.
|
||||
Variable r : A -> A -> A.
|
||||
Infixl 30 ++ : r.
|
||||
Variable s : A -> A -> A.
|
||||
Infixl 40 ** : s.
|
||||
Show c ** d ++ e ** c.
|
||||
print c ** d ++ e ** c.
|
||||
Variable p1 : Bool.
|
||||
Variable p2 : Bool.
|
||||
Variable p3 : Bool.
|
||||
Show p1 || p2 && p3.
|
||||
print p1 || p2 && p3.
|
||||
SetOption lean::pp::notation false.
|
||||
Show c ** d ++ e ** c.
|
||||
Show p1 || p2 && p3.
|
||||
print c ** d ++ e ** c.
|
||||
print p1 || p2 && p3.
|
||||
SetOption lean::pp::notation true.
|
||||
Show c = d || d = c.
|
||||
Show not p1 || p2.
|
||||
Show p1 && p3 || p2 && p3.
|
||||
print c = d || d = c.
|
||||
print not p1 || p2.
|
||||
print p1 && p3 || p2 && p3.
|
||||
SetOption lean::pp::notation false.
|
||||
Show not p1 || p2.
|
||||
Show p1 && p3 || p2 && p3.
|
||||
print not p1 || p2.
|
||||
print p1 && p3 || p2 && p3.
|
||||
|
|
|
@ -3,14 +3,14 @@ Variable N : Type
|
|||
Variable n1 : N
|
||||
Variable n2 : N
|
||||
SetOption lean::pp::implicit true
|
||||
Show f n1 n2
|
||||
Show f (fun x : N -> N, x) (fun y : _, y)
|
||||
print f n1 n2
|
||||
print f (fun x : N -> N, x) (fun y : _, y)
|
||||
Variable EqNice {A : Type} (lhs rhs : A) : Bool
|
||||
Infix 50 === : EqNice
|
||||
Show n1 === n2
|
||||
print n1 === n2
|
||||
Check f n1 n2
|
||||
Check @Congr
|
||||
Show f n1 n2
|
||||
print f n1 n2
|
||||
Variable a : N
|
||||
Variable b : N
|
||||
Variable c : N
|
||||
|
@ -18,4 +18,4 @@ Variable g : N -> N
|
|||
Axiom H1 : a = b && b = c
|
||||
Theorem Pr : (g a) = (g c) :=
|
||||
Congr (Refl g) (Trans (Conjunct1 H1) (Conjunct2 H1))
|
||||
Show Environment 2
|
||||
print Environment 2
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
Variable N : Type
|
||||
Variable a : N
|
||||
Variable b : N
|
||||
Show a = b
|
||||
print a = b
|
||||
Check a = b
|
||||
SetOption lean::pp::implicit true
|
||||
Show a = b
|
||||
Show (Type 1) = (Type 1)
|
||||
Show true = false
|
||||
print a = b
|
||||
print (Type 1) = (Type 1)
|
||||
print true = false
|
||||
|
|
|
@ -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
|
||||
SetOption lean::pp::implicit true
|
||||
Show Environment 2
|
||||
print Environment 2
|
||||
|
||||
-- Display the theorem hiding implicit arguments
|
||||
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) :=
|
||||
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,
|
||||
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
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
|
||||
-- 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) :=
|
||||
|
@ -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))
|
||||
|
||||
SetOption lean::pp::implicit true
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
|
||||
-- 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) :=
|
||||
|
@ -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))
|
||||
|
||||
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) :=
|
||||
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))
|
||||
|
||||
SetOption lean::pp::implicit false
|
||||
Show Environment 1
|
||||
print Environment 1
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
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
|
||||
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
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
λ (A B : Type) (a : B), f B a
|
||||
Failed to solve
|
||||
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
|
||||
with arguments:
|
||||
B
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue