Skip to content

Support quantifiers in cvc5 and bitwuzla (#662) - #669

Open
filipeom wants to merge 1 commit into
mainfrom
filip/issue-662
Open

Support quantifiers in cvc5 and bitwuzla (#662)#669
filipeom wants to merge 1 commit into
mainfrom
filip/issue-662

Conversation

@filipeom

Copy link
Copy Markdown
Member

Closes #662

@filipeom
filipeom requested a review from a team as a code owner July 29, 2026 19:32
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for creating symbolic variables across SMT solver backends.
    • Added universal and existential quantifier construction for boolean expressions.
    • Improved handling of quantified variables in generated solver expressions.
  • Bug Fixes

    • Quantified formulas now work with CVC5 and Bitwuzla instead of failing as unsupported.
  • Tests

    • Added regression coverage for existential bitvector formulas across multiple solvers.

Walkthrough

Changes

Quantified term support

Layer / File(s) Summary
Variable and quantifier contracts
src/smtml/mappings_intf.ml, src/smtml/dolmenexpr_to_expr.*, src/smtml/typed.*, src/smtml/mappings.nop.ml
Adds variable constructors to mapping and Dolmen interfaces and exposes typed Boolean forall and exists helpers.
Backend term construction
src/smtml/z3_mappings.default.ml, src/smtml/cvc5_mappings.default.ml, src/smtml/bitwuzla_mappings.default.ml
Adds backend variable constructors and implements CVC5 and Bitwuzla quantifier construction.
Variable-aware encoding and regression coverage
src/smtml/mappings.ml, test/regression/*
Encodes quantifier binders as variables and adds an existential bitvector regression test for CVC5 and Bitwuzla.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding quantifier support for CVC5 and Bitwuzla.
Description check ✅ Passed The description is related to the changeset and references the linked issue.
Linked Issues check ✅ Passed The PR implements the missing existential encoding for CVC5 and Bitwuzla, satisfying issue #662.
Out of Scope Changes check ✅ Passed The added API and mapping updates are consistent with broader quantifier support and do not look unrelated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/smtml/dolmenexpr_to_expr.mli (1)

63-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Complete odoc documentation for the new quantifier APIs.

Both interface additions expose public functions without the required parameter and return documentation.

  • src/smtml/dolmenexpr_to_expr.mli#L63-L63: document var with @param and @return tags.
  • src/smtml/typed.mli#L142-L147: document vars, e, and the return value for forall and exists.

As per path instructions, interface files must fully document public functions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/smtml/dolmenexpr_to_expr.mli` at line 63, The public quantifier APIs lack
complete odoc parameter and return documentation. In
src/smtml/dolmenexpr_to_expr.mli lines 63-63, document var’s string and ty
parameters and returned term; in src/smtml/typed.mli lines 142-147, document
vars and e plus the return values of forall and exists, without changing their
signatures or behavior.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/regression/test_issue_662.ml`:
- Line 1: Add the repository-standard SPDX, copyright, and author header to
test_issue_662.ml, followed by a top-level (** ... *) module documentation
comment before the existing Smtml.Typed.Bitv32.symbol declaration.
- Around line 12-16: Update both backend result matches in test_issue_662.ml to
succeed only for Sat and fail the regression for Unsat or Unknown. Extend the
regression with a universally quantified unsatisfiable case that ensures the
tested variable is actually bound, and assert that both backends return Sat for
the intended cases while preserving explicit failure for unexpected results.

---

Nitpick comments:
In `@src/smtml/dolmenexpr_to_expr.mli`:
- Line 63: The public quantifier APIs lack complete odoc parameter and return
documentation. In src/smtml/dolmenexpr_to_expr.mli lines 63-63, document var’s
string and ty parameters and returned term; in src/smtml/typed.mli lines
142-147, document vars and e plus the return values of forall and exists,
without changing their signatures or behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 80f1a65b-5543-466e-b6ef-93b8fe9daa62

📥 Commits

Reviewing files that changed from the base of the PR and between c753128 and 9d895fd.

📒 Files selected for processing (12)
  • src/smtml/bitwuzla_mappings.default.ml
  • src/smtml/cvc5_mappings.default.ml
  • src/smtml/dolmenexpr_to_expr.ml
  • src/smtml/dolmenexpr_to_expr.mli
  • src/smtml/mappings.ml
  • src/smtml/mappings.nop.ml
  • src/smtml/mappings_intf.ml
  • src/smtml/typed.ml
  • src/smtml/typed.mli
  • src/smtml/z3_mappings.default.ml
  • test/regression/dune
  • test/regression/test_issue_662.ml

@@ -0,0 +1,26 @@
let x = Smtml.Typed.Bitv32.symbol (Smtml.Symbol.make (Smtml.Ty.Ty_bitv 32) "x")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the required OCaml file header and module documentation.

This new .ml file is missing the SPDX, copyright, author header, and top-level (** ... *) module comment.

As per path instructions, every new .ml/.mli file must include these headers. Based on learnings, new OCaml modules in this repository also require a top-level module documentation comment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/regression/test_issue_662.ml` at line 1, Add the repository-standard
SPDX, copyright, and author header to test_issue_662.ml, followed by a top-level
(** ... *) module documentation comment before the existing
Smtml.Typed.Bitv32.symbol declaration.

Sources: Path instructions, Learnings

Comment on lines +12 to +16
let () =
match CVC5.check solver [ Smtml.Typed.Unsafe.unwrap expr ] with
| `Sat -> Format.printf "SAT@\n"
| `Unsat -> Format.printf "UNSAT@\n"
| `Unknown -> Format.printf "UNKNOWN@\n"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that both backends return Sat.

Both matches only print Unsat or Unknown and then exit successfully, so Dune treats the regression as passing even when quantifier encoding is wrong. Fail on any result other than Sat; add a universal unsatisfiable case to ensure the variable is actually bound.

As per path instructions, regression tests should cover expected results and error paths.

Also applies to: 22-26

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/regression/test_issue_662.ml` around lines 12 - 16, Update both backend
result matches in test_issue_662.ml to succeed only for Sat and fail the
regression for Unsat or Unknown. Extend the regression with a universally
quantified unsatisfiable case that ensures the tested variable is actually
bound, and assert that both backends return Sat for the intended cases while
preserving explicit failure for unexpected results.

Source: Path instructions

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.

Unimplemented method for CVC5 and Bitwulza (exist)

1 participant