gdp-wired 0.41.0 → 0.41.1
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/dist/kernel/kernel.js +24 -5
- package/package.json +1 -1
package/dist/kernel/kernel.js
CHANGED
|
@@ -792,8 +792,14 @@ function inScope(what, ts, vars, maps = [], flags = []) {
|
|
|
792
792
|
// A name the kernel's linear forms would read as something else: '1' is the constant, and '*', '[', ']', ',' and ':'
|
|
793
793
|
// build monomials and cells; '#' marks the fresh name a law is proven at (k#, its key's), which a name of the machine or
|
|
794
794
|
// another key of the law would capture. Such a name could never be proven about; refused instead, with its name.
|
|
795
|
-
|
|
796
|
-
|
|
795
|
+
// The names the kernel makes are kept apart the same way: '?' a flag's variable ?f and its witnesses w?f, w2?f; '~' a
|
|
796
|
+
// state named after a step (s~1); ''' the state and maps after the step (s', M'); '⟦' and '⟧' a term's column (⟦n⟧).
|
|
797
|
+
// ('@', a later step's a@2, ?f@2, I@2, is not reserved: compose's steps names its inputs x@s1; stepLawObligations
|
|
798
|
+
// keeps a later step's names apart from every name of the machine instead.) A name of the machine, a law's or step
|
|
799
|
+
// law's key with one of them would be read as the kernel's own (a param ?f as the flag f's 0/1 variable: "s <= ?f" was
|
|
800
|
+
// accepted, false at ?f = 0; Lean refuses it).
|
|
801
|
+
const plainName = (what, name) => { if (name === '1' || /[*[\],:#?~'⟦⟧]/.test(name))
|
|
802
|
+
throw new Error(`${what}: the name ${name} is reserved (1, or * [ ] , : # ? ~ ' ⟦ ⟧)`); };
|
|
797
803
|
const distinct = (what, names) => { const seen = new Set(); for (const name of names) {
|
|
798
804
|
if (seen.has(name))
|
|
799
805
|
throw new Error(`${what} declares ${name} twice`);
|
|
@@ -1532,6 +1538,7 @@ export function checkRecurCases(l, r) {
|
|
|
1532
1538
|
// hold of every request where the sums are exact: Sums.lean's sum_allowed).
|
|
1533
1539
|
export function progressObligations(m0, laws, instances, p) {
|
|
1534
1540
|
const m = plainOf(m0), own = m0.sums && Object.keys(m0.sums).length ? m0.assume : m.assume;
|
|
1541
|
+
scope(m, laws); // (as obligations scopes it: a param ?f would be read as the flag f's variable here too)
|
|
1535
1542
|
if (!m.inputs.every(i => i in p.request) || !Object.values(p.request).every(natural) || mentions(p.when, m.inputs))
|
|
1536
1543
|
throw new Error('outside the kernel');
|
|
1537
1544
|
for (const e of Object.values(p.request))
|
|
@@ -1621,11 +1628,17 @@ export function stepLawObligations(machine, laws, instances, sl) {
|
|
|
1621
1628
|
const later = laters.flatMap(l => Object.values(l.vars).map(e => e.name)), laterMaps = laters.flatMap(l => Object.values(l.maps));
|
|
1622
1629
|
const names = Array.from({ length: k - 1 }, (_, i) => state.map(n => stateName(n, i + 1))).flat();
|
|
1623
1630
|
const taken = [...m.params, ...m.inputs, ...state, ...maps, ...carried];
|
|
1631
|
+
// (and every name the run reads besides: the functions, each flag's variable ?f and its witnesses, which a later
|
|
1632
|
+
// step's names, a@2, I@2, ?f@2, must not be: a function I@2 was read as the second request's carried map)
|
|
1633
|
+
const own = [...taken, ...Object.keys(m.fns ?? {}), ...flagNames.map(f => `?${f}`), ...quantified(m).flatMap(([f, q]) => witnessesOf(f, q))];
|
|
1624
1634
|
for (const p of [...primes, ...later, ...laterMaps, ...names])
|
|
1625
|
-
if (
|
|
1635
|
+
if (own.includes(p))
|
|
1626
1636
|
throw new Error(`${m.name}: ${p} is a name of the machine and a name a step law reads`);
|
|
1627
1637
|
for (const key of [sl.forall, ...(sl.keys ?? [])])
|
|
1628
|
-
if (key
|
|
1638
|
+
if (key)
|
|
1639
|
+
plainName(`step law ${sl.name}'s key`, key);
|
|
1640
|
+
for (const key of [sl.forall, ...(sl.keys ?? [])])
|
|
1641
|
+
if (key && [...own, ...primes, ...later, ...names].includes(key))
|
|
1629
1642
|
throw new Error(`step law ${sl.name}'s key ${key} is already a name of ${m.name}`);
|
|
1630
1643
|
if (sl.keys?.length && (!sl.forall || new Set([sl.forall, ...sl.keys]).size !== sl.keys.length + 1))
|
|
1631
1644
|
throw new Error(`step law ${sl.name}: further keys come with a first, each a different name`);
|
|
@@ -1706,6 +1719,12 @@ export function foldObligations(f, laws) {
|
|
|
1706
1719
|
throw new Error('outside the kernel');
|
|
1707
1720
|
const names = Object.keys(f.leaf);
|
|
1708
1721
|
distinct(f.name, [...f.params, ...f.inputs, ...names]);
|
|
1722
|
+
// The children's copies (l_n, r_n) are names of their own (Lean's copiesOk): a param l_size would be read as the left
|
|
1723
|
+
// child's size at a node.
|
|
1724
|
+
const copies = names.flatMap(n => [`l_${n}`, `r_${n}`]);
|
|
1725
|
+
for (const name of [...f.params, ...f.inputs, ...names])
|
|
1726
|
+
if (copies.includes(name))
|
|
1727
|
+
throw new Error(`${f.name}: ${name} is a name of the fold and a child's copy (l_<name>, r_<name>)`);
|
|
1709
1728
|
if (Object.keys(f.node).sort().join() !== [...names].sort().join())
|
|
1710
1729
|
throw new Error(`${f.name}'s leaf and node set the same names`);
|
|
1711
1730
|
inScope(`${f.name}'s leaf`, [...Object.values(f.leaf), ...(f.assume ? [f.assume] : [])], [...f.params, ...f.inputs]);
|
|
@@ -1776,7 +1795,7 @@ export function qdec(path, r) {
|
|
|
1776
1795
|
}
|
|
1777
1796
|
export function qlinear(e, path) {
|
|
1778
1797
|
switch (e.op) {
|
|
1779
|
-
case 'var': return e.name === '1' ? undefined : { row: { cs: new Map([[e.name, 1n]]), c: 0n }, den: 1n };
|
|
1798
|
+
case 'var': return e.name === '1' || /[*[\],:⟦]/.test(e.name) ? undefined : { row: { cs: new Map([[e.name, 1n]]), c: 0n }, den: 1n }; // (a row's key is its canonical text: a variable x:1,y read as x + y's)
|
|
1780
1799
|
case 'const': {
|
|
1781
1800
|
const q = ratNorm(e.q);
|
|
1782
1801
|
return { row: { cs: new Map(), c: q.num }, den: q.den };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdp-wired",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.1",
|
|
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",
|