generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 23
Add B3 Verifier: SMT-based verification for B3 programs #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MikaelMayer
wants to merge
86
commits into
main
Choose a base branch
from
b3-to-smt-converter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
20242c2
Add B3 to SMT converter with interactive test
MikaelMayer 40727c6
Fix B3 to SMT converter to match B3's SMT generation
MikaelMayer 4414ed7
Add top-level check declarations and if-then-else support
MikaelMayer 19a0bf4
Fix check statement to verify provability instead of asserting
MikaelMayer 466f586
Add support for functions with bodies
MikaelMayer f8af0a1
Refactor to two-pass approach for mutually recursive functions
MikaelMayer aaec9a3
Add quantifier pattern support and implies operator
MikaelMayer c150aba
Complete core expression support for B3 to SMT converter
MikaelMayer d73cd24
Fix function definition triggers to use function call pattern
MikaelMayer 6153a2c
Add incremental verification API with Z3 solver integration
MikaelMayer 8c4933f
Reorganize B3 verifier into modular structure
MikaelMayer 700c645
Rename Verifier/Verifier.lean to Verifier/Core.lean
MikaelMayer b7c5e14
Document why we use custom formatter instead of SMT Encoder
MikaelMayer 29908bf
Add statement-to-VC conversion (VCG foundation)
MikaelMayer f96d23b
Implement parameter-free procedure verification
MikaelMayer 6ca219d
Merge and clean up test files
MikaelMayer 95f8c12
Add source location tracking and error reporting
MikaelMayer b8fd1d6
Add counterexample display with source location and statement
MikaelMayer 3a27145
Complete B3 verifier with error reporting and model indication
MikaelMayer 5859f6e
Remove checkDecl and add conjunction refinement strategy
MikaelMayer 38e53a8
Add conjunction refinement with proper API separation
MikaelMayer 5119550
Implement general automatic refinement verification
MikaelMayer 6e94e24
Polish error messages and remove model placeholder
MikaelMayer 41119a7
Implement efficient solver reuse with push/pop
MikaelMayer c757d12
Rename Refinement to Diagnosis and expose push/pop API
MikaelMayer ae44cab
Update documentation to reflect current API
MikaelMayer 48abe84
Improve API naming and add reach support
MikaelMayer a03f0cc
Add unified addDeclaration API and move tests to proper location
MikaelMayer fb71f14
Fix namespace scope for high-level API functions
MikaelMayer 8febeb2
Add reach test and fix test file organization
MikaelMayer b5f6939
Fix reach statement semantics and output
MikaelMayer d31b140
Complete reach semantics with precondition checking examples
MikaelMayer bf8eed9
WIP: Implement streaming translation (NOT batch VCG)
MikaelMayer b3d6006
Replace SMT Decision with B3-level result types
MikaelMayer 309bec8
Use separate result types for check and reach
MikaelMayer 2905a07
WIP: Major refactoring to streaming translation and unified API
MikaelMayer bc57e12
Implement unified API with solver as parameter
MikaelMayer 1a6e5f8
Split state into SMTSolverState and B3VerificationState
MikaelMayer 54ba932
Improve result formatting and fix test expectations
MikaelMayer 5029d10
Complete B3 verifier with comprehensive documentation
MikaelMayer f8bfc43
Complete B3 verifier with comprehensive documentation
MikaelMayer 7848fd3
Reorganize documentation into unified implementation status
MikaelMayer a822591
Final documentation: add incremental API and old values
MikaelMayer 0971a6e
Remove old values from TODO - already handled via de Bruijn indices
MikaelMayer 9c40158
refactor(B3): Improve verifier with transformation, error handling, a…
MikaelMayer 7f6c312
refactor(B3): Reorganize verifier modules for clarity
MikaelMayer 8517321
refactor(B3): Clean up empty section dividers in Batch.lean
MikaelMayer c4bca29
refactor(B3): Remove redundant API.lean and legacy functions
MikaelMayer 053b54c
docs(B3): Add architecture diagram and clarify implementation status
MikaelMayer d7b2b64
chore(B3): Remove test artifact and document result type hierarchy
MikaelMayer b7b2ae9
refactor(B3): Improve naming clarity and consolidate diagnosis code
MikaelMayer 975d604
refactor(B3): Consolidate diagnosis code and improve naming
MikaelMayer 3515e53
Reorganize B3 verifier tests and improve output formatting
MikaelMayer 647058f
feat(B3): Complete error accumulation refactoring with enhanced diagn…
MikaelMayer 56b8d7e
refactor(B3): Improve verification report structure and output format…
MikaelMayer 388018f
refactor(B3): Rename modules and improve API design
MikaelMayer b6f0f26
docs(B3): Show full pipeline with B3CST.Program in example
MikaelMayer f24cd73
docs(B3): Simplify example to use programToB3AST helper
MikaelMayer 8d1b12e
docs(B3): Add diagnosis behavior explanation
MikaelMayer b517ee5
fix(B3): Fix path condition display in diagnosis and add formatStatement
MikaelMayer 1a245e0
feat(B3): Use formatStatement from Statements.lean in Verifier.lean
MikaelMayer 25ac46e
chore: Remove local development files from tracking
MikaelMayer 17cee51
feat(B3): Add StrataVerifyB3 CLI tool
MikaelMayer 8bffd3c
Merge branch 'main' into b3-to-smt-converter
MikaelMayer b8747dc
Use SMT dialect pretty-printer instead of custom string interpolation
MikaelMayer d3d3a9e
Fix SMT equality operator to use '=' instead of 'eq'
MikaelMayer c00df60
Extract pure logic from IO functions in Diagnosis
MikaelMayer 838a3c6
Extract pure logic from IO functions in Program
MikaelMayer 5ef6fd9
Extract pure logic from IO functions in Statements and Diagnosis
MikaelMayer 5a55ab8
Rename getStatementMetadata to B3AST.Statement.metadata
MikaelMayer 085078e
Update documentation per review comments
MikaelMayer a24f3d4
Integrate B3 verification into StrataVerify
MikaelMayer 9279956
Rename verification functions to emphasize SMT translation
MikaelMayer e217e99
Unify statement translation return types with optional diagnosis
MikaelMayer 04c0bb9
Merge branch 'main' into b3-to-smt-converter
MikaelMayer 2f02069
Add SMT pattern support and fix formatting issues
MikaelMayer 8c231cf
Remove accidentally committed test file
MikaelMayer 85dcc23
Switch to CVC5 and update test expectations
MikaelMayer 1620932
Fix solver lifecycle - don't call exit in tests
MikaelMayer ee80e24
Remove action plan file
MikaelMayer 9c11a05
Merge main into b3-to-smt-converter
MikaelMayer 060244c
Address Josh's review comments
MikaelMayer bca2f06
Address additional Josh review comments
MikaelMayer fcb2194
Prove termination for termToSExpr
e81132a
Merge branch 'main' into b3-to-smt-converter
aff081e
Fix if-then-else expressions
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| # Josh's Review Comments on PR #307 | ||
|
|
||
| **Reviewer:** @joscoh (Josh) | ||
| **Date:** January 15, 2026 | ||
| **Status:** Pending response | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 1: Use List.map instead of for loop ✅ DONE | ||
|
|
||
| **File:** `Strata/Languages/B3/Verifier/Program.lean` | ||
| **Line:** 106 | ||
| **Comment:** | ||
| > I think it's nicer to have `let results := results ++ List.map .error conversionErrors` | ||
| **Status:** ✅ Fixed | ||
|
|
||
| **Change Applied:** | ||
| ```lean | ||
| results := results ++ conversionErrors.map .error | ||
| ``` | ||
|
|
||
| **Commit:** (pending) | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 2: Remove unnecessary mutable variable ✅ DONE | ||
|
|
||
| **File:** `Strata/Languages/B3/Verifier/Program.lean` | ||
| **Line:** 94 | ||
| **Comment:** | ||
| > This does not need to be mutable. | ||
| **Status:** ✅ Fixed | ||
|
|
||
| **Change Applied:** | ||
| ```lean | ||
| let initialState ← initVerificationState solver | ||
| ... | ||
| let (state, conversionErrors) ← addDeclarationsAndAxioms initialState transformedProg | ||
| ``` | ||
|
|
||
| **Commit:** (pending) | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 3: Remove duplicate section header ✅ DONE | ||
|
|
||
| **File:** `Strata/Languages/B3/Verifier/Program.lean` | ||
| **Line:** 119 | ||
| **Comment:** | ||
| > Repeated section | ||
| **Status:** ✅ Fixed | ||
|
|
||
| **Change Applied:** Removed duplicate header. | ||
|
|
||
| **Commit:** (pending) | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 4: Remove unused section header ✅ DONE | ||
|
|
||
| **File:** `Strata/Languages/B3/Verifier/State.lean` | ||
| **Line:** 63 | ||
| **Comment:** | ||
| > Is this section header used? | ||
| **Status:** ✅ Fixed | ||
|
|
||
| **Change Applied:** Removed unused "Verification State" header that was immediately followed by "Verification Context and Results" header. | ||
|
|
||
| **Commit:** (pending) | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 5: Use reverse list building pattern ✅ DONE | ||
|
|
||
| **File:** `Strata/Languages/B3/Verifier/Program.lean` | ||
| **Line:** 202 | ||
| **Comment:** | ||
| > Again, it would be better to build the reverse list with `::` and reverse the whole thing at the end. | ||
| **Status:** ✅ Fixed | ||
|
|
||
| **Change Applied:** | ||
| ```lean | ||
| let mut reportsRev := [] | ||
| ... | ||
| reportsRev := {procedureName := name, results := resultsWithDiag} :: reportsRev | ||
| ... | ||
| return reportsRev.reverse | ||
| ``` | ||
|
|
||
| **Commit:** (pending) | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 6: Same optimization for Statements.lean ✅ DONE | ||
|
|
||
| **File:** `Strata/Languages/B3/Verifier/Statements.lean` | ||
| **Line:** 98 | ||
| **Comment:** | ||
| > Same as above | ||
| **Status:** ✅ Fixed | ||
|
|
||
| **Change Applied:** Used `::` and reverse pattern in both `statementToSMTWithoutDiagnosis` (Statements.lean) and `statementToSMT` (Diagnosis.lean). | ||
|
|
||
| **Commit:** (pending) | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 7: No partial evaluation in B3? ✅ RESPONDED | ||
|
|
||
| **File:** `StrataTest/Languages/B3/Verifier/VerifierTests.lean` | ||
| **Line:** 485 | ||
| **Comment:** | ||
| > I take it from this test this is no B3 partial evaluation, right? | ||
| **Status:** ✅ Clarified by user | ||
|
|
||
| **Response:** User confirmed this is correct - B3 doesn't do partial evaluation, it translates directly to SMT terms and lets the SMT.Factory layer handle constant folding. | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 8: Declaration ordering and dependencies ✅ RESPONDED | ||
|
|
||
| **File:** `Strata/Languages/B3/Transform/FunctionToAxiom.lean` | ||
| **Line:** 154 | ||
| **Comment:** | ||
| > Makes sense, but it seems a little strange to me that getting things in the correct order is bound up with generating axioms for functions (with another function encoding, we would still need to make sure the order is consistent). And this doesn't even completely enforce the right order, since I don't think it deals with dependencies between e.g. two functions, one of which calls the other. | ||
| **Status:** ✅ Clarified | ||
|
|
||
| **Note:** The ordering is: types → function declarations → axioms → other. This is correct for SMT-LIB where sorts must come before functions, and function declarations before axioms. Function-to-function dependencies don't matter for declarations (only for axioms), and the current ordering handles this correctly. | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 9: Remove bullet points from Formatter.lean docstring | ||
|
|
||
| **File:** `Strata/Languages/B3/Verifier/Formatter.lean` | ||
| **Comment:** | ||
| > I don't think we need these bullets here personally. | ||
| **Current Code:** | ||
| ```lean | ||
| This module uses `SMTDDM.toString` which translates SMT terms to the SMT dialect's | ||
| AST and then uses the dialect's formatter to generate SMT-LIB strings. This approach: | ||
| - Is more efficient than string interpolation | ||
| - Produces direct, readable SMT-LIB output (no A-normal form) | ||
| - Leverages the existing SMT dialect infrastructure | ||
| - Ensures consistency with other SMT formatting in Strata | ||
| ``` | ||
|
|
||
| **Recommendation:** **Accept** - Simplify the docstring to be more concise without the bullet points. | ||
|
|
||
| **Effort:** Trivial | ||
|
|
||
| --- | ||
|
|
||
| ## Comment 9: Remove bullet points from Formatter.lean docstring ✅ DONE | ||
|
|
||
| **File:** `Strata/Languages/B3/Verifier/Formatter.lean` | ||
| **Comment:** | ||
| > I don't think we need these bullets here personally. | ||
| **Status:** ✅ Fixed | ||
|
|
||
| **Change Applied:** Simplified docstring to remove bullet points, keeping just the essential description. | ||
|
|
||
| **Commit:** (pending) | ||
|
|
||
| --- | ||
|
|
||
| ## Summary | ||
|
|
||
| **Total Comments:** 9 | ||
|
|
||
| **Status:** | ||
| - ✅ **Fixed:** 6 (Comments 1, 2, 3, 4, 5, 6, 9) | ||
| - ✅ **Responded:** 2 (Comments 7, 8) | ||
|
|
||
| **All comments addressed!** | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be committed to the repo.