refactor(builtin): only load the kernel and natural numbers by default

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-12-30 13:35:37 -08:00
parent a017801983
commit 08718e33dc
168 changed files with 362 additions and 357 deletions

View file

@ -1,4 +1,5 @@
Import tactic
Import int
Definition a : Nat := 10
(* Trivial indicates a "proof by evaluation" *)
Theorem T1 : a > 0 := (by trivial)

View file

@ -68,9 +68,9 @@ endfunction()
add_kernel_theory("kernel.lean" "${CMAKE_CURRENT_BINARY_DIR}/macros.lua")
add_kernel_theory("nat.lean" "${CMAKE_CURRENT_BINARY_DIR}/kernel.olean")
add_kernel_theory("int.lean" "${CMAKE_CURRENT_BINARY_DIR}/nat.olean")
add_kernel_theory("real.lean" "${CMAKE_CURRENT_BINARY_DIR}/int.olean")
add_theory("int.lean" "${CMAKE_CURRENT_BINARY_DIR}/nat.olean")
add_theory("real.lean" "${CMAKE_CURRENT_BINARY_DIR}/int.olean")
add_theory("specialfn.lean" "${CMAKE_CURRENT_BINARY_DIR}/real.olean")
add_theory("cast.lean" "${CMAKE_CURRENT_BINARY_DIR}/kernel.olean")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -21,7 +21,9 @@ Author: Leonardo de Moura
#include "kernel/io_state.h"
#include "library/expr_pair.h"
#include "library/expr_pair_maps.h"
#include "library/all/all.h"
#include "library/arith/nat.h"
#include "library/arith/int.h"
#include "library/arith/real.h"
#include "frontends/lean/operator_info.h"
#include "frontends/lean/coercion.h"
#include "frontends/lean/frontend.h"
@ -554,17 +556,21 @@ static lean_extension & to_ext(environment const & env) {
return env->get_extension<lean_extension>(g_lean_extension_initializer.m_extid);
}
/**
\brief Import all definitions and notation.
*/
void init_frontend(environment const & env, io_state & ios, bool no_kernel) {
ios.set_formatter(mk_pp_formatter(env));
if (!no_kernel)
import_all(env);
if (!no_kernel) {
import_kernel(env);
import_nat(env);
}
}
void init_frontend(environment const & env) {
io_state ios;
void init_full_frontend(environment const & env, io_state & ios) {
init_frontend(env, ios);
import_int(env);
import_real(env);
}
void init_full_frontend(environment const & env) {
io_state ios;
init_full_frontend(env, ios);
}
void add_infix(environment const & env, io_state const & ios, name const & opn, unsigned p, expr const & d) {

View file

@ -14,10 +14,16 @@ Author: Leonardo de Moura
namespace lean {
/**
\brief Import all definitions and notation.
\brief Load kernel, nat and set pretty printer.
*/
void init_frontend(environment const & env, io_state & ios, bool no_kernel = false);
void init_frontend(environment const & env);
/*
\brief Load kernel, nat, int, real and set pretty printer.
It is used for testing.
*/
void init_full_frontend(environment const & env, io_state & ios);
void init_full_frontend(environment const & env);
/**
@name Notation for parsing and pretty printing.

View file

@ -1139,6 +1139,24 @@ static int environment_is_opaque(lua_State * L) {
return 1;
}
static int environment_import(lua_State * L) {
rw_shared_environment env(L, 1);
int nargs = lua_gettop(L);
if (nargs == 3) {
env->import(luaL_checkstring(L, 2), to_io_state(L, 3));
} else {
io_state * ios = get_io_state(L);
if (ios) {
env->import(luaL_checkstring(L, 2), *ios);
} else {
io_state ios;
ios.set_options(get_global_options(L));
env->import(luaL_checkstring(L, 2), ios);
}
}
return 0;
}
static const struct luaL_Reg environment_m[] = {
{"__gc", environment_gc}, // never throws
{"__tostring", safe_function<environment_tostring>},
@ -1162,6 +1180,7 @@ static const struct luaL_Reg environment_m[] = {
{"local_objects", safe_function<environment_local_objects>},
{"set_opaque", safe_function<environment_set_opaque>},
{"is_opaque", safe_function<environment_is_opaque>},
{"import", safe_function<environment_import>},
{0, 0}
};

View file

@ -42,7 +42,7 @@ static void parse_error(environment const & env, io_state const & ios, char cons
}
static void tst1() {
environment env; io_state ios; init_frontend(env, ios);
environment env; io_state ios; init_full_frontend(env, ios);
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");
@ -63,7 +63,7 @@ static void check(environment const & env, io_state & ios, char const * str, exp
}
static void tst2() {
environment env; io_state ios; init_frontend(env, ios);
environment env; io_state ios; init_full_frontend(env, ios);
env->add_var("x", Bool);
env->add_var("y", Bool);
env->add_var("z", Bool);
@ -80,7 +80,7 @@ static void tst2() {
}
static void tst3() {
environment env; io_state ios; init_frontend(env, ios);
environment env; io_state ios; init_full_frontend(env, ios);
parse(env, ios, "Help");
parse(env, ios, "Help Options");
parse_error(env, ios, "Help Echo");

View file

@ -63,7 +63,7 @@ static void tst2() {
static void tst3() {
std::cout << "tst3\n";
environment env; init_frontend(env);
environment env; init_full_frontend(env);
try {
env->add_definition("a", Int, Const("a"));
lean_unreachable();
@ -108,7 +108,7 @@ static void tst3() {
static void tst4() {
std::cout << "tst4\n";
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_definition("a", Int, iVal(1), true); // add opaque definition
expr t = iAdd(Const("a"), iVal(1));
std::cout << t << " --> " << normalize(t, env) << "\n";
@ -121,7 +121,7 @@ static void tst4() {
}
static void tst5() {
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_definition("a", Int, iVal(1), true); // add opaque definition
try {
std::cout << type_check(iAdd(Const("a"), Int), env) << "\n";
@ -132,7 +132,7 @@ static void tst5() {
}
static void tst6() {
environment env; init_frontend(env);
environment env; init_full_frontend(env);
level u = env->add_uvar("u", level() + 1);
level w = env->add_uvar("w", u + 1);
env->add_var("f", mk_arrow(Type(u), Type(u)));
@ -159,7 +159,7 @@ static void tst6() {
}
static void tst7() {
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Int);
env->add_var("b", Int);
expr t = If(Int, True, Const("a"), Const("b"));
@ -207,7 +207,7 @@ static void tst9() {
static void tst10() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_definition("a", Int, iVal(1));
lean_assert(env->get_object("a").get_weight() == 1);
expr a = Const("a");

View file

@ -546,7 +546,7 @@ static void tst26() {
*/
std::cout << "\ntst26\n";
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> up;
type_checker checker(env);
@ -588,7 +588,7 @@ static void tst27() {
*/
std::cout << "\ntst27\n";
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> up;
type_checker checker(env);

View file

@ -191,7 +191,7 @@ static void tst2() {
static void tst3() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("a", Bool);
expr t1 = Const("a");
expr t2 = Const("a");
@ -219,7 +219,7 @@ static void tst5() {
#if !defined(__APPLE__) && defined(LEAN_MULTI_THREAD)
expr t = mk_big(18);
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("f", Bool >> (Bool >> Bool));
env->add_var("a", Bool);
normalizer proc(env);
@ -255,7 +255,7 @@ static void tst6() {
static void tst7() {
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
expr m1 = menv->mk_metavar();
expr x = Const("x");
@ -279,7 +279,7 @@ static void tst7() {
static void tst8() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("P", Int >> (Int >> Bool));
expr P = Const("P");
expr v0 = Var(0);
@ -307,7 +307,7 @@ static void tst9() {
static void tst10() {
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
context ctx({{"x", Bool}, {"y", Bool}});
expr m = menv->mk_metavar(ctx);

View file

@ -26,7 +26,7 @@ expr norm(expr const & e, environment & env) {
}
static void mk(expr const & a) {
environment env; init_frontend(env);
environment env; init_full_frontend(env);
expr b = Const("b");
for (unsigned i = 0; i < 100; i++) {
expr h = Const("h");

View file

@ -78,7 +78,7 @@ static void tst2() {
static void tst3() {
environment env;
init_frontend(env);
init_full_frontend(env);
expr f = Fun("a", Bool, Eq(Const("a"), True));
std::cout << type_check(f, env) << "\n";
lean_assert(type_check(f, env) == mk_arrow(Bool, Bool));
@ -88,7 +88,7 @@ static void tst3() {
static void tst4() {
environment env;
init_frontend(env);
init_full_frontend(env);
expr a = Eq(iVal(1), iVal(2));
expr pr = mk_lambda("x", a, Var(0));
std::cout << type_check(pr, env) << "\n";
@ -96,7 +96,7 @@ static void tst4() {
static void tst5() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("P", Bool);
expr P = Const("P");
expr H = Const("H");
@ -114,7 +114,7 @@ static void tst5() {
static void tst6() {
environment env;
init_frontend(env);
init_full_frontend(env);
expr A = Const("A");
expr f = Const("f");
expr x = Const("x");
@ -129,7 +129,7 @@ static void tst6() {
static void tst7() {
environment env;
init_frontend(env);
init_full_frontend(env);
expr A = Const(name{"foo", "bla", "bla", "foo"});
expr f = Const("f");
expr x = Const("x");
@ -144,7 +144,7 @@ static void tst7() {
static void tst8() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("P", mk_arrow(Int, mk_arrow(Int, Bool)));
env->add_var("x", Int);
expr P = Const("P");
@ -164,7 +164,7 @@ static void tst8() {
static void tst9() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("P", mk_arrow(Int, mk_arrow(Int, Bool)));
env->add_var("x", Int);
expr P = Const("P");
@ -184,7 +184,7 @@ static void tst9() {
static void tst10() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("f", mk_arrow(Int, Int));
env->add_var("b", Int);
expr f = Const("f");
@ -201,7 +201,7 @@ static void tst10() {
static void tst11() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("f", Int >> (Int >> Int));
env->add_var("a", Int);
unsigned n = 1000;
@ -232,7 +232,7 @@ static void tst12() {
#if !defined(__APPLE__) && defined(LEAN_MULTI_THREAD)
expr t = mk_big(18);
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("f", Int >> (Int >> Int));
env->add_var("a", Int);
type_checker checker(env);
@ -255,7 +255,7 @@ static void tst12() {
static void tst13() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var("f", Type() >> Type());
expr f = Const("f");
std::cout << type_check(f(Bool), env) << "\n";
@ -264,7 +264,7 @@ static void tst13() {
static void tst14() {
environment env;
init_frontend(env);
init_full_frontend(env);
expr f = Const("f");
expr a = Const("a");
env->add_var("f", Int >> Int);
@ -282,7 +282,7 @@ static void tst14() {
static void tst15() {
environment env;
init_frontend(env);
init_full_frontend(env);
context ctx1, ctx2;
expr A = Const("A");
expr vec1 = Const("vec1");
@ -350,7 +350,7 @@ static void f2(type_checker & tc, expr const & F) {
static void tst17() {
environment env;
init_frontend(env);
init_full_frontend(env);
type_checker tc(env);
expr A = Const("A");
expr F;
@ -374,7 +374,7 @@ static std::ostream & operator<<(std::ostream & out, buffer<unification_constrai
static void tst18() {
environment env;
init_frontend(env);
init_full_frontend(env);
type_inferer type_of(env);
expr f = Const("f");
expr g = Const("g");
@ -406,7 +406,7 @@ static expr mk_big(unsigned val, unsigned depth) {
static void tst19() {
environment env;
init_frontend(env);
init_full_frontend(env);
type_inferer type_of(env);
type_checker type_of_slow(env);
expr t = mk_big(0, 10);
@ -428,7 +428,7 @@ static void tst19() {
static void tst20() {
environment env;
init_frontend(env);
init_full_frontend(env);
context ctx1, ctx2;
expr A = Const("A");
expr vec1 = Const("vec1");
@ -456,7 +456,7 @@ static void tst20() {
static void tst21() {
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> uc;
type_inferer inferer(env);

View file

@ -16,7 +16,7 @@ using namespace lean;
static void tst0() {
environment env;
init_frontend(env);
init_full_frontend(env);
normalizer norm(env);
env->add_var("n", Nat);
expr n = Const("n");
@ -47,7 +47,7 @@ static void tst0() {
static void tst1() {
environment env;
init_frontend(env);
init_full_frontend(env);
expr e = mk_int_value(mpz(10));
lean_assert(is_int_value(e));
lean_assert(type_check(e, env) == Int);
@ -56,7 +56,7 @@ static void tst1() {
static void tst2() {
environment env;
init_frontend(env);
init_full_frontend(env);
expr e = iAdd(iVal(10), iVal(30));
std::cout << e << "\n";
std::cout << normalize(e, env) << "\n";
@ -73,7 +73,7 @@ static void tst2() {
static void tst3() {
environment env;
init_frontend(env);
init_full_frontend(env);
expr e = iMul(iVal(10), iVal(30));
std::cout << e << "\n";
std::cout << normalize(e, env) << "\n";
@ -90,7 +90,7 @@ static void tst3() {
static void tst4() {
environment env;
init_frontend(env);
init_full_frontend(env);
expr e = iSub(iVal(10), iVal(30));
std::cout << e << "\n";
std::cout << normalize(e, env) << "\n";
@ -107,7 +107,7 @@ static void tst4() {
static void tst5() {
environment env;
init_frontend(env);
init_full_frontend(env);
env->add_var(name("a"), Int);
expr e = Eq(iVal(3), iVal(4));
std::cout << e << " --> " << normalize(e, env) << "\n";

View file

@ -20,7 +20,7 @@ using namespace lean;
static void tst1() {
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> ucs;
type_checker checker(env);
@ -75,7 +75,7 @@ static void tst2() {
?m4 in { Id, nat2int, nat2real }
*/
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> ucs;
type_checker checker(env);
@ -116,7 +116,7 @@ static void tst3() {
?m5 in { Id, int2real }
*/
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> ucs;
type_checker checker(env);
@ -158,7 +158,7 @@ static void tst4() {
?m6 in { Id, int2real }
*/
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> ucs;
type_checker checker(env);
@ -202,7 +202,7 @@ static void tst5() {
?m4 in { Id, int2real }
*/
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> ucs;
type_checker checker(env);
@ -239,7 +239,7 @@ static void tst6() {
Theorem T : (f a (f b b)) == a := Subst _ _ _ _ H1 H2
*/
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> ucs;
type_checker checker(env);
@ -307,7 +307,7 @@ static void unsolved(expr const & e, environment const & env) {
static void tst7() {
std::cout << "\nTST 7\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr A = Const("A");
expr B = Const("B");
expr F = Const("F");
@ -328,7 +328,7 @@ static void tst7() {
static void tst8() {
std::cout << "\nTST 8\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr a = Const("a");
expr b = Const("b");
expr c = Const("c");
@ -354,7 +354,7 @@ static void tst8() {
static void tst9() {
std::cout << "\nTST 9\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr Nat = Const("N");
env->add_var("N", Type());
env->add_var("vec", Nat >> Type());
@ -386,7 +386,7 @@ static void tst9() {
static void tst10() {
std::cout << "\nTST 10\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr Nat = Const("N");
env->add_var("N", Type());
expr R = Const("R");
@ -410,7 +410,7 @@ static void tst10() {
static void tst11() {
std::cout << "\nTST 11\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr A = Const("A");
expr B = Const("B");
expr a = Const("a");
@ -428,7 +428,7 @@ static void tst11() {
static void tst12() {
std::cout << "\nTST 12\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr lst = Const("list");
expr nil = Const("nil");
expr cons = Const("cons");
@ -449,7 +449,7 @@ static void tst12() {
static void tst13() {
std::cout << "\nTST 13\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr B = Const("B");
expr A = Const("A");
expr x = Const("x");
@ -472,7 +472,7 @@ static void tst13() {
static void tst14() {
std::cout << "\nTST 14\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr A = Const("A");
expr B = Const("B");
expr f = Const("f");
@ -513,7 +513,7 @@ static void tst14() {
static void tst15() {
std::cout << "\nTST 15\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr A = Const("A");
expr B = Const("B");
expr C = Const("C");
@ -539,7 +539,7 @@ static void tst15() {
static void tst16() {
std::cout << "\nTST 16\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr a = Const("a");
expr b = Const("b");
expr c = Const("c");
@ -560,7 +560,7 @@ static void tst16() {
EqTIntro(c, EqMP(a, c, Symm(Bool, c, a, Trans(Bool, c, b, a, Symm(Bool, b, c, H2), Symm(Bool, a, b, H1))), H3))),
env);
environment env2;
init_frontend(env2);
init_full_frontend(env2);
success(Fun({{a, Bool}, {b, Bool}, {c, Bool}, {H1, Eq(a, b)}, {H2, Eq(b, c)}, {H3, a}},
EqTIntro(_, EqMP(_, _, Symm(_, _, _, Trans(_, _, _, _, Symm(_, _, _, H2), Symm(_, _, _, H1))), H3))),
Fun({{a, Bool}, {b, Bool}, {c, Bool}, {H1, Eq(a, b)}, {H2, Eq(b, c)}, {H3, a}},
@ -577,7 +577,7 @@ static void tst16() {
void tst17() {
std::cout << "\nTST 17\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr A = Const("A");
expr B = Const("B");
expr a = Const("a");
@ -592,7 +592,7 @@ void tst17() {
void tst18() {
std::cout << "\nTST 18\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr A = Const("A");
expr h = Const("h");
expr f = Const("f");
@ -606,7 +606,7 @@ void tst18() {
void tst19() {
std::cout << "\nTST 19\n";
environment env;
init_frontend(env);
init_full_frontend(env);
expr R = Const("R");
expr A = Const("A");
expr r = Const("r");
@ -633,7 +633,7 @@ void tst19() {
void tst20() {
std::cout << "\nTST 20\n";
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
expr N = Const("N1");
expr M = Const("M1");
@ -666,7 +666,7 @@ void tst20() {
void tst21() {
std::cout << "\nTST 21\n";
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
expr N = Const("N");
expr M = Const("M");
@ -698,7 +698,7 @@ void tst21() {
void tst22() {
std::cout << "\nTST 22\n";
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
expr N = Const("N");
env->add_var("N", Type());
@ -733,7 +733,7 @@ void tst22() {
void tst23() {
std::cout << "\nTST 23\n";
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
expr N = Const("N");
env->add_var("N", Type());
@ -763,7 +763,7 @@ void tst23() {
void tst24() {
std::cout << "\nTST 24\n";
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
expr N = Const("N");
env->add_var("N", Type());
@ -783,7 +783,7 @@ void tst24() {
void tst25() {
std::cout << "\nTST 25\n";
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
expr N = Const("N");
env->add_var("N", Type());
@ -819,7 +819,7 @@ void tst26() {
Axiom H : g _ a = a
*/
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> ucs;
type_checker checker(env);
@ -849,7 +849,7 @@ void tst27() {
fun f : _, eq _ ((g _ f) a) a
*/
environment env;
init_frontend(env);
init_full_frontend(env);
metavar_env menv;
buffer<unification_constraint> ucs;
type_checker checker(env);

View file

@ -38,7 +38,7 @@ static void theorem_rewriter1_tst() {
Eq(nAdd(Const("x"), Const("y")), nAdd(Const("y"), Const("x")))));
expr add_comm_thm_body = Const("ADD_COMM");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_var("b", Nat);
env->add_axiom("ADD_COMM", add_comm_thm_type); // ADD_COMM : Pi (x, y: N), x + y = y + z
@ -70,7 +70,7 @@ static void theorem_rewriter2_tst() {
Eq(nAdd(Const("x"), zero), Const("x")));
expr add_id_thm_body = Const("ADD_ID");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_axiom("ADD_ID", add_id_thm_type); // ADD_ID : Pi (x : N), x = x + 0
@ -108,7 +108,7 @@ static void then_rewriter1_tst() {
Eq(nAdd(Const("x"), zero), Const("x")));
expr add_id_thm_body = Const("ADD_ID");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_axiom("ADD_COMM", add_comm_thm_type); // ADD_COMM : Pi (x, y: N), x + y = y + z
env->add_axiom("ADD_ID", add_id_thm_type); // ADD_ID : Pi (x : N), x = x + 0
@ -164,7 +164,7 @@ static void then_rewriter2_tst() {
Eq(nAdd(Const("x"), zero), Const("x")));
expr add_id_thm_body = Const("ADD_ID");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_axiom("ADD_ASSOC", add_assoc_thm_type); // ADD_ASSOC : Pi (x, y, z : N), x + (y + z) = (x + y) + z
env->add_axiom("ADD_COMM", add_comm_thm_type); // ADD_COMM : Pi (x, y: N), x + y = y + z
@ -223,7 +223,7 @@ static void orelse_rewriter1_tst() {
Eq(nAdd(Const("x"), zero), Const("x")));
expr add_id_thm_body = Const("ADD_ID");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_var("b", Nat);
env->add_axiom("ADD_COMM", add_comm_thm_type); // ADD_COMM : Pi (x, y: N), x + y = y + z
@ -270,7 +270,7 @@ static void orelse_rewriter2_tst() {
Eq(nAdd(Const("x"), zero), Const("x")));
expr add_id_thm_body = Const("ADD_ID");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_var("b", Nat);
env->add_axiom("ADD_ASSOC", add_assoc_thm_type);
@ -319,7 +319,7 @@ static void try_rewriter1_tst() {
Eq(nAdd(Const("x"), zero), Const("x")));
expr add_id_thm_body = Const("ADD_ID");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_var("b", Nat);
env->add_axiom("ADD_COMM", add_comm_thm_type); // ADD_COMM : Pi (x, y: N), x + y = y + z
@ -370,7 +370,7 @@ static void try_rewriter2_tst() {
Eq(nAdd(Const("x"), zero), Const("x")));
expr add_id_thm_body = Const("ADD_ID");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_var("b", Nat);
env->add_axiom("ADD_COMM", add_comm_thm_type); // ADD_COMM : Pi (x, y: N), x + y = y + z
@ -416,7 +416,7 @@ static void app_rewriter1_tst() {
Eq(nAdd(Const("x"), Const("y")), nAdd(Const("y"), Const("x")))));
expr add_comm_thm_body = Const("ADD_COMM");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("f1", Nat >> Nat);
env->add_var("f2", Nat >> (Nat >> Nat));
env->add_var("f3", Nat >> (Nat >> (Nat >> Nat)));
@ -506,7 +506,7 @@ static void repeat_rewriter1_tst() {
Eq(nAdd(Const("x"), zero), Const("x")));
expr add_id_thm_body = Const("ADD_ID");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_axiom("ADD_ASSOC", add_assoc_thm_type); // ADD_ASSOC : Pi (x, y, z : N), x + (y + z) = (x + y) + z
env->add_axiom("ADD_COMM", add_comm_thm_type); // ADD_COMM : Pi (x, y: N), x + y = y + z
@ -564,7 +564,7 @@ static void repeat_rewriter2_tst() {
Eq(nAdd(Const("x"), zero), Const("x")));
expr add_id_thm_body = Const("ADD_ID");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("a", Nat);
env->add_axiom("ADD_ASSOC", add_assoc_thm_type); // ADD_ASSOC : Pi (x, y, z : N), x + (y + z) = (x + y) + z
env->add_axiom("ADD_COMM", add_comm_thm_type); // ADD_COMM : Pi (x, y: N), x + y = y + z
@ -611,7 +611,7 @@ static void depth_rewriter1_tst() {
Eq(nAdd(Const("x"), Const("y")), nAdd(Const("y"), Const("x")))));
expr add_comm_thm_body = Const("ADD_COMM");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("f1", Nat >> Nat);
env->add_var("f2", Nat >> (Nat >> Nat));
env->add_var("f3", Nat >> (Nat >> (Nat >> Nat)));
@ -658,7 +658,7 @@ static void lambda_body_rewriter_tst() {
Eq(nAdd(Const("x"), Const("y")), nAdd(Const("y"), Const("x")))));
expr add_comm_thm_body = Const("ADD_COMM");
environment env; init_frontend(env);
environment env; init_full_frontend(env);
env->add_var("f1", Nat >> Nat);
env->add_var("f2", Nat >> (Nat >> Nat));
env->add_var("f3", Nat >> (Nat >> (Nat >> Nat)));
@ -703,7 +703,7 @@ static void lambda_type_rewriter_tst() {
// Result : fun (x : vec(Nat, b + a)), x
cout << "=== lambda_type_rewriter_tst() ===" << std::endl;
context ctx;
environment env; init_frontend(env);
environment env; init_full_frontend(env);
expr a = Const("a"); // a : Nat
env->add_var("a", Nat);
expr b = Const("b"); // b : Nat

View file

@ -49,7 +49,7 @@ static void check_failure(tactic t, ro_environment const & env, io_state const &
static void tst1() {
environment env;
io_state io(options(), mk_simple_formatter());
init_frontend(env);
init_full_frontend(env);
env->add_var("p", Bool);
env->add_var("q", Bool);
expr p = Const("p");
@ -115,7 +115,7 @@ static void tst1() {
static void tst2() {
environment env;
io_state io(options(), mk_simple_formatter());
init_frontend(env);
init_full_frontend(env);
env->add_var("p", Bool);
env->add_var("q", Bool);
env->add_var("r", Bool);

View file

@ -1,3 +1,4 @@
Import int.
Axiom PlusComm(a b : Int) : a + b == b + a.
Variable a : Int.
Check (Abst (fun x : Int, (PlusComm a x))).

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: PlusComm
Assumed: a
Abst (λ x : , PlusComm a x) : (λ x : , a + x) == (λ x : , x + a)

View file

@ -1,4 +1,5 @@
(** import("tactic.lua") **)
Import tactic.
Import int.
Variable f : Int -> Int -> Bool
Variable P : Int -> Int -> Bool

View file

@ -1,5 +1,7 @@
Set: pp::colors
Set: pp::unicode
Imported 'tactic'
Imported 'int'
Assumed: f
Assumed: P
Assumed: Ax1

View file

@ -1,3 +1,4 @@
Import int.
Check 10 + 20
Check 10
Check 10 - 20

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
10 + 20 :
10 :
10 - 20 :

View file

@ -1,3 +1,5 @@
Import int.
Import real.
Show 1/2
Eval 4/6
Show 3 div 2

View file

@ -1,5 +1,7 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Imported 'real'
1 / 2
2/3
3 div 2

View file

@ -1,3 +1,4 @@
Import int.
Eval 8 mod 3
Eval 8 div 4
Eval 7 div 3

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
2
2
2

View file

@ -1,3 +1,4 @@
Import int.
SetOption pp::unicode false
Show 3 | 6
Eval 3 | 6

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Set: pp::unicode
3 | 6
true

View file

@ -1,3 +1,4 @@
Import int.
Eval | -2 |
(*
Unfortunately, we can't write |-2|, because |- is considered a single token.

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
2
3
Defined: x

View file

@ -1,3 +1,4 @@
Import real.
Eval 10.3
Eval 0.3
Eval 0.3 + 0.1

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'real'
103/10
3/10
2/5

View file

@ -1,3 +1,4 @@
Import int.
Show (Int -> Int) -> Int
Show Int -> Int -> Int
Show Int -> (Int -> Int)

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
() →

View file

@ -1,3 +1,4 @@
Import int.
Variable g : Pi A : Type, A -> A.
Variables a b : Int
Axiom H1 : g _ a > 0

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: g
Assumed: a
Assumed: b

View file

@ -1,3 +1,4 @@
Import int.
Variable list : Type -> Type
Variable nil {A : Type} : list A
Variable cons {A : Type} (head : A) (tail : list A) : list A

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: list
Assumed: nil
Assumed: cons

View file

@ -1,3 +1,4 @@
Import int.
Variable list : Type -> Type
Variable nil {A : Type} : list A
Variable cons {A : Type} (head : A) (tail : list A) : list A

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: list
Assumed: nil
Assumed: cons

View file

@ -1,3 +1,4 @@
Import int.
Variable f {A : Type} (a : A) : A
Variable a : Int
Definition tst : Bool := (fun x, (f x) > 10) a

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: f
Assumed: a
Defined: tst

View file

@ -1,3 +1,4 @@
Import int.
Variable g {A : Type} (a : A) : A
Variable a : Int
Variable b : Int

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: g
Assumed: a
Assumed: b

View file

@ -1,3 +1,5 @@
Import int.
Import real.
Variable f {A : Type} (a : A) : A
Variable a : Int
Variable b : Real

View file

@ -1,5 +1,7 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Imported 'real'
Assumed: f
Assumed: a
Assumed: b

View file

@ -1,3 +1,4 @@
Import real.
Variable f {A : Type} (a b : A) : Bool
Variable a : Int
Variable b : Real

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'real'
Assumed: f
Assumed: a
Assumed: b

View file

@ -1,3 +1,4 @@
Import int.
Variable list : Type → Type
Variable nil {A : Type} : list A
Variable cons {A : Type} (head : A) (tail : list A) : list A

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: list
Assumed: nil
Assumed: cons

View file

@ -1,4 +1,5 @@
Import cast
Import cast.
Import int.
Variable vector : Type -> Nat -> Type
Axiom N0 (n : Nat) : n + 0 = n

View file

@ -1,13 +1,14 @@
Set: pp::colors
Set: pp::unicode
Imported 'cast'
Imported 'int'
Assumed: vector
Assumed: N0
Proved: V0
Assumed: f
Assumed: m
Assumed: v1
Error (line: 14, pos: 6) type mismatch at application
Error (line: 15, pos: 6) type mismatch at application
f m v1
Function type:
Π (n : ), vector n →

View file

@ -1,3 +1,4 @@
Import int.
Definition id (A : Type) : (Type U) := A.
Variable p : (Int -> Int) -> Bool.
Check fun (x : id Int), x.

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Defined: id
Assumed: p
λ x : id , x : id → id

View file

@ -2,10 +2,6 @@
Set: pp::unicode
Assumed: f
Failed to solve
⊢ (?M::1 ≈ λ x : , x) ⊕ (?M::1 ≈ nat_to_int) ⊕ (?M::1 ≈ nat_to_real)
(line: 4: pos: 8) Coercion for
10
Failed to solve
⊢ Bool ≺
Substitution
⊢ Bool ≺ ?M::0
@ -13,100 +9,16 @@ Failed to solve
@f
with arguments:
?M::0
?M::1 10
10
Assignment
≺ ?M::0
Substitution
⊢ ?M::5[inst:0 (10)] ≺ ?M::0
(line: 4: pos: 6) Type of argument 2 must be convertible to the expected type in the application of
@f
with arguments:
?M::0
?M::1 10
10
Assignment
x : ≈ ?M::5
Destruct/Decompose
≈ Π x : ?M::4, ?M::5
Substitution
⊢ ?M::3 ≈ Π x : ?M::4, ?M::5
Function expected at
?M::1 10
Assignment
≺ ?M::3
Propagate type, ?M::1 : ?M::3
Assignment
⊢ ?M::1 ≈ λ x : , x
Assumption 0
Failed to solve
⊢ Bool ≺
Substitution
⊢ Bool ≺ ?M::0
(line: 4: pos: 6) Type of argument 3 must be convertible to the expected type in the application of
@f
with arguments:
?M::0
?M::1 10
Assignment
≺ ?M::0
Substitution
⊢ ?M::5[inst:0 (10)] ≺ ?M::0
(line: 4: pos: 6) Type of argument 2 must be convertible to the expected type in the application of
@f
with arguments:
?M::0
?M::1 10
Assignment
a : ≈ ?M::5
Destruct/Decompose
≈ Π x : ?M::4, ?M::5
Substitution
⊢ ?M::3 ≈ Π x : ?M::4, ?M::5
Function expected at
?M::1 10
Assignment
≺ ?M::3
Propagate type, ?M::1 : ?M::3
Assignment
⊢ ?M::1 ≈ nat_to_int
Assumption 1
Failed to solve
⊢ Bool ≺
Substitution
⊢ Bool ≺ ?M::0
(line: 4: pos: 6) Type of argument 3 must be convertible to the expected type in the application of
@f
with arguments:
?M::0
?M::1 10
Assignment
≺ ?M::0
Substitution
⊢ ?M::5[inst:0 (10)] ≺ ?M::0
(line: 4: pos: 6) Type of argument 2 must be convertible to the expected type in the application of
@f
with arguments:
?M::0
?M::1 10
Assignment
a : ≈ ?M::5
Destruct/Decompose
≈ Π x : ?M::4, ?M::5
Substitution
⊢ ?M::3 ≈ Π x : ?M::4, ?M::5
Function expected at
?M::1 10
Assignment
≺ ?M::3
Propagate type, ?M::1 : ?M::3
Assignment
⊢ ?M::1 ≈ nat_to_real
Assumption 2
Assumed: g
Error (line: 7, pos: 8) invalid expression, it still contains metavariables after elaboration, metavariable: ?M::1, type:
Type

View file

@ -7,8 +7,6 @@
Set: lean::pp::implicit
Import "kernel"
Import "nat"
Import "int"
Import "real"
Variable C {A B : Type} (H : @eq Type A B) (a : A) : B
Variable D {A A' : Type} {B : A → Type} {B' : A' → Type} (H : @eq Type (Π x : A, B x) (Π x : A', B' x)) :
@eq Type A A'

View file

@ -7,8 +7,6 @@
Set: lean::pp::implicit
Import "kernel"
Import "nat"
Import "int"
Import "real"
Variable C {A B : Type} (H : @eq Type A B) (a : A) : B
Variable D {A A' : Type} {B : A → Type} {B' : A' → Type} (H : @eq Type (Π x : A, B x) (Π x : A', B' x)) :
@eq Type A A'

View file

@ -1,4 +1,4 @@
Import int.
Variable i : Int
Check i = 0
SetOption pp::coercion true

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: i
i = 0 : Bool
Set: lean::pp::coercion

View file

@ -1,3 +1,4 @@
Import int.
Variable List : Type -> Type
Variable nil {A : Type} : List A
Variable cons {A : Type} (head : A) (tail : List A) : List A

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: List
Assumed: nil
Assumed: cons

View file

@ -1,3 +1,4 @@
Import int.
Variable a : Int
Variable P : Int -> Int -> Bool
Axiom H : P a a

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: a
Assumed: P
Assumed: H

View file

@ -1,3 +1,4 @@
Import int.
Variable a : Int
Variable P : Int -> Int -> Bool
Variable f : Int -> Int -> Int

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: a
Assumed: P
Assumed: f

View file

@ -1,3 +1,4 @@
Import int.
Variable P : Int -> Int -> Bool
Theorem T1 (R1 : not (exists x y, P x y)) : forall x y, not (P x y) :=

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: P
Proved: T1
Assumed: Ax

View file

@ -1,3 +1,4 @@
Import int.
Variable P : Int -> Int -> Int -> Bool
Axiom Ax1 : exists x y z, P x y z
Axiom Ax2 : forall x y z, not (P x y z)

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: P
Assumed: Ax1
Assumed: Ax2

View file

@ -1,3 +1,4 @@
Import int.
Variable f {A : Type} : A -> A -> A
Variable module::g {A : Type} : A -> A -> A
Check @f

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: f
Assumed: module::g
@f : Π (A : Type), A → A → A
@ -8,4 +9,4 @@ module::@g : Π (A : Type), A → A → A
h::1::explicit : Π (A B : Type), A → B → A
Assumed: @h
Assumed: h
Error (line: 8, pos: 37) failed to mark implicit arguments for 'h', the frontend already has an object named '@h'
Error (line: 9, pos: 37) failed to mark implicit arguments for 'h', the frontend already has an object named '@h'

View file

@ -1,3 +1,4 @@
Import int.
Variable P : Int -> Bool
Axiom Ax (x : Int) : P x
Check ForallIntro Ax

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: P
Assumed: Ax
ForallIntro Ax : ∀ x : , P x

View file

@ -1,3 +1,4 @@
Import int.
Variable g {A : Type} (a : A) : A
Variable a : Int
Variable b : Int

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: g
Assumed: a
Assumed: b

View file

@ -1,3 +1,5 @@
Import int.
Import real.
Variable f : Int -> Int -> Int
Show forall a, f a a > 0
Show forall a b, f a b > 0

View file

@ -1,5 +1,7 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Imported 'real'
Assumed: f
∀ a : , f a a > 0
∀ a b : , f a b > 0

View file

@ -1,3 +1,4 @@
Import real.
Variable f {A : Type} (x y : A) : A
Check f 10 20
Check f 10

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'real'
Assumed: f
f 10 20 :
f 10 :
@ -7,6 +8,6 @@ f 10 :
Assumed: g
g 10 20 : Bool → Bool
let r : := g 10 20 in r :
Error (line: 10, pos: 0) invalid expression, unexpected token
Error (line: 11, pos: 0) invalid expression, unexpected token
Set: lean::pp::implicit
let r : := @g 10 20 in r :

View file

@ -1,3 +1,5 @@
Import int.
Show 10 = 20
Variable f : Int -> Int -> Int
Variable g : Int -> Int -> Int -> Int

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
10 = 20
Assumed: f
Assumed: g

View file

@ -1,3 +1,4 @@
Import int.
Variable f {A : Type} (a1 a2 : A) {B : Type} (b1 b2 : B) : A
Variable g {A1 A2 : Type} (a1 : A1) (a2 : A2) {B : Type} (b : B) : A1
Variable p (a1 a2 : Int) {B : Type} (b1 b2 b3 : B) : B

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: f
Assumed: g
Assumed: p

View file

@ -1,3 +1,5 @@
Import int.
Import real.
Variable f {A : Type} (a1 a2 : A) : A
Variable g : Int -> Int -> Int
Variable h : Int -> Int -> Real -> Int

View file

@ -1,5 +1,7 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Imported 'real'
Assumed: f
Assumed: g
Assumed: h

View file

@ -1,3 +1,4 @@
Import int.
Variable f {A : Type} : A -> A -> A
Infixl 65 + : f
Show true + false

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: f
+ ⊥
10 + 20

View file

@ -1,3 +1,4 @@
Import int.
(** import("tactic.lua") **)
Variable q : Int -> Int -> Bool.
Variable p : Int -> Bool.

View file

@ -1,6 +1,7 @@
# Set: pp::colors
Set: pp::unicode
Assumed: q
Imported 'int'
# Assumed: q
# Assumed: p
# Assumed: Ax
# Assumed: a

View file

@ -1,3 +1,4 @@
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

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
let a : := 10, b : := 20, c : := 30, d : := 10 in a + b + c + d
let a : := 1000000000000000000,
b : := 20000000000000000000,

View file

@ -1,3 +1,4 @@
Import int.
Variable magic : Pi (H : Bool), H

View file

@ -1,5 +1,6 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Assumed: magic
Set: lean::pp::notation
Set: lean::pp::coercion

View file

@ -1,3 +1,4 @@
Import int.
Show
let b := true,

View file

@ -1,23 +1,24 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
let b := , a : := b in a
Assumed: vector
Assumed: const
let a := 10, v1 := const a , v2 := v1 in v2 : vector Bool 10
let a := 10, v1 : vector Bool a := const a , v2 : vector Bool a := v1 in v2
let a := 10, v1 : vector Bool a := const a , v2 : vector Bool a := v1 in v2 : vector Bool 10
Error (line: 31, pos: 26) type mismatch at definition 'v2', expected type
Error (line: 32, pos: 26) type mismatch at definition 'v2', expected type
vector a
Given type:
vector Bool a
Assumed: foo
Coercion foo
Error (line: 40, pos: 26) type mismatch at definition 'v2', expected type
Error (line: 41, pos: 26) type mismatch at definition 'v2', expected type
vector a
Given type:
vector Bool a
Set: lean::pp::coercion
Error (line: 48, pos: 26) type mismatch at definition 'v2', expected type
Error (line: 49, pos: 26) type mismatch at definition 'v2', expected type
vector a
Given type:
vector Bool a

View file

@ -1,3 +1,5 @@
Import int.
(**
function add_paren(code)
return "(" .. "** " .. code .. " **" .. ")"

View file

@ -1,4 +1,5 @@
Set: pp::colors
Set: pp::unicode
Imported 'int'
Variable x :
done

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