lean4-htt/tests/lean/run/wfEqns2.lean
jrr6 5f4e6a86d5
feat: update and explain "unknown constant" and "failed to infer type" errors (#9423)
This PR updates the formatting of, and adds explanations for, "unknown
identifier" errors as well as "failed to infer type" errors for binders
and definitions.

It attempts to ameliorate some of the confusion encountered in #1592 by
modifying the wording of the "header is elaborated before body is
processed" note and adding further discussion and examples of this
behavior in the corresponding error explanation.
2025-07-18 19:20:31 +00:00

87 lines
1.6 KiB
Text

mutual
def g (i j : Nat) : Nat :=
if i < 5 then 0 else
match j with
| Nat.zero => 1
| Nat.succ j => h i j
termination_by (i + j, 0)
decreasing_by
· apply Prod.Lex.left
apply Nat.lt_succ_self
def h (i j : Nat) : Nat :=
match j with
| 0 => g i 0
| Nat.succ j => g i j
termination_by (i + j, 1)
decreasing_by
· apply Prod.Lex.right
decide
· apply Prod.Lex.left
apply Nat.lt_succ_self
end
/-- info: g.eq_1 (i : Nat) : g i Nat.zero = if i < 5 then 0 else 1 -/
#guard_msgs in
#check g.eq_1
/-- info: g.eq_2 (i j_2 : Nat) : g i j_2.succ = if i < 5 then 0 else h i j_2 -/
#guard_msgs in
#check g.eq_2
/--
info: g.eq_def (i j : Nat) :
g i j =
if i < 5 then 0
else
match j with
| Nat.zero => 1
| j.succ => h i j
-/
#guard_msgs in
#check g.eq_def
/-- error: Unknown identifier `g.eq_3` -/
#guard_msgs in
#check g.eq_3
/-- info: h.eq_1 (i : Nat) : h i 0 = g i 0 -/
#guard_msgs in
#check h.eq_1
/-- info: h.eq_2 (i j_2 : Nat) : h i j_2.succ = g i j_2 -/
#guard_msgs in
#check h.eq_2
/--
info: h.eq_def (i j : Nat) :
h i j =
match j with
| 0 => g i 0
| j.succ => g i j
-/
#guard_msgs in
#check h.eq_def
/-- error: Unknown identifier `h.eq_3` -/
#guard_msgs in
#check h.eq_3
/--
info: g._mutual.eq_def (i : Nat) (x✝ : Nat ⊕' Nat) :
g._mutual i x✝ =
PSum.casesOn x✝
(fun j =>
if i < 5 then 0
else
match j with
| Nat.zero => 1
| j.succ => g._mutual i (PSum.inr j))
fun j =>
match j with
| 0 => g._mutual i (PSum.inl 0)
| j.succ => g._mutual i (PSum.inl j)
-/
#guard_msgs in
#check g._mutual.eq_def