@lapxo/obligations 0.4.1 → 0.4.3
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 +2 -2
- package/TARGET.bound +97 -10
- package/dist/lattice/obligatory.js +29 -1
- package/dist/measures/capacity.d.ts +22 -0
- package/dist/measures/capacity.js +16 -0
- package/dist/measures/confidence.d.ts +73 -0
- package/dist/measures/confidence.js +52 -0
- package/dist/measures/index.d.ts +9 -1
- package/dist/measures/index.js +5 -1
- package/dist/measures/mix-loss.d.ts +187 -0
- package/dist/measures/mix-loss.js +101 -0
- package/dist/measures/phase-defect.d.ts +40 -0
- package/dist/measures/phase-defect.js +33 -0
- package/dist/measures/tolerant-subsets.d.ts +79 -0
- package/dist/measures/tolerant-subsets.js +60 -0
- package/docs/measures.md +25 -1
- package/package.json +1 -1
- package/receipts.bound +304 -107
- package/samples/measures/common-cause-capacity.json +48 -0
- package/samples/measures/confidence/union-bound.json +54 -0
- package/samples/measures/confidence.json +70 -0
- package/samples/measures/l7-tolerant-k.json +90 -0
- package/samples/measures/l8-phase-defect.json +19 -0
- package/samples/measures/l9-mix-loss.json +36 -0
- package/samples/measures/t12/common-cause.json +32 -0
- package/samples/measures/tolerant-count.json +144 -0
- package/samples/no/installed-artifact.json +102 -5
- package/samples/yes/installed-artifact.json +36 -49
- package/vectors/laws/implementation-043.json +98 -0
- package/vectors/laws/l7-tolerant-k.json +253 -0
- package/vectors/laws/l8-phase-defect.json +214 -0
- package/vectors/laws/l9-mix-loss.json +130 -0
- package/vectors/laws/policy.json +22 -0
- package/vectors/measures/common-cause-capacity.cli.json +97 -0
- package/vectors/measures/confidence/expected.json +26 -0
- package/vectors/measures/confidence.cli.json +97 -0
- package/vectors/measures/implementation-042.json +86 -0
- package/vectors/measures/installed-artifact.cli.json +12 -28
- package/vectors/measures/t12/expected.json +35 -0
- package/vectors/measures/tolerant-count.cli.json +97 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type DeclaredFailure } from './confidence.ts';
|
|
2
|
+
export declare function tolerantSubsetConfidence(failures: readonly DeclaredFailure[], k: number, probabilitySpace: string): {
|
|
3
|
+
model: "declared-failure-subset-bound@1";
|
|
4
|
+
status: "conditional-bound";
|
|
5
|
+
unit: "probability";
|
|
6
|
+
probabilitySpace: string;
|
|
7
|
+
declarations: {
|
|
8
|
+
id: string;
|
|
9
|
+
p: Readonly<{
|
|
10
|
+
numerator: string;
|
|
11
|
+
denominator: string;
|
|
12
|
+
}>;
|
|
13
|
+
justification: string;
|
|
14
|
+
}[];
|
|
15
|
+
allowedFailures: number;
|
|
16
|
+
totalDeclarations: number;
|
|
17
|
+
conditions: readonly ["common-probability-space", "declared-marginal-upper-bounds"];
|
|
18
|
+
referencesVerified: false;
|
|
19
|
+
terms: {
|
|
20
|
+
id: string;
|
|
21
|
+
subsets: string;
|
|
22
|
+
contribution: Readonly<{
|
|
23
|
+
numerator: string;
|
|
24
|
+
denominator: string;
|
|
25
|
+
}>;
|
|
26
|
+
}[];
|
|
27
|
+
uncappedFailureBound: Readonly<{
|
|
28
|
+
numerator: string;
|
|
29
|
+
denominator: string;
|
|
30
|
+
}>;
|
|
31
|
+
failureUpperBound: Readonly<{
|
|
32
|
+
numerator: string;
|
|
33
|
+
denominator: string;
|
|
34
|
+
}>;
|
|
35
|
+
value: Readonly<{
|
|
36
|
+
numerator: string;
|
|
37
|
+
denominator: string;
|
|
38
|
+
}>;
|
|
39
|
+
trivial: boolean;
|
|
40
|
+
};
|
|
41
|
+
export type JointIndependenceDeclaration = Readonly<{
|
|
42
|
+
probabilitySpace: string;
|
|
43
|
+
jointIndependence: true;
|
|
44
|
+
justification: string;
|
|
45
|
+
}>;
|
|
46
|
+
export declare function independentCountConfidence(failures: readonly DeclaredFailure[], k: number, declaration: JointIndependenceDeclaration): {
|
|
47
|
+
model: "declared-joint-independent-count-bound@1";
|
|
48
|
+
status: "conditional-bound";
|
|
49
|
+
unit: "probability";
|
|
50
|
+
probabilitySpace: string;
|
|
51
|
+
declarations: {
|
|
52
|
+
id: string;
|
|
53
|
+
p: Readonly<{
|
|
54
|
+
numerator: string;
|
|
55
|
+
denominator: string;
|
|
56
|
+
}>;
|
|
57
|
+
justification: string;
|
|
58
|
+
}[];
|
|
59
|
+
allowedFailures: number;
|
|
60
|
+
totalDeclarations: number;
|
|
61
|
+
jointIndependence: {
|
|
62
|
+
declared: true;
|
|
63
|
+
justification: string;
|
|
64
|
+
};
|
|
65
|
+
referencesVerified: false;
|
|
66
|
+
bernoulliEnvelope: Readonly<{
|
|
67
|
+
numerator: string;
|
|
68
|
+
denominator: string;
|
|
69
|
+
}>[];
|
|
70
|
+
failureUpperBound: Readonly<{
|
|
71
|
+
numerator: string;
|
|
72
|
+
denominator: string;
|
|
73
|
+
}>;
|
|
74
|
+
value: Readonly<{
|
|
75
|
+
numerator: string;
|
|
76
|
+
denominator: string;
|
|
77
|
+
}>;
|
|
78
|
+
trivial: boolean;
|
|
79
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { unionBoundConfidence } from "./confidence.js";
|
|
2
|
+
import { add, sub, mul, q, rational, zero, one, pack } from "./rational.js";
|
|
3
|
+
const refuse = (cause) => { throw new Error('REFUSE·L7 ' + cause); };
|
|
4
|
+
function inputs(failures, k, probabilitySpace) {
|
|
5
|
+
if (typeof probabilitySpace !== 'string' || probabilitySpace.trim() === '')
|
|
6
|
+
refuse('common-probability-space-required');
|
|
7
|
+
const base = unionBoundConfidence(failures), m = base.declarations.length;
|
|
8
|
+
if (!Number.isSafeInteger(k) || k < 0 || k > m)
|
|
9
|
+
refuse('allowed-failure-count-outside-0..m');
|
|
10
|
+
return { base, m };
|
|
11
|
+
}
|
|
12
|
+
function choose(n, k) {
|
|
13
|
+
if (k > n)
|
|
14
|
+
return 0n;
|
|
15
|
+
let c = 1n;
|
|
16
|
+
for (let j = 1; j <= Math.min(k, n - k); j++)
|
|
17
|
+
c = c * BigInt(n - j + 1) / BigInt(j);
|
|
18
|
+
return c;
|
|
19
|
+
}
|
|
20
|
+
export function tolerantSubsetConfidence(failures, k, probabilitySpace) {
|
|
21
|
+
const { base, m } = inputs(failures, k, probabilitySpace);
|
|
22
|
+
const ordered = base.declarations.map(entry => ({ entry, p: rational(entry.p) })).sort((a, b) => {
|
|
23
|
+
const d = a.p[0] * b.p[1] - b.p[0] * a.p[1];
|
|
24
|
+
return d < 0n ? -1 : d > 0n ? 1 : 0;
|
|
25
|
+
});
|
|
26
|
+
let sum = zero;
|
|
27
|
+
const terms = k === m ? [] : ordered.slice(0, m - k).map(({ entry, p }, j) => {
|
|
28
|
+
const coefficient = choose(m - j - 1, k), contribution = mul(p, q(coefficient));
|
|
29
|
+
sum = add(sum, contribution);
|
|
30
|
+
return { id: entry.id, subsets: String(coefficient), contribution: pack(contribution) };
|
|
31
|
+
});
|
|
32
|
+
const trivial = sum[0] >= sum[1], upper = trivial ? one : sum;
|
|
33
|
+
return { model: 'declared-failure-subset-bound@1', status: 'conditional-bound',
|
|
34
|
+
unit: 'probability', probabilitySpace, declarations: base.declarations,
|
|
35
|
+
allowedFailures: k, totalDeclarations: m, conditions: ['common-probability-space', 'declared-marginal-upper-bounds'],
|
|
36
|
+
referencesVerified: false, terms, uncappedFailureBound: pack(sum), failureUpperBound: pack(upper),
|
|
37
|
+
value: pack(sub(one, upper)), trivial };
|
|
38
|
+
}
|
|
39
|
+
export function independentCountConfidence(failures, k, declaration) {
|
|
40
|
+
if (!declaration || declaration.jointIndependence !== true)
|
|
41
|
+
refuse('joint-independence-required');
|
|
42
|
+
if (typeof declaration.justification !== 'string' || declaration.justification.trim() === '')
|
|
43
|
+
refuse('joint-independence-justification-required');
|
|
44
|
+
const { base, m } = inputs(failures, k, declaration.probabilitySpace);
|
|
45
|
+
let distribution = [one];
|
|
46
|
+
for (const entry of base.declarations) {
|
|
47
|
+
const p = rational(entry.p), next = Array.from({ length: distribution.length + 1 }, () => zero);
|
|
48
|
+
for (let j = 0; j < distribution.length; j++) {
|
|
49
|
+
next[j] = add(next[j], mul(distribution[j], sub(one, p)));
|
|
50
|
+
next[j + 1] = add(next[j + 1], mul(distribution[j], p));
|
|
51
|
+
}
|
|
52
|
+
distribution = next;
|
|
53
|
+
}
|
|
54
|
+
const upper = distribution.slice(k + 1).reduce(add, zero);
|
|
55
|
+
return { model: 'declared-joint-independent-count-bound@1', status: 'conditional-bound',
|
|
56
|
+
unit: 'probability', probabilitySpace: declaration.probabilitySpace, declarations: base.declarations,
|
|
57
|
+
allowedFailures: k, totalDeclarations: m, jointIndependence: { declared: true, justification: declaration.justification },
|
|
58
|
+
referencesVerified: false, bernoulliEnvelope: distribution.map(pack), failureUpperBound: pack(upper),
|
|
59
|
+
value: pack(sub(one, upper)), trivial: upper[0] === upper[1] };
|
|
60
|
+
}
|
package/docs/measures.md
CHANGED
|
@@ -194,4 +194,28 @@ Helly is a property of a declared geometric family, not a probabilistic independ
|
|
|
194
194
|
|
|
195
195
|
## 17. Publication and stability
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
The historical nine publication groups are linked to their contracts, yes/no data and declared Bound 0.1.7 captures in two places. The 0.4.2 operations below require new captures under their selected reader; historical implementation-bound receipts do not cover changed bytes. Validation readers are maintained TypeScript worlds with ordinary modular compilation; no .mjs bundle or private executor ships in this library. Their implementation inventory is retained once by digest. The installed archive must expose the same public exports, preserve the four states, match all published bytes and close native receipts without a private store. Declaring these requirements does not pay them.
|
|
198
|
+
|
|
199
|
+
## 18. Declared failure bounds
|
|
200
|
+
|
|
201
|
+
`unionBoundConfidence(failures)` requires distinct nonempty IDs, explicit rational probabilities in [0,1], and nonempty justification references. The caller must establish every failure bound in one probability space. References are retained, not verified. The returned lower bound for all events succeeding is max(0,1−Σp_i), with exact rational arithmetic. The empty family gives 1; Σp_i≥1 gives the trivial bound 0. No independence, truth probability, or algebraic state is inferred.
|
|
202
|
+
|
|
203
|
+
`tolerantCountConfidence(failures,k)` requires a safe integer 0≤k≤m. For k<m it bounds failure by min(1,min_{0≤j≤k}(Σ of the m−j smallest p_i)/(k+1−j)); its exact success lower bound is the complement. For k=m success is certain. For m=3,k=1 and all p_i=1/10 the result is 17/20, not an inferred success rate. The distinct subset-intersection guarantee gives the weaker bound 7/10. Three disjoint paired failures among six events, each pair having probability 1/10, refute the former 4/5 claim: success is 7/10.
|
|
204
|
+
|
|
205
|
+
These operations compute conditional probability bounds. They select neither a geometric tolerance nor a consumer policy. Count-tolerant intersection T_k and widened-interval intersection T_eps remain named forms; tolerant-choice remains open.
|
|
206
|
+
|
|
207
|
+
## 19. Declared covering cause
|
|
208
|
+
|
|
209
|
+
`commonCauseCapacityBound(n,c,q,{logarithm:'binary64-log2'})` requires integer n≥2 and explicit rational c,q in [0,1]. Truth is uniform; the covering-cause indicator is independent of truth; when active, every report copies one symmetric channel with accuracy q. The inactive private channel is unrestricted. Revealing the indicator gives the upper bound log2(n)−c[h(q)+(1−q)log2(n−1)] in approximate bits. Copy count is no input. This is neither finite-sample mutual information nor an achievability claim.
|
|
210
|
+
|
|
211
|
+
At n=4,c=1,q=1/4 the bound is exactly zero; q=0 gives log2(4/3), and q=1 gives two bits. Missing q refuses. The operational declaration or detection of activation remains open in identification.model. Unconditioned coincidence does not identify q.
|
|
212
|
+
|
|
213
|
+
M/3 and M/4 retain their existing definitions. Partial-factor governance proposals do not supply a conditional joint observation and selection law. The information carried by dissent, including a bottom symbol, is open for those unspecified proposals.
|
|
214
|
+
|
|
215
|
+
## Obligations 0.4.3 — proposed conditional measures
|
|
216
|
+
|
|
217
|
+
L7: conditional bound on one declared common probability space: P(N>k)<=min(1,sum over |S|=k+1 of min p_i), with rational declared marginal failure upper bounds and 0<=k<=m. Trivial iff computed upper bound is one. Counterexamples refute the former top-k+1 success guarantee. Joint-independent Bernoulli convolution is a separate declared hypothesis; rho=0 and pairwise independence do not supply it. Existing stronger 0.4.2 count bound is unchanged and needs no joint independence.
|
|
218
|
+
|
|
219
|
+
L8: law by enumeration only for 3<=n<=64, positive integer divisors p|n and integer 0<=s<p. D=log2(n/p)-h(s/p), explicit binary64-log2 approximation. Odd-period minimum uses h(floor(p/2)/p), even-period minimum uses one. Complete maximum at zero; nonzero domain has endpoints 1,p-1, empty when p=1. No information or worst-case interpretation follows from nonnegativity. T87 retains its separate wrapped-phase amplitude identity.
|
|
220
|
+
|
|
221
|
+
L9: law by counterexample of existence of noninjective weighted mix, and measure with a declared prior on a finite explicitly supplied set of named-factor configurations. Equal-weight ab and ba give the same bottom tie and different named forks. Loss is H(configuration | mix)=H(configuration)-H(mix); a uniform prior must be explicitly selected, absent prior is unmeasured. The four-state uniform example has mean loss 0.5 bits and one bit conditioned on tie; the injective named fork has zero loss. Defines no new algebraic act, governance selection, M/3 or M/4 law, or destroyed field.
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@lapxo/obligations","version":"0.4.
|
|
1
|
+
{"name":"@lapxo/obligations","version":"0.4.3","description":"The algebra of a cell: two poles, origins with phase, eight acts.","type":"module","license":"MIT","author":"Lapxo","repository":{"type":"git","url":"git+https://github.com/Lapxo/obligations.git"},"keywords":["obligations","lattice","provenance"],"sideEffects":false,"engines":{"node":">=22.12"},"exports":{".":{"types":"./dist/lattice/index.d.ts","default":"./dist/lattice/index.js"},"./debit":{"types":"./dist/debit/debit.d.ts","default":"./dist/debit/debit.js"},"./encounter":{"types":"./dist/field/encounter.d.ts","default":"./dist/field/encounter.js"},"./field":{"types":"./dist/field/field.d.ts","default":"./dist/field/field.js"},"./forms":{"types":"./dist/lattice/forms.d.ts","default":"./dist/lattice/forms.js"},"./lattice":{"types":"./dist/lattice/lattice.d.ts","default":"./dist/lattice/lattice.js"},"./measures":{"types":"./dist/measures/index.d.ts","default":"./dist/measures/index.js"},"./packed":{"types":"./dist/debit/packed.d.ts","default":"./dist/debit/packed.js"},"./present":{"types":"./dist/field/present.d.ts","default":"./dist/field/present.js"},"./price":{"types":"./dist/lattice/price/index.d.ts","default":"./dist/lattice/price/index.js"},"./replay":{"types":"./dist/replay.d.ts","default":"./dist/replay.js"},"./shuffle":{"types":"./dist/debit/shuffle.d.ts","default":"./dist/debit/shuffle.js"},"./signatures":{"types":"./dist/field/signatures.d.ts","default":"./dist/field/signatures.js"},"./views/field":{"types":"./dist/views/field.d.ts","default":"./dist/views/field.js"},"./views/product":{"types":"./dist/views/product.d.ts","default":"./dist/views/product.js"},"./package.json":"./package.json"},"files":["dist","README.md","LICENSE","TARGET.bound","receipts.bound","docs/measures.md","samples/measures","vectors/measures","samples/yes/algebra-is-closed.json","samples/yes/field-uses-price-and-debit.json","samples/yes/three-theories-one-algebra.json","src/lattice/index.ts","src/field/motion.ts","samples/yes/installed-artifact.json","samples/no/installed-artifact.json","vectors/measures/installed-artifact.cli.json","docs/img","docs/paper.md","docs/reference.md","docs/learn/in-phase.md","docs/learn/price.md","docs/learn/signature.md","docs/learn/thermometer.md","docs/learn/withdrawal.md","vectors/laws/policy.json","vectors/laws/l7-tolerant-k.json","vectors/laws/l8-phase-defect.json","vectors/laws/l9-mix-loss.json","vectors/laws/implementation-043.json"],"scripts":{"build":"tsc --build","test":"node --import ./test/setup.ts --test --test-concurrency=2 test/*.test.ts test/measures/*.test.ts"},"devDependencies":{"@types/node":"^22","typescript":"^5.9.3"}}
|