Remarks:
- Some tests do not produce error messages anymore because they can be
processed using the new equation compiler preprocessor.
- Some error messages got worse because of the preprocessing step.
We use metavariables in the preprocessing step. This information
may "leak" to users. Another problem is that some variable names
are lost. Example: in the following definition
def to_nat : ∀ {n}, fi n → nat
| (succ n) f0 := 0
| (succ n) (fs i) := succ (to_nat i)
The preprocessing step uses metavariables for pattern variables.
Thus, we have
def to_nat : ∀ {n}, fi n → nat
| (succ ?n) (@f0 ?x) := 0
| (succ ?n) (@fs ?x ?i) := succ (to_nat i)
when solving the constraint `succ ?n =?= succ ?x`, Lean assigns
?n := ?x
after solving these constraints, the preprocessor converts
metavariables into pattern variables again, and we have
def to_nat : ∀ {n}, fi n → nat
| (succ x) (@f0 x) := 0
| (succ x) (@fs x i) := succ (to_nat i)
So, we get the following equation lemmas:
to_nat.equations._eqn_1 : ∀ (x : ℕ), @to_nat (succ x) (@f0 x) = 0
to_nat.equations._eqn_2 : ∀ (x : ℕ) (i : fi x), @to_nat (succ x) (@fs x i) = succ (@to_nat x i)
instead of
to_nat.equations._eqn_1 : ∀ (n : ℕ), @to_nat (succ n) (@f0 n) = 0
to_nat.equations._eqn_2 : ∀ (n : ℕ) (i : fi n), @to_nat (succ n) (@fs n i) = succ (@to_nat n i)
21 lines
681 B
Text
21 lines
681 B
Text
universe variables u
|
|
inductive vec (A : Type u) : nat → Type (max 1 u)
|
|
| nil {} : vec 0
|
|
| cons : Π {n}, A → vec n → vec (n+1)
|
|
|
|
open vec
|
|
|
|
variables {A : Type u}
|
|
variables f : A → A → A
|
|
|
|
/- The new equation compiler can process this example.
|
|
So, this is not a test about error messages anymore.
|
|
-/
|
|
def map_head : ∀ {n}, vec A n → vec A n → vec A n
|
|
| .(0) nil nil := nil
|
|
| .(n+1) (@cons .(A) .(n) a va) (@cons .(A) n b vb) := cons (f a b) va
|
|
|
|
/- The following shorter version is also accepted. -/
|
|
def map_head2 : ∀ {n}, vec A n → vec A n → vec A n
|
|
| _ nil nil := nil
|
|
| _ (cons a va) (cons b vb) := cons (f a b) va
|