refactor(frontends/lean): remove hardcoded Type', and define it using notation
This commit is contained in:
parent
76d21900a2
commit
f78d831de3
7 changed files with 23 additions and 14 deletions
|
@ -2,10 +2,7 @@
|
|||
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||
-- Authors: Leonardo de Moura, Jeremy Avigad
|
||||
|
||||
import general_notation
|
||||
|
||||
definition Prop [reducible] := Type.{0}
|
||||
|
||||
import general_notation type
|
||||
|
||||
-- implication
|
||||
-- -----------
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||
-- Authors: Leonardo de Moura
|
||||
|
||||
definition Type₁ [reducible] := Type.{1}
|
||||
definition Type₂ [reducible] := Type.{2}
|
||||
definition Type₃ [reducible] := Type.{3}
|
||||
notation `Prop`:max := Type.{0}
|
||||
notation `Type₁`:max := Type.{1}
|
||||
notation `Type₂`:max := Type.{2}
|
||||
notation `Type₃`:max := Type.{3}
|
||||
notation `Type'`:max := Type.{_+1}
|
||||
notation `Type₊`:max := Type.{_+1}
|
||||
|
|
|
@ -252,6 +252,12 @@ order for the change to take effect."
|
|||
("inn" . ("∉"))
|
||||
("nin" . ("∌"))
|
||||
|
||||
;; Types
|
||||
|
||||
("T1" . ("Type₁"))
|
||||
("T2" . ("Type₂"))
|
||||
("T+" . ("Type₊"))
|
||||
|
||||
;; Intersections, unions etc.
|
||||
|
||||
("intersection" . ,(lean-input-to-string-list "∩⋂∧⋀⋏⨇⊓⨅⋒∏ ⊼ ⨉"))
|
||||
|
@ -421,7 +427,7 @@ order for the change to take effect."
|
|||
;; Big/small, black/white.
|
||||
|
||||
("t" . ,(lean-input-to-string-list "▸▹►▻◂◃◄◅▴▵▾▿◢◿◣◺◤◸◥◹"))
|
||||
("T" . ,(lean-input-to-string-list "◀◁▶▷▲△▼▽◬◭◮"))
|
||||
("Tr" . ,(lean-input-to-string-list "◀◁▶▷▲△▼▽◬◭◮"))
|
||||
|
||||
("tb" . ,(lean-input-to-string-list "◂▸▴▾◄►◢◣◤◥"))
|
||||
("tw" . ,(lean-input-to-string-list "◃▹▵▿◅▻◿◺◸◹"))
|
||||
|
|
|
@ -36,10 +36,6 @@ static expr parse_Type(parser & p, unsigned, expr const *, pos_info const & pos)
|
|||
}
|
||||
}
|
||||
|
||||
static expr parse_Type_prime(parser & p, unsigned, expr const *, pos_info const & pos) {
|
||||
return p.save_pos(mk_sort(mk_succ(mk_level_placeholder())), pos);
|
||||
}
|
||||
|
||||
static expr parse_let(parser & p, pos_info const & pos);
|
||||
static expr parse_let_body(parser & p, pos_info const & pos) {
|
||||
if (p.curr_is_token(get_comma_tk())) {
|
||||
|
@ -407,7 +403,6 @@ parse_table init_nud_table() {
|
|||
r = r.add({transition("fun", Binders), transition(",", mk_scoped_expr_action(x0))}, x0);
|
||||
r = r.add({transition("Pi", Binders), transition(",", mk_scoped_expr_action(x0, 0, false))}, x0);
|
||||
r = r.add({transition("Type", mk_ext_action(parse_Type))}, x0);
|
||||
r = r.add({transition("Type'", mk_ext_action(parse_Type_prime))}, x0);
|
||||
r = r.add({transition("let", mk_ext_action(parse_let_expr))}, x0);
|
||||
r = r.add({transition("calc", mk_ext_action(parse_calc_expr))}, x0);
|
||||
r = r.add({transition("#", mk_ext_action(parse_overwrite_notation))}, x0);
|
||||
|
|
|
@ -72,7 +72,7 @@ void init_token_table(token_table & t) {
|
|||
{{"fun", 0}, {"Pi", 0}, {"let", 0}, {"in", 0}, {"have", 0}, {"show", 0}, {"obtain", 0}, {"by", 0}, {"then", 0},
|
||||
{"from", 0}, {"(", g_max_prec}, {")", 0}, {"{", g_max_prec}, {"}", 0}, {"_", g_max_prec},
|
||||
{"[", g_max_prec}, {"]", 0}, {"⦃", g_max_prec}, {"⦄", 0}, {".{", 0}, {"Type", g_max_prec},
|
||||
{"Type'", g_max_prec}, {"using", 0}, {"|", 0}, {"!", g_max_prec}, {"with", 0}, {"...", 0}, {",", 0},
|
||||
{"using", 0}, {"|", 0}, {"!", g_max_prec}, {"with", 0}, {"...", 0}, {",", 0},
|
||||
{".", 0}, {":", 0}, {"::", 0}, {"calc", 0}, {":=", 0}, {"--", 0}, {"#", 0},
|
||||
{"(*", 0}, {"/-", 0}, {"begin", g_max_prec}, {"proof", g_max_prec}, {"qed", 0}, {"@", g_max_prec},
|
||||
{"including", 0}, {"sorry", g_max_prec}, {"+", g_plus_prec}, {g_cup, g_cup_prec}, {"->", g_arrow_prec},
|
||||
|
|
7
tests/lean/prodtst.lean
Normal file
7
tests/lean/prodtst.lean
Normal file
|
@ -0,0 +1,7 @@
|
|||
import type
|
||||
|
||||
inductive prod (A B : Type₊) :=
|
||||
mk : A → B → prod A B
|
||||
|
||||
set_option pp.universes true
|
||||
check @prod
|
1
tests/lean/prodtst.lean.expected.out
Normal file
1
tests/lean/prodtst.lean.expected.out
Normal file
|
@ -0,0 +1 @@
|
|||
prod.{l_1 l_2} : Type.{succ l_1} → Type.{succ l_2} → Type.{max (succ l_1) (succ l_2)}
|
Loading…
Reference in a new issue