gdp-wired 0.31.0 → 0.32.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 +82 -6
- package/dist/core/c/reader.d.ts +86 -0
- package/dist/core/c/reader.js +860 -0
- package/dist/core/cli.d.ts +66 -0
- package/dist/core/cli.js +582 -0
- package/dist/core/dsl.d.ts +4 -2
- package/dist/core/dsl.js +22 -12
- package/dist/core/effect.d.ts +6 -4
- package/dist/core/effect.js +48 -10
- package/dist/core/ex/harness.exs +177 -0
- package/dist/core/ex/json.exs +46 -0
- package/dist/core/ex/reader.exs +462 -0
- package/dist/core/exists.d.ts +3 -0
- package/dist/core/exists.js +3 -1
- package/dist/core/extract-c.d.ts +35 -0
- package/dist/core/extract-c.js +424 -0
- package/dist/core/extract-check.js +27 -6
- package/dist/core/extract-ex.d.ts +16 -0
- package/dist/core/extract-ex.js +33 -0
- package/dist/core/extract-go-check.d.ts +28 -0
- package/dist/core/extract-go-check.js +639 -0
- package/dist/core/extract-go.d.ts +231 -0
- package/dist/core/extract-go.js +1166 -0
- package/dist/core/extract-jvm.d.ts +23 -0
- package/dist/core/extract-jvm.js +220 -0
- package/dist/core/extract-print.js +17 -7
- package/dist/core/extract-py.d.ts +15 -0
- package/dist/core/extract-py.js +31 -0
- package/dist/core/extract-rb.d.ts +17 -0
- package/dist/core/extract-rb.js +31 -0
- package/dist/core/extract-read.d.ts +20 -0
- package/dist/core/extract-read.js +46 -6
- package/dist/core/extract-rs.d.ts +12 -0
- package/dist/core/extract-rs.js +306 -0
- package/dist/core/extract-shapes.d.ts +2 -0
- package/dist/core/extract-shapes.js +6 -5
- package/dist/core/extract-step.d.ts +806 -0
- package/dist/core/extract-step.js +4141 -0
- package/dist/core/extract-swift.d.ts +27 -0
- package/dist/core/extract-swift.js +484 -0
- package/dist/core/extract-xstate.d.ts +10 -3
- package/dist/core/extract-xstate.js +50 -4
- package/dist/core/extract.d.ts +22 -3
- package/dist/core/extract.js +107 -18
- package/dist/core/go/go.mod +3 -0
- package/dist/core/go/reader.go +901 -0
- package/dist/core/infer.js +1770 -52
- package/dist/core/jvm/Harness.java +361 -0
- package/dist/core/jvm/JavaReader.java +825 -0
- package/dist/core/jvm/Jvm.java +332 -0
- package/dist/core/jvm/KtReader.java +960 -0
- package/dist/core/jvm/Rt.java +10 -0
- package/dist/core/laws.d.ts +66 -0
- package/dist/core/laws.js +522 -0
- package/dist/core/py/harness.py +328 -0
- package/dist/core/py/reader.py +447 -0
- package/dist/core/rb/harness.rb +233 -0
- package/dist/core/rb/reader.rb +375 -0
- package/dist/core/rs/Cargo.lock +108 -0
- package/dist/core/rs/Cargo.toml +14 -0
- package/dist/core/rs/src/main.rs +681 -0
- package/dist/core/swift/Harness.swift +124 -0
- package/dist/core/swift/Main.swift +34 -0
- package/dist/core/swift/Package.swift +13 -0
- package/dist/core/swift/Sources/gdp-swiftreader/main.swift +1341 -0
- package/dist/kernel/cdcl.js +43 -18
- package/dist/kernel/epr.d.ts +35 -0
- package/dist/kernel/epr.js +1676 -0
- package/dist/kernel/prove.d.ts +44 -0
- package/dist/kernel/prove.js +668 -54
- package/dist/lean-kernel/emit.d.ts +1 -0
- package/dist/lean-kernel/emit.js +21 -4
- package/package.json +53 -6
package/dist/lean-kernel/emit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { atMost, n, not, pointWrite } from "../core/machine.js";
|
|
2
2
|
import { add, k, scale, sub } from "../core/solver.js";
|
|
3
3
|
import { boundOf, caseGoals, check, checkRecur, checkRecurCases, coverGoal, recurGoal, canon, decided, factorsOf, isCell, isMonomial, columnTerm, stateName, termColumn, truth, historyMachine, sumMachine, sumCovers, sumParts, foldObligations, kInductionStart, kInductionSteps, leafConstraints, loopLiveness, loopMachine, linear, livenessHelpful, livenessParts, livenessLevels, livenessRanks, strongly, loopObligations, trueC, obligations, progressObligations, stepLawObligations, substC, witnessesOf, withProducts } from "../kernel/kernel.js";
|
|
4
|
-
import { chooseLevels, grow, minimal, proveBuilt, proveLaws, proveStepLaws, withDeadline } from "../kernel/prove.js";
|
|
4
|
+
import { chooseLevels, clock, grow, minimal, proveBuilt, proveLaws, proveSetFast, proveStepLaws, withDeadline } from "../kernel/prove.js";
|
|
5
5
|
import { refinement, refinementSides } from "../core/compose.js";
|
|
6
6
|
import { leanSurface, leanTerms } from "./lean-terms.js";
|
|
7
7
|
import { descentGoal, mainGoal, premiseGoal } from "../kernel/cyclic.js";
|
|
@@ -1364,11 +1364,24 @@ example : checkSMachine ${id}_tampered ${id}_proof = false := by ${checkBy}` : '
|
|
|
1364
1364
|
// is made with no cyclic certificate of its own (quietly): the export makes the certificate it exports from the usual
|
|
1365
1365
|
// trees (cycMachineProof), and the usual export reads the trees, so a certificate made here is never read.
|
|
1366
1366
|
const usualMade = new Map();
|
|
1367
|
+
// Where the usual proof fails and there are no step laws, the search's own set proof (proveSetFast: per-law instances
|
|
1368
|
+
// of each law's sort, a refutation's core widened to its goal, its trees checked by checkLaws): the laws the engine
|
|
1369
|
+
// proved that way (ring's) go to Lean from the trees that proof made, which Lean checks as any (`certReport.fast`).
|
|
1367
1370
|
function proveStepLawsOnce(m, laws, stepLaws) {
|
|
1368
1371
|
const key = JSON.stringify([m, laws, stepLaws]), had = usualMade.get(key);
|
|
1369
1372
|
if (had)
|
|
1370
1373
|
return had;
|
|
1371
|
-
|
|
1374
|
+
// (with no step laws, the usual proof within usualMs of the cost model's clock (GDP_LEAN_USUAL_MS, 60 s): past it, the
|
|
1375
|
+
// fast one; wo's set with its ghost ran the usual proof 8 minutes and more)
|
|
1376
|
+
const fastToo = !stepLaws.length && !laws.some(l => l.some?.length);
|
|
1377
|
+
let r = quietly(() => (fastToo ? withDeadline(clock() + Number(envOf()?.GDP_LEAN_USUAL_MS ?? 60_000), () => proveStepLaws(m, laws, stepLaws)) : proveStepLaws(m, laws, stepLaws)));
|
|
1378
|
+
if (!r.proven && fastToo) {
|
|
1379
|
+
const f = quietly(() => proveSetFast(m, laws));
|
|
1380
|
+
if (f.proven && f.checked && f.proof) {
|
|
1381
|
+
r = { proven: true, checked: true, nodes: f.nodes, leaves: f.leaves, proof: { laws: f.proof, instances: {}, perStep: {}, trees: {} } };
|
|
1382
|
+
certReport.fast.push(m.name);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1372
1385
|
usualMade.set(key, r);
|
|
1373
1386
|
return r;
|
|
1374
1387
|
}
|
|
@@ -1378,7 +1391,7 @@ const envOf = () => globalThis.process?.env;
|
|
|
1378
1391
|
export const cyclicCerts = certMode;
|
|
1379
1392
|
let certsOn = false, cycTexts = 0;
|
|
1380
1393
|
// What the last toLean exported from cyclic certificates, and what went the usual way (and why).
|
|
1381
|
-
export const certReport = { cyclic: [], usual: [], translatedSteps: [] };
|
|
1394
|
+
export const certReport = { cyclic: [], usual: [], translatedSteps: [], fast: [] };
|
|
1382
1395
|
// Each item's cyclic certificate is made within one deadline (GDP_CERT_MS, 10 s by default), every goal it grows (the
|
|
1383
1396
|
// translation's leaves grown again, the searched nodes) bounded by it: past it, the item goes the usual way.
|
|
1384
1397
|
function cycMachineProof(m, laws, allSteps, allows = []) {
|
|
@@ -1950,6 +1963,7 @@ export function toLean(items, opts = {}) {
|
|
|
1950
1963
|
certReport.cyclic = [];
|
|
1951
1964
|
certReport.usual = [];
|
|
1952
1965
|
certReport.translatedSteps = [];
|
|
1966
|
+
certReport.fast = [];
|
|
1953
1967
|
cycTexts = 0;
|
|
1954
1968
|
usualMade.clear();
|
|
1955
1969
|
// The proofs found with only the instances their leaves use: the same laws, from fewer hypotheses for Lean to build.
|
|
@@ -1993,7 +2007,10 @@ function toLeanWith(items, opts) {
|
|
|
1993
2007
|
// Laws with "there exists" go in as the kernel proved them (core/exists.ts): the machine with the ghosts their
|
|
1994
2008
|
// witnesses are, each law with its witness terms in place or over its ghosts, each stated again as ∃ (readable).
|
|
1995
2009
|
if (item.laws.some(l => l.some?.length)) {
|
|
1996
|
-
|
|
2010
|
+
// (with no step laws, the search's set proof first, proveSome's witnesses with proveSetFast as its whole-set
|
|
2011
|
+
// prover: the same ghosted machine and laws, without the usual proof and certificate the export makes again below)
|
|
2012
|
+
const it = item, fast = it.stepLaws?.length ? undefined : quietly(() => proveSetFast(it.machine, it.laws));
|
|
2013
|
+
const r = fast?.proven && fast.checked && fast.laws ? fast : proveStepLaws(it.machine, it.laws, it.stepLaws ?? []);
|
|
1997
2014
|
if (!r.proven || !r.laws)
|
|
1998
2015
|
throw new Error(`${it.id}: not proven (${r.failed?.stuck ?? ''})`);
|
|
1999
2016
|
const ghosts = [...(it.ghosts ?? []), ...Object.keys(r.machine?.state ?? {}).filter(n => !(n in it.machine.state))];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdp-wired",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "An automatic prover for stateful rules (budgets, caps, windows, workflows, policies): laws proven with no proof to write, checked again in Lean, counterexamples found on the GPU, the rule shipped as code",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"verification",
|
|
@@ -100,8 +100,59 @@
|
|
|
100
100
|
"types": "./dist/core/effect.d.ts",
|
|
101
101
|
"default": "./dist/core/effect.js"
|
|
102
102
|
},
|
|
103
|
+
"./extract-py": {
|
|
104
|
+
"types": "./dist/core/extract-py.d.ts",
|
|
105
|
+
"default": "./dist/core/extract-py.js"
|
|
106
|
+
},
|
|
107
|
+
"./extract-ex": {
|
|
108
|
+
"types": "./dist/core/extract-ex.d.ts",
|
|
109
|
+
"default": "./dist/core/extract-ex.js"
|
|
110
|
+
},
|
|
111
|
+
"./extract-rb": {
|
|
112
|
+
"types": "./dist/core/extract-rb.d.ts",
|
|
113
|
+
"default": "./dist/core/extract-rb.js"
|
|
114
|
+
},
|
|
115
|
+
"./extract-c": {
|
|
116
|
+
"types": "./dist/core/extract-c.d.ts",
|
|
117
|
+
"default": "./dist/core/extract-c.js"
|
|
118
|
+
},
|
|
119
|
+
"./extract-cpp": {
|
|
120
|
+
"types": "./dist/core/extract-c.d.ts",
|
|
121
|
+
"default": "./dist/core/extract-c.js"
|
|
122
|
+
},
|
|
123
|
+
"./extract-java": {
|
|
124
|
+
"types": "./dist/core/extract-jvm.d.ts",
|
|
125
|
+
"default": "./dist/core/extract-jvm.js"
|
|
126
|
+
},
|
|
127
|
+
"./extract-kotlin": {
|
|
128
|
+
"types": "./dist/core/extract-jvm.d.ts",
|
|
129
|
+
"default": "./dist/core/extract-jvm.js"
|
|
130
|
+
},
|
|
131
|
+
"./extract-rs": {
|
|
132
|
+
"types": "./dist/core/extract-rs.d.ts",
|
|
133
|
+
"default": "./dist/core/extract-rs.js"
|
|
134
|
+
},
|
|
135
|
+
"./extract-swift": {
|
|
136
|
+
"types": "./dist/core/extract-swift.d.ts",
|
|
137
|
+
"default": "./dist/core/extract-swift.js"
|
|
138
|
+
},
|
|
139
|
+
"./extract-go": {
|
|
140
|
+
"types": "./dist/core/extract-go.d.ts",
|
|
141
|
+
"default": "./dist/core/extract-go.js"
|
|
142
|
+
},
|
|
143
|
+
"./cli": {
|
|
144
|
+
"types": "./dist/core/cli.d.ts",
|
|
145
|
+
"default": "./dist/core/cli.js"
|
|
146
|
+
},
|
|
147
|
+
"./laws": {
|
|
148
|
+
"types": "./dist/core/laws.d.ts",
|
|
149
|
+
"default": "./dist/core/laws.js"
|
|
150
|
+
},
|
|
103
151
|
"./package.json": "./package.json"
|
|
104
152
|
},
|
|
153
|
+
"bin": {
|
|
154
|
+
"gdp-wired": "dist/core/cli.js"
|
|
155
|
+
},
|
|
105
156
|
"files": [
|
|
106
157
|
"dist",
|
|
107
158
|
"README.md",
|
|
@@ -112,16 +163,12 @@
|
|
|
112
163
|
},
|
|
113
164
|
"peerDependencies": {
|
|
114
165
|
"@gdp-ts/core": ">=0.1.0",
|
|
115
|
-
"effect": "^3.22.0 || ^4.0.0",
|
|
116
166
|
"typescript": ">=5.0.0"
|
|
117
167
|
},
|
|
118
168
|
"peerDependenciesMeta": {
|
|
119
169
|
"@gdp-ts/core": {
|
|
120
170
|
"optional": true
|
|
121
171
|
},
|
|
122
|
-
"effect": {
|
|
123
|
-
"optional": true
|
|
124
|
-
},
|
|
125
172
|
"typescript": {
|
|
126
173
|
"optional": true
|
|
127
174
|
}
|
|
@@ -134,7 +181,7 @@
|
|
|
134
181
|
"prepublishOnly": "bun scripts/build.ts",
|
|
135
182
|
"smoke": "sh scripts/smoke.sh",
|
|
136
183
|
"bar": "bun gates/bar.ts",
|
|
137
|
-
"test": "bun scripts/gen-lean-library.ts --check && cd core && bun test solver.test.ts dsl.test.ts sums.test.ts arith.test.ts conformance.test.ts compose.test.ts quantifiers.test.ts functions.test.ts keyterms.test.ts lists.test.ts liveness.test.ts sizes.test.ts values.test.ts rationals.test.ts builders.test.ts gdp.test.ts datatypes.test.ts lemmas.test.ts discover.test.ts infer.test.ts cyclic.test.ts cycles.test.ts nonterm.test.ts data.test.ts hypothesis.test.ts seqs.test.ts abstract.test.ts search.test.ts invoices.test.ts folds.test.ts trees.test.ts pairs.test.ts chart.test.ts xstate.test.ts extract.test.ts effect.test.ts && cd ../kernel && bun test tamper.test.ts refusals.test.ts steplaw.test.ts sets.test.ts cdcl.test.ts && cd ../examples && bun test examples.test.ts && cd .. && bun examples/readme.ts && bun examples/guide.ts && bun examples/composition.ts && bun examples/sets.ts && bun examples/quantifiers.ts && bun examples/functions.ts && bun examples/datatypes.ts && bun examples/lemmas.ts && bun examples/discover.ts && bun examples/invoices.ts && bun examples/folds.ts && bun examples/trees.ts && bun examples/pairs.ts && bun examples/groups.ts && bun examples/charts.ts && bun examples/xstate.ts && bun examples/effect.ts && bun examples/infer.ts && bun examples/arith.ts && bun examples/cyclic.ts && bun examples/cycles.ts && bun examples/data.ts && bun examples/abstract.ts && bun test compare/tip/translate.test.ts && bun examples/scopes.ts && bun examples/lists.ts && bun examples/sizes.ts && bun examples/liveness.ts && bun examples/sums.ts && bun examples/nonterm.ts && bun examples/rationals.ts && bun examples/budget.ts && bun examples/gdp.ts && bun examples/steps.ts && bun examples/jev-fabric/run.ts"
|
|
184
|
+
"test": "bun scripts/gen-lean-library.ts --check && cd core && bun test exports.test.ts cli.test.ts solver.test.ts dsl.test.ts sums.test.ts arith.test.ts conformance.test.ts compose.test.ts quantifiers.test.ts functions.test.ts keyterms.test.ts lists.test.ts liveness.test.ts sizes.test.ts values.test.ts rationals.test.ts builders.test.ts gdp.test.ts datatypes.test.ts lemmas.test.ts discover.test.ts infer.test.ts cyclic.test.ts cycles.test.ts nonterm.test.ts data.test.ts hypothesis.test.ts seqs.test.ts abstract.test.ts search.test.ts invoices.test.ts folds.test.ts trees.test.ts pairs.test.ts chart.test.ts xstate.test.ts extract.test.ts effect.test.ts && cd ../kernel && bun test tamper.test.ts refusals.test.ts steplaw.test.ts sets.test.ts cdcl.test.ts && cd ../examples && bun test examples.test.ts && cd .. && bun examples/readme.ts && bun examples/guide.ts && bun examples/composition.ts && bun examples/sets.ts && bun examples/quantifiers.ts && bun examples/functions.ts && bun examples/datatypes.ts && bun examples/lemmas.ts && bun examples/discover.ts && bun examples/invoices.ts && bun examples/folds.ts && bun examples/trees.ts && bun examples/pairs.ts && bun examples/groups.ts && bun examples/charts.ts && bun examples/xstate.ts && bun examples/effect.ts && bun examples/infer.ts && bun examples/arith.ts && bun examples/cyclic.ts && bun examples/cycles.ts && bun examples/data.ts && bun examples/abstract.ts && bun test compare/tip/translate.test.ts && bun examples/scopes.ts && bun examples/lists.ts && bun examples/sizes.ts && bun examples/liveness.ts && bun examples/sums.ts && bun examples/nonterm.ts && bun examples/rationals.ts && bun examples/budget.ts && bun examples/gdp.ts && bun examples/steps.ts && bun examples/jev-fabric/run.ts"
|
|
138
185
|
},
|
|
139
186
|
"devDependencies": {
|
|
140
187
|
"@gdp-ts/core": "0.1.0",
|