Skip to content

Add fp.min, fp.max#8888

Open
tautschnig wants to merge 3 commits intodiffblue:developfrom
tautschnig:fp.min_max
Open

Add fp.min, fp.max#8888
tautschnig wants to merge 3 commits intodiffblue:developfrom
tautschnig:fp.min_max

Conversation

@tautschnig
Copy link
Copy Markdown
Collaborator

Implement fp.min and fp.max in the SMT2 parser as compound expressions:

  • NaN handling: if either operand is NaN, return the other
  • Comparison: use fp.lt/fp.gt for normal ordering
  • Zero tie-breaking: fp.min prefers negative sign, fp.max prefers positive
  • 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.

@tautschnig tautschnig self-assigned this Mar 24, 2026
Copilot AI review requested due to automatic review settings March 24, 2026 18:26
Comment thread regression/smt2_solver/fp-issues/z3-4880-min-neg-zero.desc Outdated
Comment thread src/solvers/smt2/smt2_parser.cpp Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds SMT-LIB fp.min / fp.max support to the SMT2 parser by lowering them into compound expressions with IEEE-754-style NaN handling, ordered comparison, and signed-zero tie-breaking.

Changes:

  • Implement parsing for fp.min and fp.max in smt2_parser.cpp using conditional expressions.
  • Add regression tests for signed-zero tie-breaking and basic min/max behavior (including NaN handling).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/solvers/smt2/smt2_parser.cpp Adds fp.min / fp.max expression constructors with NaN + tie-breaking logic.
regression/smt2_solver/fp-issues/z3-4880-min-neg-zero.smt2 Adds a focused regression for fp.min(-0, +0) sign behavior.
regression/smt2_solver/fp-issues/z3-4880-min-neg-zero.desc Registers the new regression and expected outcome (unsat).
regression/smt2_solver/fp-issues/fp-min-max.smt2 Adds broader tests for fp.min / fp.max including NaN and signed zeros.
regression/smt2_solver/fp-issues/fp-min-max.desc Registers the new fp.min/max regression and expected outcome (sat).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/solvers/smt2/smt2_parser.cpp Outdated
Comment thread src/solvers/smt2/smt2_parser.cpp Outdated
Comment thread src/solvers/smt2/smt2_parser.cpp Outdated
Comment thread src/solvers/smt2/smt2_parser.cpp Outdated
Comment thread src/solvers/smt2/smt2_parser.cpp Outdated
Comment thread src/solvers/smt2/smt2_parser.cpp Outdated
Comment thread src/solvers/smt2/smt2_parser.cpp Outdated
Comment thread src/solvers/smt2/smt2_parser.cpp Outdated
Comment thread regression/smt2_solver/fp-issues/fp-min-max.smt2
tautschnig and others added 3 commits April 3, 2026 15:20
Implement the three missing FP predicates in the SMT2 parser:
- fp.isSubnormal: not NaN, not infinite, not zero, and not normal
- fp.isNegative: sign bit is 1 and not NaN
- fp.isPositive: sign bit is 0 and not NaN

These are expressed as compound expressions using existing predicates,
requiring no back-end changes.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Extract a shared fp_unary_operand helper lambda that parses and
validates the single FloatingPoint operand common to all fp.is*
predicate handlers. This removes the duplicated arity and type
checks from fp.isNaN, fp.isInfinite, fp.isNormal, fp.isZero,
fp.isSubnormal, fp.isNegative, and fp.isPositive.

Also uses typed expression classes (isnan_exprt, isinf_exprt)
consistently in the pre-existing handlers.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Implement fp.min and fp.max in the SMT2 parser as compound expressions:
- NaN handling: if either operand is NaN, return the other
- Comparison: use fp.lt/fp.gt for normal ordering
- Zero tie-breaking: fp.min prefers negative sign, fp.max prefers positive

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 88.33333% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.47%. Comparing base (803f904) to head (388503f).

Files with missing lines Patch % Lines
src/solvers/smt2/smt2_parser.cpp 88.33% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8888   +/-   ##
========================================
  Coverage    80.47%   80.47%           
========================================
  Files         1704     1704           
  Lines       188694   188728   +34     
  Branches        73       73           
========================================
+ Hits        151843   151881   +38     
+ Misses       36851    36847    -4     

☔ View full report in Codecov by Sentry.
📢 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.

auto y_nan = isnan_exprt(op[1]);
auto x_cmp_y = binary_relation_exprt(op[0], relation_id, op[1]);
const auto &type = to_floatbv_type(op[0].type());
// Reinterpret float bits as bitvector to extract the sign bit.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

use sign_exprt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants