Python language support for Strata. This package translates Python programs into Strata's intermediate representations (Core, Laurel) for formal verification.
lake buildThis builds the StrataPython library, DiffTestCore executable, and the StrataPythonTest compile-time tests.
StrataPython provides:
- Python AST - Types generated from the Python dialect DDM definition
- Python-to-Laurel translation - Translation through the Laurel IR (higher-level, supports dispatch and overloads).
- Python-to-Core translation - Deprecated. Direct translation from Python to Core IR, kept for
pyInterpretandpyAnalyzeToGoto; new features should target the Laurel path - PySpec pipeline - Reads Python type specifications (
.pyspec.st.ion) and generates Laurel declarations for verification - Regex support - Translates Python regular expressions to Core SMT assertions
- Overload resolution - Identifies and resolves dispatch-based service overloads
Strata(parent package) - Core IR, Laurel IR, verification infrastructure, SMT backendStrataDDM(transitive via Strata) - Dialect Definition Mechanism, Ion format
The package is the repository root:
.
βββ StrataPython.lean # Public API (readPythonIon, pySpecsDir, pyTranslateLaurel, etc.)
βββ StrataPython/
β βββ Cli.lean # Shared CLI helpers for the Scripts/ executables
β βββ PythonDialect.lean # DDM dialect definition + generated types (expr, stmt, etc.)
β βββ PythonIdent.lean # Module-qualified Python identifiers
β βββ ReadPython.lean # Read Python AST from Ion format
β βββ PythonToCore.lean # Direct Python β Core translation
β βββ PythonToLaurel.lean # Python β Laurel translation (main pipeline)
β βββ PySpecPipeline.lean # PySpec reading, overload resolution, Laurel construction
β βββ PyFactory.lean # Core expression factory with regex support
β βββ CorePrelude.lean # Python Core runtime prelude
β βββ PythonLaurelCorePrelude.lean # Laurel-translated runtime prelude
β βββ PythonRuntimeLaurelPart.lean # Runtime support as Laurel declarations
β βββ PythonLaurelTypedExpr.lean # Type-tagged Laurel expression builders
β βββ FunctionSignatures.lean # Function signature types for Core translation
β βββ OverloadTable.lean # Overload dispatch table
β βββ Specs.lean # PySpec file reading, module discovery, translation
β βββ Specs/
β β βββ DDM.lean # PySpec DDM dialect and serialization
β β βββ Decls.lean # PySpec type declarations (SpecType, FunctionDecl, etc.)
β β βββ IdentifyOverloads.lean # AST walker for overload resolution
β β βββ MessageKind.lean # Pipeline message classification
β β βββ ToLaurel.lean # PySpec β Laurel translation
β βββ Regex/
β β βββ ReParser.lean # Python regex parser
β β βββ ReToCore.lean # Regex β Core SMT translation
β βββ Pipeline/
β βββ PyAnalyzeLaurel.lean # Full analysis pipeline (Python β Laurel β Core β SMT)
βββ Scripts/ # Executable entry points (pyInterpret, pyAnalyzeLaurel, etc.)
βββ Tools/
β βββ strata-python/ # Python tooling package (Ion reader, dialect generator)
βββ StrataPythonTest/ # Compile-time tests (built with lake build)
βββ StrataPythonTestExtra/ # Runtime tests (run with lake test, require Python)
βββ DiffTestCore.lean # Regex differential testing tool
βββ StrataTestMain.lean # Test driver for StrataPythonTestExtra
βββ AGENTS.md # Guide for AI agents working in this package
βββ lakefile.toml
βββ lean-toolchain
βββ lake-manifest.json
lake build StrataPythonTestPYTHON=python lake testThe runtime tests require both the strata-base package (from the parent
Strata repository) and the in-repo strata-python package:
pip install <strata-repo>/Tools/Python-base
pip install ./Tools/strata-pythoncd StrataPythonTest/Regex
python diff_test.py| Namespace | Contents |
|---|---|
StrataPython |
Public API, generated AST types (expr, stmt, etc.), Core translation |
StrataPython.ToLaurel |
Python-to-Laurel translation internals |
StrataPython.Specs |
PySpec reading, translation, module discovery |
StrataPython.Specs.ToLaurel |
PySpec-to-Laurel declaration generation |
StrataPython.Specs.IdentifyOverloads |
Overload resolution AST walker |
StrataPython.Laurel |
Type-tagged Laurel expression builders |
StrataPython.Pipeline |
Full pyAnalyzeLaurel pipeline |