closes #318 Like Lean 3, we are doing it only for theorems. @Kha, we talked about doing it for definitions too, it sounded like a good idea, and it would make the system's behavior more uniform, but unfortunately it creates too many problems. There are so many trivial cases where it breaks. Here are some examples. 1- Definitions that take multiple bundled structures ``` def foo (s1 : Group) (s2 : CommRing) ... ``` They are universe polymorphic, and the different structures must be in the same universe, but we don't know it when we elaborate the header, that is, we need to elaborate the body. An extreme case is `PUnit` occurring in the header. It is universe polymorphic, but we only lear the constraints on this universe after we elaborate the body. 2- All files containing unification hints broke. Again, there are universe constraints on the header that we only learn after we elaborate the body. 3- Many `CoeSort` and `CoeFun` examples broke. Example: ``` structure Group := (carrier : Type u) (mul : carrier → carrier → carrier) (one : carrier) instance GroupToType : CoeSort Group (Type u) := CoeSort.mk (fun g => g.carrier) ``` We would have to write ``` instance GroupToType : CoeSort Group.{u} (Type u) := CoeSort.mk (fun g => g.carrier) ``` We would have to provide universe level parameters manually in this kind of instance. I think it would be too annoying.
13 lines
303 B
Text
13 lines
303 B
Text
def Hd : List α → Type
|
||
| [] => PUnit
|
||
| a :: _ => α
|
||
|
||
def hd : (as : List α) → Hd as
|
||
| [] => ()
|
||
| a :: l => a
|
||
|
||
theorem inj_hd (α : Type) : (a a': α) → (l l' : List α) → a :: l = a' :: l' → a = a' := by
|
||
intro a a' l l' h
|
||
show hd (a :: l) = hd (a' :: l')
|
||
cases h
|
||
rfl
|