Expand description
Proof-mode recursion classifier.
Backend-neutral pattern matching over the Aver AST that decides,
for each recursive pure fn (or mutual-recursion SCC), which
RecursionPlan variant applies — or emits a ProofModeIssue
when the shape falls outside the supported set.
Lean and Dafny consume the same plans through
[crate::codegen::recursion::analyze_plans]; a couple of helpers
that depend on AST queries tied to Lean’s toplevel (pure-fn
predicate, recursive-type-def predicate, type-def name) still live
in crate::codegen::lean and are re-used here through
pub(crate) exports. That could move to a neutral AST helper
module in a later pass.
Functions§
- analyze_
plans_ in_ scope - Classify every recursive pure fn in
inputs. The returned map assigns each supported function aRecursionPlan; anything that falls outside the recognised shapes becomes aProofModeIssue. - scc_
has_ growing_ accumulator - True iff some intra-SCC call passes a non-trivially-shrinking
expression into a callee’s sizeOf parameter — tail-recursive
accumulator patterns like
[x] + acc/List.prepend(x, acc)/acc + [x], plus arbitraryFnCall(...)results we can’t statically prove shrink. These all fail termination-by-measure even though fuel encoding handles them fine; backends fall back to fuel for those SCCs. - sizeof_
measure_ param_ indices - SizeOf-measure param indices for a fn — every non-scalar param
position contributes a term to the structural measure. Matches
the picks made for the Lean
termination_byclause and the Dafny nativedecreasestuple so the same params drive measure inference on both backends.