Skip to content

Add VC Arithmetic Simplification#251

Open
rcosta358 wants to merge 9 commits into
vc-foldingfrom
vc-arithmetic
Open

Add VC Arithmetic Simplification#251
rcosta358 wants to merge 9 commits into
vc-foldingfrom
vc-arithmetic

Conversation

@rcosta358

Copy link
Copy Markdown
Collaborator

Description

This PR adds VC simplification for arithmetic identity expressions through VCImplication chains for when operands are not constants. When a refinement contains simplifiable arithmetic such as neutral elements, zero multiplication, double negation, negated operands, or guarded division/modulo identities, it simplifies the VC node while preserving its origin and the rest of the VC chain.

This new simplification pass is done after substitution and folding, with the following simplifications:

  • x + 0 → x
  • 0 + x → x
  • x - 0 → x
  • 0 - x → -x
  • x + (-x) → 0
  • (-x) + x → 0
  • x - x → 0
  • -(-x) → x
  • x + (-y) → x - y
  • x - (-y) → x + y
  • x * 1 → x
  • 1 * x → x
  • x * 0 → 0
  • 0 * x → 0
  • x / 1 → x
  • 0 / x → 0 (if x != 0)
  • x / x → 1 (if x != 0)
  • x % 1 → 0
  • x % x → 0 (if x != 0)

Example

x * 1 > 0

is simplified to

x > 0

with origin x * 1 > 0

Related Issue

None.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactoring

Checklist

  • Added/updated tests
  • mvn test passes locally
  • Updated docs/README if behavior or API changed

@rcosta358 rcosta358 self-assigned this Jun 13, 2026
@rcosta358 rcosta358 added enhancement New feature or request simplification Related to the simplification of expressions labels Jun 13, 2026
@rcosta358 rcosta358 requested a review from CatarinaGamboa June 13, 2026 17:44

@CatarinaGamboa CatarinaGamboa left a comment

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.

lgtm

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

Labels

enhancement New feature or request simplification Related to the simplification of expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants