Expand SMT decidable fragment: match, ADTs, decreases (#13)#176
Merged
Conversation
Add Z3 translation for match expressions, ADT constructors, and decreases clauses, promoting contracts from Tier 3 (runtime) to Tier 1 (statically verified). Verification coverage goes from 88/96 (91.7%) to 92/96 (95.8%) across all 15 examples. Phase A: Translate MatchExpr, ConstructorCall, NullaryConstructor to Z3 using algebraic datatype sorts with nested If-chains. Phase B: Verify Nat decreases via direct < comparison at recursive call sites with path-condition tracking. Phase C: Verify ADT decreases via structural rank functions with ForAll axioms for recursive constructor fields. Co-Authored-By: Claude <noreply@anthropic.invalid>
Document the tier model and verification stats (92/96 contracts, 95.8% static) with a breakdown of the 4 remaining Tier 3 contracts and what the Tier 1 decidable fragment covers. Co-Authored-By: Claude <noreply@anthropic.invalid>
- README.md: Mark #13 as done (v0.0.51), annotate #45 as partially done - E522 rationale: Remove "pattern matching" from unsupported examples (match expressions are now Tier 1) - E525 rationale: Replace "not yet implemented" with accurate description of what IS verified (self-recursive Nat/ADT) and what still falls back (mutual recursion, untranslatable measures) Co-Authored-By: Claude <noreply@anthropic.invalid>
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.
Summary
MatchExpr,ConstructorCall, andNullaryConstructorto Z3 usingz3.Datatypesorts with nestedIf-chains for match arms and recognizer/accessor-based pattern bindings<comparison for Nat measures, structural rank functions withForAllaxioms for ADT measuresContracts promoted to Tier 1
ensures(@Nat.result >= 0)onlengthdecreases(@Nat.0)decreases(@List<Int>.0)onlengthdecreases(@List<Int>.0)onsumRemaining 4 Tier 3 contracts
Implementation
vera/smt.py(+376 lines): ADT sort creation, match/constructor translation, rank functions, per-sort length functionsvera/verifier.py(+276 lines): Constructor registration in_register_data, ADT parameter declarations,_verify_decreaseswith recursive call collection and path-condition trackingtests/test_verifier.py(+357 lines): 16 new tests across 3 new test classes (match/ADT verification, Nat decreases, ADT decreases)Test plan
pytest tests/ -v)mypy vera/)python scripts/check_examples.py)python scripts/check_version_sync.py)Closes #13
🤖 Generated with Claude Code