selveri 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- selveri-0.9.0/PKG-INFO +193 -0
- selveri-0.9.0/README.md +175 -0
- selveri-0.9.0/pyproject.toml +39 -0
- selveri-0.9.0/setup.cfg +4 -0
- selveri-0.9.0/src/selveri/__init__.py +1 -0
- selveri-0.9.0/src/selveri/__main__.py +4 -0
- selveri-0.9.0/src/selveri/abstract_machine/__init__.py +9 -0
- selveri-0.9.0/src/selveri/abstract_machine/config.py +11 -0
- selveri-0.9.0/src/selveri/abstract_machine/interpreter.py +1016 -0
- selveri-0.9.0/src/selveri/cli.py +118 -0
- selveri-0.9.0/src/selveri/common/__init__.py +44 -0
- selveri-0.9.0/src/selveri/common/diagnostics.py +594 -0
- selveri-0.9.0/src/selveri/common/errors.py +430 -0
- selveri-0.9.0/src/selveri/common/runtime.py +117 -0
- selveri-0.9.0/src/selveri/common/types.py +6 -0
- selveri-0.9.0/src/selveri/compiler/__init__.py +4 -0
- selveri-0.9.0/src/selveri/compiler/compiler.py +1300 -0
- selveri-0.9.0/src/selveri/high_level/__init__.py +3 -0
- selveri-0.9.0/src/selveri/high_level/ast.py +313 -0
- selveri-0.9.0/src/selveri/high_level/parser.py +374 -0
- selveri-0.9.0/src/selveri/high_level/preprocessor.py +253 -0
- selveri-0.9.0/src/selveri/ir/__init__.py +19 -0
- selveri-0.9.0/src/selveri/ir/instr.py +27 -0
- selveri-0.9.0/src/selveri/ir/text.py +163 -0
- selveri-0.9.0/src/selveri/spec/__init__.py +3 -0
- selveri-0.9.0/src/selveri/spec/models.py +142 -0
- selveri-0.9.0/src/selveri/spec/parser.py +206 -0
- selveri-0.9.0/src/selveri/verifier/__init__.py +9 -0
- selveri-0.9.0/src/selveri/verifier/engine.py +694 -0
- selveri-0.9.0/src/selveri/verifier/future_automaton.py +177 -0
- selveri-0.9.0/src/selveri/verifier/future_mapper.py +70 -0
- selveri-0.9.0/src/selveri/verifier/models.py +47 -0
- selveri-0.9.0/src/selveri/verifier/z3_mapper.py +434 -0
- selveri-0.9.0/src/selveri.egg-info/PKG-INFO +193 -0
- selveri-0.9.0/src/selveri.egg-info/SOURCES.txt +37 -0
- selveri-0.9.0/src/selveri.egg-info/dependency_links.txt +1 -0
- selveri-0.9.0/src/selveri.egg-info/entry_points.txt +2 -0
- selveri-0.9.0/src/selveri.egg-info/requires.txt +3 -0
- selveri-0.9.0/src/selveri.egg-info/top_level.txt +1 -0
selveri-0.9.0/PKG-INFO
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: selveri
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: SelVeri: Self-Verifying Programming Language
|
|
5
|
+
Author-email: Yağız Kaan Aydoğdu <y.kaan.aydogdu@gmail.com>, Yusuf Demir <yusufdemir12610@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/Selveri-Corp/selveri
|
|
7
|
+
Project-URL: Issues, https://github.com/Selveri-Corp/selveri/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
Requires-Dist: lark
|
|
16
|
+
Requires-Dist: ltlf2dfa
|
|
17
|
+
Requires-Dist: z3-solver
|
|
18
|
+
|
|
19
|
+
# SelVeri : Self-Verifying Programming Language
|
|
20
|
+
|
|
21
|
+
SelVeri is an **educational, imperative** programming language designed to bridge the gap between sequential programming and formal methods.
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
## Source layout
|
|
26
|
+
|
|
27
|
+
Python package root: `src/selveri/`
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
src/selveri/
|
|
31
|
+
├── __init__.py
|
|
32
|
+
├── __main__.py # python -m selveri
|
|
33
|
+
├── cli.py # CLI entry (parse → compile → run)
|
|
34
|
+
│
|
|
35
|
+
├── common/ # shared infrastructure
|
|
36
|
+
│ ├── diagnostics.py # source spans, rendered errors
|
|
37
|
+
│ ├── errors.py # SelVeriError hierarchy
|
|
38
|
+
│ ├── runtime.py # State, Scope, DeclType
|
|
39
|
+
│ └── types.py # shared scalars (e.g. real = float)
|
|
40
|
+
│
|
|
41
|
+
├── high_level/ # .svi source language
|
|
42
|
+
│ ├── ast.py # HL AST nodes
|
|
43
|
+
│ ├── parser.py # Lark parser, parse_selveri
|
|
44
|
+
│ ├── preprocessor.py # {spec} extraction
|
|
45
|
+
│ └── grammars/
|
|
46
|
+
│ └── grammar.lark
|
|
47
|
+
│
|
|
48
|
+
├── spec/ # specification / annotation language
|
|
49
|
+
│ ├── models.py # Spec, RawSpec, domains
|
|
50
|
+
│ ├── parser.py # parse_spec
|
|
51
|
+
│ └── grammars/
|
|
52
|
+
│ └── spec_grammar.lark
|
|
53
|
+
│
|
|
54
|
+
├── compiler/ # high-level AST → SelVerIR
|
|
55
|
+
│ └── compiler.py
|
|
56
|
+
│
|
|
57
|
+
├── ir/ # intermediate representation
|
|
58
|
+
│ ├── instr.py # IRInstr
|
|
59
|
+
│ └── text.py # IR text parse/serialize helpers
|
|
60
|
+
│
|
|
61
|
+
├── abstract_machine/ # SelVerIR interpreter (VM)
|
|
62
|
+
│ ├── config.py # RuntimeConfiguration
|
|
63
|
+
│ └── interpreter.py
|
|
64
|
+
│
|
|
65
|
+
└── verifier/ # Z3 / LTL verification engine
|
|
66
|
+
├── engine.py # VerificationEngine
|
|
67
|
+
├── z3_mapper.py
|
|
68
|
+
├── future_mapper.py
|
|
69
|
+
├── future_automaton.py
|
|
70
|
+
└── models.py # FutureAutomaton, obligations, …
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Pipeline flow: `high_level` → `compiler` → `ir` → `abstract_machine`, with `spec` + `verifier` hooked into compile/run, and `common` used throughout.
|
|
74
|
+
|
|
75
|
+
## Setup
|
|
76
|
+
|
|
77
|
+
Create a Virtual Environment (Optional):
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
python -m venv .venv
|
|
81
|
+
.\.venv\Scripts\activate (for Windows)
|
|
82
|
+
source .\.venv\Scripts\activate (for Linux/MacOS)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Install dependencies:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
pip install -r requirements.txt
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Or install the project in editable mode to enable the `selveri` command:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
pip install -e .
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Future LTL (fLTL) and MONA
|
|
98
|
+
|
|
99
|
+
Specs using temporal operators such as **Eventually**, **Always**, and **Until** are verified by compiling an automaton through [MONA](https://www.brics.dk/mona/). The `mona` executable must be on your `PATH`; otherwise SelVeri raises a verification error for those specs.
|
|
100
|
+
|
|
101
|
+
**Linux (Debian/Ubuntu)** — MONA is packaged as `mona` in the universe repository:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
sudo apt update
|
|
105
|
+
sudo apt install mona
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**macOS / Windows** — Install from the [official MONA page](https://www.brics.dk/mona/), or use a Linux environment (**WSL** on Windows, then follow the Debian/Ubuntu steps).
|
|
109
|
+
|
|
110
|
+
To confirm:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
mona -h
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Run Full Pipeline
|
|
117
|
+
|
|
118
|
+
Run parser -> compiler -> interpreter from the project root:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
python selveri.py examples/example_loop.svi
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
After editable install, you can use the command directly:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
selveri examples/example_loop.svi
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
By default, IR is **not** written to disk. To generate `.svir` output, pass `--emit-ir`:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
selveri examples/example_loop.svi --emit-ir
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Or choose a custom path:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
selveri examples/example_loop.svi --emit-ir --output-ir out/example_loop.svir
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Error Diagnostics
|
|
143
|
+
|
|
144
|
+
SelVeri reports parser, preprocessor, compiler, runtime, and verification
|
|
145
|
+
failures as structured diagnostics with source spans, labels, hints, and
|
|
146
|
+
counterexamples when available.
|
|
147
|
+
|
|
148
|
+
See [docs/errors.md](docs/errors.md) for diagnostic codes, examples, and
|
|
149
|
+
guidance for adding new errors.
|
|
150
|
+
|
|
151
|
+
# Selveri VsCode Extension
|
|
152
|
+
|
|
153
|
+
## Prerequisites
|
|
154
|
+
|
|
155
|
+
The `selveri` Python package and LSP dependencies must be installed in the interpreter used by the extension:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pip install -e <path_to_selveri>
|
|
159
|
+
pip install -r vscode-selveri/server/requirements.txt
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Build & Install
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
cd vscode-selveri
|
|
166
|
+
npm install
|
|
167
|
+
npm run compile
|
|
168
|
+
npx vsce package
|
|
169
|
+
code --install-extension selveri-0.9.0.vsix
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Development
|
|
173
|
+
|
|
174
|
+
1. Open the `vscode-selveri` folder in VS Code.
|
|
175
|
+
2. Open `client/src/extension.ts`.
|
|
176
|
+
3. Press F5 to launch an Extension Development Host.
|
|
177
|
+
|
|
178
|
+
Example `.vscode/launch.json`:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"version": "0.2.0",
|
|
183
|
+
"configurations": [
|
|
184
|
+
{
|
|
185
|
+
"name": "Launch Extension",
|
|
186
|
+
"type": "extensionHost",
|
|
187
|
+
"request": "launch",
|
|
188
|
+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
|
|
189
|
+
"outFiles": ["${workspaceFolder}/client/out/**/*.js"]
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
```
|
selveri-0.9.0/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# SelVeri : Self-Verifying Programming Language
|
|
2
|
+
|
|
3
|
+
SelVeri is an **educational, imperative** programming language designed to bridge the gap between sequential programming and formal methods.
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
## Source layout
|
|
8
|
+
|
|
9
|
+
Python package root: `src/selveri/`
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
src/selveri/
|
|
13
|
+
├── __init__.py
|
|
14
|
+
├── __main__.py # python -m selveri
|
|
15
|
+
├── cli.py # CLI entry (parse → compile → run)
|
|
16
|
+
│
|
|
17
|
+
├── common/ # shared infrastructure
|
|
18
|
+
│ ├── diagnostics.py # source spans, rendered errors
|
|
19
|
+
│ ├── errors.py # SelVeriError hierarchy
|
|
20
|
+
│ ├── runtime.py # State, Scope, DeclType
|
|
21
|
+
│ └── types.py # shared scalars (e.g. real = float)
|
|
22
|
+
│
|
|
23
|
+
├── high_level/ # .svi source language
|
|
24
|
+
│ ├── ast.py # HL AST nodes
|
|
25
|
+
│ ├── parser.py # Lark parser, parse_selveri
|
|
26
|
+
│ ├── preprocessor.py # {spec} extraction
|
|
27
|
+
│ └── grammars/
|
|
28
|
+
│ └── grammar.lark
|
|
29
|
+
│
|
|
30
|
+
├── spec/ # specification / annotation language
|
|
31
|
+
│ ├── models.py # Spec, RawSpec, domains
|
|
32
|
+
│ ├── parser.py # parse_spec
|
|
33
|
+
│ └── grammars/
|
|
34
|
+
│ └── spec_grammar.lark
|
|
35
|
+
│
|
|
36
|
+
├── compiler/ # high-level AST → SelVerIR
|
|
37
|
+
│ └── compiler.py
|
|
38
|
+
│
|
|
39
|
+
├── ir/ # intermediate representation
|
|
40
|
+
│ ├── instr.py # IRInstr
|
|
41
|
+
│ └── text.py # IR text parse/serialize helpers
|
|
42
|
+
│
|
|
43
|
+
├── abstract_machine/ # SelVerIR interpreter (VM)
|
|
44
|
+
│ ├── config.py # RuntimeConfiguration
|
|
45
|
+
│ └── interpreter.py
|
|
46
|
+
│
|
|
47
|
+
└── verifier/ # Z3 / LTL verification engine
|
|
48
|
+
├── engine.py # VerificationEngine
|
|
49
|
+
├── z3_mapper.py
|
|
50
|
+
├── future_mapper.py
|
|
51
|
+
├── future_automaton.py
|
|
52
|
+
└── models.py # FutureAutomaton, obligations, …
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Pipeline flow: `high_level` → `compiler` → `ir` → `abstract_machine`, with `spec` + `verifier` hooked into compile/run, and `common` used throughout.
|
|
56
|
+
|
|
57
|
+
## Setup
|
|
58
|
+
|
|
59
|
+
Create a Virtual Environment (Optional):
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
python -m venv .venv
|
|
63
|
+
.\.venv\Scripts\activate (for Windows)
|
|
64
|
+
source .\.venv\Scripts\activate (for Linux/MacOS)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Install dependencies:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
pip install -r requirements.txt
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Or install the project in editable mode to enable the `selveri` command:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
pip install -e .
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Future LTL (fLTL) and MONA
|
|
80
|
+
|
|
81
|
+
Specs using temporal operators such as **Eventually**, **Always**, and **Until** are verified by compiling an automaton through [MONA](https://www.brics.dk/mona/). The `mona` executable must be on your `PATH`; otherwise SelVeri raises a verification error for those specs.
|
|
82
|
+
|
|
83
|
+
**Linux (Debian/Ubuntu)** — MONA is packaged as `mona` in the universe repository:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
sudo apt update
|
|
87
|
+
sudo apt install mona
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**macOS / Windows** — Install from the [official MONA page](https://www.brics.dk/mona/), or use a Linux environment (**WSL** on Windows, then follow the Debian/Ubuntu steps).
|
|
91
|
+
|
|
92
|
+
To confirm:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
mona -h
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Run Full Pipeline
|
|
99
|
+
|
|
100
|
+
Run parser -> compiler -> interpreter from the project root:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
python selveri.py examples/example_loop.svi
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
After editable install, you can use the command directly:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
selveri examples/example_loop.svi
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
By default, IR is **not** written to disk. To generate `.svir` output, pass `--emit-ir`:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
selveri examples/example_loop.svi --emit-ir
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Or choose a custom path:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
selveri examples/example_loop.svi --emit-ir --output-ir out/example_loop.svir
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Error Diagnostics
|
|
125
|
+
|
|
126
|
+
SelVeri reports parser, preprocessor, compiler, runtime, and verification
|
|
127
|
+
failures as structured diagnostics with source spans, labels, hints, and
|
|
128
|
+
counterexamples when available.
|
|
129
|
+
|
|
130
|
+
See [docs/errors.md](docs/errors.md) for diagnostic codes, examples, and
|
|
131
|
+
guidance for adding new errors.
|
|
132
|
+
|
|
133
|
+
# Selveri VsCode Extension
|
|
134
|
+
|
|
135
|
+
## Prerequisites
|
|
136
|
+
|
|
137
|
+
The `selveri` Python package and LSP dependencies must be installed in the interpreter used by the extension:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pip install -e <path_to_selveri>
|
|
141
|
+
pip install -r vscode-selveri/server/requirements.txt
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Build & Install
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
cd vscode-selveri
|
|
148
|
+
npm install
|
|
149
|
+
npm run compile
|
|
150
|
+
npx vsce package
|
|
151
|
+
code --install-extension selveri-0.9.0.vsix
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Development
|
|
155
|
+
|
|
156
|
+
1. Open the `vscode-selveri` folder in VS Code.
|
|
157
|
+
2. Open `client/src/extension.ts`.
|
|
158
|
+
3. Press F5 to launch an Extension Development Host.
|
|
159
|
+
|
|
160
|
+
Example `.vscode/launch.json`:
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"version": "0.2.0",
|
|
165
|
+
"configurations": [
|
|
166
|
+
{
|
|
167
|
+
"name": "Launch Extension",
|
|
168
|
+
"type": "extensionHost",
|
|
169
|
+
"request": "launch",
|
|
170
|
+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
|
|
171
|
+
"outFiles": ["${workspaceFolder}/client/out/**/*.js"]
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "selveri"
|
|
7
|
+
version = "0.9.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Yağız Kaan Aydoğdu", email = "y.kaan.aydogdu@gmail.com" },
|
|
10
|
+
{ name = "Yusuf Demir", email = "yusufdemir12610@gmail.com" },
|
|
11
|
+
]
|
|
12
|
+
description = "SelVeri: Self-Verifying Programming Language"
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
dependencies = [
|
|
16
|
+
"lark",
|
|
17
|
+
"ltlf2dfa",
|
|
18
|
+
"z3-solver",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: POSIX :: Linux",
|
|
24
|
+
"Operating System :: MacOS :: MacOS X",
|
|
25
|
+
"Operating System :: Microsoft :: Windows",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
selveri = "selveri.cli:main"
|
|
30
|
+
|
|
31
|
+
[tool.setuptools]
|
|
32
|
+
package-dir = {"" = "src"}
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.packages.find]
|
|
35
|
+
where = ["src"]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://github.com/Selveri-Corp/selveri"
|
|
39
|
+
Issues = "https://github.com/Selveri-Corp/selveri/issues"
|
selveri-0.9.0/setup.cfg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.8.0"
|