fix(frontends/lean/pp): pretty printer for Type
Add parenthesis around Type when it has a universe. Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
ae01d3818d
commit
f43db96e1f
7 changed files with 56 additions and 55 deletions
|
@ -197,12 +197,10 @@ class pp_fn {
|
|||
*/
|
||||
bool is_atomic(expr const & e) {
|
||||
switch (e.kind()) {
|
||||
case expr_kind::Var: case expr_kind::Constant:
|
||||
case expr_kind::Var: case expr_kind::Constant: case expr_kind::Type:
|
||||
return true;
|
||||
case expr_kind::Value:
|
||||
return !is_choice(e);
|
||||
case expr_kind::Type:
|
||||
return e == Type();
|
||||
case expr_kind::MetaVar:
|
||||
return !metavar_lctx(e);
|
||||
case expr_kind::App:
|
||||
|
@ -257,7 +255,7 @@ class pp_fn {
|
|||
if (e == Type()) {
|
||||
return mk_result(g_Type_fmt, 1);
|
||||
} else {
|
||||
return mk_result(format{g_Type_fmt, space(), ::lean::pp(ty_level(e), m_unicode)}, 1);
|
||||
return mk_result(paren(format{g_Type_fmt, space(), ::lean::pp(ty_level(e), m_unicode)}), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ p f : Bool
|
|||
g a : Bool
|
||||
Defined: c2
|
||||
Assumed: b
|
||||
c2::explicit : Π (T : Type), Type 3 → T → Type 3
|
||||
c2::explicit : Π (T : Type), (Type 3) → T → (Type 3)
|
||||
Assumed: g2
|
||||
g2 : c2 (Type 2) b → Bool
|
||||
Assumed: a2
|
||||
|
|
|
@ -210,7 +210,8 @@ Failed to solve
|
|||
Bool
|
||||
Bool
|
||||
Failed to solve
|
||||
⊢ (?M::0 ≈ Type) ⊕ (?M::0 ≈ Type 1) ⊕ (?M::0 ≈ Type 2) ⊕ (?M::0 ≈ Type M) ⊕ (?M::0 ≈ Type U)
|
||||
⊢
|
||||
(?M::0 ≈ Type) ⊕ (?M::0 ≈ (Type 1)) ⊕ (?M::0 ≈ (Type 2)) ⊕ (?M::0 ≈ (Type M)) ⊕ (?M::0 ≈ (Type U))
|
||||
Destruct/Decompose
|
||||
⊢ Type ≺ ?M::0
|
||||
(line: 24: pos: 6) Type of argument 2 must be convertible to the expected type in the application of
|
||||
|
@ -220,9 +221,9 @@ Failed to solve
|
|||
Bool
|
||||
Bool
|
||||
Failed to solve
|
||||
⊢ Type 1 ≺ Type
|
||||
⊢ (Type 1) ≺ Type
|
||||
Substitution
|
||||
⊢ Type 1 ≺ ?M::1
|
||||
⊢ (Type 1) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type
|
||||
|
@ -231,51 +232,52 @@ Failed to solve
|
|||
⊢ ?M::1 ≈ Type
|
||||
Assumption 0
|
||||
Failed to solve
|
||||
⊢ Type 2 ≺ Type
|
||||
⊢ (Type 2) ≺ Type
|
||||
Substitution
|
||||
⊢ Type 2 ≺ ?M::1
|
||||
⊢ (Type 2) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type 1
|
||||
⊢ ?M::0 ≈ (Type 1)
|
||||
Assumption 2
|
||||
Assignment
|
||||
⊢ ?M::1 ≈ Type
|
||||
Assumption 0
|
||||
Failed to solve
|
||||
⊢ Type 3 ≺ Type
|
||||
⊢ (Type 3) ≺ Type
|
||||
Substitution
|
||||
⊢ Type 3 ≺ ?M::1
|
||||
⊢ (Type 3) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type 2
|
||||
⊢ ?M::0 ≈ (Type 2)
|
||||
Assumption 3
|
||||
Assignment
|
||||
⊢ ?M::1 ≈ Type
|
||||
Assumption 0
|
||||
Failed to solve
|
||||
⊢ Type M+1 ≺ Type
|
||||
⊢ (Type M+1) ≺ Type
|
||||
Substitution
|
||||
⊢ Type M+1 ≺ ?M::1
|
||||
⊢ (Type M+1) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type M
|
||||
⊢ ?M::0 ≈ (Type M)
|
||||
Assumption 4
|
||||
Assignment
|
||||
⊢ ?M::1 ≈ Type
|
||||
Assumption 0
|
||||
Failed to solve
|
||||
⊢ Type U+1 ≺ Type
|
||||
⊢ (Type U+1) ≺ Type
|
||||
Substitution
|
||||
⊢ Type U+1 ≺ ?M::1
|
||||
⊢ (Type U+1) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type U
|
||||
⊢ ?M::0 ≈ (Type U)
|
||||
Assumption 5
|
||||
Assignment
|
||||
⊢ ?M::1 ≈ Type
|
||||
Assumption 0
|
||||
Failed to solve
|
||||
⊢ (?M::0 ≈ Type) ⊕ (?M::0 ≈ Type 1) ⊕ (?M::0 ≈ Type 2) ⊕ (?M::0 ≈ Type M) ⊕ (?M::0 ≈ Type U)
|
||||
⊢
|
||||
(?M::0 ≈ Type) ⊕ (?M::0 ≈ (Type 1)) ⊕ (?M::0 ≈ (Type 2)) ⊕ (?M::0 ≈ (Type M)) ⊕ (?M::0 ≈ (Type U))
|
||||
Destruct/Decompose
|
||||
⊢ Type ≺ ?M::0
|
||||
(line: 24: pos: 6) Type of argument 2 must be convertible to the expected type in the application of
|
||||
|
@ -285,9 +287,9 @@ Failed to solve
|
|||
Bool
|
||||
Bool
|
||||
Failed to solve
|
||||
⊢ Type 1 ≺ Bool
|
||||
⊢ (Type 1) ≺ Bool
|
||||
Substitution
|
||||
⊢ Type 1 ≺ ?M::1
|
||||
⊢ (Type 1) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type
|
||||
|
@ -296,45 +298,45 @@ Failed to solve
|
|||
⊢ ?M::1 ≈ Bool
|
||||
Assumption 6
|
||||
Failed to solve
|
||||
⊢ Type 2 ≺ Bool
|
||||
⊢ (Type 2) ≺ Bool
|
||||
Substitution
|
||||
⊢ Type 2 ≺ ?M::1
|
||||
⊢ (Type 2) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type 1
|
||||
⊢ ?M::0 ≈ (Type 1)
|
||||
Assumption 8
|
||||
Assignment
|
||||
⊢ ?M::1 ≈ Bool
|
||||
Assumption 6
|
||||
Failed to solve
|
||||
⊢ Type 3 ≺ Bool
|
||||
⊢ (Type 3) ≺ Bool
|
||||
Substitution
|
||||
⊢ Type 3 ≺ ?M::1
|
||||
⊢ (Type 3) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type 2
|
||||
⊢ ?M::0 ≈ (Type 2)
|
||||
Assumption 9
|
||||
Assignment
|
||||
⊢ ?M::1 ≈ Bool
|
||||
Assumption 6
|
||||
Failed to solve
|
||||
⊢ Type M+1 ≺ Bool
|
||||
⊢ (Type M+1) ≺ Bool
|
||||
Substitution
|
||||
⊢ Type M+1 ≺ ?M::1
|
||||
⊢ (Type M+1) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type M
|
||||
⊢ ?M::0 ≈ (Type M)
|
||||
Assumption 10
|
||||
Assignment
|
||||
⊢ ?M::1 ≈ Bool
|
||||
Assumption 6
|
||||
Failed to solve
|
||||
⊢ Type U+1 ≺ Bool
|
||||
⊢ (Type U+1) ≺ Bool
|
||||
Substitution
|
||||
⊢ Type U+1 ≺ ?M::1
|
||||
⊢ (Type U+1) ≺ ?M::1
|
||||
Propagate type, ?M::0 : ?M::1
|
||||
Assignment
|
||||
⊢ ?M::0 ≈ Type U
|
||||
⊢ ?M::0 ≈ (Type U)
|
||||
Assumption 11
|
||||
Assignment
|
||||
⊢ ?M::1 ≈ Bool
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
λ (f : N → N) (y : N), g (f a)
|
||||
λ (a : N) (f : N → N) (g : (N → N) → N → N) (h : N → N → N) (z : N), h (g (λ x : N, f (f x)) (f a)) (f a)
|
||||
λ (a b : N) (g : Bool → N) (y : Bool), g (a == b)
|
||||
λ (a : Type) (b : a → Type) (g : Type U → Bool) (y : Type U), g (Π x : a, b x)
|
||||
λ (a : Type) (b : a → Type) (g : (Type U) → Bool) (y : (Type U)), g (Π x : a, b x)
|
||||
λ (f : N → N) (y z : N), g (f a)
|
||||
λ (f g : N → N) (y z : N), g (f a)
|
||||
λ (f : N → N) (y z : N), P (f a) y z
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
⊤
|
||||
Assumed: a
|
||||
a ⊕ a ⊕ a
|
||||
Subst::explicit : Π (A : Type U) (a b : A) (P : A → Bool), P a → a == b → P b
|
||||
Subst::explicit : Π (A : (Type U)) (a b : A) (P : A → Bool), P a → a == b → P b
|
||||
Proved: EM2
|
||||
EM2 : Π a : Bool, a ∨ ¬ a
|
||||
EM2 a : a ∨ ¬ a
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
Set: pp::colors
|
||||
Set: pp::unicode
|
||||
Assumed: x
|
||||
x : Type U+3 ⊔ M+2 ⊔ 3
|
||||
x : (Type U+3 ⊔ M+2 ⊔ 3)
|
||||
Assumed: f
|
||||
f : Type U+10 → Type
|
||||
f : (Type U+10) → Type
|
||||
f x : Type
|
||||
Type 4 : Type 5
|
||||
x : Type U+3 ⊔ M+2 ⊔ 3
|
||||
Type U ⊔ M : Type U+1 ⊔ M+1
|
||||
Type U+3
|
||||
Type U+3 : Type U+4
|
||||
Type U ⊔ M : Type U+1 ⊔ M+1
|
||||
Type U ⊔ M ⊔ 3 : Type U+1 ⊔ M+1 ⊔ 4
|
||||
Type U+1 ⊔ M ⊔ 3
|
||||
Type U+1 ⊔ M ⊔ 3 : Type U+2 ⊔ M+1 ⊔ 4
|
||||
Type U → Type 5
|
||||
Type U → Type 5 : Type U+1 ⊔ 6
|
||||
Type M ⊔ 3 → Type U+5 : Type M+1 ⊔ 4 ⊔ U+6
|
||||
Type M ⊔ 3 → Type U → Type 5
|
||||
Type M ⊔ 3 → Type U → Type 5 : Type M+1 ⊔ 6 ⊔ U+1
|
||||
Type U
|
||||
(Type 4) : (Type 5)
|
||||
x : (Type U+3 ⊔ M+2 ⊔ 3)
|
||||
(Type U ⊔ M) : (Type U+1 ⊔ M+1)
|
||||
(Type U+3)
|
||||
(Type U+3) : (Type U+4)
|
||||
(Type U ⊔ M) : (Type U+1 ⊔ M+1)
|
||||
(Type U ⊔ M ⊔ 3) : (Type U+1 ⊔ M+1 ⊔ 4)
|
||||
(Type U+1 ⊔ M ⊔ 3)
|
||||
(Type U+1 ⊔ M ⊔ 3) : (Type U+2 ⊔ M+1 ⊔ 4)
|
||||
(Type U) → (Type 5)
|
||||
(Type U) → (Type 5) : (Type U+1 ⊔ 6)
|
||||
(Type M ⊔ 3) → (Type U+5) : (Type M+1 ⊔ 4 ⊔ U+6)
|
||||
(Type M ⊔ 3) → (Type U) → (Type 5)
|
||||
(Type M ⊔ 3) → (Type U) → (Type 5) : (Type M+1 ⊔ 6 ⊔ U+1)
|
||||
(Type U)
|
||||
|
|
|
@ -10,7 +10,8 @@ f::explicit ((N → N) → N → N) (λ x : N → N, x) (λ y : N → N, y)
|
|||
Assumed: EqNice
|
||||
EqNice::explicit N n1 n2
|
||||
f::explicit N n1 n2 : N
|
||||
Congr::explicit : Π (A : Type U) (B : A → Type U) (f g : Π x : A, B x) (a b : A), f == g → a == b → f a == g b
|
||||
Congr::explicit :
|
||||
Π (A : (Type U)) (B : A → (Type U)) (f g : Π x : A, B x) (a b : A), f == g → a == b → f a == g b
|
||||
f::explicit N n1 n2
|
||||
Assumed: a
|
||||
Assumed: b
|
||||
|
|
Loading…
Reference in a new issue