How khoasuythan/formal_verification-in-the-loop works
This is a Streamlit research application for generating Dafny code with LLMs and iteratively repairing it against Dafny/Z3 verification. The main workflow accepts a Dafny specification, detects its algorithmic topology, prompts a model, protects the original specification, normalizes and verifies generated code, then feeds diagnostics into subsequent repair attempts until success or the Pass@K limit. Separate product branches support cross-model benchmarking and research metrics. Relationships are limited to those visible in excerpts, SOURCE INDEX references, or README documentation; unsampled subsystems are represented only where documented.
Main entry points: pipeline_controller.py Pass@K Controller · cross_model_evaluator.py Cross-Model Evaluator · llm_agent.py LLM Agent · app.py Streamlit Studio
Components 25
User Interface
- Streamlit Studio
app.py - Pipeline View
web_demo/tabs/tab_pipeline_view.py - Cross-Model View
web_demo/tabs/tab_cross_model_view.py - Metrics View
web_demo/tabs/tab_metrics_view.py
Verified Repair
- Pass@K Controller
core/pipeline_controller.py - Topology Detection
core/topology_detector.py - Spec Integrity Guard
core/spec_locker.py - Syntax Normalization
core/syntax_normalizer.py - Template Preservation
core/template_preserver.py - AST Invariant Patching
core/ast_localizer.py - SMT Diagnostics
core/diagnostic_parser.py - Dafny Verification
core/dafny_engine.py
Model Services
- LLM Agent
agents/llm_agent.py - Reasoning Extraction
core/cot_extractor.py - Token Tracking
core/token_tracker.py
Research Evaluation
- Cross-Model Evaluator
core/cross_model_evaluator.py - Hallucination Analysis
core/hallucination_classifier.py - Benchmark Specifications
data/benchmarks - Experiment Metrics
experiments/evaluate_metrics.py - LaTeX Export
core/latex_exporter.py
Verification Support
- Verification Cache
core/verification_cache.py - Run Results and History
artifacts/results
Other components
- Researcher
- Dafny and Z3
- Local and Cloud LLMs
Connections 30
- Researcher → Streamlit Studio: uses
README.md - Streamlit Studio → Pipeline View: routes to
app.py - Streamlit Studio → Cross-Model View: routes to
app.py - Streamlit Studio → Metrics View: routes to
app.py - Pipeline View → Pass@K Controller: runs tasks
web_demo/tabs/tab_pipeline_view.py - Pass@K Controller → Topology Detection: classifies spec
core/pipeline_controller.py - Pass@K Controller → LLM Agent: requests generation
core/pipeline_controller.py - Pass@K Controller → Spec Integrity Guard: checks integrity
core/pipeline_controller.py - Pass@K Controller → Syntax Normalization: normalizes code
core/pipeline_controller.py - Pass@K Controller → Template Preservation: preserves template
core/pipeline_controller.py - Pass@K Controller → Dafny Verification: verifies candidate
core/pipeline_controller.py - Pass@K Controller → SMT Diagnostics: analyzes failures
core/pipeline_controller.py - Pass@K Controller → AST Invariant Patching: patches invariants
core/pipeline_controller.py - Dafny Verification → Dafny and Z3: invokes verifier
core/dafny_engine.py - Dafny Verification → Verification Cache: reads and writes
core/dafny_engine.py - LLM Agent → Local and Cloud LLMs: requests completion
agents/llm_agent.py - LLM Agent → Reasoning Extraction: extracts reasoning
agents/llm_agent.py - LLM Agent → Token Tracking: records usage
agents/llm_agent.py - Cross-Model View → Cross-Model Evaluator: runs comparison
web_demo/tabs/tab_cross_model_view.py - Cross-Model Evaluator → Pass@K Controller: evaluates tasks
core/cross_model_evaluator.py - Cross-Model Evaluator → LLM Agent: selects models
core/cross_model_evaluator.py - Cross-Model Evaluator → Dafny Verification: verifies results
core/cross_model_evaluator.py - Cross-Model Evaluator → Hallucination Analysis: analyzes hallucinations
core/cross_model_evaluator.py - Cross-Model Evaluator → Verification Cache: configures cache
core/cross_model_evaluator.py - Cross-Model Evaluator → Benchmark Specifications: evaluates specs
README.md - Cross-Model Evaluator → Run Results and History: stores checkpoints
core/cross_model_evaluator.py - Metrics View → Experiment Metrics: presents metrics
web_demo/tabs/tab_metrics_view.py - Metrics View → LaTeX Export: exports tables
web_demo/tabs/tab_metrics_view.py - Metrics View → Run Results and History: reads results
web_demo/tabs/tab_metrics_view.py - Pipeline View → Run Results and History: loads run history
web_demo/tabs/tab_pipeline_view.py