This directory provides documentation for each VeriStruct module, which together form a comprehensive verification solution.
See the RingBuffer Example for a walkthrough showing how the modules handle a real verification task.
- Generates mathematical abstractions for data structures
- Creates View functions for formal specifications
- Handles vector and collection abstractions
- Maintains type safety and semantic correctness
- Improves existing View functions
- Optimizes mathematical abstractions
- Simplifies representations
- Maintains semantic equivalence
- Generates invariant functions
- Captures data structure constraints
- Implements well-formed conditions
- Ensures type safety
- Adds requires/ensures clauses
- Implements spec functions
- Handles trait specifications
- Maintains code safety
- Generates verification proofs
- Implements loop invariants
- Handles proof assertions
- Manages proof blocks
- Loads lemma files based on keywords found in the code
- Inserts lemmas after the
verus!{marker before planning - Uses explicit keyword-to-file mapping for precise lemma selection
graph TD
A[View Inference] --> B[View Refinement]
B --> C[Invariant Inference]
C --> D[Specification Inference]
D --> E[Proof Generation]
F[Context Manager] --> A
F --> B
F --> C
F --> D
F --> E
G[Repair System] --> A
G --> B
G --> C
G --> D
G --> E
All modules share these common features:
-
Safety Checking:
- Code change validation
- Type safety verification
- Semantic preservation
- Structure maintenance
-
Error Handling:
- Multiple retry attempts
- Temperature adjustment
- Type error fixing
- Compilation error repair
-
Result Management:
- Best result tracking
- Sample preservation
- Score-based evaluation
- Global optimization
-
Extension Points:
- Custom patterns
- Evaluation metrics
- Example management
- Result processing
The modules work together in a coordinated workflow:
-
Initial Phase:
- View Inference creates base abstractions
- View Refinement optimizes representations
- Invariant Inference adds constraints
-
Specification Phase:
- Specification Inference adds contracts
- Proof Generation verifies correctness
- Error handling manages failures
-
Verification Phase:
- All modules contribute to verification
- Repair system handles failures
- Context manager tracks progress
- Result manager optimizes output
When working with modules:
-
Module Selection:
- Use appropriate module for task
- Follow dependency order
- Handle errors appropriately
- Track progress consistently
-
Code Safety:
- Validate all changes
- Maintain type safety
- Preserve semantics
- Check compilation
-
Error Recovery:
- Use multiple attempts
- Adjust parameters
- Follow fallbacks
- Log progress
-
Result Optimization:
- Track best results
- Evaluate samples
- Preserve history
- Maintain context
When extending modules:
-
Pattern Addition:
- Follow module conventions
- Maintain safety checks
- Handle errors properly
- Update documentation
-
Metric Creation:
- Define clear criteria
- Implement evaluation
- Handle edge cases
- Document usage
-
Example Management:
- Provide clear examples
- Include edge cases
- Document patterns
- Maintain consistency
The VeriStruct module system provides a comprehensive approach to code verification. Each module focuses on a specific aspect while maintaining integration with the overall system. The modular architecture allows for continuous improvement and adaptation to new verification challenges. Together, the modules collaborate to transform individual analyses into a cohesive verification workflow.