This PR makes functions defined by well-founded recursion use an `opaque` well-founded proof by default. This reliably prevents kernel reduction of such definitions and proofs, which tends to be prohibitively slow (fixes #2171), and which regularly causes hard-to-debug kernel type-checking failures. This changes renders `unseal` ineffective for such definitions. To avoid the opaque proof, annotate the function definition with `@[semireducible]`.
22 lines
450 B
Text
22 lines
450 B
Text
def numChars (s : String) : Nat :=
|
||
go s.iter
|
||
where
|
||
go (i : String.Iterator) : Nat :=
|
||
if h : i.hasNext then
|
||
go i.next + 1
|
||
else
|
||
0
|
||
|
||
#guard numChars "aαc" == 3
|
||
|
||
example : numChars "aαc" = 3 := by native_decide
|
||
|
||
def numChars2 (s : String) : Nat :=
|
||
go s.iter
|
||
where
|
||
go (i : String.Iterator) : Nat :=
|
||
match h : i.hasNext with
|
||
| true => go i.next + 1
|
||
| false => 0
|
||
|
||
example : numChars2 "aαc" = 3 := by native_decide
|