Repository navigation
SMT2: do not define a symbol by an expression that refers to it - #9179
Merged
kroening merged 1 commit intoOct 8, 2026
Merged
Conversation
smt2_convt::set_to turns the equality of a not yet declared symbol and an
expression into a define-fun of that symbol. When the expression refers to
the symbol itself, e.g., x == (x & y) | z, the result is a definition that
refers to the symbol being defined, which solvers reject ("Symbol 'x' not
declared as a variable" in cvc5). Such an equality is a constraint on x,
and is now emitted as declare-fun followed by an assert, as it already was
for back-ends that use declare-fun throughout.
Co-authored-by: Kiro <[email protected]>
tautschnig
requested review from
TGWDB,
kroening,
martin-cs and
peterschrammel
as code owners
October 8, 2026 11:20
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix correctly prevents recursive definitions while preserving existing behavior and includes appropriate regression coverage.
0 open findings
What changed in this PR
Prevents invalid self-referential SMT2 define-fun output by emitting such equalities as declarations plus assertions.
Changes:
- Detects references to the prospective definition symbol.
- Adds unit coverage for self-referential and ordinary equalities.
| File | Description |
|---|---|
src/solvers/smt2/smt2_conv.cpp |
Guards definition generation against self-reference. |
unit/solvers/smt2/smt2_conv.cpp |
Verifies declaration/assertion and definition paths. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9179 +/- ##
========================================
Coverage 80.85% 80.86%
========================================
Files 1717 1717
Lines 190161 190181 +20
Branches 73 73
========================================
+ Hits 153759 153782 +23
+ Misses 36402 36399 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kroening
approved these changes
Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
smt2_convt::set_to turns the equality of a not yet declared symbol and an expression into a define-fun of that symbol. When the expression refers to the symbol itself, e.g., x == (x & y) | z, the result is a definition that refers to the symbol being defined, which solvers reject ("Symbol 'x' not declared as a variable" in cvc5). Such an equality is a constraint on x, and is now emitted as declare-fun followed by an assert, as it already was for back-ends that use declare-fun throughout.