Ceil simplifier#4157
Draft
ehildenb wants to merge 4 commits into
Draft
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.