lean4-htt/tests/lean/run/7458.lean
Wojciech Rozowski 134d11f1a3
fix: ignore optParams in isNatCmp (#7551)
This PR changes `isNatCmp` to ignore optional arguments annotations,
when checking for `<`-like comparison between elements of `Nat`. That
previously caused `guessLex` to fail when checking termination of a
function, whose signature involved an optional argument of the type
`Nat`.

Closes https://github.com/leanprover/lean4/issues/7458
2025-03-18 21:21:43 +00:00

39 lines
824 B
Text

-- The following two snippets causes Lean to throw error:
def areAllSame' (arr : Array Nat) (i : Nat := 0) :=
if _ : i < arr.size then
if arr[i] = arr[0] then
areAllSame' arr (i + 1)
else
false
else
true
def areAllSame2' (arr : Array Nat) (i : Nat := 0) (j : Nat) :=
if _ : i < arr.size then
if arr[i] = arr[0] then
areAllSame2' arr (i + 1) (j + 1)
else
false
else
true
--Removing the optional argument works
def areAllSame (arr : Array Nat) (i : Nat) :=
if _ : i < arr.size then
if arr[i] = arr[0] then
areAllSame arr (i + 1)
else
false
else
true
def areAllSame2 (arr : Array Nat) (i : Nat) (j : Nat) :=
if _ : i < arr.size then
if arr[i] = arr[0] then
areAllSame2 arr (i + 1) (j + 1)
else
false
else
true