C4: Contract verifier — Z3-backed verification#10
Merged
Conversation
Implements Tier 1 contract verification using Z3 SMT solver. Functions with decidable contracts (linear integer arithmetic, comparisons, Boolean logic, if/else) are proved automatically. Unsupported constructs (match, effects, recursion, quantifiers) fall back to Tier 3 with a warning. Counterexample generation shows concrete inputs that break violated contracts. New modules: vera/smt.py (AST→Z3 translation), vera/verifier.py (verification orchestration). New CLI command: vera verify <file>. 51 new tests (335 total). Version 0.0.8. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7 tasks
aallan
added a commit
that referenced
this pull request
May 12, 2026
…ecks The four `in`/`not in` substring assertions on mono-suffix strings in `TestGenericMonoSuffixFromSlotRef604` could pass on longer symbol variants (e.g. `$option_map$Int_Int_X` would satisfy `"$option_map$Int_Int" in wat`). No current code path produces longer variants, but the assertions weren't precise about what they were pinning. Replaced each substring check with a boundary-safe regex using a negative lookahead: `re.search(r"\$option_map\$<suffix>(?![A-Za-z0-9_])", wat)`. The pattern rejects any continuation character that would indicate a longer variant. `re` was already imported at top of file. Two test methods updated: - `test_mono_suffix_correct_for_slotref_fn_alias_arg` — positive `$option_map$Int_Int` + negative `$option_map$Int_Bool` - `test_parameterised_alias_substitutes_type_args` — positive `$option_map$Int_Int` + negative `$option_map$T_T` Validation: all 4 tests in `TestGenericMonoSuffixFromSlotRef604` pass against current compiler output. Refs #604 #655 #659 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
requires/ensuresclauses — Tier 1 (decidable fragment: QF_LIA + Boolean logic +length) proved automatically, Tier 3 (unsupported constructs) warned gracefullyvera/smt.py(AST→Z3 translation layer),vera/verifier.py(verification orchestration)vera verify <file>— type-checks then verifies contracts, prints tier summaryWhat it verifies
safe_divide.veraabsolute_value.veramodules.vera(clamp)factorial.veragenerics.veraincrement.veraTest plan
pytest tests/ -v— 335 passedmypy vera/— no issues (11 source files)python scripts/check_version_sync.py— 0.0.8 consistentpython scripts/check_examples.py— all 13 examples pass (check + verify)python scripts/check_spec_examples.py— 154 spec blocks valid🤖 Generated with Claude Code