@lapxo/obligations 0.2.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/LICENSE +21 -0
- package/README.md +169 -0
- package/dist/debit/debit.d.ts +3 -0
- package/dist/debit/debit.js +19 -0
- package/dist/debit/graph.d.ts +10 -0
- package/dist/debit/graph.js +57 -0
- package/dist/debit/ideal.d.ts +20 -0
- package/dist/debit/ideal.js +80 -0
- package/dist/debit/masks.d.ts +16 -0
- package/dist/debit/masks.js +95 -0
- package/dist/debit/packed.d.ts +30 -0
- package/dist/debit/packed.js +114 -0
- package/dist/debit/provenance.d.ts +3 -0
- package/dist/debit/provenance.js +8 -0
- package/dist/debit/register.d.ts +7 -0
- package/dist/debit/register.js +17 -0
- package/dist/debit/shuffle.d.ts +3 -0
- package/dist/debit/shuffle.js +30 -0
- package/dist/debit/standing.d.ts +3 -0
- package/dist/debit/standing.js +12 -0
- package/dist/debit/unit-span.d.ts +8 -0
- package/dist/debit/unit-span.js +63 -0
- package/dist/debit/unit.d.ts +22 -0
- package/dist/debit/unit.js +110 -0
- package/dist/debit/vector-move.d.ts +12 -0
- package/dist/debit/vector-move.js +48 -0
- package/dist/debit/vector.d.ts +26 -0
- package/dist/debit/vector.js +68 -0
- package/dist/field/encounter.d.ts +9 -0
- package/dist/field/encounter.js +36 -0
- package/dist/field/field.d.ts +39 -0
- package/dist/field/field.js +79 -0
- package/dist/field/frontier.d.ts +20 -0
- package/dist/field/frontier.js +16 -0
- package/dist/field/motion.d.ts +14 -0
- package/dist/field/motion.js +38 -0
- package/dist/field/present.d.ts +8 -0
- package/dist/field/present.js +18 -0
- package/dist/field/signatures.d.ts +6 -0
- package/dist/field/signatures.js +19 -0
- package/dist/field/yield.d.ts +15 -0
- package/dist/field/yield.js +16 -0
- package/dist/lattice/axioms.d.ts +14 -0
- package/dist/lattice/axioms.js +140 -0
- package/dist/lattice/declaration.d.ts +9 -0
- package/dist/lattice/declaration.js +12 -0
- package/dist/lattice/errors.d.ts +6 -0
- package/dist/lattice/errors.js +11 -0
- package/dist/lattice/forms.d.ts +38 -0
- package/dist/lattice/forms.js +198 -0
- package/dist/lattice/index.d.ts +45 -0
- package/dist/lattice/index.js +29 -0
- package/dist/lattice/lattice.d.ts +18 -0
- package/dist/lattice/lattice.js +14 -0
- package/dist/lattice/obligatory.d.ts +27 -0
- package/dist/lattice/obligatory.js +33 -0
- package/dist/lattice/order.d.ts +6 -0
- package/dist/lattice/order.js +150 -0
- package/dist/lattice/price/attainable.d.ts +22 -0
- package/dist/lattice/price/attainable.js +37 -0
- package/dist/lattice/price/blocks.d.ts +2 -0
- package/dist/lattice/price/blocks.js +26 -0
- package/dist/lattice/price/index.d.ts +7 -0
- package/dist/lattice/price/index.js +5 -0
- package/dist/lattice/price/premium.d.ts +18 -0
- package/dist/lattice/price/premium.js +80 -0
- package/dist/lattice/price/quote.d.ts +30 -0
- package/dist/lattice/price/quote.js +53 -0
- package/dist/lattice/scale-lattice.d.ts +5 -0
- package/dist/lattice/scale-lattice.js +35 -0
- package/dist/lattice/types.d.ts +40 -0
- package/dist/lattice/types.js +1 -0
- package/dist/lattice/vacuity.d.ts +22 -0
- package/dist/lattice/vacuity.js +55 -0
- package/dist/replay.d.ts +2 -0
- package/dist/replay.js +4 -0
- package/dist/views/chain.d.ts +5 -0
- package/dist/views/chain.js +5 -0
- package/dist/views/complement.d.ts +2 -0
- package/dist/views/complement.js +2 -0
- package/dist/views/dual.d.ts +1 -0
- package/dist/views/dual.js +1 -0
- package/dist/views/field/physics.d.ts +13 -0
- package/dist/views/field/physics.js +64 -0
- package/dist/views/field/policy.d.ts +20 -0
- package/dist/views/field/policy.js +68 -0
- package/dist/views/field/self.d.ts +8 -0
- package/dist/views/field/self.js +14 -0
- package/dist/views/field/wave.d.ts +16 -0
- package/dist/views/field/wave.js +34 -0
- package/dist/views/field.d.ts +12 -0
- package/dist/views/field.js +9 -0
- package/dist/views/galois.d.ts +2 -0
- package/dist/views/galois.js +2 -0
- package/dist/views/ideal.d.ts +10 -0
- package/dist/views/ideal.js +10 -0
- package/dist/views/product/design.d.ts +13 -0
- package/dist/views/product/design.js +66 -0
- package/dist/views/product/mould.d.ts +14 -0
- package/dist/views/product/mould.js +55 -0
- package/dist/views/product/polygon.d.ts +10 -0
- package/dist/views/product/polygon.js +65 -0
- package/dist/views/product/reach.d.ts +14 -0
- package/dist/views/product/reach.js +106 -0
- package/dist/views/product/resolution.d.ts +8 -0
- package/dist/views/product/resolution.js +34 -0
- package/dist/views/product.d.ts +12 -0
- package/dist/views/product.js +10 -0
- package/dist/views/quotient.d.ts +2 -0
- package/dist/views/quotient.js +2 -0
- package/dist/views/spectrum.d.ts +4 -0
- package/dist/views/spectrum.js +4 -0
- package/dist/views/valuation.d.ts +9 -0
- package/dist/views/valuation.js +9 -0
- package/package.json +91 -0
- package/receipts.bound +491 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { meetAt, origins } from "../../field/encounter.js";
|
|
2
|
+
const at = (cell) => cell.at.join('/');
|
|
3
|
+
const spoke = (cell, bounds) => [...new Set(cell.seen.map((s) => s.origin))].filter((one) => !bounds.includes(one));
|
|
4
|
+
export function neighbours(world, bounds = []) {
|
|
5
|
+
const byOrigin = new Map();
|
|
6
|
+
for (const cell of world)
|
|
7
|
+
for (const one of spoke(cell, bounds))
|
|
8
|
+
byOrigin.set(one, [...(byOrigin.get(one) ?? []), at(cell)]);
|
|
9
|
+
const out = new Map();
|
|
10
|
+
for (const held of byOrigin.values()) {
|
|
11
|
+
for (const a of held) {
|
|
12
|
+
const mine = out.get(a) ?? new Set();
|
|
13
|
+
for (const b of held)
|
|
14
|
+
if (b !== a)
|
|
15
|
+
mine.add(b);
|
|
16
|
+
out.set(a, mine);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return new Map([...out].map(([place, said]) => [place, [...said]]));
|
|
20
|
+
}
|
|
21
|
+
export function distance(world, from, to, bounds = []) {
|
|
22
|
+
if (from === to)
|
|
23
|
+
return 0;
|
|
24
|
+
const next = neighbours(world, bounds);
|
|
25
|
+
const seen = new Set([from]);
|
|
26
|
+
let edge = [from];
|
|
27
|
+
for (let step = 1; edge.length; step += 1) {
|
|
28
|
+
const further = [];
|
|
29
|
+
for (const one of edge) {
|
|
30
|
+
for (const other of next.get(one) ?? []) {
|
|
31
|
+
if (seen.has(other))
|
|
32
|
+
continue;
|
|
33
|
+
if (other === to)
|
|
34
|
+
return step;
|
|
35
|
+
seen.add(other);
|
|
36
|
+
further.push(other);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
edge = further;
|
|
40
|
+
}
|
|
41
|
+
return world.length;
|
|
42
|
+
}
|
|
43
|
+
export function horizon(world, from, bounds = []) {
|
|
44
|
+
const next = neighbours(world, bounds);
|
|
45
|
+
const seen = new Set([from]);
|
|
46
|
+
const edge = [from];
|
|
47
|
+
while (edge.length) {
|
|
48
|
+
const one = edge.pop();
|
|
49
|
+
for (const other of next.get(one) ?? [])
|
|
50
|
+
if (!seen.has(other)) {
|
|
51
|
+
seen.add(other);
|
|
52
|
+
edge.push(other);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return world.map(at).filter((place) => !seen.has(place));
|
|
56
|
+
}
|
|
57
|
+
export function reach(world, from, bounds = []) {
|
|
58
|
+
return world.length - horizon(world, from, bounds).length - 1;
|
|
59
|
+
}
|
|
60
|
+
export function tunnel(world, places, bounds = []) {
|
|
61
|
+
const crossed = [];
|
|
62
|
+
for (const a of places)
|
|
63
|
+
for (const b of places)
|
|
64
|
+
if (a < b && distance(world, a, b, bounds) >= world.length)
|
|
65
|
+
crossed.push([a, b]);
|
|
66
|
+
return crossed;
|
|
67
|
+
}
|
|
68
|
+
export function curvature(world) {
|
|
69
|
+
const counts = world.map((cell) => origins(cell)).filter((n) => n > 0).sort((a, b) => b - a);
|
|
70
|
+
if (!counts.length)
|
|
71
|
+
return 0;
|
|
72
|
+
const top = counts.slice(0, Math.max(1, Math.floor(counts.length / 10)));
|
|
73
|
+
const low = counts.slice(-Math.max(1, Math.floor(counts.length / 10)));
|
|
74
|
+
const mean = (xs) => xs.reduce((s, x) => s + x, 0) / xs.length;
|
|
75
|
+
if (mean(low) === 0)
|
|
76
|
+
throw new Error('obligations: REFUSE·curvature the sparsest tenth of this field holds no origin, so there is no ratio to take');
|
|
77
|
+
return mean(top) / mean(low);
|
|
78
|
+
}
|
|
79
|
+
export function grow(walls, placed) {
|
|
80
|
+
const edges = [...new Set(walls)].sort((a, b) => a - b);
|
|
81
|
+
const held = [...placed].sort((a, b) => a - b);
|
|
82
|
+
const first = edges[0] ?? 0;
|
|
83
|
+
const last = edges[edges.length - 1] ?? 0;
|
|
84
|
+
return held.map((one) => {
|
|
85
|
+
const lo = Math.max(...edges.filter((w) => w <= one), first);
|
|
86
|
+
const hi = Math.min(...edges.filter((w) => w >= one), last);
|
|
87
|
+
const inside = held.filter((other) => other > lo && other < hi);
|
|
88
|
+
const i = inside.indexOf(one);
|
|
89
|
+
const left = i > 0 ? (inside[i - 1] + one) / 2 : lo;
|
|
90
|
+
const right = i < inside.length - 1 ? (inside[i + 1] + one) / 2 : hi;
|
|
91
|
+
return { at: one, width: right - left };
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export function entangled(world, bound) {
|
|
95
|
+
return world.filter((cell) => cell.seen.some((s) => s.origin === bound)).map(at);
|
|
96
|
+
}
|
|
97
|
+
export function resting(world, bound, was, now) {
|
|
98
|
+
const under = (span, cell) => {
|
|
99
|
+
const held = meetAt({ ...cell, seen: cell.seen.map((s) => (s.origin === bound ? { ...s, span } : s)) });
|
|
100
|
+
return held.hi >= held.lo;
|
|
101
|
+
};
|
|
102
|
+
return entangled(world, bound).flatMap((place) => {
|
|
103
|
+
const cell = world.find((one) => at(one) === place);
|
|
104
|
+
return cell !== undefined && under(was, cell) !== under(now, cell) ? [place] : [];
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Point } from '../../field/field.ts';
|
|
2
|
+
export declare function agreements(cells: readonly Point[], steps: number): {
|
|
3
|
+
readonly agreed: number;
|
|
4
|
+
readonly forks: number;
|
|
5
|
+
readonly cells: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function residual(cells: readonly Point[], steps: number): number;
|
|
8
|
+
export declare function sufficient(cells: readonly Point[], upTo: number, tolerance?: number): number;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { coarsen } from "../../field/field.js";
|
|
2
|
+
import { verdict } from "../../field/encounter.js";
|
|
3
|
+
import { area } from "./polygon.js";
|
|
4
|
+
export function agreements(cells, steps) {
|
|
5
|
+
const pooled = new Map();
|
|
6
|
+
for (const cell of cells) {
|
|
7
|
+
const coarse = coarsen(cell, steps);
|
|
8
|
+
const key = coarse.at.join('/');
|
|
9
|
+
const held = pooled.get(key);
|
|
10
|
+
pooled.set(key, held === undefined ? coarse : { ...held, seen: [...held.seen, ...coarse.seen] });
|
|
11
|
+
}
|
|
12
|
+
const said = [...pooled.values()].map((one) => verdict(one));
|
|
13
|
+
return { agreed: said.filter((one) => one === 'together').length, forks: said.filter((one) => one === 'apart').length, cells: pooled.size };
|
|
14
|
+
}
|
|
15
|
+
export function residual(cells, steps) {
|
|
16
|
+
const pooled = new Map();
|
|
17
|
+
for (const cell of cells) {
|
|
18
|
+
const coarse = coarsen(cell, steps);
|
|
19
|
+
const key = coarse.at.join('/');
|
|
20
|
+
const held = pooled.get(key);
|
|
21
|
+
pooled.set(key, held === undefined ? coarse : { ...held, seen: [...held.seen, ...coarse.seen] });
|
|
22
|
+
}
|
|
23
|
+
return [...pooled.values()].reduce((sum, one) => sum + area(one), 0);
|
|
24
|
+
}
|
|
25
|
+
export function sufficient(cells, upTo, tolerance = 1e-9) {
|
|
26
|
+
let held = residual(cells, 1);
|
|
27
|
+
for (let steps = 2; steps <= upTo; steps += 1) {
|
|
28
|
+
const now = residual(cells, steps);
|
|
29
|
+
if (Math.abs(now - held) <= tolerance)
|
|
30
|
+
return steps - 1;
|
|
31
|
+
held = now;
|
|
32
|
+
}
|
|
33
|
+
return upTo;
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { buildGraph, reachIds } from '../debit/graph.ts';
|
|
2
|
+
export { or } from '../debit/packed.ts';
|
|
3
|
+
export { compose, fuse } from '../debit/unit.ts';
|
|
4
|
+
export { continuousForm, intervals, ladderForm } from '../lattice/forms.ts';
|
|
5
|
+
export { fromScale } from '../lattice/scale-lattice.ts';
|
|
6
|
+
export { area, centre, density, hull, outliers, steady, vertices, width } from './product/polygon.ts';
|
|
7
|
+
export type { Vertex } from './product/polygon.ts';
|
|
8
|
+
export { pour, red, stretch, tense, tighter } from './product/mould.ts';
|
|
9
|
+
export type { Lock } from './product/mould.ts';
|
|
10
|
+
export { agreements, residual, sufficient } from './product/resolution.ts';
|
|
11
|
+
export { curvature, distance, entangled, grow, horizon, neighbours, reach, resting, tunnel } from './product/reach.ts';
|
|
12
|
+
export { apart, design, horizonTotal, lone, loom, rank, sited } from './product/design.ts';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { buildGraph, reachIds } from "../debit/graph.js";
|
|
2
|
+
export { or } from "../debit/packed.js";
|
|
3
|
+
export { compose, fuse } from "../debit/unit.js";
|
|
4
|
+
export { continuousForm, intervals, ladderForm } from "../lattice/forms.js";
|
|
5
|
+
export { fromScale } from "../lattice/scale-lattice.js";
|
|
6
|
+
export { area, centre, density, hull, outliers, steady, vertices, width } from "./product/polygon.js";
|
|
7
|
+
export { pour, red, stretch, tense, tighter } from "./product/mould.js";
|
|
8
|
+
export { agreements, residual, sufficient } from "./product/resolution.js";
|
|
9
|
+
export { curvature, distance, entangled, grow, horizon, neighbours, reach, resting, tunnel } from "./product/reach.js";
|
|
10
|
+
export { apart, design, horizonTotal, lone, loom, rank, sited } from "./product/design.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { unitStream } from '../debit/shuffle.ts';
|
|
2
|
+
export { declarationOf, degenerate, movesOf, premiumOf, registerOf, stateOf, unitOf, withdrawsExactly } from '../field/motion.ts';
|
|
3
|
+
export { asUnit, conj, declaration, disj } from '../lattice/declaration.ts';
|
|
4
|
+
export { chain, height, order } from '../lattice/order.ts';
|
|
5
|
+
export { best, collapses, costOfState, gap, isSupermodular, premium, pricesAnything } from '../lattice/price/premium.ts';
|
|
6
|
+
export { defect, dropTo, price, slack } from '../lattice/price/quote.ts';
|
|
7
|
+
export { isMonotone, vacuityOf } from '../lattice/vacuity.ts';
|
|
8
|
+
export { frontier } from '../field/frontier.ts';
|
|
9
|
+
export { yieldOf } from '../field/yield.ts';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { unitStream } from "../debit/shuffle.js";
|
|
2
|
+
export { declarationOf, degenerate, movesOf, premiumOf, registerOf, stateOf, unitOf, withdrawsExactly } from "../field/motion.js";
|
|
3
|
+
export { asUnit, conj, declaration, disj } from "../lattice/declaration.js";
|
|
4
|
+
export { chain, height, order } from "../lattice/order.js";
|
|
5
|
+
export { best, collapses, costOfState, gap, isSupermodular, premium, pricesAnything } from "../lattice/price/premium.js";
|
|
6
|
+
export { defect, dropTo, price, slack } from "../lattice/price/quote.js";
|
|
7
|
+
export { isMonotone, vacuityOf } from "../lattice/vacuity.js";
|
|
8
|
+
export { frontier } from "../field/frontier.js";
|
|
9
|
+
export { yieldOf } from "../field/yield.js";
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lapxo/obligations",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The algebra of a cell: two poles, origins with phase, six operations.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Lapxo",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/lapxo/obligations.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"obligations",
|
|
14
|
+
"lattice",
|
|
15
|
+
"provenance"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22.12"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/lattice/index.d.ts",
|
|
24
|
+
"default": "./dist/lattice/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./debit": {
|
|
27
|
+
"types": "./dist/debit/debit.d.ts",
|
|
28
|
+
"default": "./dist/debit/debit.js"
|
|
29
|
+
},
|
|
30
|
+
"./encounter": {
|
|
31
|
+
"types": "./dist/field/encounter.d.ts",
|
|
32
|
+
"default": "./dist/field/encounter.js"
|
|
33
|
+
},
|
|
34
|
+
"./field": {
|
|
35
|
+
"types": "./dist/field/field.d.ts",
|
|
36
|
+
"default": "./dist/field/field.js"
|
|
37
|
+
},
|
|
38
|
+
"./forms": {
|
|
39
|
+
"types": "./dist/lattice/forms.d.ts",
|
|
40
|
+
"default": "./dist/lattice/forms.js"
|
|
41
|
+
},
|
|
42
|
+
"./lattice": {
|
|
43
|
+
"types": "./dist/lattice/lattice.d.ts",
|
|
44
|
+
"default": "./dist/lattice/lattice.js"
|
|
45
|
+
},
|
|
46
|
+
"./packed": {
|
|
47
|
+
"types": "./dist/debit/packed.d.ts",
|
|
48
|
+
"default": "./dist/debit/packed.js"
|
|
49
|
+
},
|
|
50
|
+
"./present": {
|
|
51
|
+
"types": "./dist/field/present.d.ts",
|
|
52
|
+
"default": "./dist/field/present.js"
|
|
53
|
+
},
|
|
54
|
+
"./price": {
|
|
55
|
+
"types": "./dist/lattice/price/index.d.ts",
|
|
56
|
+
"default": "./dist/lattice/price/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./replay": {
|
|
59
|
+
"types": "./dist/replay.d.ts",
|
|
60
|
+
"default": "./dist/replay.js"
|
|
61
|
+
},
|
|
62
|
+
"./shuffle": {
|
|
63
|
+
"types": "./dist/debit/shuffle.d.ts",
|
|
64
|
+
"default": "./dist/debit/shuffle.js"
|
|
65
|
+
},
|
|
66
|
+
"./signatures": {
|
|
67
|
+
"types": "./dist/field/signatures.d.ts",
|
|
68
|
+
"default": "./dist/field/signatures.js"
|
|
69
|
+
},
|
|
70
|
+
"./views/field": {
|
|
71
|
+
"types": "./dist/views/field.d.ts",
|
|
72
|
+
"default": "./dist/views/field.js"
|
|
73
|
+
},
|
|
74
|
+
"./views/product": {
|
|
75
|
+
"types": "./dist/views/product.d.ts",
|
|
76
|
+
"default": "./dist/views/product.js"
|
|
77
|
+
},
|
|
78
|
+
"./package.json": "./package.json"
|
|
79
|
+
},
|
|
80
|
+
"files": [
|
|
81
|
+
"dist",
|
|
82
|
+
"receipts.bound"
|
|
83
|
+
],
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "tsc --build"
|
|
86
|
+
},
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"@types/node": "^22",
|
|
89
|
+
"typescript": "^5.9.3"
|
|
90
|
+
}
|
|
91
|
+
}
|