Skip to content

Ceil simplifier#4157

Draft
ehildenb wants to merge 4 commits into
masterfrom
ceil-simplifier
Draft

Ceil simplifier#4157
ehildenb wants to merge 4 commits into
masterfrom
ceil-simplifier

Conversation

@ehildenb

Copy link
Copy Markdown
Member

No description provided.

ehildenb and others added 4 commits June 18, 2026 04:44
Collects all maximal sub-terms of a term that are rooted at a partial
(non-total, non-constructor) symbol. These sub-terms represent the
definedness conditions that must hold for the enclosing rule to be
applied soundly — i.e. each collected sub-term must not evaluate to
bottom.

Used by ApplyEquations for runtime definedness discharge.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 9b7b65ce2b5ed3139c4326b92f1bdbc1aa8e679a)
…s discharge

Adds an evaluateCeils flag to EquationConfig controlling whether the
equation engine attempts to discharge definedness conditions for rules
whose RHS contains partial-function applications.

When evaluateCeils=True (via runEquationTWithCeils / evaluatePatternWithCeils):
- Rules with notPreservesDefinednessReasons=[] proceed unconditionally (already
  guaranteed by the preserves-definedness attribute).
- Rules with no undefined sub-terms in the RHS also proceed unconditionally.
- Rules that have undefined sub-terms require runtime discharge: each partial-
  function sub-term is evaluated with evaluateCeils=False; if the result
  changed (i.e. the term was defined), the condition is considered discharged.
  All conditions must discharge for the rule to apply.

The tryEvaluate heuristic — "if evaluating with evaluateCeils=False changes
the term, it was defined" — is an under-approximation: it may miss some
cases (returning false negatives), but never unsoundly accepts an undefined term.

Also exports evaluatePatternWithCeils for use in the implies checker.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit b37c3cdafcc077a82e389a9988d9cfc47660c961)
…aluatePatternWithCeils

When matching during implies returns MatchIndeterminate, the handler
simplifies the LHS pattern and retries; switch that simplification call
from 'evaluatePattern' to 'evaluatePatternWithCeils' so the LHS-simplify
pass can discharge runtime definedness side-conditions (the capability
the prior commit added).  No structural change to the retry logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 1c7164d5d1734fd71bf437939bc446d691613c9b)
In the MatchIndeterminate branch: after failing to change the LHS
with evaluatePatternWithCeils, also attempt simplifying the RHS with
the LHS constraints added to its context. If the RHS term changes, retry
matching. This handles cases like hashLoc(...) => keccak(buf(...) +Bytes
buf(32, 0)) where the consequent can be simplified to match the antecedent
once LHS constraints are propagated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 373d1446e66559bda7e860307e3f67bd9e210b10)
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.

1 participant