Skip to content

SMT2: do not define a symbol by an expression that refers to it - #9179

Merged
kroening merged 1 commit into
diffblue:developfrom
tautschnig:kiro/smt2-self-referential-equality
Oct 8, 2026
Merged

kroening merged 1 commit into
diffblue:developfrom
tautschnig:kiro/smt2-self-referential-equality

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

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.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

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]>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.86%. Comparing base (4b26409) to head (ff9415c).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kroening
kroening merged commit f17df18 into diffblue:develop Oct 8, 2026
43 checks passed
@tautschnig
tautschnig deleted the kiro/smt2-self-referential-equality branch October 12, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants