Skip to content

Conversation

tautschnig
Copy link
Collaborator

We were missing front-end support for reals and did not consistently support all of integers, naturals, rationals, reals but instead would only handle varying subsets in each place.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • 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 Jun 11, 2024
@tautschnig tautschnig force-pushed the bugfixes/mathematical-types branch from 34b8cbe to e5a11d2 Compare June 11, 2024 19:53
@tautschnig tautschnig force-pushed the bugfixes/mathematical-types branch from e5a11d2 to 19a8310 Compare September 22, 2025 20:02
@tautschnig tautschnig force-pushed the bugfixes/mathematical-types branch 2 times, most recently from cebcc43 to 9cd88b5 Compare September 23, 2025 15:33
@tautschnig tautschnig force-pushed the bugfixes/mathematical-types branch 2 times, most recently from 667b5f5 to 5a6f0b8 Compare September 23, 2025 18:51
We were missing front-end support for reals and did not consistently
support all of integers, naturals, rationals, reals but instead would
only handle varying subsets in each place.
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

❌ Patch coverage is 63.53591% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.48%. Comparing base (5f4c82d) to head (9d13355).

Files with missing lines Patch % Lines
src/ansi-c/c_typecast.cpp 57.69% 22 Missing ⚠️
src/solvers/smt2/smt2_conv.cpp 73.23% 19 Missing ⚠️
src/util/real.cpp 45.45% 6 Missing ⚠️
src/util/simplify_expr.cpp 28.57% 5 Missing ⚠️
src/solvers/flattening/boolbv_width.cpp 0.00% 4 Missing ⚠️
src/util/real.h 42.85% 4 Missing ⚠️
src/util/rational_tools.cpp 66.66% 3 Missing ⚠️
src/ansi-c/c_typecheck_type.cpp 75.00% 1 Missing ⚠️
src/util/arith_tools.cpp 50.00% 1 Missing ⚠️
src/util/pointer_offset_size.cpp 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8324      +/-   ##
===========================================
+ Coverage    80.43%   80.48%   +0.05%     
===========================================
  Files         1695     1697       +2     
  Lines       208285   208385     +100     
  Branches        73       73              
===========================================
+ Hits        167524   167726     +202     
+ Misses       40761    40659     -102     

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

class realt
{
protected:
mp_integer integral, fractional;
Copy link
Collaborator

@kroening kroening Sep 24, 2025

Choose a reason for hiding this comment

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

Representing real numbers like floating-point numbers will at the very least irritate. Please add a comment why this is the right choice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, which approach would you have chosen instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

E.g., you could have represented the algebraic numbers via the root of a polynomial; I'd be curious what the various SMT solvers output as models.

Copy link
Contributor

@polgreen polgreen Sep 24, 2025

Choose a reason for hiding this comment

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

z3 and cvc5 seem to output Reals as fractions, unless the denominator is 1, when they just output a singular decimal.

Whilst they use decimals, I've not managed to make it produce a number that isn't an integer as the nominator or denominator, or as a singular decimal.

(set-logic ALL)
(declare-fun x () Real)
(declare-fun y () Real)
(declare-fun z () Real)
(assert (= y (/ 100 30)))
(assert (= x 0.111111))
(assert (= z 7))
(check-sat)
(get-model)

z3 says:

(
  (define-fun z () Real
    7.0)
  (define-fun y () Real
    (/ 10.0 3.0))
  (define-fun x () Real
    (/ 111111.0 1000000.0))
)

cvc5 says

(
(define-fun x () Real (/ 111111 1000000))
(define-fun y () Real (/ 10 3))
(define-fun z () Real 7.0)
)

For irrational numbers, they output the root of a polynomial.

(set-logic ALL)
(declare-fun y () Real)
(assert (= (* y y) 2 ))
(check-sat)
(get-model)

z3 says

(
  (define-fun y () Real
    (root-obj (+ (^ x 2) (- 2)) 1))
)

cvc5 segfaults...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suspect we'll eventually want the algebraic numbers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll try to address this (even when I'd argue that the current PR already addresses a number of CBMC invariant failures that the included regression tests cause when attempted without the code changes).

Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to implement this right now; my suggestion is to add a comment, then merge this PR.

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