Prove the semver and solver kernel instead of testing it
Move number parsing, version ordering and constraints, version sorting and solver literals into src/kernel, with contracts checked by moon prove under overflow-checked integers. Replace the semver behaviour tests with those proofs, keep tests for string parsing, and run the proofs in CI. Version numbers are now 64-bit: the old parser silently wrapped at 2^31. Drop pick_tag, which only tests called. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d815bbb75
commit
83e694c6c4
16 files changed
+874
-330
No files matched your search
@@ -0,0 +1,24 @@
|
||||
# kernel
|
||||
|
||||
The proved part of Orbit. `src/main` runs this code, so the proofs replace tests
|
||||
of it. There are no axioms. Contracts are in `.mbt`, specifications in `.mbtp`.
|
||||
|
||||
| File | Proved |
|
||||
|---|---|
|
||||
| `nat` | The result is the decimal value, or -1 for an empty string, a non-digit, or 10^18 and up. Nothing overflows. |
|
||||
| `version` | `compare` is a total order, and each constraint operator accepts exactly its interval. |
|
||||
| `sort` | `sort_desc` terminates and lists every index once, highest version first and stable. |
|
||||
| `lit` | Literals round trip to their variable and sign, and a literal and its complement never agree. |
|
||||
|
||||
Run `just prove`. It selects the machine-integer prelude. Plain `moon prove`
|
||||
models integers as unbounded, so it would miss overflow.
|
||||
|
||||
Not proved, and still tested in `src/main`: splitting strings, ranking
|
||||
prereleases (`Key.pre`), and anything that does I/O. The prover treats strings
|
||||
as opaque. `src/main` is not proof-enabled, so its calls must meet the
|
||||
`proof_require` clauses by themselves.
|
||||
|
||||
**Writing specifications:** `moonc-prove` 0.10.20 drops the parentheses around an
|
||||
implication, so `(a → b) && (c → d)` is read as `((a → b) && c) → d`. Never put
|
||||
`→` or a quantifier under `&&` or `||`. Give it its own predicate, or use `==`.
|
||||
After changing a proof, break the code on purpose and check that it fails.
|
||||
Reference in new issue
Block a user