Skip to content

Move is_{true,false,zero,one} from exprt to constant_exprt #8664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

tautschnig
Copy link
Collaborator

true/false/zero/one are constants, so only for a constant_exprt those methods can ever evaluate to true.

This commit both deprecates the exprt methods and removes all their uses from the code base.

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

true/false/zero/one are constants, so only for a `constant_exprt` those
methods can ever evaluate to true.

This commit both deprecates the `exprt` methods and removes all their
uses from the code base.
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 79.36085% with 155 lines in your changes missing coverage. Please review.

Project coverage is 80.38%. Comparing base (7a6e2f7) to head (1a6ab22).
Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
src/util/std_expr.cpp 71.92% 16 Missing ⚠️
src/goto-instrument/goto_program2code.cpp 70.00% 12 Missing ⚠️
src/analyses/invariant_set.cpp 0.00% 10 Missing ⚠️
src/analyses/custom_bitvector_analysis.cpp 0.00% 9 Missing ⚠️
src/goto-instrument/dot.cpp 0.00% 9 Missing ⚠️
src/goto-checker/counterexample_beautification.cpp 0.00% 8 Missing ⚠️
src/analyses/goto_rw.cpp 12.50% 7 Missing ⚠️
src/util/simplify_expr_int.cpp 81.08% 7 Missing ⚠️
...goto-instrument/accelerate/sat_path_enumerator.cpp 0.00% 6 Missing ⚠️
src/util/interval.cpp 60.00% 6 Missing ⚠️
... and 29 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8664      +/-   ##
===========================================
- Coverage    80.39%   80.38%   -0.01%     
===========================================
  Files         1688     1688              
  Lines       207134   207448     +314     
  Branches        73       73              
===========================================
+ Hits        166520   166759     +239     
- Misses       40614    40689      +75     

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

Copy link
Collaborator

@feliperodri feliperodri left a comment

Choose a reason for hiding this comment

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

All changes in the contract-related modules LGTM.

@kroening
Copy link
Member

This does increase verbosity.

@kroening
Copy link
Member

I think I'd prefer that we make the constructors of true_exprt, false_exprt etc. return a lazily constructed static object; we could then write expr == true_exprt{} and the like.

@kroening
Copy link
Member

For numbers, this will be a bit more verbose, but I don't have a great idea.

@tautschnig
Copy link
Collaborator Author

Can I suggest to take three different approaches:

  1. is_true and is_false get replaced by == true_exprt{} and == false_exprt{}, respectively per your suggestion.
  2. We get rid of is_one: it isn't used widely and we actually have multiple implementations with the same name already.
  3. We do for is_zero what this PR proposes.

Would that work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants