Merge commit 'd803bfe2b1fe7f5e219e50ac20d6801a0a58ac75' as 'vendor/ruvector'
This commit is contained in:
446
vendor/ruvector/examples/prime-radiant/wasm/pkg/example.ts
vendored
Normal file
446
vendor/ruvector/examples/prime-radiant/wasm/pkg/example.ts
vendored
Normal file
@@ -0,0 +1,446 @@
|
||||
/**
|
||||
* Prime-Radiant Advanced WASM - JavaScript/TypeScript API Example
|
||||
*
|
||||
* This example demonstrates usage of all 6 mathematical engines:
|
||||
* - CohomologyEngine: Sheaf cohomology computations
|
||||
* - CategoryEngine: Functorial retrieval and topos operations
|
||||
* - HoTTEngine: Type checking and path operations
|
||||
* - SpectralEngine: Eigenvalue computation and Cheeger bounds
|
||||
* - CausalEngine: Causal inference and interventions
|
||||
* - QuantumEngine: Topological invariants and quantum simulation
|
||||
*/
|
||||
|
||||
import init, {
|
||||
CohomologyEngine,
|
||||
SpectralEngine,
|
||||
CausalEngine,
|
||||
QuantumEngine,
|
||||
CategoryEngine,
|
||||
HoTTEngine,
|
||||
getVersion,
|
||||
initModule,
|
||||
type SheafGraph,
|
||||
type SheafNode,
|
||||
type SheafEdge,
|
||||
type Graph,
|
||||
type CausalModel,
|
||||
type QuantumState,
|
||||
type Complex,
|
||||
type Category,
|
||||
type CatObject,
|
||||
type Morphism,
|
||||
type HoTTType,
|
||||
type HoTTTerm,
|
||||
type HoTTPath,
|
||||
} from './prime_radiant_advanced_wasm';
|
||||
|
||||
// ============================================================================
|
||||
// Initialization
|
||||
// ============================================================================
|
||||
|
||||
async function main() {
|
||||
// Initialize WASM module
|
||||
await init();
|
||||
initModule();
|
||||
|
||||
console.log(`Prime-Radiant Advanced WASM v${getVersion()}`);
|
||||
console.log('='.repeat(50));
|
||||
|
||||
// Run all examples
|
||||
await cohomologyExample();
|
||||
await spectralExample();
|
||||
await causalExample();
|
||||
await quantumExample();
|
||||
await categoryExample();
|
||||
await hottExample();
|
||||
|
||||
console.log('\nAll examples completed successfully!');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Cohomology Engine Example
|
||||
// ============================================================================
|
||||
|
||||
async function cohomologyExample() {
|
||||
console.log('\n--- Cohomology Engine Example ---');
|
||||
|
||||
const cohomology = new CohomologyEngine();
|
||||
|
||||
// Create a belief graph with consistent sections
|
||||
const consistentGraph: SheafGraph = {
|
||||
nodes: [
|
||||
{ id: 0, label: 'Belief A', section: [1.0, 0.5], weight: 1.0 },
|
||||
{ id: 1, label: 'Belief B', section: [1.0, 0.5], weight: 1.0 },
|
||||
{ id: 2, label: 'Belief C', section: [1.0, 0.5], weight: 1.0 },
|
||||
],
|
||||
edges: [
|
||||
{
|
||||
source: 0,
|
||||
target: 1,
|
||||
restriction_map: [1.0, 0.0, 0.0, 1.0], // Identity map
|
||||
source_dim: 2,
|
||||
target_dim: 2,
|
||||
},
|
||||
{
|
||||
source: 1,
|
||||
target: 2,
|
||||
restriction_map: [1.0, 0.0, 0.0, 1.0],
|
||||
source_dim: 2,
|
||||
target_dim: 2,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// Compute cohomology
|
||||
const result = cohomology.computeCohomology(consistentGraph);
|
||||
console.log('Cohomology of consistent graph:');
|
||||
console.log(` H^0 dimension: ${result.h0_dim}`);
|
||||
console.log(` H^1 dimension: ${result.h1_dim}`);
|
||||
console.log(` Euler characteristic: ${result.euler_characteristic}`);
|
||||
console.log(` Is consistent: ${result.is_consistent}`);
|
||||
|
||||
// Create an inconsistent graph
|
||||
const inconsistentGraph: SheafGraph = {
|
||||
nodes: [
|
||||
{ id: 0, label: 'Belief A', section: [1.0, 0.0], weight: 1.0 },
|
||||
{ id: 1, label: 'Belief B', section: [0.0, 1.0], weight: 1.0 }, // Different!
|
||||
],
|
||||
edges: [
|
||||
{
|
||||
source: 0,
|
||||
target: 1,
|
||||
restriction_map: [1.0, 0.0, 0.0, 1.0],
|
||||
source_dim: 2,
|
||||
target_dim: 2,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// Detect obstructions
|
||||
const obstructions = cohomology.detectObstructions(inconsistentGraph);
|
||||
console.log(`\nDetected ${obstructions.length} obstruction(s):`);
|
||||
for (const obs of obstructions) {
|
||||
console.log(` ${obs.description}`);
|
||||
}
|
||||
|
||||
// Compute consistency energy
|
||||
const energy = cohomology.consistencyEnergy(inconsistentGraph);
|
||||
console.log(` Consistency energy: ${energy.toFixed(6)}`);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Spectral Engine Example
|
||||
// ============================================================================
|
||||
|
||||
async function spectralExample() {
|
||||
console.log('\n--- Spectral Engine Example ---');
|
||||
|
||||
const spectral = new SpectralEngine();
|
||||
|
||||
// Create a path graph: 0 -- 1 -- 2 -- 3 -- 4
|
||||
const pathGraph: Graph = {
|
||||
n: 5,
|
||||
edges: [
|
||||
[0, 1, 1.0],
|
||||
[1, 2, 1.0],
|
||||
[2, 3, 1.0],
|
||||
[3, 4, 1.0],
|
||||
],
|
||||
};
|
||||
|
||||
// Compute Cheeger bounds
|
||||
const cheeger = spectral.computeCheegerBounds(pathGraph);
|
||||
console.log('Cheeger bounds for path graph:');
|
||||
console.log(` Lower bound: ${cheeger.lower_bound.toFixed(6)}`);
|
||||
console.log(` Upper bound: ${cheeger.upper_bound.toFixed(6)}`);
|
||||
console.log(` Fiedler value (λ₂): ${cheeger.fiedler_value.toFixed(6)}`);
|
||||
|
||||
// Compute spectral gap
|
||||
const gap = spectral.computeSpectralGap(pathGraph);
|
||||
console.log(`\nSpectral gap analysis:`);
|
||||
console.log(` λ₁ = ${gap.lambda_1.toFixed(6)}`);
|
||||
console.log(` λ₂ = ${gap.lambda_2.toFixed(6)}`);
|
||||
console.log(` Gap = ${gap.gap.toFixed(6)}`);
|
||||
console.log(` Ratio = ${gap.ratio.toFixed(6)}`);
|
||||
|
||||
// Predict minimum cut
|
||||
const prediction = spectral.predictMinCut(pathGraph);
|
||||
console.log(`\nMin-cut prediction:`);
|
||||
console.log(` Predicted cut: ${prediction.predicted_cut.toFixed(6)}`);
|
||||
console.log(` Confidence: ${(prediction.confidence * 100).toFixed(1)}%`);
|
||||
console.log(` Cut nodes: [${prediction.cut_nodes.join(', ')}]`);
|
||||
|
||||
// Create a barbell graph (two cliques connected by single edge)
|
||||
const barbellGraph: Graph = {
|
||||
n: 6,
|
||||
edges: [
|
||||
// First clique
|
||||
[0, 1, 1.0], [0, 2, 1.0], [1, 2, 1.0],
|
||||
// Second clique
|
||||
[3, 4, 1.0], [3, 5, 1.0], [4, 5, 1.0],
|
||||
// Bridge
|
||||
[2, 3, 1.0],
|
||||
],
|
||||
};
|
||||
|
||||
const barbellGap = spectral.computeSpectralGap(barbellGraph);
|
||||
console.log(`\nBarbell graph spectral gap: ${barbellGap.gap.toFixed(6)}`);
|
||||
console.log('(Small gap indicates bottleneck structure)');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Causal Engine Example
|
||||
// ============================================================================
|
||||
|
||||
async function causalExample() {
|
||||
console.log('\n--- Causal Engine Example ---');
|
||||
|
||||
const causal = new CausalEngine();
|
||||
|
||||
// Build a causal model: Age -> Income, Education -> Income, Income -> Savings
|
||||
const model: CausalModel = {
|
||||
variables: [
|
||||
{ name: 'Age', var_type: 'continuous' },
|
||||
{ name: 'Education', var_type: 'discrete' },
|
||||
{ name: 'Income', var_type: 'continuous' },
|
||||
{ name: 'Savings', var_type: 'continuous' },
|
||||
],
|
||||
edges: [
|
||||
{ from: 'Age', to: 'Income' },
|
||||
{ from: 'Education', to: 'Income' },
|
||||
{ from: 'Income', to: 'Savings' },
|
||||
],
|
||||
};
|
||||
|
||||
// Check if valid DAG
|
||||
const isValid = causal.isValidDag(model);
|
||||
console.log(`Model is valid DAG: ${isValid}`);
|
||||
|
||||
// Get topological order
|
||||
const order = causal.topologicalOrder(model);
|
||||
console.log(`Topological order: ${order.join(' -> ')}`);
|
||||
|
||||
// Check d-separation
|
||||
const dSep = causal.checkDSeparation(model, 'Age', 'Savings', ['Income']);
|
||||
console.log(`\nD-separation test:`);
|
||||
console.log(` Age ⊥ Savings | Income: ${dSep.d_separated}`);
|
||||
|
||||
const dSep2 = causal.checkDSeparation(model, 'Age', 'Savings', []);
|
||||
console.log(` Age ⊥ Savings | ∅: ${dSep2.d_separated}`);
|
||||
|
||||
// Find confounders
|
||||
const confounders = causal.findConfounders(model, 'Education', 'Savings');
|
||||
console.log(`\nConfounders between Education and Savings: [${confounders.join(', ')}]`);
|
||||
|
||||
// Compute causal effect
|
||||
const effect = causal.computeCausalEffect(model, 'Income', 'Savings', 10000);
|
||||
console.log(`\nCausal effect of do(Income = 10000) on Savings:`);
|
||||
console.log(` Effect: ${effect.causal_effect}`);
|
||||
console.log(` Affected variables: [${effect.affected_variables.join(', ')}]`);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Quantum Engine Example
|
||||
// ============================================================================
|
||||
|
||||
async function quantumExample() {
|
||||
console.log('\n--- Quantum Engine Example ---');
|
||||
|
||||
const quantum = new QuantumEngine();
|
||||
|
||||
// Create GHZ state (maximally entangled)
|
||||
const ghz = quantum.createGHZState(3);
|
||||
console.log(`GHZ state (3 qubits):`);
|
||||
console.log(` Dimension: ${ghz.dimension}`);
|
||||
console.log(` |000⟩ amplitude: ${ghz.amplitudes[0].re.toFixed(4)}`);
|
||||
console.log(` |111⟩ amplitude: ${ghz.amplitudes[7].re.toFixed(4)}`);
|
||||
|
||||
// Create W state
|
||||
const w = quantum.createWState(3);
|
||||
console.log(`\nW state (3 qubits):`);
|
||||
console.log(` |001⟩ amplitude: ${w.amplitudes[1].re.toFixed(4)}`);
|
||||
console.log(` |010⟩ amplitude: ${w.amplitudes[2].re.toFixed(4)}`);
|
||||
console.log(` |100⟩ amplitude: ${w.amplitudes[4].re.toFixed(4)}`);
|
||||
|
||||
// Compute fidelity between states
|
||||
const fidelity = quantum.computeFidelity(ghz, w);
|
||||
console.log(`\nFidelity between GHZ and W states:`);
|
||||
console.log(` Fidelity: ${fidelity.fidelity.toFixed(6)}`);
|
||||
console.log(` Trace distance: ${fidelity.trace_distance.toFixed(6)}`);
|
||||
|
||||
// Compute entanglement entropy
|
||||
const entropy = quantum.computeEntanglementEntropy(ghz, 1);
|
||||
console.log(`\nEntanglement entropy of GHZ (split at qubit 1): ${entropy.toFixed(6)}`);
|
||||
|
||||
// Compute topological invariants of a simplicial complex
|
||||
// Triangle: vertices {0,1,2}, edges {01,12,02}, face {012}
|
||||
const simplices = [
|
||||
[0], [1], [2], // 0-simplices (vertices)
|
||||
[0, 1], [1, 2], [0, 2], // 1-simplices (edges)
|
||||
[0, 1, 2], // 2-simplex (face)
|
||||
];
|
||||
|
||||
const invariants = quantum.computeTopologicalInvariants(simplices);
|
||||
console.log(`\nTopological invariants of filled triangle:`);
|
||||
console.log(` Euler characteristic: ${invariants.euler_characteristic}`);
|
||||
console.log(` Is connected: ${invariants.is_connected}`);
|
||||
|
||||
// Apply Hadamard gate
|
||||
const hadamard: Complex[][] = [
|
||||
[{ re: 1 / Math.sqrt(2), im: 0 }, { re: 1 / Math.sqrt(2), im: 0 }],
|
||||
[{ re: 1 / Math.sqrt(2), im: 0 }, { re: -1 / Math.sqrt(2), im: 0 }],
|
||||
];
|
||||
|
||||
const ground: QuantumState = {
|
||||
amplitudes: [{ re: 1, im: 0 }, { re: 0, im: 0 }],
|
||||
dimension: 2,
|
||||
};
|
||||
|
||||
const result = quantum.applyGate(ground, hadamard, 0);
|
||||
console.log(`\nHadamard on |0⟩:`);
|
||||
console.log(` |0⟩ amplitude: ${result.amplitudes[0].re.toFixed(4)}`);
|
||||
console.log(` |1⟩ amplitude: ${result.amplitudes[1].re.toFixed(4)}`);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Category Engine Example
|
||||
// ============================================================================
|
||||
|
||||
async function categoryExample() {
|
||||
console.log('\n--- Category Engine Example ---');
|
||||
|
||||
const category = new CategoryEngine();
|
||||
|
||||
// Create a simple category with vector spaces
|
||||
const vecCategory: Category = {
|
||||
name: 'Vect',
|
||||
objects: [
|
||||
{ id: 'R2', dimension: 2, data: [1.0, 0.0] },
|
||||
{ id: 'R3', dimension: 3, data: [1.0, 0.0, 0.0] },
|
||||
],
|
||||
morphisms: [],
|
||||
};
|
||||
|
||||
// Create morphisms (linear maps)
|
||||
const projection: Morphism = {
|
||||
source: 'R3',
|
||||
target: 'R2',
|
||||
matrix: [1, 0, 0, 0, 1, 0], // Project to first two coordinates
|
||||
source_dim: 3,
|
||||
target_dim: 2,
|
||||
};
|
||||
|
||||
const embedding: Morphism = {
|
||||
source: 'R2',
|
||||
target: 'R3',
|
||||
matrix: [1, 0, 0, 1, 0, 0], // Embed in first two coordinates
|
||||
source_dim: 2,
|
||||
target_dim: 3,
|
||||
};
|
||||
|
||||
// Apply morphism
|
||||
const data = [1.0, 2.0, 3.0];
|
||||
const projected = category.applyMorphism(projection, data);
|
||||
console.log(`Projection of [${data.join(', ')}]: [${projected.map(x => x.toFixed(2)).join(', ')}]`);
|
||||
|
||||
// Compose morphisms (embedding then projection = identity)
|
||||
const composed = category.composeMorphisms(embedding, projection);
|
||||
console.log(`\nComposed morphism (P ∘ E):`);
|
||||
console.log(` Source: ${composed.source}`);
|
||||
console.log(` Target: ${composed.target}`);
|
||||
console.log(` Matrix: [${composed.matrix.map(x => x.toFixed(2)).join(', ')}]`);
|
||||
|
||||
// Verify category laws
|
||||
vecCategory.morphisms.push(projection);
|
||||
const lawsValid = category.verifyCategoryLaws(vecCategory);
|
||||
console.log(`\nCategory laws verified: ${lawsValid}`);
|
||||
|
||||
// Functorial retrieval
|
||||
const docsCategory: Category = {
|
||||
name: 'Docs',
|
||||
objects: [
|
||||
{ id: 'doc1', dimension: 3, data: [1.0, 0.0, 0.0] },
|
||||
{ id: 'doc2', dimension: 3, data: [0.9, 0.1, 0.0] },
|
||||
{ id: 'doc3', dimension: 3, data: [0.0, 1.0, 0.0] },
|
||||
{ id: 'doc4', dimension: 3, data: [0.0, 0.0, 1.0] },
|
||||
],
|
||||
morphisms: [],
|
||||
};
|
||||
|
||||
const query = [1.0, 0.0, 0.0];
|
||||
const results = category.functorialRetrieve(docsCategory, query, 2);
|
||||
console.log(`\nFunctorial retrieval for query [${query.join(', ')}]:`);
|
||||
for (const r of results) {
|
||||
console.log(` ${r.object_id}: similarity = ${r.similarity.toFixed(4)}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// HoTT Engine Example
|
||||
// ============================================================================
|
||||
|
||||
async function hottExample() {
|
||||
console.log('\n--- HoTT Engine Example ---');
|
||||
|
||||
const hott = new HoTTEngine();
|
||||
|
||||
// Create terms
|
||||
const star: HoTTTerm = { kind: 'star', children: [] };
|
||||
const zero: HoTTTerm = { kind: 'zero', children: [] };
|
||||
const one: HoTTTerm = { kind: 'succ', children: [zero] };
|
||||
const pair: HoTTTerm = { kind: 'pair', children: [zero, star] };
|
||||
|
||||
// Infer types
|
||||
console.log('Type inference:');
|
||||
const starType = hott.inferType(star);
|
||||
console.log(` ★ : ${starType.inferred_type?.kind}`);
|
||||
|
||||
const zeroType = hott.inferType(zero);
|
||||
console.log(` 0 : ${zeroType.inferred_type?.kind}`);
|
||||
|
||||
const oneType = hott.inferType(one);
|
||||
console.log(` S(0) : ${oneType.inferred_type?.kind}`);
|
||||
|
||||
const pairType = hott.inferType(pair);
|
||||
console.log(` (0, ★) : ${pairType.inferred_type?.name}`);
|
||||
|
||||
// Type checking
|
||||
const natType: HoTTType = { name: 'Nat', level: 0, kind: 'nat', params: [] };
|
||||
const checkResult = hott.typeCheck(zero, natType);
|
||||
console.log(`\nType checking 0 : Nat: ${checkResult.is_valid}`);
|
||||
|
||||
const boolType: HoTTType = { name: 'Bool', level: 0, kind: 'bool', params: [] };
|
||||
const checkResult2 = hott.typeCheck(zero, boolType);
|
||||
console.log(`Type checking 0 : Bool: ${checkResult2.is_valid}`);
|
||||
if (checkResult2.error) {
|
||||
console.log(` Error: ${checkResult2.error}`);
|
||||
}
|
||||
|
||||
// Path operations
|
||||
const refl = hott.createReflPath(natType, zero);
|
||||
console.log(`\nReflexivity path: refl(0) : 0 = 0`);
|
||||
|
||||
// Compose paths
|
||||
const composed = hott.composePaths(refl, refl);
|
||||
if (composed.is_valid) {
|
||||
console.log('Path composition: refl ∙ refl is valid');
|
||||
}
|
||||
|
||||
// Invert path
|
||||
const inverted = hott.invertPath(refl);
|
||||
if (inverted.is_valid) {
|
||||
console.log('Path inversion: refl⁻¹ is valid');
|
||||
}
|
||||
|
||||
// Check type equivalence
|
||||
const nat1: HoTTType = { name: 'Nat', level: 0, kind: 'nat', params: [] };
|
||||
const nat2: HoTTType = { name: 'Nat', level: 0, kind: 'nat', params: [] };
|
||||
const equiv = hott.checkTypeEquivalence(nat1, nat2);
|
||||
console.log(`\nType equivalence Nat ≃ Nat: ${equiv}`);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Run Examples
|
||||
// ============================================================================
|
||||
|
||||
main().catch(console.error);
|
||||
326
vendor/ruvector/examples/prime-radiant/wasm/pkg/prime_radiant_advanced_wasm.d.ts
vendored
Normal file
326
vendor/ruvector/examples/prime-radiant/wasm/pkg/prime_radiant_advanced_wasm.d.ts
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* Category theory engine
|
||||
*/
|
||||
export class CategoryEngine {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Apply morphism to an object
|
||||
*/
|
||||
applyMorphism(morphism_js: any, data_js: any): any;
|
||||
/**
|
||||
* Compose two morphisms
|
||||
*/
|
||||
composeMorphisms(f_js: any, g_js: any): any;
|
||||
/**
|
||||
* Functorial retrieval: find similar objects
|
||||
*/
|
||||
functorialRetrieve(category_js: any, query_js: any, k: number): any;
|
||||
/**
|
||||
* Create a new category engine
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Verify categorical laws
|
||||
*/
|
||||
verifyCategoryLaws(category_js: any): boolean;
|
||||
/**
|
||||
* Check if functor preserves composition
|
||||
*/
|
||||
verifyFunctoriality(functor_js: any, source_cat_js: any): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Causal inference engine
|
||||
*/
|
||||
export class CausalEngine {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Check d-separation between two variables
|
||||
*/
|
||||
checkDSeparation(model_js: any, x: string, y: string, conditioning_js: any): any;
|
||||
/**
|
||||
* Compute causal effect via do-operator
|
||||
*/
|
||||
computeCausalEffect(model_js: any, treatment: string, outcome: string, treatment_value: number): any;
|
||||
/**
|
||||
* Find all confounders between two variables
|
||||
*/
|
||||
findConfounders(model_js: any, treatment: string, outcome: string): any;
|
||||
/**
|
||||
* Check if model is a valid DAG
|
||||
*/
|
||||
isValidDag(model_js: any): boolean;
|
||||
/**
|
||||
* Create a new causal engine
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Get topological order of variables
|
||||
*/
|
||||
topologicalOrder(model_js: any): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sheaf cohomology computation engine
|
||||
*/
|
||||
export class CohomologyEngine {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Compute cohomology groups of a sheaf graph
|
||||
*/
|
||||
computeCohomology(graph_js: any): any;
|
||||
/**
|
||||
* Compute global sections (H^0)
|
||||
*/
|
||||
computeGlobalSections(graph_js: any): any;
|
||||
/**
|
||||
* Compute consistency energy
|
||||
*/
|
||||
consistencyEnergy(graph_js: any): number;
|
||||
/**
|
||||
* Detect all obstructions to global consistency
|
||||
*/
|
||||
detectObstructions(graph_js: any): any;
|
||||
/**
|
||||
* Create a new cohomology engine
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Create with custom tolerance
|
||||
*/
|
||||
static withTolerance(tolerance: number): CohomologyEngine;
|
||||
}
|
||||
|
||||
/**
|
||||
* HoTT type checking and path operations engine
|
||||
*/
|
||||
export class HoTTEngine {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Check type equivalence (univalence-related)
|
||||
*/
|
||||
checkTypeEquivalence(type1_js: any, type2_js: any): boolean;
|
||||
/**
|
||||
* Compose two paths
|
||||
*/
|
||||
composePaths(path1_js: any, path2_js: any): any;
|
||||
/**
|
||||
* Create reflexivity path
|
||||
*/
|
||||
createReflPath(type_js: any, point_js: any): any;
|
||||
/**
|
||||
* Infer type of a term
|
||||
*/
|
||||
inferType(term_js: any): any;
|
||||
/**
|
||||
* Invert a path
|
||||
*/
|
||||
invertPath(path_js: any): any;
|
||||
/**
|
||||
* Create a new HoTT engine
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Type check a term
|
||||
*/
|
||||
typeCheck(term_js: any, expected_type_js: any): any;
|
||||
/**
|
||||
* Create with strict mode
|
||||
*/
|
||||
static withStrictMode(strict: boolean): HoTTEngine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quantum computing and topological analysis engine
|
||||
*/
|
||||
export class QuantumEngine {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Simulate quantum circuit evolution
|
||||
*/
|
||||
applyGate(state_js: any, gate_js: any, target_qubit: number): any;
|
||||
/**
|
||||
* Compute entanglement entropy
|
||||
*/
|
||||
computeEntanglementEntropy(state_js: any, subsystem_size: number): number;
|
||||
/**
|
||||
* Compute quantum state fidelity
|
||||
*/
|
||||
computeFidelity(state1_js: any, state2_js: any): any;
|
||||
/**
|
||||
* Compute topological invariants of a simplicial complex
|
||||
*/
|
||||
computeTopologicalInvariants(simplices_js: any): any;
|
||||
/**
|
||||
* Create a GHZ state
|
||||
*/
|
||||
createGHZState(num_qubits: number): any;
|
||||
/**
|
||||
* Create a W state
|
||||
*/
|
||||
createWState(num_qubits: number): any;
|
||||
/**
|
||||
* Create a new quantum engine
|
||||
*/
|
||||
constructor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Spectral analysis engine
|
||||
*/
|
||||
export class SpectralEngine {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Compute the algebraic connectivity (Fiedler value)
|
||||
*/
|
||||
algebraicConnectivity(graph_js: any): number;
|
||||
/**
|
||||
* Compute Cheeger bounds for a graph
|
||||
*/
|
||||
computeCheegerBounds(graph_js: any): any;
|
||||
/**
|
||||
* Compute eigenvalues of the graph Laplacian
|
||||
*/
|
||||
computeEigenvalues(graph_js: any): any;
|
||||
/**
|
||||
* Compute Fiedler vector
|
||||
*/
|
||||
computeFiedlerVector(graph_js: any): any;
|
||||
/**
|
||||
* Compute spectral gap
|
||||
*/
|
||||
computeSpectralGap(graph_js: any): any;
|
||||
/**
|
||||
* Create a new spectral engine
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Predict minimum cut
|
||||
*/
|
||||
predictMinCut(graph_js: any): any;
|
||||
/**
|
||||
* Create with configuration
|
||||
*/
|
||||
static withConfig(num_eigenvalues: number, tolerance: number, max_iterations: number): SpectralEngine;
|
||||
}
|
||||
|
||||
/**
|
||||
* JavaScript-friendly error type
|
||||
*/
|
||||
export class WasmError {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
readonly code: string;
|
||||
readonly message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get library version
|
||||
*/
|
||||
export function getVersion(): string;
|
||||
|
||||
/**
|
||||
* Initialize the WASM module
|
||||
*/
|
||||
export function initModule(): void;
|
||||
|
||||
export function start(): void;
|
||||
|
||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||
|
||||
export interface InitOutput {
|
||||
readonly memory: WebAssembly.Memory;
|
||||
readonly __wbg_categoryengine_free: (a: number, b: number) => void;
|
||||
readonly __wbg_hottengine_free: (a: number, b: number) => void;
|
||||
readonly __wbg_spectralengine_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmerror_free: (a: number, b: number) => void;
|
||||
readonly categoryengine_applyMorphism: (a: number, b: any, c: any) => [number, number, number];
|
||||
readonly categoryengine_composeMorphisms: (a: number, b: any, c: any) => [number, number, number];
|
||||
readonly categoryengine_functorialRetrieve: (a: number, b: any, c: any, d: number) => [number, number, number];
|
||||
readonly categoryengine_new: () => number;
|
||||
readonly categoryengine_verifyCategoryLaws: (a: number, b: any) => [number, number, number];
|
||||
readonly categoryengine_verifyFunctoriality: (a: number, b: any, c: any) => [number, number, number];
|
||||
readonly causalengine_checkDSeparation: (a: number, b: any, c: number, d: number, e: number, f: number, g: any) => [number, number, number];
|
||||
readonly causalengine_computeCausalEffect: (a: number, b: any, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
||||
readonly causalengine_findConfounders: (a: number, b: any, c: number, d: number, e: number, f: number) => [number, number, number];
|
||||
readonly causalengine_isValidDag: (a: number, b: any) => [number, number, number];
|
||||
readonly causalengine_topologicalOrder: (a: number, b: any) => [number, number, number];
|
||||
readonly cohomologyengine_computeCohomology: (a: number, b: any) => [number, number, number];
|
||||
readonly cohomologyengine_computeGlobalSections: (a: number, b: any) => [number, number, number];
|
||||
readonly cohomologyengine_consistencyEnergy: (a: number, b: any) => [number, number, number];
|
||||
readonly cohomologyengine_detectObstructions: (a: number, b: any) => [number, number, number];
|
||||
readonly cohomologyengine_withTolerance: (a: number) => number;
|
||||
readonly getVersion: () => [number, number];
|
||||
readonly hottengine_checkTypeEquivalence: (a: number, b: any, c: any) => [number, number, number];
|
||||
readonly hottengine_composePaths: (a: number, b: any, c: any) => [number, number, number];
|
||||
readonly hottengine_createReflPath: (a: number, b: any, c: any) => [number, number, number];
|
||||
readonly hottengine_inferType: (a: number, b: any) => [number, number, number];
|
||||
readonly hottengine_invertPath: (a: number, b: any) => [number, number, number];
|
||||
readonly hottengine_new: () => number;
|
||||
readonly hottengine_typeCheck: (a: number, b: any, c: any) => [number, number, number];
|
||||
readonly hottengine_withStrictMode: (a: number) => number;
|
||||
readonly initModule: () => [number, number];
|
||||
readonly quantumengine_applyGate: (a: number, b: any, c: any, d: number) => [number, number, number];
|
||||
readonly quantumengine_computeEntanglementEntropy: (a: number, b: any, c: number) => [number, number, number];
|
||||
readonly quantumengine_computeFidelity: (a: number, b: any, c: any) => [number, number, number];
|
||||
readonly quantumengine_computeTopologicalInvariants: (a: number, b: any) => [number, number, number];
|
||||
readonly quantumengine_createGHZState: (a: number, b: number) => [number, number, number];
|
||||
readonly quantumengine_createWState: (a: number, b: number) => [number, number, number];
|
||||
readonly spectralengine_algebraicConnectivity: (a: number, b: any) => [number, number, number];
|
||||
readonly spectralengine_computeCheegerBounds: (a: number, b: any) => [number, number, number];
|
||||
readonly spectralengine_computeEigenvalues: (a: number, b: any) => [number, number, number];
|
||||
readonly spectralengine_computeFiedlerVector: (a: number, b: any) => [number, number, number];
|
||||
readonly spectralengine_computeSpectralGap: (a: number, b: any) => [number, number, number];
|
||||
readonly spectralengine_new: () => number;
|
||||
readonly spectralengine_predictMinCut: (a: number, b: any) => [number, number, number];
|
||||
readonly spectralengine_withConfig: (a: number, b: number, c: number) => number;
|
||||
readonly start: () => void;
|
||||
readonly wasmerror_code: (a: number) => [number, number];
|
||||
readonly wasmerror_message: (a: number) => [number, number];
|
||||
readonly causalengine_new: () => number;
|
||||
readonly cohomologyengine_new: () => number;
|
||||
readonly quantumengine_new: () => number;
|
||||
readonly __wbg_causalengine_free: (a: number, b: number) => void;
|
||||
readonly __wbg_cohomologyengine_free: (a: number, b: number) => void;
|
||||
readonly __wbg_quantumengine_free: (a: number, b: number) => void;
|
||||
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
||||
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
||||
readonly __wbindgen_exn_store: (a: number) => void;
|
||||
readonly __externref_table_alloc: () => number;
|
||||
readonly __wbindgen_externrefs: WebAssembly.Table;
|
||||
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
||||
readonly __externref_table_dealloc: (a: number) => void;
|
||||
readonly __wbindgen_start: () => void;
|
||||
}
|
||||
|
||||
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
||||
|
||||
/**
|
||||
* Instantiates the given `module`, which can either be bytes or
|
||||
* a precompiled `WebAssembly.Module`.
|
||||
*
|
||||
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {InitOutput}
|
||||
*/
|
||||
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
||||
|
||||
/**
|
||||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
||||
* for everything else, calls `WebAssembly.instantiate` directly.
|
||||
*
|
||||
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||
Reference in New Issue
Block a user