SelVeri: Self-Verifying Programming Language
Project description
SelVeri : Self-Verifying Programming Language
SelVeri is an educational, imperative programming language designed to bridge the gap between sequential programming and formal methods.
Unlike traditional languages that rely on runtime errors or unit tests to catch bugs, SelVeri employs Dynamic Verification by utilizing its First-Order Logic Runtime Engine. SelVeri integrates the Z3 SMT Solver directly into its runtime. This allows developers to embed complex mathematical and logical specifications—including quantifiers ($\forall, \exists$) and logical implications—which are verified in real-time as the program executes.
Source layout
Python package root: src/selveri/
src/selveri/
├── __init__.py
├── __main__.py # python -m selveri
├── cli.py # CLI entry (parse → compile → run)
│
├── common/ # shared infrastructure
│ ├── diagnostics.py # source spans, rendered errors
│ ├── errors.py # SelVeriError hierarchy
│ ├── runtime.py # State, Scope, DeclType
│ └── types.py # shared scalars (e.g. real = float)
│
├── high_level/ # .svi source language
│ ├── ast.py # HL AST nodes
│ ├── parser.py # Lark parser, parse_selveri
│ ├── preprocessor.py # {spec} extraction
│ └── grammars/
│ └── grammar.lark
│
├── spec/ # specification / annotation language
│ ├── models.py # Spec, RawSpec, domains
│ ├── parser.py # parse_spec
│ └── grammars/
│ └── spec_grammar.lark
│
├── compiler/ # high-level AST → SelVerIR
│ └── compiler.py
│
├── ir/ # intermediate representation
│ ├── instr.py # IRInstr
│ └── text.py # IR text parse/serialize helpers
│
├── abstract_machine/ # SelVerIR interpreter (VM)
│ ├── config.py # RuntimeConfiguration
│ └── interpreter.py
│
└── verifier/ # Z3 / LTL verification engine
├── engine.py # VerificationEngine
├── z3_mapper.py
├── future_mapper.py
├── future_automaton.py
└── models.py # FutureAutomaton, obligations, …
Pipeline flow: high_level → compiler → ir → abstract_machine, with spec + verifier hooked into compile/run, and common used throughout.
Setup
Create a Virtual Environment (Optional):
python -m venv .venv
.\.venv\Scripts\activate (for Windows)
source .\.venv\Scripts\activate (for Linux/MacOS)
Install dependencies:
pip install -r requirements.txt
Or install the project in editable mode to enable the selveri command:
pip install -e .
Future LTL (fLTL) and MONA
Specs using temporal operators such as Eventually, Always, and Until are verified by compiling an automaton through MONA. The mona executable must be on your PATH; otherwise SelVeri raises a verification error for those specs.
Linux (Debian/Ubuntu) — MONA is packaged as mona in the universe repository:
sudo apt update
sudo apt install mona
macOS / Windows — Install from the official MONA page, or use a Linux environment (WSL on Windows, then follow the Debian/Ubuntu steps).
To confirm:
mona -h
Run Full Pipeline
Run parser -> compiler -> interpreter from the project root:
python selveri.py examples/example_loop.svi
After editable install, you can use the command directly:
selveri examples/example_loop.svi
By default, IR is not written to disk. To generate .svir output, pass --emit-ir:
selveri examples/example_loop.svi --emit-ir
Or choose a custom path:
selveri examples/example_loop.svi --emit-ir --output-ir out/example_loop.svir
Error Diagnostics
SelVeri reports parser, preprocessor, compiler, runtime, and verification failures as structured diagnostics with source spans, labels, hints, and counterexamples when available.
See docs/errors.md for diagnostic codes, examples, and guidance for adding new errors.
Selveri VsCode Extension
Prerequisites
The selveri Python package and LSP dependencies must be installed in the interpreter used by the extension:
pip install -e <path_to_selveri>
pip install -r vscode-selveri/server/requirements.txt
Build & Install
cd vscode-selveri
npm install
npm run compile
npx vsce package
code --install-extension selveri-0.9.2.vsix
Development
- Open the
vscode-selverifolder in VS Code. - Open
client/src/extension.ts. - Press F5 to launch an Extension Development Host.
Example .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/client/out/**/*.js"]
}
]
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file selveri-0.9.2.tar.gz.
File metadata
- Download URL: selveri-0.9.2.tar.gz
- Upload date:
- Size: 59.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f008c77cea1ba6edc4640508988d7db8296fc227deba1e9cc25f30a0ed606496
|
|
| MD5 |
74149f047a34791a169c126e66ffa7ac
|
|
| BLAKE2b-256 |
4c769ae2842b304540cae8b6b5b0b571d6586374001b4cb491271514ce3846d7
|
Provenance
The following attestation bundles were made for selveri-0.9.2.tar.gz:
Publisher:
publish.yml on SelVeri-Corp/selveri
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
selveri-0.9.2.tar.gz -
Subject digest:
f008c77cea1ba6edc4640508988d7db8296fc227deba1e9cc25f30a0ed606496 - Sigstore transparency entry: 1702090753
- Sigstore integration time:
-
Permalink:
SelVeri-Corp/selveri@f8a64cf81049bb558840c0d588b584d867a05422 -
Branch / Tag:
refs/tags/0.9.2 - Owner: https://github.com/SelVeri-Corp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f8a64cf81049bb558840c0d588b584d867a05422 -
Trigger Event:
release
-
Statement type:
File details
Details for the file selveri-0.9.2-py3-none-any.whl.
File metadata
- Download URL: selveri-0.9.2-py3-none-any.whl
- Upload date:
- Size: 65.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
315330cc87eb934d7360631055521a22759fc193a0ea4b93a14f5b5f90b59ec5
|
|
| MD5 |
b7b330a7a9b2d090afac16d4d1212da0
|
|
| BLAKE2b-256 |
748744297f0e702a179c88454c0c2a508bbfedbc72f0f00eb105a895d1d12b74
|
Provenance
The following attestation bundles were made for selveri-0.9.2-py3-none-any.whl:
Publisher:
publish.yml on SelVeri-Corp/selveri
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
selveri-0.9.2-py3-none-any.whl -
Subject digest:
315330cc87eb934d7360631055521a22759fc193a0ea4b93a14f5b5f90b59ec5 - Sigstore transparency entry: 1702090774
- Sigstore integration time:
-
Permalink:
SelVeri-Corp/selveri@f8a64cf81049bb558840c0d588b584d867a05422 -
Branch / Tag:
refs/tags/0.9.2 - Owner: https://github.com/SelVeri-Corp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f8a64cf81049bb558840c0d588b584d867a05422 -
Trigger Event:
release
-
Statement type: