From 2b2aa228e301998da82793386ac5d59c983c218c Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 8 Jan 2014 12:34:55 -0800 Subject: [PATCH] refactor(builtin/kernel): start with small universes The universe constraint manager is more flexible now. We don't need to start with a huge universe U >= 512. We can start small, and increase it on demand. If module mod1 needs it, it can always add universe U >= 3 Signed-off-by: Leonardo de Moura --- src/builtin/kernel.lean | 4 +--- src/builtin/obj/kernel.olean | Bin 15086 -> 15032 bytes src/kernel/builtin.cpp | 2 -- src/kernel/builtin.h | 1 - src/library/elaborator/elaborator.cpp | 16 +++------------- src/tests/library/elaborator/elaborator.cpp | 6 ++++-- tests/lean/cast4.lean | 3 +++ tests/lean/cast4.lean.expected.out | 1 + tests/lean/norm_bug1.lean | 3 +++ tests/lean/norm_bug1.lean.expected.out | 1 + tests/lean/tst15.lean | 2 ++ tests/lean/tst5.lean | 1 + tests/lean/type_inf_bug1.lean | 3 +++ tests/lean/type_inf_bug1.lean.expected.out | 1 + tests/lean/univ.lean | 3 +++ tests/lean/univ.lean.expected.out | 5 +++-- tests/lean/univ2.lean | 4 +++- tests/lean/univ2.lean.expected.out | 3 +-- 18 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/builtin/kernel.lean b/src/builtin/kernel.lean index 68240a21a..ba17645ca 100644 --- a/src/builtin/kernel.lean +++ b/src/builtin/kernel.lean @@ -1,7 +1,6 @@ import macros -universe M ≥ 512 -universe U ≥ M+512 +universe U ≥ 1 variable Bool : Type -- The following builtin declarations can be removed as soon as Lean supports inductive datatypes and match expressions @@ -10,7 +9,6 @@ builtin false : Bool builtin if {A : (Type U)} : Bool → A → A → A definition TypeU := (Type U) -definition TypeM := (Type M) definition not (a : Bool) : Bool := a → false diff --git a/src/builtin/obj/kernel.olean b/src/builtin/obj/kernel.olean index 1cd0eb5b84b0324694c10362e699a51ac66a3aca..1729d77efadeadb278fac1fdcdd186afdaa2925e 100644 GIT binary patch literal 15032 zcmbVT4UnBxdH&A1Ke-5-np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*$L47%^d#5I*CwH_x4qgL%c(wpe%do-Zr>O$qaE~T7QXXLUvOdgtHHuLbbOGk0 z4V06cDn4WQ<>;53cn_Cz`8nMIUJJfEcfpvs7Fvxb2^sCS^ zf`V#D?*P^GJ)L_t@jpVgUXBSPB?C1M z!%t9zfYPUTeYc%xwqp=+lh5wRk=vffliOb6r|^CSLe<5_ggxw2Y-+q9HksOlQ9xhS ze;(j7hdv^zUSQ4H5M0ZDF=8k(jGh_>iOGC3?s0+9(TCQ@ylMZHqLU9%8n{pKnJ0O1 zNmwQSq#!!@Jz&UFzw)6=flfX&0FYN|{*?w*`{Wb`I_&o=%=Y&f#Ont-j^hPNbtxK? zfiiunRdQe4S**vv%5(iFp9gFYV@iFaW$tMTa*su-xVh}C5Gu(o;d*wIYqvJxpUfa*5Af-Ow7k1D_1Ks~|v*8r5txju7W z&RelCAwS}u=E_BfDFktT`DGFVPqj~j!0!A(!RO%I&b@iJ{a4RCZK;AaTacZO1mM)_ N-Z-`6P53{q{||(63zPr= diff --git a/src/kernel/builtin.cpp b/src/kernel/builtin.cpp index 0e79d06f1..0e6bdf9fb 100644 --- a/src/kernel/builtin.cpp +++ b/src/kernel/builtin.cpp @@ -13,9 +13,7 @@ Author: Leonardo de Moura namespace lean { // ======================================= // Bultin universe variables m and u -static level m_lvl(name("M")); static level u_lvl(name("U")); -expr const TypeM = Type(m_lvl); expr const TypeU = Type(u_lvl); // ======================================= diff --git a/src/kernel/builtin.h b/src/kernel/builtin.h index 2a980ecfc..e5a7e925b 100644 --- a/src/kernel/builtin.h +++ b/src/kernel/builtin.h @@ -9,7 +9,6 @@ Author: Leonardo de Moura namespace lean { // See src/builtin/kernel.lean for signatures. -extern expr const TypeM; extern expr const TypeU; /** \brief Return the Lean Boolean type. */ diff --git a/src/library/elaborator/elaborator.cpp b/src/library/elaborator/elaborator.cpp index 3d65fb900..6b9ec8307 100644 --- a/src/library/elaborator/elaborator.cpp +++ b/src/library/elaborator/elaborator.cpp @@ -148,7 +148,6 @@ class elaborator::imp { justification m_conflict; bool m_first; level m_U; // universe U used for builtin kernel axioms - level m_M; // universe M // options bool m_use_justifications; @@ -1179,19 +1178,15 @@ class elaborator::imp { // We approximate and only consider the most useful ones. justification new_jst(new destruct_justification(c)); if (is_bool(a)) { - expr choices[5] = { Bool, Type(), Type(level() + 1), TypeM, TypeU }; + expr choices[5] = { Bool, Type(), Type(level() + 1), TypeU }; push_active(mk_choice_constraint(get_context(c), b, 5, choices, new_jst)); return true; } else if (m_env->is_ge(ty_level(a), m_U)) { expr choices[2] = { a, Type(ty_level(a) + 1) }; push_active(mk_choice_constraint(get_context(c), b, 2, choices, new_jst)); return true; - } else if (m_env->is_ge(ty_level(a), m_M)) { - expr choices[3] = { a, Type(ty_level(a) + 1), TypeU }; - push_active(mk_choice_constraint(get_context(c), b, 3, choices, new_jst)); - return true; } else { - expr choices[4] = { a, Type(ty_level(a) + 1), TypeM, TypeU }; + expr choices[4] = { a, Type(ty_level(a) + 1), TypeU }; push_active(mk_choice_constraint(get_context(c), b, 4, choices, new_jst)); return true; } @@ -1254,13 +1249,9 @@ class elaborator::imp { push_active(mk_choice_constraint(get_context(c), a, 2, choices, new_jst)); return true; } else if (b == TypeU) { - expr choices[5] = { TypeU, TypeM, Type(level() + 1), Type(), Bool }; + expr choices[5] = { TypeU, Type(level() + 1), Type(), Bool }; push_active(mk_choice_constraint(get_context(c), a, 5, choices, new_jst)); return true; - } else if (b == TypeM) { - expr choices[4] = { TypeM, Type(level() + 1), Type(), Bool }; - push_active(mk_choice_constraint(get_context(c), a, 4, choices, new_jst)); - return true; } else { level const & lvl = ty_level(b); lean_assert(!lvl.is_bottom()); @@ -1772,7 +1763,6 @@ public: m_next_id = 0; m_first = true; m_U = m_env->get_uvar("U"); - m_M = m_env->get_uvar("M"); // display(std::cout); } diff --git a/src/tests/library/elaborator/elaborator.cpp b/src/tests/library/elaborator/elaborator.cpp index 4ca6365c9..f6693a0db 100644 --- a/src/tests/library/elaborator/elaborator.cpp +++ b/src/tests/library/elaborator/elaborator.cpp @@ -14,6 +14,7 @@ Author: Leonardo de Moura #include "kernel/builtin.h" #include "library/io_state_stream.h" #include "library/placeholder.h" +#include "library/printer.h" #include "library/arith/arith.h" #include "library/elaborator/elaborator.h" #include "frontends/lean/frontend.h" @@ -821,6 +822,7 @@ void tst26() { */ environment env; init_test_frontend(env); + env->add_uvar_cnstr("U", level() + 2); metavar_env menv; buffer ucs; type_checker checker(env); @@ -861,7 +863,7 @@ void tst27() { expr eq = Const("my_eq"); env->add_var("my_eq", Pi({A, TypeU}, A >> (A >> Bool))); env->add_var("g", Pi({A, TypeU}, A >> A)); - env->add_var("a", TypeM); + env->add_var("a", Type()); expr m1 = menv->mk_metavar(); expr m2 = menv->mk_metavar(); expr m3 = menv->mk_metavar(); @@ -872,7 +874,7 @@ void tst27() { metavar_env s = elb.next(); std::cout << s->instantiate_metavars(F) << "\n"; lean_assert_eq(s->instantiate_metavars(F), - Fun({f, TypeM >> TypeM}, eq(TypeM, g(TypeM >> TypeM, f)(a), a))); + Fun({f, Type() >> Type()}, eq(Type(), g(Type() >> Type(), f)(a), a))); } int main() { diff --git a/tests/lean/cast4.lean b/tests/lean/cast4.lean index 92a2dbc6e..9496058bc 100644 --- a/tests/lean/cast4.lean +++ b/tests/lean/cast4.lean @@ -1,5 +1,8 @@ import cast set::option pp::colors false +universe M >= 1 +universe U >= M + 1 +definition TypeM := (Type M) check fun (A A': TypeM) (B : A -> TypeM) diff --git a/tests/lean/cast4.lean.expected.out b/tests/lean/cast4.lean.expected.out index 3ac2e07f2..a162a3574 100644 --- a/tests/lean/cast4.lean.expected.out +++ b/tests/lean/cast4.lean.expected.out @@ -2,6 +2,7 @@ Set: pp::unicode Imported 'cast' Set: pp::colors + Defined: TypeM λ (A A' : TypeM) (B : A → TypeM) (B' : A' → TypeM) diff --git a/tests/lean/norm_bug1.lean b/tests/lean/norm_bug1.lean index 983defd58..c22faac50 100644 --- a/tests/lean/norm_bug1.lean +++ b/tests/lean/norm_bug1.lean @@ -1,5 +1,8 @@ import cast set::option pp::colors false +universe M >= 1 +universe U >= M + 1 +definition TypeM := (Type M) check fun (A A': TypeM) (a : A) diff --git a/tests/lean/norm_bug1.lean.expected.out b/tests/lean/norm_bug1.lean.expected.out index cfbb3104f..05a5fdabc 100644 --- a/tests/lean/norm_bug1.lean.expected.out +++ b/tests/lean/norm_bug1.lean.expected.out @@ -2,6 +2,7 @@ Set: pp::unicode Imported 'cast' Set: pp::colors + Defined: TypeM λ (A A' : TypeM) (a : A) (b : A') (L2 : A' == A), let b' : A := cast L2 b, L3 : b == b' := cast::eq L2 b in L3 : ∀ (A A' : TypeM) (a : A) (b : A') (L2 : A' == A), b == cast L2 b λ (A A' : TypeM) diff --git a/tests/lean/tst15.lean b/tests/lean/tst15.lean index 5e0956c62..b1116ed13 100644 --- a/tests/lean/tst15.lean +++ b/tests/lean/tst15.lean @@ -1,3 +1,5 @@ +universe M >= 1 +universe U >= M + 1 variable x : (Type max U+1+2 M+1 M+2 3) check x variable f : (Type U+10) -> Type diff --git a/tests/lean/tst5.lean b/tests/lean/tst5.lean index ccdba11e0..0f1b6fa5c 100644 --- a/tests/lean/tst5.lean +++ b/tests/lean/tst5.lean @@ -1,3 +1,4 @@ +universe U >= 3 variable N : Type variable a : N variable b : N diff --git a/tests/lean/type_inf_bug1.lean b/tests/lean/type_inf_bug1.lean index eb1f1e326..75458f944 100644 --- a/tests/lean/type_inf_bug1.lean +++ b/tests/lean/type_inf_bug1.lean @@ -1,5 +1,8 @@ import cast set::option pp::colors false +universe M >= 1 +universe U >= M + 1 +definition TypeM := (Type M) check fun (A A': TypeM) (a : A) diff --git a/tests/lean/type_inf_bug1.lean.expected.out b/tests/lean/type_inf_bug1.lean.expected.out index 9da17743b..0e2af54dc 100644 --- a/tests/lean/type_inf_bug1.lean.expected.out +++ b/tests/lean/type_inf_bug1.lean.expected.out @@ -2,6 +2,7 @@ Set: pp::unicode Imported 'cast' Set: pp::colors + Defined: TypeM λ (A A' : TypeM) (a : A) (b : A') (L2 : A' == A), let b' : A := cast L2 b, L3 : b == b' := cast::eq L2 b in L3 : ∀ (A A' : TypeM) (a : A) (b : A') (L2 : A' == A), b == cast L2 b λ (A A' : TypeM) diff --git a/tests/lean/univ.lean b/tests/lean/univ.lean index 504c4effd..16397efc9 100644 --- a/tests/lean/univ.lean +++ b/tests/lean/univ.lean @@ -1,4 +1,7 @@ +universe M >= 1 +universe U >= M + 1 +definition TypeM := (Type M) universe Z ≥ M+3 (* local env = get_environment() diff --git a/tests/lean/univ.lean.expected.out b/tests/lean/univ.lean.expected.out index e326845ac..2b668484b 100644 --- a/tests/lean/univ.lean.expected.out +++ b/tests/lean/univ.lean.expected.out @@ -1,4 +1,5 @@ Set: pp::colors Set: pp::unicode -Error (line: 27, pos: 0) universe constraint produces an integer overflow: Z2 >= Z1 + 1073741824 -Error (line: 40, pos: 0) universe constraint inconsistency: U1 >= U4 + 0 + Defined: TypeM +Error (line: 30, pos: 0) universe constraint produces an integer overflow: Z2 >= Z1 + 1073741824 +Error (line: 43, pos: 0) universe constraint inconsistency: U1 >= U4 + 0 diff --git a/tests/lean/univ2.lean b/tests/lean/univ2.lean index 00ea05ce6..1a67e40f8 100644 --- a/tests/lean/univ2.lean +++ b/tests/lean/univ2.lean @@ -1,7 +1,9 @@ +universe M >= 1 +universe U >= M + 1 universe Z >= max U+1 M+1 print environment 2 (* local env = get_environment() assert(env:get_universe_distance("Z", "U") == 1) -assert(env:get_universe_distance("Z", "M") == 513) +assert(env:get_universe_distance("Z", "M") == 2) *) diff --git a/tests/lean/univ2.lean.expected.out b/tests/lean/univ2.lean.expected.out index d7a2c5f98..d62395bb1 100644 --- a/tests/lean/univ2.lean.expected.out +++ b/tests/lean/univ2.lean.expected.out @@ -1,5 +1,4 @@ Set: pp::colors Set: pp::unicode -import "kernel" -import "Nat" +universe U ≥ M+1 universe Z ≥ U+1 ⊔ M+1