Skip to content

Add fp.isSubnormal, fp.isNegative, fp.isPositive to SMT2 parser#8889

Merged
tautschnig merged 2 commits into
diffblue:developfrom
tautschnig:fp.isSNP
May 27, 2026
Merged

Add fp.isSubnormal, fp.isNegative, fp.isPositive to SMT2 parser#8889
tautschnig merged 2 commits into
diffblue:developfrom
tautschnig:fp.isSNP

Conversation

@tautschnig
Copy link
Copy Markdown
Collaborator

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.

  • 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:28
Comment thread src/solvers/smt2/smt2_parser.cpp 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 support for three missing SMT-LIB FP predicates (fp.isSubnormal, fp.isNegative, fp.isPositive) in the SMT2 parser by lowering them to compound expressions over existing internal FP predicates, and introduces a regression test to exercise the new parse paths.

Changes:

  • Implement fp.isSubnormal, fp.isNegative, and fp.isPositive in smt2_parsert::setup_expressions().
  • Add a new regression test case under regression/smt2_solver/fp-predicates/ to check satisfiability and NaN behavior.

Reviewed changes

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

File Description
src/solvers/smt2/smt2_parser.cpp Adds parser handlers for the three FP predicates via existing internal expressions.
regression/smt2_solver/fp-predicates/fp-predicates1.smt2 New SMT2 input covering the new predicates (sat + NaN checks).
regression/smt2_solver/fp-predicates/fp-predicates1.desc Registers the new regression test and expected output.

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

Comment thread regression/smt2_solver/fp/fp-predicates1.smt2
Comment thread regression/smt2_solver/fp/fp-predicates1.smt2
Comment thread regression/smt2_solver/fp/fp-predicates1.smt2
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
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.56%. Comparing base (df24632) to head (c4d1cdd).

Files with missing lines Patch % Lines
src/solvers/smt2/smt2_parser.cpp 92.85% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8889      +/-   ##
===========================================
- Coverage    80.57%   80.56%   -0.01%     
===========================================
  Files         1708     1708              
  Lines       189217   189212       -5     
  Branches        73       73              
===========================================
- Hits        152460   152446      -14     
- Misses       36757    36766       +9     

☔ 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.

@kroening
Copy link
Copy Markdown
Collaborator

Put the tests into regression/smt2_solver/fp?

@tautschnig
Copy link
Copy Markdown
Collaborator Author

Put the tests into regression/smt2_solver/fp?

Done.

tautschnig and others added 2 commits May 27, 2026 12:16
Implement the three missing FP predicates in the SMT2 parser:
- fp.isSubnormal: finite, non-zero, and not normal -- mirrors
  SMT-LIB's own definition (Theory of Floating-Point Numbers,
  fp.isSubnormal). Encoded with isfinite_exprt and the existing
  is-not-zero / is-not-normal helpers.
- fp.isNegative: sign bit is 1 and not NaN. The explicit not(isnan)
  is required: float_bvt::sign_bit returns the raw top bit (true
  for -NaN), whereas SMT-LIB's fp.isNegative is false for any NaN.
- fp.isPositive: symmetric counterpart, sign bit is 0 and not NaN.

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

Regression test in regression/smt2_solver/fp-predicates/ exercises
both directions:
- under-approximation: a (check-sat) over six declared constants and
  a handful of concrete-bit-pattern witnesses (smallest positive
  Float32 subnormal, +/-0, NaN) checks that each predicate holds on
  values it should accept;
- over-approximation: three (check-sat-assuming ...) calls assert
  that the predicates do *not* return true on values they should
  reject (-0 is not positive, +0 is not negative, 1.0 is not
  subnormal). Each is expected to return unsat.

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 unary FP
handlers. This removes the duplicated arity and type checks from
fp.abs, fp.isNaN, fp.isInfinite, fp.isNormal, fp.isZero,
fp.isSubnormal, fp.isNegative, and fp.isPositive. The helper sits
just before fp.abs so it covers every unary FP handler in the file.

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>
@tautschnig tautschnig merged commit 79f0f3a into diffblue:develop May 27, 2026
42 of 43 checks passed
@tautschnig tautschnig deleted the fp.isSNP branch May 27, 2026 21:29
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.

5 participants