Commit 26b96ad
committed
feat(types): add native type-system decoration layer + Sigma variant
Introduces a unified native type-system layer so backends that already
understand richer type disciplines can expose that understanding through
ECHIDNA's IR instead of delegating opaquely. This is Step 1 + Step 2 of the
plan: the low-risk foundation; per-backend wiring (Step 3) can follow
incrementally.
Changes:
1. Core IR gap closed: adds `Term::Sigma` (dependent pair / Σ type) as the
dual of `Term::Pi`. Pi-only was a genuine IR gap — dependent products
were representable but dependent pairs were not.
2. New `src/rust/types/` module with `TypeInfo` — an optional sidecar
decoration attachable to `Hypothesis`, `Definition`, and `Variable`.
`TypeInfo` spans eight dimensions:
- `Universe` (level + cumulativity + impredicativity + HoTT n-level)
- `Multiplicity` (QTT Zero/One/Omega, Linear, Affine, Shared, Graded(n))
- `EffectRow` (row-polymorphic algebraic effects: IO, State,
Exception, NonDet, Async, Div, Ghost, Tot, Custom)
- `refinement: Term` (refinement predicate {x:T | P x})
- `Modality` (alethic Box/Diamond; epistemic Knows/Believes;
Common, Distributed; deontic Obligation/Permission;
Provability; Custom)
- `TemporalOp` (LTL G/F/X/U/R, past-time Since/Triggered,
CTL AG/EG/AF/EF/AX/EX, μ-calculus Mu/Nu)
- `Semiring` (Boolean, Natural, Tropical {min-plus/max-plus},
Viterbi, Lukasiewicz, Custom)
- `relational_arity` (1 = ordinary, 2 = dyadic/parametric, n = n-ary)
All decorations are optional — backends that don't understand a field
simply ignore it. `TypeInfo::default()` is the no-decoration case and
serialises as `{}`.
3. Plumbing: `Hypothesis`, `Definition`, and `Variable` gain an optional
`type_info: Option<TypeInfo>` field with `#[serde(default, skip_serializing_if)]`
so prior-format JSON still deserialises cleanly. Added `new()` and
`with_type_info()` constructor helpers on all three structs.
4. Sigma rendering wired into every backend that renders `Pi`:
- Lean: `(x : A) × B`
- Agda: `Σ A λ x → B`
- Idris2: `(x : A ** B)`
- HOL4: existential approximation (no native Σ)
- HOL Light: existential approximation
- Mizar: `ex x being A st B`
- PVS: `EXISTS` approximation
- ACL2: `(and A B)` approximation
Also wired into aspect tagging (new `sigma_count` TheoremFeatures field
aggregated into `Aspect::DependentTypes`), GNN graph construction
(sigma binder nodes), and GNN one-hot embeddings (index 13 reserved).
5. Tests: 11 new unit tests in `src/rust/types/mod.rs` covering
multiplicity attachment, effect-row composition, epistemic modality,
tropical semiring, refinement predicates, HoTT universe levels, dyadic
relational arity, JSON roundtripping, empty-decoration compactness,
Sigma rendering+roundtrip, and backwards-compatible deserialisation of
prior-format Hypothesis JSON without `type_info`.
What this enables (follow-on work, not in this commit):
- Idris2 backend reading `multiplicity` → emits 0/1/ω bindings
- F* backend reading `effects` + `refinement`
- Lean 4 reading `universe.impredicative` / `homotopy_level`
- PVS reading `refinement` → predicate subtype
- SPIN/NuSMV/PRISM reading `temporal`
- Alloy reading `relational_arity`
- Future epistemic / tropical backends reading `modality` / `semiring`
- GNN guided search discriminating on type-info features
Compatibility:
- All changes are additive. `Option<TypeInfo>` is None by default;
existing code paths are unchanged.
- ~40 struct-literal construction sites updated to include
`type_info: None` — mechanical, inspected change.
Note: a pre-existing unrelated build issue exists in
`src/rust/provers/z3.rs` (`super::outcome::ProverOutcome` references a
module that does not exist in `src/rust/provers/`, and an orphan
`async fn check` outside the `ProverBackend` trait). Verified to exist
on a clean tree prior to this commit; this change does not regress it.
https://claude.ai/code/session_01FYkVX52Tdn6Arp9dWfPLxq1 parent aaeef38 commit 26b96ad
30 files changed
Lines changed: 744 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
304 | 316 | | |
305 | 317 | | |
306 | 318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
422 | 425 | | |
423 | 426 | | |
424 | 427 | | |
| |||
652 | 655 | | |
653 | 656 | | |
654 | 657 | | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
655 | 661 | | |
656 | 662 | | |
657 | 663 | | |
| |||
748 | 754 | | |
749 | 755 | | |
750 | 756 | | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
751 | 762 | | |
752 | 763 | | |
753 | 764 | | |
| |||
809 | 820 | | |
810 | 821 | | |
811 | 822 | | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
812 | 830 | | |
813 | 831 | | |
814 | 832 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
| |||
121 | 133 | | |
122 | 134 | | |
123 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
124 | 143 | | |
125 | 144 | | |
126 | 145 | | |
| |||
190 | 209 | | |
191 | 210 | | |
192 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
193 | 232 | | |
194 | 233 | | |
195 | 234 | | |
| |||
223 | 262 | | |
224 | 263 | | |
225 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
226 | 282 | | |
227 | 283 | | |
228 | 284 | | |
229 | 285 | | |
230 | 286 | | |
231 | 287 | | |
232 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
233 | 306 | | |
234 | 307 | | |
235 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| 353 | + | |
353 | 354 | | |
354 | 355 | | |
355 | 356 | | |
| |||
367 | 368 | | |
368 | 369 | | |
369 | 370 | | |
370 | | - | |
| 371 | + | |
| 372 | + | |
371 | 373 | | |
372 | 374 | | |
373 | 375 | | |
| |||
394 | 396 | | |
395 | 397 | | |
396 | 398 | | |
397 | | - | |
| 399 | + | |
398 | 400 | | |
399 | 401 | | |
400 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
375 | 392 | | |
376 | 393 | | |
377 | 394 | | |
| |||
642 | 659 | | |
643 | 660 | | |
644 | 661 | | |
| 662 | + | |
645 | 663 | | |
646 | 664 | | |
647 | 665 | | |
| |||
687 | 705 | | |
688 | 706 | | |
689 | 707 | | |
| 708 | + | |
690 | 709 | | |
691 | 710 | | |
692 | 711 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| 384 | + | |
384 | 385 | | |
385 | 386 | | |
386 | 387 | | |
| |||
390 | 391 | | |
391 | 392 | | |
392 | 393 | | |
| 394 | + | |
393 | 395 | | |
394 | 396 | | |
395 | 397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
980 | 980 | | |
981 | 981 | | |
982 | 982 | | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
983 | 995 | | |
984 | 996 | | |
985 | 997 | | |
| |||
1250 | 1262 | | |
1251 | 1263 | | |
1252 | 1264 | | |
| 1265 | + | |
1253 | 1266 | | |
1254 | 1267 | | |
1255 | 1268 | | |
| |||
1291 | 1304 | | |
1292 | 1305 | | |
1293 | 1306 | | |
| 1307 | + | |
1294 | 1308 | | |
1295 | 1309 | | |
1296 | 1310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
137 | 147 | | |
138 | 148 | | |
139 | 149 | | |
| |||
263 | 273 | | |
264 | 274 | | |
265 | 275 | | |
| 276 | + | |
266 | 277 | | |
267 | 278 | | |
268 | 279 | | |
| |||
318 | 329 | | |
319 | 330 | | |
320 | 331 | | |
| 332 | + | |
321 | 333 | | |
322 | 334 | | |
323 | 335 | | |
| |||
0 commit comments