lean4-htt/tests/lean/run/numChars.lean
Joachim Breitner 41a2e9af19
feat: well-founded recursion: opaque well-foundedness proofs (#5182)
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]`.
2025-03-19 09:21:04 +00:00

22 lines
450 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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