matyos 0.18.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.
- matyos-0.18.0/LICENSE +21 -0
- matyos-0.18.0/PKG-INFO +327 -0
- matyos-0.18.0/README.md +251 -0
- matyos-0.18.0/el_cli.py +450 -0
- matyos-0.18.0/matyos/__init__.py +2 -0
- matyos-0.18.0/matyos/__main__.py +6 -0
- matyos-0.18.0/matyos/cli.py +232 -0
- matyos-0.18.0/matyos/discovery/__init__.py +30 -0
- matyos-0.18.0/matyos/discovery/__main__.py +58 -0
- matyos-0.18.0/matyos/discovery/anomaly.py +121 -0
- matyos-0.18.0/matyos/discovery/engine.py +96 -0
- matyos-0.18.0/matyos/discovery/generator.py +96 -0
- matyos-0.18.0/matyos/discovery/objects.py +81 -0
- matyos-0.18.0/matyos/discovery/scorer.py +150 -0
- matyos-0.18.0/matyos/discovery/triage.py +54 -0
- matyos-0.18.0/matyos/discovery/verify.py +156 -0
- matyos-0.18.0/matyos/frontend/__init__.py +0 -0
- matyos-0.18.0/matyos/frontend/surface.py +604 -0
- matyos-0.18.0/matyos/frontend/tactics.py +403 -0
- matyos-0.18.0/matyos/kernel/__init__.py +0 -0
- matyos-0.18.0/matyos/kernel/core.py +532 -0
- matyos-0.18.0/matyos/kernel/equality.py +112 -0
- matyos-0.18.0/matyos/kernel/inductive.py +159 -0
- matyos-0.18.0/matyos/logic/__init__.py +0 -0
- matyos-0.18.0/matyos/logic/realistic.py +222 -0
- matyos-0.18.0/matyos/mcp_server.py +125 -0
- matyos-0.18.0/matyos/project/__init__.py +0 -0
- matyos-0.18.0/matyos/project/engine.py +367 -0
- matyos-0.18.0/matyos/stdlib/arith.elk +28 -0
- matyos-0.18.0/matyos/stdlib/bool.elk +22 -0
- matyos-0.18.0/matyos/stdlib/eq.elk +22 -0
- matyos-0.18.0/matyos/stdlib/logic.elk +15 -0
- matyos-0.18.0/matyos/stdlib/nat.elk +167 -0
- matyos-0.18.0/matyos.egg-info/PKG-INFO +327 -0
- matyos-0.18.0/matyos.egg-info/SOURCES.txt +54 -0
- matyos-0.18.0/matyos.egg-info/dependency_links.txt +1 -0
- matyos-0.18.0/matyos.egg-info/entry_points.txt +3 -0
- matyos-0.18.0/matyos.egg-info/requires.txt +27 -0
- matyos-0.18.0/matyos.egg-info/top_level.txt +3 -0
- matyos-0.18.0/pyproject.toml +176 -0
- matyos-0.18.0/setup.cfg +4 -0
- matyos-0.18.0/setup.py +28 -0
- matyos-0.18.0/tests/test_cli.py +83 -0
- matyos-0.18.0/tests/test_discovery.py +112 -0
- matyos-0.18.0/tests/test_el.py +391 -0
- matyos-0.18.0/tests/test_encoding.py +30 -0
- matyos-0.18.0/tests/test_equality.py +283 -0
- matyos-0.18.0/tests/test_inductive.py +315 -0
- matyos-0.18.0/tests/test_kernel_core.py +420 -0
- matyos-0.18.0/tests/test_library.py +71 -0
- matyos-0.18.0/tests/test_mcp_server.py +45 -0
- matyos-0.18.0/tests/test_project.py +403 -0
- matyos-0.18.0/tests/test_realistic.py +277 -0
- matyos-0.18.0/tests/test_scientific.py +329 -0
- matyos-0.18.0/tests/test_surface.py +357 -0
- matyos-0.18.0/tests/test_tactics.py +267 -0
matyos-0.18.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 MatyOS Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
matyos-0.18.0/PKG-INFO
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: matyos
|
|
3
|
+
Version: 0.18.0
|
|
4
|
+
Summary: MatyOS — a dependently-typed, LLM-native proof assistant with a discovery engine
|
|
5
|
+
Author: AHMED HAFDI
|
|
6
|
+
Author-email: Ahmed Hafdi <58536023+HAFDIAHMED@users.noreply.github.com>
|
|
7
|
+
Maintainer-email: Ahmed Hafdi <58536023+HAFDIAHMED@users.noreply.github.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 MatyOS Project
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
|
|
30
|
+
Project-URL: Homepage, https://github.com/MatyOS-Project/MatyOS
|
|
31
|
+
Project-URL: Documentation, https://github.com/MatyOS-Project/MatyOS/tree/main/docs
|
|
32
|
+
Project-URL: Repository, https://github.com/MatyOS-Project/MatyOS
|
|
33
|
+
Project-URL: Bug Tracker, https://github.com/MatyOS-Project/MatyOS/issues
|
|
34
|
+
Keywords: proof-assistant,dependent-types,theorem-prover,mathematics,discovery,mcp,llm
|
|
35
|
+
Classifier: Development Status :: 3 - Alpha
|
|
36
|
+
Classifier: Intended Audience :: Science/Research
|
|
37
|
+
Classifier: Intended Audience :: Developers
|
|
38
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
39
|
+
Classifier: Operating System :: OS Independent
|
|
40
|
+
Classifier: Programming Language :: Python :: 3
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
45
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
46
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
47
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
48
|
+
Requires-Python: >=3.8
|
|
49
|
+
Description-Content-Type: text/markdown
|
|
50
|
+
License-File: LICENSE
|
|
51
|
+
Provides-Extra: dev
|
|
52
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
53
|
+
Requires-Dist: pytest-cov>=2.0; extra == "dev"
|
|
54
|
+
Requires-Dist: black>=22.0; extra == "dev"
|
|
55
|
+
Requires-Dist: flake8>=4.0; extra == "dev"
|
|
56
|
+
Requires-Dist: mypy>=0.950; extra == "dev"
|
|
57
|
+
Requires-Dist: pre-commit>=2.0; extra == "dev"
|
|
58
|
+
Requires-Dist: isort>=5.0; extra == "dev"
|
|
59
|
+
Provides-Extra: docs
|
|
60
|
+
Requires-Dist: sphinx>=4.0; extra == "docs"
|
|
61
|
+
Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
|
|
62
|
+
Requires-Dist: myst-parser>=0.17; extra == "docs"
|
|
63
|
+
Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
|
|
64
|
+
Provides-Extra: test
|
|
65
|
+
Requires-Dist: pytest>=6.0; extra == "test"
|
|
66
|
+
Requires-Dist: pytest-cov>=2.0; extra == "test"
|
|
67
|
+
Requires-Dist: coverage>=6.0; extra == "test"
|
|
68
|
+
Provides-Extra: discovery
|
|
69
|
+
Requires-Dist: mpmath>=1.3; extra == "discovery"
|
|
70
|
+
Provides-Extra: mcp
|
|
71
|
+
Requires-Dist: mpmath>=1.3; extra == "mcp"
|
|
72
|
+
Requires-Dist: mcp>=1.0; extra == "mcp"
|
|
73
|
+
Dynamic: author
|
|
74
|
+
Dynamic: license-file
|
|
75
|
+
Dynamic: requires-python
|
|
76
|
+
|
|
77
|
+
<p align="center">
|
|
78
|
+
<img src="assets/logo.png" width="140" alt="MatyOS logo"/>
|
|
79
|
+
</p>
|
|
80
|
+
|
|
81
|
+
<h1 align="center">MatyOS</h1>
|
|
82
|
+
|
|
83
|
+
<p align="center">
|
|
84
|
+
<strong>A dependently-typed proof assistant, built to be LLM-native.</strong>
|
|
85
|
+
</p>
|
|
86
|
+
|
|
87
|
+
<p align="center">
|
|
88
|
+
<img src="https://img.shields.io/badge/tests-233%20passing-brightgreen" alt="tests"/>
|
|
89
|
+
<img src="https://img.shields.io/badge/platforms-win%20%C2%B7%20linux%20%C2%B7%20macos-blue" alt="platforms"/>
|
|
90
|
+
<img src="https://img.shields.io/badge/license-MIT-green" alt="license"/>
|
|
91
|
+
<img src="https://img.shields.io/badge/status-early%20%C2%B7%20sound%20kernel-orange" alt="status"/>
|
|
92
|
+
</p>
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
MatyOS is a proof assistant in the tradition of **Lean, Coq and Agda**: you
|
|
97
|
+
state theorems as types and prove them by writing terms that a small, trusted
|
|
98
|
+
**kernel** checks. Its long-term goal is to be a system that **large language
|
|
99
|
+
models can use to do mathematics** — analysis, conjecture, and proof — with
|
|
100
|
+
first-class support for *uncertainty* (the `realistic` truth value).
|
|
101
|
+
|
|
102
|
+
> **Honest status.** This is an early but *sound* core, not yet a Lean
|
|
103
|
+
> competitor in capability. What works today: a trusted dependent-type kernel,
|
|
104
|
+
> inductive types with recursors, propositional equality, proof by induction,
|
|
105
|
+
> strict-positivity checking, definitions, an impredicative `Prop`, a text
|
|
106
|
+
> front-end, and a three-valued "realistic" logic — all covered by 233 tests.
|
|
107
|
+
> The road to Lean-class mathematics (elaboration, tactics, and above all a
|
|
108
|
+
> mathematics library) is mapped honestly in [ROADMAP.md](ROADMAP.md).
|
|
109
|
+
|
|
110
|
+
## Why another proof assistant?
|
|
111
|
+
|
|
112
|
+
Lean/Coq/Agda were designed for humans, decades before LLMs. MatyOS is designed
|
|
113
|
+
from day one around two bets:
|
|
114
|
+
|
|
115
|
+
1. **Soundness is sacred.** Every proof — however it is produced, including by
|
|
116
|
+
an LLM — reduces to a term checked by a tiny trusted kernel. Nothing is ever
|
|
117
|
+
"assumed proven".
|
|
118
|
+
2. **Uncertainty is first-class.** Real mathematical work (especially an LLM's)
|
|
119
|
+
is full of *plausible-but-unproven* steps. MatyOS treats this rigorously with
|
|
120
|
+
a three-valued logic (`true` / `false` / `realistic`) that lives in an
|
|
121
|
+
epistemic layer *above* the kernel, so conjecture and certainty never get
|
|
122
|
+
confused. See [the `realistic` idea](#the-realistic-idea).
|
|
123
|
+
|
|
124
|
+
## Install
|
|
125
|
+
|
|
126
|
+
Download the `matyos` binary for your platform from the
|
|
127
|
+
[**Releases**](https://github.com/MatyOS-Project/MatyOS/releases) page.
|
|
128
|
+
|
|
129
|
+
Then put it on your `PATH` — or let the installer do it for you (it copies the
|
|
130
|
+
binary to a per-user location and updates your `PATH`):
|
|
131
|
+
|
|
132
|
+
```console
|
|
133
|
+
:: Windows (run from the folder containing matyos.exe / this repo)
|
|
134
|
+
> powershell -ExecutionPolicy Bypass -File install.ps1
|
|
135
|
+
|
|
136
|
+
# Linux / macOS
|
|
137
|
+
$ bash install-matyos.sh
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Open a **new terminal**, and the `matyos` command is available everywhere:
|
|
141
|
+
|
|
142
|
+
```console
|
|
143
|
+
$ matyos version
|
|
144
|
+
$ matyos check demo.elk # type-check a proof file
|
|
145
|
+
$ matyos help
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`matyos check` exits `0` when every proof in the file holds and non-zero when
|
|
149
|
+
any proof fails, so it drops straight into CI.
|
|
150
|
+
|
|
151
|
+
> Want to build from source or contribute? See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
152
|
+
|
|
153
|
+
## A first proof
|
|
154
|
+
|
|
155
|
+
Proofs are written in a small, readable language (`.elk`) and checked by the
|
|
156
|
+
kernel. Here is arithmetic *from scratch* — declaring the natural numbers,
|
|
157
|
+
defining addition, and proving `n + 0 = n` by induction
|
|
158
|
+
([`stdlib/arith.elk`](matyos/stdlib/arith.elk)):
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
inductive Nat : Type :=
|
|
162
|
+
| zero : Nat
|
|
163
|
+
| succ : Nat -> Nat
|
|
164
|
+
|
|
165
|
+
def add (m : Nat) (n : Nat) : Nat :=
|
|
166
|
+
Nat.rec (fun (_ : Nat) => Nat) n (fun (k : Nat) (ih : Nat) => succ ih) m
|
|
167
|
+
|
|
168
|
+
def cong (A : Type) (B : Type) (f : A -> B) (a : A) (b : A) (e : Eq A a b)
|
|
169
|
+
: Eq B (f a) (f b) :=
|
|
170
|
+
Eq.J A a (fun (x : A) (_ : Eq A a x) => Eq B (f a) (f x)) (refl B (f a)) b e
|
|
171
|
+
|
|
172
|
+
def add_zero_right (n : Nat) : Eq Nat (add n zero) n :=
|
|
173
|
+
Nat.rec (fun (m : Nat) => Eq Nat (add m zero) m)
|
|
174
|
+
(refl Nat zero)
|
|
175
|
+
(fun (k : Nat) (ih : Eq Nat (add k zero) k) =>
|
|
176
|
+
cong Nat Nat succ (add k zero) k ih)
|
|
177
|
+
n
|
|
178
|
+
|
|
179
|
+
example : forall (n : Nat), Eq Nat (add n zero) n := add_zero_right
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```console
|
|
183
|
+
$ matyos check stdlib/arith.elk
|
|
184
|
+
inductive Nat : Type0 (2 constructors)
|
|
185
|
+
def add : (Nat -> (Nat -> Nat))
|
|
186
|
+
eval ... = (succ (succ (succ (succ (succ zero))))) -- 2 + 3 = 5
|
|
187
|
+
def cong : (Pi (x0 : Type0), ...)
|
|
188
|
+
def add_zero_right : (Pi (x0 : Nat), (((Eq Nat) ((add x0) zero)) x0))
|
|
189
|
+
example : (Pi (x0 : Nat), (((Eq Nat) ((add x0) zero)) x0)) [QED]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Projects & the scientific method
|
|
193
|
+
|
|
194
|
+
Real work is bigger than one proof. A **MatyOS project** is a directory that
|
|
195
|
+
mirrors the scientific method — *assume* (hypothesis/conjecture) → *state*
|
|
196
|
+
(theorem) → *experiment* (test) → *certify* (proof) — and `matyos check` runs the
|
|
197
|
+
whole thing and reports the honest status of every claim. Scaffold one and check
|
|
198
|
+
it:
|
|
199
|
+
|
|
200
|
+
```console
|
|
201
|
+
$ matyos new my_theory
|
|
202
|
+
Created project 'my_theory'. Try: matyos check my_theory
|
|
203
|
+
|
|
204
|
+
$ matyos check my_theory
|
|
205
|
+
==========================================================
|
|
206
|
+
MatyOS project: my_theory
|
|
207
|
+
==========================================================
|
|
208
|
+
|
|
209
|
+
theory: theories/arithmetic
|
|
210
|
+
definitions: Nat, add, cong
|
|
211
|
+
hypotheses / conjectures (realistic):
|
|
212
|
+
[CONJ] add_comm : ...commutativity of addition...
|
|
213
|
+
theorems:
|
|
214
|
+
[PROVEN] add_zero_right (certified)
|
|
215
|
+
tests:
|
|
216
|
+
[PASS] add_2_3
|
|
217
|
+
[PASS] add_0_4
|
|
218
|
+
----------------------------------------------------------
|
|
219
|
+
Summary
|
|
220
|
+
theorems : 1 proven (1 certified, 0 conditional), 0 open
|
|
221
|
+
conjectures: 1 (realistic)
|
|
222
|
+
tests : 2 passed, 0 failed, 0 ran
|
|
223
|
+
status : OK (exit 0)
|
|
224
|
+
----------------------------------------------------------
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
The report draws a hard line between **certified** theorems (depend on nothing
|
|
228
|
+
unproven) and **conditional / realistic** ones (rest on an open conjecture) — and
|
|
229
|
+
that dependency is tracked transitively, so an assumption buried deep in a chain
|
|
230
|
+
of lemmas can never launder itself into a certified result.
|
|
231
|
+
|
|
232
|
+
When a theory is **complete** (no open theorems, no failed checks), seal it into a
|
|
233
|
+
single compressed, self-describing `.matyos` archive — a *sigma of files* bundling
|
|
234
|
+
every theory, theorem, proof and test, plus a machine-readable `MANIFEST.json`:
|
|
235
|
+
|
|
236
|
+
```console
|
|
237
|
+
$ matyos build my_theory # refuses to seal an incomplete project
|
|
238
|
+
sealed -> my_theory.matyos (1 certified, 0 conditional, 0 open)
|
|
239
|
+
$ matyos info my_theory.matyos # read the manifest without re-checking
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Each file type has its own black-and-white icon:
|
|
243
|
+
|
|
244
|
+

|
|
245
|
+
|
|
246
|
+
`.matyos` archive (`Σ`) · `.thm` theorem (`∀`) · `.prf` proof (`∎`) · `.hyp`
|
|
247
|
+
hypothesis (`∃`) · `.test` test (`✓`) · `.elk` definitions (`λ`).
|
|
248
|
+
Full details: [docs/projects.md](docs/projects.md).
|
|
249
|
+
|
|
250
|
+
A worked theory, [`examples/projects/arithmetic`](examples/projects/arithmetic),
|
|
251
|
+
proves **`m + n = n + m`** (commutativity of addition) by induction — a real,
|
|
252
|
+
kernel-certified theorem, built on the equality toolkit in
|
|
253
|
+
[`stdlib/eq.elk`](matyos/stdlib/eq.elk) (`symm`, `trans`, `cong`, `subst`). And
|
|
254
|
+
[`stdlib/nat.elk`](matyos/stdlib/nat.elk) proves that **ℕ is a commutative semiring** —
|
|
255
|
+
associativity & commutativity of `+` and `×`, identities `0`/`1`, distributivity
|
|
256
|
+
— plus ordering (`≤`), every law certified by induction.
|
|
257
|
+
|
|
258
|
+
### Logic is just types (Curry–Howard)
|
|
259
|
+
|
|
260
|
+
Propositions are types; proofs are programs ([`examples/proofs/curry_howard.elk`](examples/proofs/curry_howard.elk)):
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
def id (A : Type) (x : A) : A := x -- A implies A
|
|
264
|
+
def const (A : Type) (B : Type) (a : A) (b : B) : A := a
|
|
265
|
+
def modus_ponens (A : Type) (B : Type) (f : A -> B) (a : A) : B := f a
|
|
266
|
+
|
|
267
|
+
example : forall (A : Type), A -> A := id
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
The kernel *rejects* non-proofs: an ill-typed term like `fun (A:Type)(x:A) => x x`
|
|
271
|
+
(self-application) does not type-check, so it cannot masquerade as a proof.
|
|
272
|
+
|
|
273
|
+
## The `realistic` idea
|
|
274
|
+
|
|
275
|
+
Classical logic forces every proposition to be `true` or `false`. Real
|
|
276
|
+
reasoning — and LLM reasoning especially — also needs **"not (yet) known"**.
|
|
277
|
+
MatyOS gives this a precise, textbook semantics (Kleene **K3** and Łukasiewicz
|
|
278
|
+
**Ł3** three-valued logics):
|
|
279
|
+
|
|
280
|
+
| formula | classical | with a `realistic` atom |
|
|
281
|
+
|---|---|---|
|
|
282
|
+
| `P \/ ~P` (excluded middle) | valid | **not valid** — undetermined when `P` is `realistic` |
|
|
283
|
+
| `~(P /\ ~P)` (non-contradiction) | valid | **not valid** |
|
|
284
|
+
| `P -> P` (self-implication) | valid | not valid in Kleene · valid in Łukasiewicz |
|
|
285
|
+
|
|
286
|
+
The failure of excluded middle for a `realistic` atom is the *point*: an
|
|
287
|
+
uncertain proposition is neither affirmed nor denied. Crucially, `realistic`
|
|
288
|
+
lives **above** the trusted kernel — conjectures carry evidence/confidence and a
|
|
289
|
+
status (`conjectured → certified / refuted`), and the kernel only ever certifies
|
|
290
|
+
real proofs. This is the intended bridge between informal LLM reasoning and
|
|
291
|
+
formal verification (see Realistic track R0–R3 in [ROADMAP.md](ROADMAP.md)).
|
|
292
|
+
|
|
293
|
+
## Architecture
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
matyos/ the proof assistant
|
|
297
|
+
├── kernel/ the TRUSTED core — small and auditable
|
|
298
|
+
│ ├── core terms, normalization, definitional equality, type inference
|
|
299
|
+
│ ├── inductive inductive types, recursors, iota-reduction, strict positivity
|
|
300
|
+
│ └── equality propositional equality (Eq) + the J eliminator
|
|
301
|
+
├── frontend/ tokenizer + parser for the .elk proof language
|
|
302
|
+
├── logic/ three-valued ("realistic") logic
|
|
303
|
+
└── cli the `matyos` command
|
|
304
|
+
|
|
305
|
+
matyos/stdlib/ standard library, written in MatyOS itself (.elk)
|
|
306
|
+
examples/ example proofs (.elk)
|
|
307
|
+
docs/ design + language reference
|
|
308
|
+
ROADMAP.md the honest, phased plan toward a Lean-class system
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**Trust boundary:** only the **kernel** must be trusted. The parser, the
|
|
312
|
+
standard library, the `realistic` layer, and any future tactics or LLM output
|
|
313
|
+
all ultimately produce terms that the kernel re-checks. If the kernel is sound,
|
|
314
|
+
a term that type-checks against a proposition *is* a proof of it.
|
|
315
|
+
|
|
316
|
+
## Documentation
|
|
317
|
+
|
|
318
|
+
- [ROADMAP.md](ROADMAP.md) — phased plan and current status (honest about scale)
|
|
319
|
+
- [docs/architecture.md](docs/architecture.md) — design and trust model
|
|
320
|
+
- [docs/language.md](docs/language.md) — the `.elk` language reference
|
|
321
|
+
- [docs/projects.md](docs/projects.md) — projects, the scientific-method workflow, and the `.matyos` archive
|
|
322
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) — building from source, running tests
|
|
323
|
+
- [docs/legacy-el-language.md](docs/legacy-el-language.md) — the project's original imperative language
|
|
324
|
+
|
|
325
|
+
## License
|
|
326
|
+
|
|
327
|
+
MIT. See [LICENSE](LICENSE).
|
matyos-0.18.0/README.md
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/logo.png" width="140" alt="MatyOS logo"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">MatyOS</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>A dependently-typed proof assistant, built to be LLM-native.</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://img.shields.io/badge/tests-233%20passing-brightgreen" alt="tests"/>
|
|
13
|
+
<img src="https://img.shields.io/badge/platforms-win%20%C2%B7%20linux%20%C2%B7%20macos-blue" alt="platforms"/>
|
|
14
|
+
<img src="https://img.shields.io/badge/license-MIT-green" alt="license"/>
|
|
15
|
+
<img src="https://img.shields.io/badge/status-early%20%C2%B7%20sound%20kernel-orange" alt="status"/>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
MatyOS is a proof assistant in the tradition of **Lean, Coq and Agda**: you
|
|
21
|
+
state theorems as types and prove them by writing terms that a small, trusted
|
|
22
|
+
**kernel** checks. Its long-term goal is to be a system that **large language
|
|
23
|
+
models can use to do mathematics** — analysis, conjecture, and proof — with
|
|
24
|
+
first-class support for *uncertainty* (the `realistic` truth value).
|
|
25
|
+
|
|
26
|
+
> **Honest status.** This is an early but *sound* core, not yet a Lean
|
|
27
|
+
> competitor in capability. What works today: a trusted dependent-type kernel,
|
|
28
|
+
> inductive types with recursors, propositional equality, proof by induction,
|
|
29
|
+
> strict-positivity checking, definitions, an impredicative `Prop`, a text
|
|
30
|
+
> front-end, and a three-valued "realistic" logic — all covered by 233 tests.
|
|
31
|
+
> The road to Lean-class mathematics (elaboration, tactics, and above all a
|
|
32
|
+
> mathematics library) is mapped honestly in [ROADMAP.md](ROADMAP.md).
|
|
33
|
+
|
|
34
|
+
## Why another proof assistant?
|
|
35
|
+
|
|
36
|
+
Lean/Coq/Agda were designed for humans, decades before LLMs. MatyOS is designed
|
|
37
|
+
from day one around two bets:
|
|
38
|
+
|
|
39
|
+
1. **Soundness is sacred.** Every proof — however it is produced, including by
|
|
40
|
+
an LLM — reduces to a term checked by a tiny trusted kernel. Nothing is ever
|
|
41
|
+
"assumed proven".
|
|
42
|
+
2. **Uncertainty is first-class.** Real mathematical work (especially an LLM's)
|
|
43
|
+
is full of *plausible-but-unproven* steps. MatyOS treats this rigorously with
|
|
44
|
+
a three-valued logic (`true` / `false` / `realistic`) that lives in an
|
|
45
|
+
epistemic layer *above* the kernel, so conjecture and certainty never get
|
|
46
|
+
confused. See [the `realistic` idea](#the-realistic-idea).
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
Download the `matyos` binary for your platform from the
|
|
51
|
+
[**Releases**](https://github.com/MatyOS-Project/MatyOS/releases) page.
|
|
52
|
+
|
|
53
|
+
Then put it on your `PATH` — or let the installer do it for you (it copies the
|
|
54
|
+
binary to a per-user location and updates your `PATH`):
|
|
55
|
+
|
|
56
|
+
```console
|
|
57
|
+
:: Windows (run from the folder containing matyos.exe / this repo)
|
|
58
|
+
> powershell -ExecutionPolicy Bypass -File install.ps1
|
|
59
|
+
|
|
60
|
+
# Linux / macOS
|
|
61
|
+
$ bash install-matyos.sh
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Open a **new terminal**, and the `matyos` command is available everywhere:
|
|
65
|
+
|
|
66
|
+
```console
|
|
67
|
+
$ matyos version
|
|
68
|
+
$ matyos check demo.elk # type-check a proof file
|
|
69
|
+
$ matyos help
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`matyos check` exits `0` when every proof in the file holds and non-zero when
|
|
73
|
+
any proof fails, so it drops straight into CI.
|
|
74
|
+
|
|
75
|
+
> Want to build from source or contribute? See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
76
|
+
|
|
77
|
+
## A first proof
|
|
78
|
+
|
|
79
|
+
Proofs are written in a small, readable language (`.elk`) and checked by the
|
|
80
|
+
kernel. Here is arithmetic *from scratch* — declaring the natural numbers,
|
|
81
|
+
defining addition, and proving `n + 0 = n` by induction
|
|
82
|
+
([`stdlib/arith.elk`](matyos/stdlib/arith.elk)):
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
inductive Nat : Type :=
|
|
86
|
+
| zero : Nat
|
|
87
|
+
| succ : Nat -> Nat
|
|
88
|
+
|
|
89
|
+
def add (m : Nat) (n : Nat) : Nat :=
|
|
90
|
+
Nat.rec (fun (_ : Nat) => Nat) n (fun (k : Nat) (ih : Nat) => succ ih) m
|
|
91
|
+
|
|
92
|
+
def cong (A : Type) (B : Type) (f : A -> B) (a : A) (b : A) (e : Eq A a b)
|
|
93
|
+
: Eq B (f a) (f b) :=
|
|
94
|
+
Eq.J A a (fun (x : A) (_ : Eq A a x) => Eq B (f a) (f x)) (refl B (f a)) b e
|
|
95
|
+
|
|
96
|
+
def add_zero_right (n : Nat) : Eq Nat (add n zero) n :=
|
|
97
|
+
Nat.rec (fun (m : Nat) => Eq Nat (add m zero) m)
|
|
98
|
+
(refl Nat zero)
|
|
99
|
+
(fun (k : Nat) (ih : Eq Nat (add k zero) k) =>
|
|
100
|
+
cong Nat Nat succ (add k zero) k ih)
|
|
101
|
+
n
|
|
102
|
+
|
|
103
|
+
example : forall (n : Nat), Eq Nat (add n zero) n := add_zero_right
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```console
|
|
107
|
+
$ matyos check stdlib/arith.elk
|
|
108
|
+
inductive Nat : Type0 (2 constructors)
|
|
109
|
+
def add : (Nat -> (Nat -> Nat))
|
|
110
|
+
eval ... = (succ (succ (succ (succ (succ zero))))) -- 2 + 3 = 5
|
|
111
|
+
def cong : (Pi (x0 : Type0), ...)
|
|
112
|
+
def add_zero_right : (Pi (x0 : Nat), (((Eq Nat) ((add x0) zero)) x0))
|
|
113
|
+
example : (Pi (x0 : Nat), (((Eq Nat) ((add x0) zero)) x0)) [QED]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Projects & the scientific method
|
|
117
|
+
|
|
118
|
+
Real work is bigger than one proof. A **MatyOS project** is a directory that
|
|
119
|
+
mirrors the scientific method — *assume* (hypothesis/conjecture) → *state*
|
|
120
|
+
(theorem) → *experiment* (test) → *certify* (proof) — and `matyos check` runs the
|
|
121
|
+
whole thing and reports the honest status of every claim. Scaffold one and check
|
|
122
|
+
it:
|
|
123
|
+
|
|
124
|
+
```console
|
|
125
|
+
$ matyos new my_theory
|
|
126
|
+
Created project 'my_theory'. Try: matyos check my_theory
|
|
127
|
+
|
|
128
|
+
$ matyos check my_theory
|
|
129
|
+
==========================================================
|
|
130
|
+
MatyOS project: my_theory
|
|
131
|
+
==========================================================
|
|
132
|
+
|
|
133
|
+
theory: theories/arithmetic
|
|
134
|
+
definitions: Nat, add, cong
|
|
135
|
+
hypotheses / conjectures (realistic):
|
|
136
|
+
[CONJ] add_comm : ...commutativity of addition...
|
|
137
|
+
theorems:
|
|
138
|
+
[PROVEN] add_zero_right (certified)
|
|
139
|
+
tests:
|
|
140
|
+
[PASS] add_2_3
|
|
141
|
+
[PASS] add_0_4
|
|
142
|
+
----------------------------------------------------------
|
|
143
|
+
Summary
|
|
144
|
+
theorems : 1 proven (1 certified, 0 conditional), 0 open
|
|
145
|
+
conjectures: 1 (realistic)
|
|
146
|
+
tests : 2 passed, 0 failed, 0 ran
|
|
147
|
+
status : OK (exit 0)
|
|
148
|
+
----------------------------------------------------------
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The report draws a hard line between **certified** theorems (depend on nothing
|
|
152
|
+
unproven) and **conditional / realistic** ones (rest on an open conjecture) — and
|
|
153
|
+
that dependency is tracked transitively, so an assumption buried deep in a chain
|
|
154
|
+
of lemmas can never launder itself into a certified result.
|
|
155
|
+
|
|
156
|
+
When a theory is **complete** (no open theorems, no failed checks), seal it into a
|
|
157
|
+
single compressed, self-describing `.matyos` archive — a *sigma of files* bundling
|
|
158
|
+
every theory, theorem, proof and test, plus a machine-readable `MANIFEST.json`:
|
|
159
|
+
|
|
160
|
+
```console
|
|
161
|
+
$ matyos build my_theory # refuses to seal an incomplete project
|
|
162
|
+
sealed -> my_theory.matyos (1 certified, 0 conditional, 0 open)
|
|
163
|
+
$ matyos info my_theory.matyos # read the manifest without re-checking
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Each file type has its own black-and-white icon:
|
|
167
|
+
|
|
168
|
+

|
|
169
|
+
|
|
170
|
+
`.matyos` archive (`Σ`) · `.thm` theorem (`∀`) · `.prf` proof (`∎`) · `.hyp`
|
|
171
|
+
hypothesis (`∃`) · `.test` test (`✓`) · `.elk` definitions (`λ`).
|
|
172
|
+
Full details: [docs/projects.md](docs/projects.md).
|
|
173
|
+
|
|
174
|
+
A worked theory, [`examples/projects/arithmetic`](examples/projects/arithmetic),
|
|
175
|
+
proves **`m + n = n + m`** (commutativity of addition) by induction — a real,
|
|
176
|
+
kernel-certified theorem, built on the equality toolkit in
|
|
177
|
+
[`stdlib/eq.elk`](matyos/stdlib/eq.elk) (`symm`, `trans`, `cong`, `subst`). And
|
|
178
|
+
[`stdlib/nat.elk`](matyos/stdlib/nat.elk) proves that **ℕ is a commutative semiring** —
|
|
179
|
+
associativity & commutativity of `+` and `×`, identities `0`/`1`, distributivity
|
|
180
|
+
— plus ordering (`≤`), every law certified by induction.
|
|
181
|
+
|
|
182
|
+
### Logic is just types (Curry–Howard)
|
|
183
|
+
|
|
184
|
+
Propositions are types; proofs are programs ([`examples/proofs/curry_howard.elk`](examples/proofs/curry_howard.elk)):
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
def id (A : Type) (x : A) : A := x -- A implies A
|
|
188
|
+
def const (A : Type) (B : Type) (a : A) (b : B) : A := a
|
|
189
|
+
def modus_ponens (A : Type) (B : Type) (f : A -> B) (a : A) : B := f a
|
|
190
|
+
|
|
191
|
+
example : forall (A : Type), A -> A := id
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The kernel *rejects* non-proofs: an ill-typed term like `fun (A:Type)(x:A) => x x`
|
|
195
|
+
(self-application) does not type-check, so it cannot masquerade as a proof.
|
|
196
|
+
|
|
197
|
+
## The `realistic` idea
|
|
198
|
+
|
|
199
|
+
Classical logic forces every proposition to be `true` or `false`. Real
|
|
200
|
+
reasoning — and LLM reasoning especially — also needs **"not (yet) known"**.
|
|
201
|
+
MatyOS gives this a precise, textbook semantics (Kleene **K3** and Łukasiewicz
|
|
202
|
+
**Ł3** three-valued logics):
|
|
203
|
+
|
|
204
|
+
| formula | classical | with a `realistic` atom |
|
|
205
|
+
|---|---|---|
|
|
206
|
+
| `P \/ ~P` (excluded middle) | valid | **not valid** — undetermined when `P` is `realistic` |
|
|
207
|
+
| `~(P /\ ~P)` (non-contradiction) | valid | **not valid** |
|
|
208
|
+
| `P -> P` (self-implication) | valid | not valid in Kleene · valid in Łukasiewicz |
|
|
209
|
+
|
|
210
|
+
The failure of excluded middle for a `realistic` atom is the *point*: an
|
|
211
|
+
uncertain proposition is neither affirmed nor denied. Crucially, `realistic`
|
|
212
|
+
lives **above** the trusted kernel — conjectures carry evidence/confidence and a
|
|
213
|
+
status (`conjectured → certified / refuted`), and the kernel only ever certifies
|
|
214
|
+
real proofs. This is the intended bridge between informal LLM reasoning and
|
|
215
|
+
formal verification (see Realistic track R0–R3 in [ROADMAP.md](ROADMAP.md)).
|
|
216
|
+
|
|
217
|
+
## Architecture
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
matyos/ the proof assistant
|
|
221
|
+
├── kernel/ the TRUSTED core — small and auditable
|
|
222
|
+
│ ├── core terms, normalization, definitional equality, type inference
|
|
223
|
+
│ ├── inductive inductive types, recursors, iota-reduction, strict positivity
|
|
224
|
+
│ └── equality propositional equality (Eq) + the J eliminator
|
|
225
|
+
├── frontend/ tokenizer + parser for the .elk proof language
|
|
226
|
+
├── logic/ three-valued ("realistic") logic
|
|
227
|
+
└── cli the `matyos` command
|
|
228
|
+
|
|
229
|
+
matyos/stdlib/ standard library, written in MatyOS itself (.elk)
|
|
230
|
+
examples/ example proofs (.elk)
|
|
231
|
+
docs/ design + language reference
|
|
232
|
+
ROADMAP.md the honest, phased plan toward a Lean-class system
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Trust boundary:** only the **kernel** must be trusted. The parser, the
|
|
236
|
+
standard library, the `realistic` layer, and any future tactics or LLM output
|
|
237
|
+
all ultimately produce terms that the kernel re-checks. If the kernel is sound,
|
|
238
|
+
a term that type-checks against a proposition *is* a proof of it.
|
|
239
|
+
|
|
240
|
+
## Documentation
|
|
241
|
+
|
|
242
|
+
- [ROADMAP.md](ROADMAP.md) — phased plan and current status (honest about scale)
|
|
243
|
+
- [docs/architecture.md](docs/architecture.md) — design and trust model
|
|
244
|
+
- [docs/language.md](docs/language.md) — the `.elk` language reference
|
|
245
|
+
- [docs/projects.md](docs/projects.md) — projects, the scientific-method workflow, and the `.matyos` archive
|
|
246
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) — building from source, running tests
|
|
247
|
+
- [docs/legacy-el-language.md](docs/legacy-el-language.md) — the project's original imperative language
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
MIT. See [LICENSE](LICENSE).
|