lean4-htt/tests/elab/cbv_brackets.lean
Wojciech Różowski e8c3485e08
fix: cbv getting stuck after a rewrite of cbv_opaque function (#13122)
This PR fixes `cbv` tactic getting stuck after rewriting functions
marked with `cbv_opaque` that have a `cbv_eval` lemma registered.
2026-03-25 18:13:13 +00:00

17 lines
571 B
Text

def computeMaxDepth (s : String.Slice) : Int := Id.run do
let mut depth : Int := 0
let mut maxDepth : Int := 0
for c in s do
if c == '(' then
depth := depth + 1
maxDepth := max maxDepth depth
else if c == ')' then
depth := depth - 1
maxDepth := max maxDepth depth
return maxDepth
def parseNestedParens (parenString : String.Slice) : Array Int :=
(parenString.split ' ').map computeMaxDepth |>.toArray
example : parseNestedParens "() () () ()" = #[1, 1, 1, 1] := by cbv
example : parseNestedParens "() (())" = #[1, 2] := by cbv