gdp-wired 0.17.0 → 0.19.0

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.
package/README.md CHANGED
@@ -70,8 +70,9 @@ All of these are proven automatically, and each proof is also a Lean theorem:
70
70
  createActor)` drives XState's own actor and the compiled rule with the same random events, comparing every state and
71
71
  context; what a chart can't run the same way is refused when built, with the reason (`examples/xstate.ts`).
72
72
  - **What nobody stated, looked for when the prover alone stops**: where `proveRule` or `proveSteps` doesn't prove the laws
73
- and no run breaks them, it looks for lemmas about the rule's recurrences and lists (`discover`) and then invariants
74
- (`inferLaws`), within 10 s (`{search: {ms}}`; `{search: false}`, the prover alone); the verdict's `found` holds what
73
+ and no run breaks them, it looks for lemmas about the rule's recurrences and lists (`discover`), lemmas about the
74
+ functions it knows by their facts (`cycleLemmas`, each proven by a cyclic proof) and then invariants (`inferLaws`),
75
+ within 10 s (`{search: {ms}}`; `{search: false}`, the prover alone); the verdict's `found` holds what
75
76
  proved them, as laws and lemmas with the source to paste.
76
77
  - **Invariants nobody wrote** (`gdp-wired/infer`): `inferLaws(rule, laws)` proves a law that holds but isn't inductive
77
78
  alone, with the laws it finds (bounds, sums and differences over the state, the same where a flag or a choice holds
@@ -90,6 +91,12 @@ All of these are proven automatically, and each proof is also a Lean theorem:
90
91
  of a list a request carries need, from their values (bounds, linear relations, a closed form of degree 2 at most, a
91
92
  law between two points), proves it by the same induction and keeps only what the laws need; `discoverFold(fold,
92
93
  laws)` does the same for a fold over a tree. What it finds comes back as source to paste (`examples/discover.ts`).
94
+ - **Cycles nobody shaped** (`gdp-wired/cycles`): `findCycles(facts, claims)` proves claims about functions defined by
95
+ their equations with nothing a proof needs stated: the rank each induction drops (from the runs, by linear
96
+ programming, in order: McCarthy's 91 by 101 − n, Ackermann's by (m, n)), where each cycle returns (the calls its
97
+ goal reads), and the lemma a stuck one needs (g(x, 0) = 2x through g(x, a) = a + 2x; a bound on another function);
98
+ `proveLoop` with no rank finds it (two phases' (x, y)) and the invariants it needs; the kernel checks the cyclic
99
+ proof (`examples/cycles.ts`).
93
100
  - **Records and variants**: inputs, state, results, map cells and list items made of named fields, or one of several
94
101
  cases each with fields of its own (a payment by card or in cash, a seat free, held or sold), every case covered
95
102
  (`examples/datatypes.ts`).
@@ -120,7 +127,7 @@ sound.
120
127
  | Part | Trusted? | What it does |
121
128
  | --- | --- | --- |
122
129
  | `kernel/kernel.ts`, `core/check.ts` | **Yes** | Turns a rule and its laws into goals, and checks a proof tree for each: case splits on linear facts, then a linear refutation at each leaf |
123
- | `kernel/cyclic.ts` | **Yes** | Cyclic proofs: builds each node's goals (its own, and for each node it uses, that node's hypotheses and that the rank drops) and checks each tree with kernel.ts's check. Its twin is `lean-kernel/Cyclic.lean` (`cyclic_sound`) |
130
+ | `kernel/cyclic.ts` | **Yes** | Cyclic proofs: builds each node's goals (its own, and for each node it uses, that node's hypotheses and that the rank drops) and checks each tree with kernel.ts's check. Its twin is `lean-kernel/Cyclic.lean` (`cyclic_sound`), and `lean-kernel/Bridge.lean` carries a cyclic proof of a machine's law, a recurrence's lemmas or a fold's law back to the rule itself |
124
131
  | `kernel/prove.ts` | No | Finds the proof trees. If it's wrong, the kernel rejects the tree |
125
132
  | `lean-kernel/` | Optional | The kernel's twin in Lean 4.34.0, every rule proven sound there with the standard axioms only. The exporter sends the kernel's real trees; tampered ones compute to false |
126
133
  | `research/search/`, `research/synth/`, `research/hw/` | No | The GPU searches for breaking runs, and invariant and rank synthesis. Every hit is replayed or proven before it counts |
@@ -0,0 +1,73 @@
1
+ import type { C, E, Law, Machine } from './machine.js';
2
+ import type { Loop, Tree } from '../kernel/kernel.js';
3
+ import { type Cyclic, type Fact } from '../kernel/cyclic.js';
4
+ import { type NodeSpec } from './cyclic.js';
5
+ import type { StepLaw } from '../kernel/kernel.js';
6
+ export type Claim = {
7
+ name: string;
8
+ hyps?: C[];
9
+ concl: C;
10
+ };
11
+ export type CycleOptions = {
12
+ ms?: number;
13
+ depth?: number;
14
+ values?: Record<string, (...xs: number[]) => number>;
15
+ houdini?: boolean;
16
+ generalize?: boolean;
17
+ };
18
+ export type CycleFound = {
19
+ ranks: Record<string, string>;
20
+ companions: string[];
21
+ uses: number;
22
+ };
23
+ export type CycleVerdict = {
24
+ proven: boolean;
25
+ checked: boolean;
26
+ proof?: Cyclic;
27
+ specs?: NodeSpec[];
28
+ kept?: string[];
29
+ found?: CycleFound;
30
+ goal?: string;
31
+ stuck?: string;
32
+ witness?: Record<string, number>;
33
+ why?: string;
34
+ };
35
+ export declare const pairE: (a: E, b: E) => E;
36
+ export declare const argsKey: (args: E[]) => E;
37
+ export declare const linE: (coef: Record<string, number>, c: number) => E;
38
+ export declare const showE: (e: E) => string;
39
+ export declare const showC: (c: C) => string;
40
+ export declare function claimInstances(facts: Fact[], claim: Claim, depth?: number): NodeSpec['insts'];
41
+ export declare function findCycles(facts: Fact[], claims: Claim[], opts?: CycleOptions): CycleVerdict;
42
+ export type RankVerdict = {
43
+ proven: boolean;
44
+ checked: boolean;
45
+ rank?: E[];
46
+ laws?: Law[];
47
+ found?: {
48
+ rank: string;
49
+ laws: string[];
50
+ };
51
+ trees?: Record<string, Tree>;
52
+ goal?: string;
53
+ stuck?: string;
54
+ witness?: Record<string, number>;
55
+ why?: string;
56
+ };
57
+ export declare function findRank(l: Loop, laws?: Law[], opts?: {
58
+ ms?: number;
59
+ }): RankVerdict;
60
+ export type LemmaFound = {
61
+ law: Law;
62
+ text: string;
63
+ };
64
+ export declare function cycleLemmas(m: Machine, laws: Law[], stepLaws?: StepLaw[], opts?: {
65
+ ms?: number;
66
+ }): {
67
+ proven: boolean;
68
+ checked: boolean;
69
+ machine?: Machine;
70
+ found: LemmaFound[];
71
+ proof?: Cyclic;
72
+ why?: string;
73
+ };