@hotdocx/endash-kernel 0.1.0-preview.0 → 0.1.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/LICENSE +9 -1
- package/README.md +24 -2
- package/bin/endash-cli.cjs +4 -0
- package/bin/endash-mcp.cjs +7 -0
- package/browser.d.ts +44 -0
- package/endash-browser.js +698 -0
- package/index.cjs +704 -14
- package/index.d.ts +19 -11
- package/index.mjs +704 -14
- package/node.cjs +116606 -0
- package/node.d.ts +8 -0
- package/node.mjs +53 -0
- package/package.json +51 -7
- package/types/ast.d.ts +964 -0
- package/types/book/book_compiler.d.ts +57 -0
- package/types/book/html_renderer.d.ts +27 -0
- package/types/book/literate_en.d.ts +40 -0
- package/types/book/schema.d.ts +279 -0
- package/types/browser.d.ts +44 -0
- package/types/builders.d.ts +191 -0
- package/types/cache/core_snapshot.d.ts +259 -0
- package/types/cas/bar_hochschild.d.ts +106 -0
- package/types/cas/cotangent_deformation.d.ts +100 -0
- package/types/cas/cyclic_homology.d.ts +100 -0
- package/types/cas/derham_hkr.d.ts +117 -0
- package/types/cas/ext_algebra.d.ts +112 -0
- package/types/cas/groebner_syzygy.d.ts +43 -0
- package/types/cas/hilbert_proj_ag.d.ts +97 -0
- package/types/cas/hnf_snf.d.ts +49 -0
- package/types/cas/lefschetz_weil.d.ts +114 -0
- package/types/cas/localization_cech.d.ts +201 -0
- package/types/cas/matrix.d.ts +45 -0
- package/types/cas/modules_complexes.d.ts +141 -0
- package/types/cas/perm_coset_cgt.d.ts +166 -0
- package/types/cas/poly.d.ts +66 -0
- package/types/cas/reify_proofs.d.ts +104 -0
- package/types/cas/resolutions_spectral_seq.d.ts +193 -0
- package/types/cas/rings.d.ts +70 -0
- package/types/cas/smith_resultant_gauss.d.ts +164 -0
- package/types/cas/theta_stepanov.d.ts +182 -0
- package/types/check.d.ts +65 -0
- package/types/cli/endash_cli.d.ts +19 -0
- package/types/context.d.ts +110 -0
- package/types/duality.d.ts +76 -0
- package/types/elab/elab_ast.d.ts +274 -0
- package/types/elab/elaborate.d.ts +106 -0
- package/types/elab/env.d.ts +170 -0
- package/types/elab/match.d.ts +123 -0
- package/types/elab/pretty.d.ts +14 -0
- package/types/elab/structure.d.ts +46 -0
- package/types/elab/tactics.d.ts +238 -0
- package/types/elab/typeclass.d.ts +31 -0
- package/types/elab/unify.d.ts +166 -0
- package/types/eval.d.ts +28 -0
- package/types/index.d.ts +98 -0
- package/types/kernel_ops.d.ts +196 -0
- package/types/mcp/endash_mcp_server.d.ts +63 -0
- package/types/module/comparator.d.ts +86 -0
- package/types/module/desugar.d.ts +94 -0
- package/types/module/goal_inspector.d.ts +104 -0
- package/types/module/loader.d.ts +105 -0
- package/types/module/node_fs_provider.d.ts +26 -0
- package/types/module/package_builder.d.ts +83 -0
- package/types/module/proof_graph.d.ts +80 -0
- package/types/module/quasiquote.d.ts +37 -0
- package/types/module/stdlib_fresh_builders.d.ts +10 -0
- package/types/module/stdlib_tactic_hooks.d.ts +20 -0
- package/types/parser/lexer.d.ts +12 -0
- package/types/parser/parser.d.ts +78 -0
- package/types/parser/pratt.d.ts +17 -0
- package/types/parser/span.d.ts +26 -0
- package/types/parser/surface_ast.d.ts +501 -0
- package/types/stdlib_types.d.ts +113 -0
- package/types/value.d.ts +942 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase H5 Proof–CAS Bridge & Custom `.en` Tactics (`endash/src/cas/reify_proofs.ts`):
|
|
3
|
+
*
|
|
4
|
+
* Connects the untrusted zero-dependency `BigInt` Typed CAS (`endash/src/cas/*`)
|
|
5
|
+
* to the trusted `endash` kernel (`checkTerm` / `declareTheorem`) across an
|
|
6
|
+
* air-tight LCF certificate boundary:
|
|
7
|
+
* 1. CAS computes unimodular SNF matrices `(U, UInv, D, V, VInv)` and LES/Snake
|
|
8
|
+
* lifts heuristically in fast V8 `BigInt` arithmetic;
|
|
9
|
+
* 2. `reify_proofs.ts` reifies those matrices into explicit `endash` `Term`s
|
|
10
|
+
* paired with `refl` equations (`U*UInv = I`, `V*VInv = I`, `U*M*V = D`);
|
|
11
|
+
* 3. `checkTerm` verifies every equation by NbE conversion with **0 axioms** —
|
|
12
|
+
* and deterministically rejects any forged certificate (`NC-10b`)!
|
|
13
|
+
*/
|
|
14
|
+
import { Term } from '../ast';
|
|
15
|
+
import { GlobalEnv } from '../context';
|
|
16
|
+
import { ElabEnv } from '../elab/env';
|
|
17
|
+
import { ProofState } from '../elab/tactics';
|
|
18
|
+
import { Value } from '../value';
|
|
19
|
+
import { SnfCertificate } from './hnf_snf';
|
|
20
|
+
import { DenseMatrix } from './matrix';
|
|
21
|
+
import { UniPoly } from './poly';
|
|
22
|
+
import { BigRat, EuclideanDomain } from './rings';
|
|
23
|
+
export interface ReifyRingSpec<T> {
|
|
24
|
+
readonly ns: string;
|
|
25
|
+
readonly domain: EuclideanDomain<T>;
|
|
26
|
+
readonly carrierG: Term;
|
|
27
|
+
readonly zeroTerm: Term;
|
|
28
|
+
readonly oneTerm: Term;
|
|
29
|
+
readonly addFn: Term;
|
|
30
|
+
readonly mulFn: Term;
|
|
31
|
+
reifyElem(x: T): Term;
|
|
32
|
+
extractElem?(v: Value): T | null;
|
|
33
|
+
}
|
|
34
|
+
export declare function extractNatVal(rawV: Value, session?: ProofState['session']): number | null;
|
|
35
|
+
export declare function extractIntVal(rawV: Value, session?: ProofState['session']): bigint | null;
|
|
36
|
+
export declare function extractListVals(rawV: Value, session?: ProofState['session']): Value[] | null;
|
|
37
|
+
export declare function extractBoolVal(rawV: Value): boolean | null;
|
|
38
|
+
export declare const IntReifySpec: ReifyRingSpec<bigint>;
|
|
39
|
+
export declare const F2FieldDomain: import("./rings").ExactField<bigint>;
|
|
40
|
+
export declare const F2FieldReifySpec: ReifyRingSpec<bigint>;
|
|
41
|
+
export declare const F2PolyDomain: import("./poly").UnivariatePolyRing<bigint>;
|
|
42
|
+
export declare const F2PolyReifySpec: ReifyRingSpec<UniPoly<bigint>>;
|
|
43
|
+
export declare const QPolyDomain: import("./poly").UnivariatePolyRing<BigRat>;
|
|
44
|
+
export declare function reifyRatTerm(r: BigRat): Term;
|
|
45
|
+
/**
|
|
46
|
+
* Sigma-free canonical rational carrier `RatBox := List Int` (`[num, inl(den - 1)]`):
|
|
47
|
+
* Avoiding Sigma (`Int × Nat`) prevents judgmental Sigma η-duplication (`fst`/`snd`)
|
|
48
|
+
* during symbolic `convGrpd` on matrix certificates, keeping `RatRing.SnfCert` O(k) (`< 250 ms`)!
|
|
49
|
+
*/
|
|
50
|
+
export declare const ratBoxCarrierG: Term;
|
|
51
|
+
export declare function reifyRatBoxTerm(r: BigRat): Term;
|
|
52
|
+
export declare const RatFieldReifySpec: ReifyRingSpec<BigRat>;
|
|
53
|
+
export declare const QPolyReifySpec: ReifyRingSpec<UniPoly<BigRat>>;
|
|
54
|
+
export declare function reifyMatrix<T>(spec: ReifyRingSpec<T>, M: DenseMatrix<T>): Term;
|
|
55
|
+
export declare function extractMatrixFromVal<T>(spec: ReifyRingSpec<T>, rows: number, cols: number, v: Value): DenseMatrix<T> | null;
|
|
56
|
+
export declare function getCasKernelGlobalEnvFor<T>(spec: ReifyRingSpec<T>): GlobalEnv;
|
|
57
|
+
export declare function getCasKernelGlobalEnv(): GlobalEnv;
|
|
58
|
+
export interface VerifiedSnfProofBundle<T> {
|
|
59
|
+
readonly snf: SnfCertificate<T>;
|
|
60
|
+
readonly certTypeTerm: Term;
|
|
61
|
+
readonly certProofTerm: Term;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Build the explicit 4-matrix + 5-`refl` SNF witness `Term` for `(M, D, U, UInv, V, VInv)`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function buildSnfCertWitnessTerm<T>(spec: ReifyRingSpec<T>, m: number, n: number, mTerm: Term, dTerm: Term, uTerm: Term, uInvTerm: Term, vTerm: Term, vInvTerm: Term): {
|
|
67
|
+
readonly certTypeTerm: Term;
|
|
68
|
+
readonly certProofTerm: Term;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Compute SNF via untrusted CAS (or accept `forgedOverrides` for `NC-10b` testing!),
|
|
72
|
+
* reify all matrices into `endash` `Term`s, and **verify from scratch in the trusted
|
|
73
|
+
* `endash` kernel (`declareTheorem` -> `checkGrpd` + `checkTerm` + `axiomsUsed === 0`)**!
|
|
74
|
+
*/
|
|
75
|
+
export declare function certifySnfInKernel<T>(spec: ReifyRingSpec<T>, M: DenseMatrix<T>, forgedOverrides?: {
|
|
76
|
+
readonly U?: DenseMatrix<T>;
|
|
77
|
+
readonly UInv?: DenseMatrix<T>;
|
|
78
|
+
readonly D?: DenseMatrix<T>;
|
|
79
|
+
readonly V?: DenseMatrix<T>;
|
|
80
|
+
readonly VInv?: DenseMatrix<T>;
|
|
81
|
+
}): VerifiedSnfProofBundle<T>;
|
|
82
|
+
/**
|
|
83
|
+
* Verify in the trusted `endash` kernel that `dPrev * dCurr = 0` (`NC-10b` rejects `d o d' != 0`!).
|
|
84
|
+
*/
|
|
85
|
+
export declare function certifyChainZeroInKernel<T>(spec: ReifyRingSpec<T>, dPrev: DenseMatrix<T>, dCurr: DenseMatrix<T>): {
|
|
86
|
+
readonly tyTerm: Term;
|
|
87
|
+
readonly proofTerm: Term;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Verify a cycle-lift witness `[A | R_dst] * stackedLift = target` inside the trusted `endash` kernel!
|
|
91
|
+
* (`NC-10b` deterministically rejects any forged lift `stackedLift`!)
|
|
92
|
+
*/
|
|
93
|
+
export declare function certifyLinearLiftInKernel<T>(spec: ReifyRingSpec<T>, augMatrix: DenseMatrix<T>, target: DenseMatrix<T>, forgedWitness?: DenseMatrix<T>): {
|
|
94
|
+
readonly tyTerm: Term;
|
|
95
|
+
readonly proofTerm: Term;
|
|
96
|
+
};
|
|
97
|
+
export declare function trySolveSnfGoalWithSpec<T>(state: ProofState, spec: ReifyRingSpec<T>): boolean;
|
|
98
|
+
export declare function installCasBridgeAndTactics(env: ElabEnv): ElabEnv;
|
|
99
|
+
/**
|
|
100
|
+
* Attach custom JS tactic handlers (`cas_matrix_eq`, `cas_snf`, `cas_homology`)
|
|
101
|
+
* to an `ElabEnv` (used both during fresh elaboration and when hydrating
|
|
102
|
+
* `Algebra.CAS` / `Algebra.Geometry` from a verified Core snapshot!).
|
|
103
|
+
*/
|
|
104
|
+
export declare function installCasTacticsOnly(env: ElabEnv): ElabEnv;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase S3 Typed CAS Engine & LCF Proof–CAS Bridge (`endash/src/cas/resolutions_spectral_seq.ts`):
|
|
3
|
+
* 1. Canonical 2-Term Free Resolutions over any `EuclideanDomain<T>` (`Z`, `F_2[x]`, `Q[x]`)
|
|
4
|
+
* and Multivariate Schreyer Syzygy / Koszul Resolutions over `k[x, y]` (`groebner_syzygy.ts`);
|
|
5
|
+
* 2. Exact Bifunctor Kronecker Total-Hom & Total-Tensor Complexes computing `Ext^n_R(M, N)`
|
|
6
|
+
* and `Tor_n^R(M, N)` for arbitrary finitely presented modules `M, N` (plus Koszul `Ext^k_{k[x,y]}(k, k)`);
|
|
7
|
+
* 3. Exact Bounded Filtered Cochain Spectral Sequence Solver (`E_0 => E_1 => E_2 => ... => E_∞`
|
|
8
|
+
* via `Z_r^{p,q} / (Z_{r-1}^{p+1,q-1} + B_r^{p,q})` over `Z`, `F_2`, `Q`), UCSS solver, and
|
|
9
|
+
* Cellular Atiyah–Hirzebruch Spectral Sequence (AHSS) models on `S^1`, `T^2`, `RP^2`, `CP^2`;
|
|
10
|
+
* 4. Air-tight LCF Kernel `CohomologyCert` (`dOut * dIn = 0`, `dOut * Z = 0`, `Z * RH = dIn`,
|
|
11
|
+
* `SnfCert(dOut)`, `SnfCert(RH)`) & `.en` tactics **`cas_ext`** and **`cas_spectral_seq`**,
|
|
12
|
+
* deterministically rejecting forged `d_r ∘ d_r != 0` or wrong invariant factors (`NC-13b` Part 2)!
|
|
13
|
+
*
|
|
14
|
+
* **`0 LOC` TCB delta**; **`0` axioms** (`axiomsUsed.size === 0`).
|
|
15
|
+
*/
|
|
16
|
+
import { Term } from '../ast';
|
|
17
|
+
import { GlobalEnv } from '../context';
|
|
18
|
+
import { ElabEnv } from '../elab/env';
|
|
19
|
+
import { SnfCertificate } from './hnf_snf';
|
|
20
|
+
import { DenseMatrix } from './matrix';
|
|
21
|
+
import { ModuleClassification, PresentedModule } from './modules_complexes';
|
|
22
|
+
import { MultiPoly, MultivariatePolyRing } from './poly';
|
|
23
|
+
import { ReifyRingSpec } from './reify_proofs';
|
|
24
|
+
import { EuclideanDomain, ExactField } from './rings';
|
|
25
|
+
export interface FreeResolution2<T> {
|
|
26
|
+
readonly domain: EuclideanDomain<T>;
|
|
27
|
+
readonly genRank0: number;
|
|
28
|
+
readonly relRank1: number;
|
|
29
|
+
/** Injective `genRank0 x relRank1` presentation matrix `d_1` (`M ≅ coker(d_1)`). */
|
|
30
|
+
readonly d1: DenseMatrix<T>;
|
|
31
|
+
/** Witness `colLift` (`origRels.cols x relRank1`) with `d_1 = R_M * colLift`. */
|
|
32
|
+
readonly colLift: DenseMatrix<T>;
|
|
33
|
+
/** Witness `colBack` (`relRank1 x origRels.cols`) with `R_M = d_1 * colBack`. */
|
|
34
|
+
readonly colBack: DenseMatrix<T>;
|
|
35
|
+
readonly snf: SnfCertificate<T>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Construct a canonical short free resolution `0 -> R^{relRank1} --d1--> R^{genRank0} -> M -> 0`
|
|
39
|
+
* over any `EuclideanDomain<T>` (`Z`, `F_p[x]`, `Q[x]`).
|
|
40
|
+
*/
|
|
41
|
+
export declare function computeFreeResolution2<T>(M: PresentedModule<T>): FreeResolution2<T>;
|
|
42
|
+
/** Kronecker tensor product `A ⊗ B` (`(A.rows * B.rows) x (A.cols * B.cols)`). */
|
|
43
|
+
export declare function kroneckerProduct<T>(dom: EuclideanDomain<T>, A: DenseMatrix<T>, B: DenseMatrix<T>): DenseMatrix<T>;
|
|
44
|
+
export interface CohomologyStepResult<T> {
|
|
45
|
+
readonly domain: EuclideanDomain<T>;
|
|
46
|
+
readonly dIn: DenseMatrix<T>;
|
|
47
|
+
readonly dOut: DenseMatrix<T>;
|
|
48
|
+
/** Kernel basis `Z` (`dOut.cols x zRank`) satisfying `dOut * Z = 0`. */
|
|
49
|
+
readonly cycleBasis: DenseMatrix<T>;
|
|
50
|
+
/** Relation matrix `RH` (`zRank x dIn.cols`) satisfying `Z * RH = dIn`. */
|
|
51
|
+
readonly quotientRelations: DenseMatrix<T>;
|
|
52
|
+
readonly presentedCohomology: PresentedModule<T>;
|
|
53
|
+
readonly classification: ModuleClassification<T>;
|
|
54
|
+
readonly snfOut: SnfCertificate<T>;
|
|
55
|
+
readonly snfH: SnfCertificate<T>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Compute exact cohomology `H = ker(dOut) / im(dIn)` (`coker(RH)`) with full SNF witnesses.
|
|
59
|
+
*/
|
|
60
|
+
export declare function computeCohomologyStep<T>(domain: EuclideanDomain<T>, dIn: DenseMatrix<T>, dOut: DenseMatrix<T>): CohomologyStepResult<T>;
|
|
61
|
+
/**
|
|
62
|
+
* Compute `Ext^n_R(M, N)` (`n in Z`) for arbitrary finitely presented modules `M, N`
|
|
63
|
+
* over any PID / `EuclideanDomain<T>` via the total Hom cochain complex
|
|
64
|
+
* `Tot Hom_R([R^{r_M} -> R^{g_M}], [R^{r_N} -> R^{g_N}])`!
|
|
65
|
+
*/
|
|
66
|
+
export declare function computeExtModule<T>(M: PresentedModule<T>, N: PresentedModule<T>, degree: number): CohomologyStepResult<T>;
|
|
67
|
+
/**
|
|
68
|
+
* Compute `Tor_n^R(M, N)` (`n >= 0`) for arbitrary finitely presented modules `M, N`
|
|
69
|
+
* over any PID / `EuclideanDomain<T>` via `Tot(P_*(M) ⊗_R P_*(N))`!
|
|
70
|
+
*/
|
|
71
|
+
export declare function computeTorModule<T>(M: PresentedModule<T>, N: PresentedModule<T>, degree: number): CohomologyStepResult<T>;
|
|
72
|
+
export interface MultivariateKoszulExt2Result<C> {
|
|
73
|
+
readonly ring: MultivariatePolyRing<C>;
|
|
74
|
+
/** `1 x 2` generator matrix `[x, y]`. */
|
|
75
|
+
readonly d1: DenseMatrix<MultiPoly<C>>;
|
|
76
|
+
/** `2 x k` Schreyer syzygy matrix (`[-y; x]` up to scalar) satisfying `d1 * d2 = 0`. */
|
|
77
|
+
readonly d2: DenseMatrix<MultiPoly<C>>;
|
|
78
|
+
/** Cochain differentials after applying `Hom_{k[x,y]}(-, k)` (evaluating at `(0, 0)`). */
|
|
79
|
+
readonly d1StarAtOrigin: DenseMatrix<C>;
|
|
80
|
+
readonly d2StarAtOrigin: DenseMatrix<C>;
|
|
81
|
+
readonly ext0: CohomologyStepResult<C>;
|
|
82
|
+
readonly ext1: CohomologyStepResult<C>;
|
|
83
|
+
readonly ext2: CohomologyStepResult<C>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Construct the 2-variable Koszul resolution of `k = k[x, y] / (x, y)` via `syzygyModule`
|
|
87
|
+
* (`src/cas/groebner_syzygy.ts`), verify `d1 * d2 = 0` in `k[x, y]`, and compute
|
|
88
|
+
* `Ext^0_{k[x,y]}(k, k) ≅ k`, `Ext^1_{k[x,y]}(k, k) ≅ k^2`, `Ext^2_{k[x,y]}(k, k) ≅ k`!
|
|
89
|
+
*/
|
|
90
|
+
export declare function computeKoszulPoly2Ext<C>(field: ExactField<C>): MultivariateKoszulExt2Result<C>;
|
|
91
|
+
export interface FilteredBasisGenerator {
|
|
92
|
+
readonly label: string;
|
|
93
|
+
readonly totalDegree: number;
|
|
94
|
+
readonly filtrationP: number;
|
|
95
|
+
}
|
|
96
|
+
export interface FilteredCochainComplex<T> {
|
|
97
|
+
readonly domain: EuclideanDomain<T>;
|
|
98
|
+
readonly generators: readonly FilteredBasisGenerator[];
|
|
99
|
+
/**
|
|
100
|
+
* Differential matrices `diffs.get(n)` : `dim(C^{n+1}) x dim(C^n)` on the generators
|
|
101
|
+
* sorted in degree `n` and `n + 1`, preserving filtration `d(F^p C^n) ⊆ F^p C^{n+1}`!
|
|
102
|
+
*/
|
|
103
|
+
readonly minDegree: number;
|
|
104
|
+
readonly maxDegree: number;
|
|
105
|
+
readonly diffs: ReadonlyMap<number, DenseMatrix<T>>;
|
|
106
|
+
}
|
|
107
|
+
export interface SpectralPageBidegreeEntry<T> {
|
|
108
|
+
readonly r: number;
|
|
109
|
+
readonly p: number;
|
|
110
|
+
readonly q: number;
|
|
111
|
+
readonly step: CohomologyStepResult<T>;
|
|
112
|
+
}
|
|
113
|
+
export interface SpectralSequenceSummary<T> {
|
|
114
|
+
readonly pages: ReadonlyMap<string, SpectralPageBidegreeEntry<T>>;
|
|
115
|
+
getEntry(r: number, p: number, q: number): SpectralPageBidegreeEntry<T>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Compute exact spectral sequence pages `E_r^{p,q} := Z_r^{p,q} / (Z_{r-1}^{p+1,q-1} + B_r^{p,q})`
|
|
119
|
+
* for any bounded filtered cochain complex over a `EuclideanDomain<T>` (`Z`, `F_2`, `Q`),
|
|
120
|
+
* verifying `d^{n+1} ∘ d^n = 0` and filtration compatibility `d(F^p) ⊆ F^p`!
|
|
121
|
+
*/
|
|
122
|
+
export declare function computeFilteredSpectralSequence<T>(fc: FilteredCochainComplex<T>, maxPageR: number, pRange: readonly [number, number], qRange: readonly [number, number]): SpectralSequenceSummary<T>;
|
|
123
|
+
/** Cellular skeletal filtration of `S^1` (`H^*(S^1; Z)`). */
|
|
124
|
+
export declare function buildCircleAhssComplex(): FilteredCochainComplex<bigint>;
|
|
125
|
+
/** Cellular skeletal filtration of `T^2 = S^1 × S^1` (`H^*(T^2; Z)`). */
|
|
126
|
+
export declare function buildTorusAhssComplex(): FilteredCochainComplex<bigint>;
|
|
127
|
+
/** Cellular skeletal filtration of `RP^2` (`d^1 = [2] : Z -> Z`, `H^2(RP^2; Z) = Z/2Z`!). */
|
|
128
|
+
export declare function buildRP2AhssComplex(): FilteredCochainComplex<bigint>;
|
|
129
|
+
/**
|
|
130
|
+
* 2-Periodic Complex `K`-Theory AHSS on `RP^2` (`KU^*(RP^2)` in degrees `-1, 0, 1`):
|
|
131
|
+
* `π_0(KU) = Z`, `π_1(KU) = 0`, `π_2(KU) = Z` (`q = 0, -1, -2`):
|
|
132
|
+
* - Total degree `0`: `(p=0, q=0)` (`e0`) and `(p=2, q=-2)` (`β * e2`)
|
|
133
|
+
* - Total degree `-1`: `(p=1, q=-2)` (`β * e1`), with `d_1 : (1, -2) -> (2, -2)` equal to `·2`!
|
|
134
|
+
* => `E_2^{0,0} = Z`, `E_2^{2,-2} = Z/2Z`, `KU^0(RP^2) = Z ⊕ Z/2Z`, `KU^{-1}(RP^2) = 0`!
|
|
135
|
+
*/
|
|
136
|
+
export declare function buildRP2ComplexKTheoryAhss(): FilteredCochainComplex<bigint>;
|
|
137
|
+
/** Even-dimensional CW filtration of `CP^2` (`p = 0, 2, 4` => `d_1 = d_2 = d_3 = 0`, `E_1 = E_∞`!). */
|
|
138
|
+
export declare function buildCP2AhssComplex(): FilteredCochainComplex<bigint>;
|
|
139
|
+
/**
|
|
140
|
+
* Universal Coefficient Spectral Sequence (UCSS) verification helper on `RP^2`:
|
|
141
|
+
* Computes homology `H_k(C_*)`, computes `Hom_Z(H_n, G)` and `Ext^1_Z(H_{n-1}, G)` via
|
|
142
|
+
* `computeExtModule`, and compares with `H^n(Hom_Z(C_*, G))`!
|
|
143
|
+
*/
|
|
144
|
+
export interface UcssDegreeCheck<T> {
|
|
145
|
+
readonly degree: number;
|
|
146
|
+
readonly homHnG: CohomologyStepResult<T>;
|
|
147
|
+
readonly ext1HnMinus1G: CohomologyStepResult<T>;
|
|
148
|
+
readonly directCohomology: CohomologyStepResult<T>;
|
|
149
|
+
}
|
|
150
|
+
export declare function computeRP2IntegralUCSS(degree: number): UcssDegreeCheck<bigint>;
|
|
151
|
+
/**
|
|
152
|
+
* Install `${ns}.matZero` and `${ns}.CohomologyCert` in an `ElabEnv` (or raw `GlobalEnv`).
|
|
153
|
+
*/
|
|
154
|
+
export declare function installCohomologyCertDefsWithCallback<T>(ns: string, spec: ReifyRingSpec<T>, defFn: (shortName: string, ty: Term, body: Term) => void): void;
|
|
155
|
+
export declare function getCohomologyKernelGlobalEnvFor<T>(spec: ReifyRingSpec<T>): GlobalEnv;
|
|
156
|
+
export interface VerifiedCohomologyCertBundle<T> {
|
|
157
|
+
readonly step: CohomologyStepResult<T>;
|
|
158
|
+
readonly certTypeTerm: Term;
|
|
159
|
+
readonly certProofTerm: Term;
|
|
160
|
+
}
|
|
161
|
+
export declare function buildCohomologyCertWitnessTerm<T>(spec: ReifyRingSpec<T>, pRows: number, mMid: number, kCols: number, zCols: number, dOutTerm: Term, dInTerm: Term, dOutDiagTerm: Term, dHDiagTerm: Term, zTerm: Term, rhTerm: Term, snfOutWitness: {
|
|
162
|
+
readonly U: DenseMatrix<T>;
|
|
163
|
+
readonly UInv: DenseMatrix<T>;
|
|
164
|
+
readonly V: DenseMatrix<T>;
|
|
165
|
+
readonly VInv: DenseMatrix<T>;
|
|
166
|
+
}, snfHWitness: {
|
|
167
|
+
readonly U: DenseMatrix<T>;
|
|
168
|
+
readonly UInv: DenseMatrix<T>;
|
|
169
|
+
readonly V: DenseMatrix<T>;
|
|
170
|
+
readonly VInv: DenseMatrix<T>;
|
|
171
|
+
}): {
|
|
172
|
+
readonly certTypeTerm: Term;
|
|
173
|
+
readonly certProofTerm: Term;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Certify a cohomology/spectral-page step `(dIn, dOut)` inside the trusted `endash` kernel
|
|
177
|
+
* (`declareTheorem` -> `checkTerm` + `axiomsUsed.size === 0`), supporting `forgedOverrides`
|
|
178
|
+
* so `NC-13b` Part 2 verifies deterministic kernel rejection of forged `d_r ∘ d_r != 0`,
|
|
179
|
+
* non-cycle `Z`, or wrong `D_H` invariant factors!
|
|
180
|
+
*/
|
|
181
|
+
export declare function certifyCohomologyStepInKernel<T>(spec: ReifyRingSpec<T>, dIn: DenseMatrix<T>, dOut: DenseMatrix<T>, forgedOverrides?: {
|
|
182
|
+
readonly dIn?: DenseMatrix<T>;
|
|
183
|
+
readonly dOut?: DenseMatrix<T>;
|
|
184
|
+
readonly Z?: DenseMatrix<T>;
|
|
185
|
+
readonly RH?: DenseMatrix<T>;
|
|
186
|
+
readonly dOutDiag?: DenseMatrix<T>;
|
|
187
|
+
readonly dHDiag?: DenseMatrix<T>;
|
|
188
|
+
}): VerifiedCohomologyCertBundle<T>;
|
|
189
|
+
/**
|
|
190
|
+
* Attach `.en` tactics `cas_ext` and `cas_spectral_seq` to an `ElabEnv`
|
|
191
|
+
* (called both during fresh `Cat.SpectralSeq` elaboration and snapshot hydration!).
|
|
192
|
+
*/
|
|
193
|
+
export declare function installSpectralSeqTacticsOnly(env: ElabEnv): ElabEnv;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase H3 Typed CAS (Part 1): Exact Coefficient Domains (`BigInt` Z, Q, F_p)
|
|
3
|
+
* and Euclidean / Field Algebraic Interfaces (`endash/src/cas/rings.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Strict Isolation & Soundness Discipline:
|
|
6
|
+
* - 0 external npm dependencies (uses native V8 `BigInt`).
|
|
7
|
+
* - 0 floating-point operations (`number` is never used for ring elements).
|
|
8
|
+
* - Lives 100% outside the trusted `endash` kernel TCB.
|
|
9
|
+
*/
|
|
10
|
+
export type EndashCasErrorCode = 'DIV_BY_ZERO' | 'NON_UNIT' | 'NON_PRIME_MODULUS' | 'DIMENSION_MISMATCH' | 'INDEX_OUT_OF_BOUNDS' | 'NOT_CHAIN_COMPLEX' | 'RELATION_NOT_PRESERVED' | 'NOT_EXACT_AT_DEGREE' | 'CERTIFICATE_INVALID';
|
|
11
|
+
export declare class EndashCasError extends Error {
|
|
12
|
+
readonly code: EndashCasErrorCode;
|
|
13
|
+
constructor(code: EndashCasErrorCode, message: string);
|
|
14
|
+
}
|
|
15
|
+
export interface ExactRing<T> {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly zero: T;
|
|
18
|
+
readonly one: T;
|
|
19
|
+
eq(a: T, b: T): boolean;
|
|
20
|
+
isZero(a: T): boolean;
|
|
21
|
+
isOne(a: T): boolean;
|
|
22
|
+
add(a: T, b: T): T;
|
|
23
|
+
sub(a: T, b: T): T;
|
|
24
|
+
neg(a: T): T;
|
|
25
|
+
mul(a: T, b: T): T;
|
|
26
|
+
fromBigInt(n: bigint): T;
|
|
27
|
+
isUnit(a: T): boolean;
|
|
28
|
+
invUnit(a: T): T;
|
|
29
|
+
/** Canonical unit factor `u` so that `mul(u, a)` is canonical (e.g. non-negative in Z, monic in K[x]). */
|
|
30
|
+
canonicalUnit(a: T): T;
|
|
31
|
+
format(a: T): string;
|
|
32
|
+
}
|
|
33
|
+
export interface ExtendedGcdResult<T> {
|
|
34
|
+
readonly g: T;
|
|
35
|
+
readonly s: T;
|
|
36
|
+
readonly t: T;
|
|
37
|
+
}
|
|
38
|
+
export interface EuclideanDomain<T> extends ExactRing<T> {
|
|
39
|
+
/** Euclidean size (`-1n` for `0`, `>= 0n` for nonzero elements). */
|
|
40
|
+
euclideanSize(a: T): bigint;
|
|
41
|
+
/** Exact division with remainder: `a = add(mul(q, b), r)` with `r = 0` or `size(r) < size(b)`. */
|
|
42
|
+
divRem(a: T, b: T): {
|
|
43
|
+
readonly q: T;
|
|
44
|
+
readonly r: T;
|
|
45
|
+
};
|
|
46
|
+
/** Exact division when `b` divides `a` (returns `null` if `r != 0`). */
|
|
47
|
+
exactDiv(a: T, b: T): T | null;
|
|
48
|
+
/** Canonical extended GCD `s*a + t*b = g` with `g` normalized by `canonicalUnit`. */
|
|
49
|
+
xgcd(a: T, b: T): ExtendedGcdResult<T>;
|
|
50
|
+
}
|
|
51
|
+
export interface ExactField<T> extends EuclideanDomain<T> {
|
|
52
|
+
inv(a: T): T;
|
|
53
|
+
div(a: T, b: T): T;
|
|
54
|
+
}
|
|
55
|
+
export declare function absBigInt(n: bigint): bigint;
|
|
56
|
+
export declare function gcdBigInt(a: bigint, b: bigint): bigint;
|
|
57
|
+
export declare function xgcdBigInt(a: bigint, b: bigint): ExtendedGcdResult<bigint>;
|
|
58
|
+
/** Euclidean division on `bigint` with non-negative remainder `0 <= r < |b|`. */
|
|
59
|
+
export declare function euclideanDivRemBigInt(a: bigint, b: bigint): {
|
|
60
|
+
readonly q: bigint;
|
|
61
|
+
readonly r: bigint;
|
|
62
|
+
};
|
|
63
|
+
export declare const IntRing: EuclideanDomain<bigint>;
|
|
64
|
+
export interface BigRat {
|
|
65
|
+
readonly num: bigint;
|
|
66
|
+
readonly den: bigint;
|
|
67
|
+
}
|
|
68
|
+
export declare function mkRat(num: bigint, den?: bigint): BigRat;
|
|
69
|
+
export declare const RatField: ExactField<BigRat>;
|
|
70
|
+
export declare function mkFpField(p: bigint): ExactField<bigint>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wave 15 Unified Browser-Safe LCF CAS Certifiers (`endash/src/cas/smith_resultant_gauss.ts`):
|
|
3
|
+
* - Part 1 (Phase N2): Constructive Smith Normal Form & p-adic DVR Cokernel Lengths (`by cas_smith`, `SmithAlg.SmithDvrCert`)
|
|
4
|
+
* - Part 2 (Phase N3): Sylvester Resultants, Bezout Cofactors, & Odd-Prime LTE (`by cas_resultant`, `SmithAlg.ResultantLteCert`)
|
|
5
|
+
* - Part 3 (Phase N4): Finite Fourier–Gauss Duality, 4-Character Translate Mean, & `SizeWindows` (`by cas_gauss`, `SmithAlg.GaussGrowthCert`)
|
|
6
|
+
*
|
|
7
|
+
* `0` Node built-ins, `0` `src/stdlib/*` imports, `0` `any` casts.
|
|
8
|
+
*/
|
|
9
|
+
import { Term } from '../ast';
|
|
10
|
+
import { ElabEnv } from '../elab/env';
|
|
11
|
+
import { ProofState } from '../elab/tactics';
|
|
12
|
+
export interface SmithDvrCertResult {
|
|
13
|
+
readonly n: number;
|
|
14
|
+
readonly p: number;
|
|
15
|
+
readonly matFlat: readonly bigint[];
|
|
16
|
+
readonly uFlat: readonly bigint[];
|
|
17
|
+
readonly uInvFlat: readonly bigint[];
|
|
18
|
+
readonly vFlat: readonly bigint[];
|
|
19
|
+
readonly vInvFlat: readonly bigint[];
|
|
20
|
+
readonly invFactors: readonly number[];
|
|
21
|
+
readonly divQuots: readonly number[];
|
|
22
|
+
readonly valExps: readonly number[];
|
|
23
|
+
readonly valUnits: readonly number[];
|
|
24
|
+
readonly detUnit: number;
|
|
25
|
+
readonly rank: number;
|
|
26
|
+
readonly absDet: number;
|
|
27
|
+
readonly cokerLenAtP: number;
|
|
28
|
+
readonly cokerSummary: readonly [number, number, number];
|
|
29
|
+
}
|
|
30
|
+
export interface ForgedSmithDvrOverrides {
|
|
31
|
+
readonly p?: number;
|
|
32
|
+
readonly matFlat?: readonly bigint[];
|
|
33
|
+
readonly uFlat?: readonly bigint[];
|
|
34
|
+
readonly uInvFlat?: readonly bigint[];
|
|
35
|
+
readonly vFlat?: readonly bigint[];
|
|
36
|
+
readonly vInvFlat?: readonly bigint[];
|
|
37
|
+
readonly invFactors?: readonly number[];
|
|
38
|
+
readonly divQuots?: readonly number[];
|
|
39
|
+
readonly valExps?: readonly number[];
|
|
40
|
+
readonly valUnits?: readonly number[];
|
|
41
|
+
readonly detUnit?: number;
|
|
42
|
+
readonly cokerSummary?: readonly number[];
|
|
43
|
+
}
|
|
44
|
+
export declare function computeSmithDvrCertData(n: number, p: number, matFlatInput: readonly (number | bigint)[]): SmithDvrCertResult;
|
|
45
|
+
export declare function mkSmithWitnessDataTupleType(): Term;
|
|
46
|
+
export declare function buildSmithDvrCertWitnessTerm(solved: SmithDvrCertResult, overrides?: ForgedSmithDvrOverrides): {
|
|
47
|
+
readonly certTypeTerm: Term;
|
|
48
|
+
readonly certProofTerm: Term;
|
|
49
|
+
};
|
|
50
|
+
export declare function trySolveSmithGoal(state: ProofState): boolean;
|
|
51
|
+
export interface ResultantLteCertResult {
|
|
52
|
+
readonly fCoeffs: readonly bigint[];
|
|
53
|
+
readonly gCoeffs: readonly bigint[];
|
|
54
|
+
readonly degF: number;
|
|
55
|
+
readonly degG: number;
|
|
56
|
+
readonly lteSpec: readonly [number, number, number];
|
|
57
|
+
readonly uCoeffs: readonly bigint[];
|
|
58
|
+
readonly vCoeffs: readonly bigint[];
|
|
59
|
+
readonly sUFlat: readonly bigint[];
|
|
60
|
+
readonly sUInvFlat: readonly bigint[];
|
|
61
|
+
readonly sVFlat: readonly bigint[];
|
|
62
|
+
readonly sVInvFlat: readonly bigint[];
|
|
63
|
+
readonly sDiag: readonly number[];
|
|
64
|
+
readonly lteUnits: readonly [number, number, number, number, number];
|
|
65
|
+
readonly resVal: bigint;
|
|
66
|
+
readonly valResAtP: number;
|
|
67
|
+
readonly valLteAtP: number;
|
|
68
|
+
readonly summary: readonly [bigint, bigint, bigint];
|
|
69
|
+
}
|
|
70
|
+
export interface ForgedResultantLteOverrides {
|
|
71
|
+
readonly lteSpec?: readonly number[];
|
|
72
|
+
readonly uCoeffs?: readonly bigint[];
|
|
73
|
+
readonly vCoeffs?: readonly bigint[];
|
|
74
|
+
readonly sUFlat?: readonly bigint[];
|
|
75
|
+
readonly sDiag?: readonly number[];
|
|
76
|
+
readonly lteUnits?: readonly number[];
|
|
77
|
+
readonly summary?: readonly bigint[];
|
|
78
|
+
}
|
|
79
|
+
export declare function computeResultantLteCertData(fCoeffsInput: readonly (number | bigint)[], gCoeffsInput: readonly (number | bigint)[], lteSpecInput: readonly number[]): ResultantLteCertResult;
|
|
80
|
+
export declare function mkResultantWitnessDataTupleType(): Term;
|
|
81
|
+
export declare function buildResultantLteCertWitnessTerm(solved: ResultantLteCertResult, overrides?: ForgedResultantLteOverrides): {
|
|
82
|
+
readonly certTypeTerm: Term;
|
|
83
|
+
readonly certProofTerm: Term;
|
|
84
|
+
};
|
|
85
|
+
export declare function trySolveResultantGoal(state: ProofState): boolean;
|
|
86
|
+
export interface GaussGrowthCertResult {
|
|
87
|
+
readonly p: number;
|
|
88
|
+
readonly psiCoeff: number;
|
|
89
|
+
readonly zeroSumVec: readonly bigint[];
|
|
90
|
+
readonly thickComponents: readonly [bigint, bigint, bigint, bigint];
|
|
91
|
+
readonly winSpec: readonly [number, number, number];
|
|
92
|
+
readonly invTable: readonly number[];
|
|
93
|
+
readonly kLowerSlack: number;
|
|
94
|
+
readonly kUpperSlack: number;
|
|
95
|
+
readonly scaledVec0: bigint;
|
|
96
|
+
readonly fourGSig: bigint;
|
|
97
|
+
readonly winLower: bigint;
|
|
98
|
+
readonly summary: readonly [bigint, bigint, bigint];
|
|
99
|
+
}
|
|
100
|
+
export interface ForgedGaussGrowthOverrides {
|
|
101
|
+
readonly gaussSpec?: readonly number[];
|
|
102
|
+
readonly zeroSumVec?: readonly bigint[];
|
|
103
|
+
readonly winSpec?: readonly number[];
|
|
104
|
+
readonly invTable?: readonly number[];
|
|
105
|
+
readonly kLowerSlack?: number;
|
|
106
|
+
readonly kUpperSlack?: number;
|
|
107
|
+
readonly summary?: readonly bigint[];
|
|
108
|
+
}
|
|
109
|
+
export declare function computeGaussGrowthCertData(gaussSpecInput: readonly number[], zeroSumVecInput: readonly (number | bigint)[], thickInput: readonly (number | bigint)[], winSpecInput: readonly number[]): GaussGrowthCertResult;
|
|
110
|
+
export declare function mkGaussWitnessDataTupleType(): Term;
|
|
111
|
+
export declare function buildGaussGrowthCertWitnessTerm(solved: GaussGrowthCertResult, overrides?: ForgedGaussGrowthOverrides): {
|
|
112
|
+
readonly certTypeTerm: Term;
|
|
113
|
+
readonly certProofTerm: Term;
|
|
114
|
+
};
|
|
115
|
+
export declare function trySolveGaussGoal(state: ProofState): boolean;
|
|
116
|
+
export declare function installSmithResultantGaussTacticsOnly(env: ElabEnv): ElabEnv;
|
|
117
|
+
export declare function buildSmith2x2Torsion2And6At2Spec(): {
|
|
118
|
+
readonly n: number;
|
|
119
|
+
readonly p: number;
|
|
120
|
+
readonly matFlat: readonly bigint[];
|
|
121
|
+
};
|
|
122
|
+
export declare function buildSmith2x2Diag4And6To2And12At2Spec(): {
|
|
123
|
+
readonly n: number;
|
|
124
|
+
readonly p: number;
|
|
125
|
+
readonly matFlat: readonly bigint[];
|
|
126
|
+
};
|
|
127
|
+
export declare function buildSmith3x3Torsion3And15At3Spec(): {
|
|
128
|
+
readonly n: number;
|
|
129
|
+
readonly p: number;
|
|
130
|
+
readonly matFlat: readonly bigint[];
|
|
131
|
+
};
|
|
132
|
+
export declare function buildResultantQuadLinP3Spec(): {
|
|
133
|
+
readonly fCoeffs: readonly bigint[];
|
|
134
|
+
readonly gCoeffs: readonly bigint[];
|
|
135
|
+
readonly lteSpec: readonly [number, number, number];
|
|
136
|
+
};
|
|
137
|
+
export declare function buildResultantQuadLinP5Spec(): {
|
|
138
|
+
readonly fCoeffs: readonly bigint[];
|
|
139
|
+
readonly gCoeffs: readonly bigint[];
|
|
140
|
+
readonly lteSpec: readonly [number, number, number];
|
|
141
|
+
};
|
|
142
|
+
export declare function buildResultantTwoQuadsP7Spec(): {
|
|
143
|
+
readonly fCoeffs: readonly bigint[];
|
|
144
|
+
readonly gCoeffs: readonly bigint[];
|
|
145
|
+
readonly lteSpec: readonly [number, number, number];
|
|
146
|
+
};
|
|
147
|
+
export declare function buildGaussF3Psi1Spec(): {
|
|
148
|
+
readonly gaussSpec: readonly [number, number];
|
|
149
|
+
readonly zeroSumVec: readonly bigint[];
|
|
150
|
+
readonly thick: readonly [bigint, bigint, bigint, bigint];
|
|
151
|
+
readonly winSpec: readonly [number, number, number];
|
|
152
|
+
};
|
|
153
|
+
export declare function buildGaussF5Psi2Spec(): {
|
|
154
|
+
readonly gaussSpec: readonly [number, number];
|
|
155
|
+
readonly zeroSumVec: readonly bigint[];
|
|
156
|
+
readonly thick: readonly [bigint, bigint, bigint, bigint];
|
|
157
|
+
readonly winSpec: readonly [number, number, number];
|
|
158
|
+
};
|
|
159
|
+
export declare function buildGaussF7Psi3Spec(): {
|
|
160
|
+
readonly gaussSpec: readonly [number, number];
|
|
161
|
+
readonly zeroSumVec: readonly bigint[];
|
|
162
|
+
readonly thick: readonly [bigint, bigint, bigint, bigint];
|
|
163
|
+
readonly winSpec: readonly [number, number, number];
|
|
164
|
+
};
|