Skip to main content

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.

User Manual

For language syntax, specification annotations, verification features, and usage examples, refer to the SelVeri User Manual.

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/payment_fraud_review.svi

After editable install, you can use the command directly:

selveri examples/payment_fraud_review.svi

By default, IR is not written to disk. To generate .svir output, pass --emit-ir:

selveri examples/payment_fraud_review.svi --emit-ir

Or choose a custom path:

selveri examples/payment_fraud_review.svi --emit-ir --output-ir out/payment_fraud_review.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-1.0.0.vsix

Development

  1. Open the vscode-selveri folder in VS Code.
  2. Open client/src/extension.ts.
  3. 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"]
    }
  ]
}

Metadata

Release files for selveri 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for selveri 1.0.0
File Size Uploaded Provenance Actions
selveri-1.0.0.tar.gz 63.2 kB With provenance Details for selveri-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for selveri 1.0.0
File Interpreter ABI Platform Actions
selveri-1.0.0-py3-none-any.whl Python 3 none any Details for selveri-1.0.0-py3-none-any.whl

Total release size: 133.1 kB

Release files / selveri-1.0.0.tar.gz

Download URL selveri-1.0.0.tar.gz
Size 63.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a9578458892a3c2b9190ba44901cdd7dee9df61e816adf7a841449e73613ee85
BLAKE2b-256 checksum
How to use checksums
afcd022f5ce953861ea67556c0f1eb30aa338e0a877571ee0e0ba49e6d78b41b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Release files / selveri-1.0.0-py3-none-any.whl

Download URL selveri-1.0.0-py3-none-any.whl
Size 69.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4fd1c2fb915babcf3ee9a4e7105f58c27613773c0407845a4416b91cb641808
BLAKE2b-256 checksum
How to use checksums
31a05bea418142fed8cb2e74d6c6cf1895e7d80f06c927398d8f42693ea71063
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Security for selveri 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for selveri-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page