This PR modifies the pretty printing of pi types. Now `∀` will be preferred over `→` for propositions if the domain is not a proposition. For example, `∀ (n : Nat), True` pretty prints as `∀ (n : Nat), True` rather than as `Nat → True`. There is also now an option `pp.foralls` (default true) that when false disables using `∀` at all, for pedagogical purposes. This PR also adjusts instance implicit binder pretty printing — nondependent pi types won't show the instance binder name. Closes #1834. The linked RFC also suggests using `_` for binder names in case of non-dependance. We're tabling that idea. Potentially it is useful for hygienic names; this could improve how `Nat → True` pretty prints as `∀ (a : Nat), True`, with this `a` that's chosen by implication notation elaboration. Relatedly, this PR exposes even further the issue where binder names are reused in a confusing way. Consider: `Nat → Nat → (a : Nat) → a = a` pretty prints as `∀ (a a a : Nat), a = a`.
51 lines
1.3 KiB
Text
51 lines
1.3 KiB
Text
---- h1
|
||
10
|
||
---- h2
|
||
3
|
||
10
|
||
0
|
||
---- h3
|
||
10
|
||
30
|
||
4
|
||
---- inv
|
||
10
|
||
match1.lean:82:0-82:73: error: dependent elimination failed, type mismatch when solving alternative with type
|
||
motive 0 (Vec.cons head✝ Vec.nil) ⋯
|
||
but expected
|
||
motive x✝ (Vec.cons head✝ tail✝) ⋯
|
||
[false, true, true]
|
||
match1.lean:119:0-119:41: error: dependent match elimination failed, inaccessible pattern found
|
||
.(j + j)
|
||
constructor expected
|
||
[false, true, true]
|
||
match1.lean:136:7-136:22: error: invalid match-expression, type of pattern variable 'a' contains metavariables
|
||
?m
|
||
fun x => ?m : ?m × ?m → ?m
|
||
fun x =>
|
||
match x with
|
||
| (a, b) => a + b : Nat × Nat → Nat
|
||
fun x =>
|
||
match x with
|
||
| (a, b) => a && b : Bool × Bool → Bool
|
||
fun x =>
|
||
match x with
|
||
| (a, b) => a + b : Nat × Nat → Nat
|
||
fun x x_1 =>
|
||
match x, x_1 with
|
||
| some a, some b => some (a + b)
|
||
| x, x_2 => none : Option Nat → Option Nat → Option Nat
|
||
fun x =>
|
||
(match (motive := Nat → Nat → Nat) x with
|
||
| 0 => id
|
||
| x.succ => id)
|
||
x : Nat → Nat
|
||
fun x =>
|
||
match x with
|
||
| #[1, 2] => 2
|
||
| #[] => 0
|
||
| #[3, 4, 5] => 3
|
||
| x => 4 : Array Nat → Nat
|
||
g.match_1.{u_1, u_2} {α : Type u_1} (motive : List α → Sort u_2) (x✝ : List α) (h_1 : (a : α) → motive [a])
|
||
(h_2 : (x : List α) → motive x) : motive x✝
|
||
fun e => nomatch e : ∀ (e : Empty), False
|