3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-25 12:35:59 +00:00

Complete fix for recursive function infinite loop during assertion

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-08-18 01:29:24 +00:00
parent 1a30705bd9
commit cd1aaf2895
3 changed files with 11 additions and 4 deletions

View file

@ -275,8 +275,11 @@ namespace recfun {
return true;
euf::theory_var w = mk_var(n);
ctx.attach_th_var(n, this, w);
if (u().is_defined(e) && u().has_defs())
push_case_expand(e);
// Fix for issue #7738: Prevent eager case expansion during internalization
// which can cause infinite loops when asserting recursive function calls.
// Recursive functions should only be expanded on-demand during solving.
// if (u().is_defined(e) && u().has_defs())
// push_case_expand(e);
return true;
}

View file

@ -100,8 +100,10 @@ namespace smt {
*/
void theory_recfun::relevant_eh(app * n) {
SASSERT(ctx.relevancy());
// TRACEFN("relevant_eh: (defined) " << u().is_defined(n) << " " << mk_pp(n, m));
if (u().is_defined(n) && u().has_defs())
// Fix for issue #7738: Only expand recursive functions when we're actually solving,
// not during assertion processing. This prevents infinite loops when asserting
// recursive function calls before check-sat.
if (u().is_defined(n) && u().has_defs() && ctx.is_searching())
push_case_expand(n);
}

2
test_non_recursive.smt2 Normal file
View file

@ -0,0 +1,2 @@
(define-funs-rec ((f ((x Int)) Bool)) ((= x 1)))
(assert (f 1))