Skip to content

Latest commit

 

History

History

inet

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@intuitionlabs/inet

Interaction combinators you can run. Build a little graph of agents, let them react, and read off the answer — the reaction is the computation.

Part of the Intuition Labs foundry — github.com/Intuition-Labs-LLC/jspace.

Install

npm i @intuitionlabs/inet

Until the first npm publish, install from the GitHub Release tarball.

Quickstart

import { makeNet, addNode, wire, freePort, freeLink, reduce } from '@intuitionlabs/inet';

const net = makeNet();
const a = addNode(net, 'CON');            // a constructor
const b = addNode(net, 'CON');            // meets another constructor
wire(net, { node: a, slot: 0 }, { node: b, slot: 0 }); // principal↔principal = active pair
freePort(net, 'w', { node: a, slot: 1 }); // name the four dangling wires
freePort(net, 'x', { node: a, slot: 2 });
freePort(net, 'y', { node: b, slot: 1 });
freePort(net, 'z', { node: b, slot: 2 });

const { steps, normal, receipt } = reduce(net);
console.log(steps, normal);               // 1 true
console.log(freeLink(net, 'w'));          // { free: 'y' }  — the two constructors annihilated
console.log(receipt.note);                // reduced to normal form in 1 step (order=asc)

The mechanism

An agent has one principal port (slot 0) and some auxiliary ports. There are three kinds: ERA (0 aux), CON (2 aux), DUP (2 aux). An active pair is two principal ports wired together. Reduction rewrites active pairs until none remain. Four rules cover every case. ERA–ERA removes both. CON–CON and DUP–DUP annihilate: aux1 joins aux1, aux2 joins aux2 (index-aligned, like a plug meeting its socket), then both agents vanish. CON–DUP commute: each agent copies the other, spawning two DUP and two CON wired into the standard Lafont square. ERA meeting a binary agent erases it and sends a fresh ERA down each of its aux wires.

The scheduler is deterministic and its order is flippable. It collects the active pairs, sorts them by (min id, max id), reduces the first, and rescans. Interaction nets are strongly confluent, so the order changes the reduction sequence but never the normal form — and, on a terminating net, not even the step count. canonicalNetHash proves this: it relabels agents by a breadth-first walk from the named free ports, so two nets that differ only in numbering hash the same. A net with no normal form (a vicious circle) is capped at maxSteps and reported normal: false. invariantClass is the same fingerprint idea for an abstract kind-labeled graph: a permutation-invariant kindMultiset/hash string. phiRegister records a correspondence claim and its witness.

Laws

  • L5 — no witness, no correspondence. phiRegister throws Error('no witness, no correspondence') on an empty or whitespace witness ref. This is the one deliberate throw on the public surface. Falsifier: test/phi.test.ts › L5 falsifier: an empty witness_ref throws the exact message.
  • L1 — R-one-source & never-alias. inet computes none of the four R scalars, so reduce's receipt never carries a scalar. Falsifier: test/rules.test.ts › reduce computes no R and never labels a scalar.
  • L7 — degrade closed. createInet with no ledger keeps an in-memory one; invariantClass returns an invalid/… class on a malformed graph instead of throwing. Pins: test/phi.test.ts › createInet ledger degrades closed, test/canon.test.ts › invariantClass degrades closed on a malformed graph.
  • Confluence (the executable witness). test/canon.test.ts › confluence: ≥3 independent active pairs… and …cascading net… reduce the same net with order: 'asc' and order: 'desc' and assert one canonicalNetHash.

Provenance

This externalizes the invariantClass and phiRegister helpers from the maxwell kernel (research_worker/src/kernel/jspace.ts), where a net's normal form is the "confluence-normal-form" executable witness a correspondence claim points at.

  • HVM2 / interaction nets — Victor Taelin, Higher Order Company (Apache-2.0): the industrial sibling, a complete interaction-net machine written entirely in C (HVM2 gen-c, pthreads + atomics). We implement the calculus originally here; no code is copied.
  • Church–Lafont: reduce = interpretability = throughput. Confluence means the normal form does not depend on the order you reduce in, so the result is a property of the net, not of the schedule.
  • The applicability layer. @terminals-tech/py2bend and the DRM compiler family (py2bend, skill2bend, tools2bend) compile Python / skills / MCP tool schemas to Bend and reduce them on HVM interaction nets. Gate with jspace, execute on nets.