Skip to content

zelph 0.9.9

Latest

Choose a tag to compare

@zipproth zipproth released this 12 Jul 18:15
· 29 commits to main since this release
3d6e9dc

zelph now runs in your browser: https://zelph.org/playground/

The Playground (WebAssembly)

The full engine — reasoning core, Janet scripting layer, and the standard library (arithmetic, primes, SPARQL, neural networks) — compiled to WebAssembly, running entirely client-side. Nothing to install, and nothing leaves your machine.

  • Guided demo rail in four groups: Arithmetic as Inference (multiply large numbers by pure graph rewriting, then peek at the intermediate facts the computation left behind), Number Theory and Meta-Rules (the textbook negation-as-failure primality rule, a batch scan, transitivity as a single meta-rule over computed facts, contradiction detection with clusters), SPARQL over Derived Facts (including MINUS and GROUP BY/COUNT over facts the reasoner derived moments earlier), and Neural Networks in the Graph (train a link predictor on the divisor facts the prime scan produced, let rule conditions verify and propose facts, then query the net's proposals with SPARQL).
  • Demo buttons type visible commands into the terminal — visitors learn the syntax by watching. The REPL is otherwise a plain, empty zelph; everything can equally be typed by hand.
  • Each result node is rendered as an interactive graph visualization (scroll/drag) beneath the terminal, and long computations are interruptible (Stop & reset).

Neural substrate fix: synapses now live solely in the weight store

Previous versions stored a synapse as a real adjacency edge plus a weight-store entry. The adjacency half corrupted the graph in both directions: synapse edges touching relation nodes (fact nodes — including every cons cell of a structural number) were indistinguishable from fact structure, so wiring numbers as neurons corrupted their cons-lists and could break hash-consing identity; conversely, real structural edges between neurons leaked into compiled networks as phantom weight-1 synapses, and training weights could be written onto structural edges.

As of 0.9.9, a synapse is solely an entry in the sparse edge-weight store, keyed by the directed node pair — no adjacency is created. Synapses are invisible to the reasoning engine by construction rather than by filtering, and any node is now a safe neuron, including fact nodes and structural numbers (the playground's neural demo group relies on exactly this). nn.zph needed no changes; the C++ layer now honors the contract the Janet API already promised.

Migration note for existing .bin files: networks trained with 0.9.8 carry the old synapse adjacency edges. This is harmless for nets whose neurons are plain nodes (the weight entries exist in parallel), but files in which fact nodes served as neurons are corrupted and must be regenerated.

SPARQL is now general purpose

stdlib/sparql.zph was built for the Wikidata use case; its grammar previously accepted only Wikidata-style prefixed names, variables, IRIs and literals. It now queries any zelph graph:

  • Bare node names are accepted as subjects, predicates, objects and in FILTER operands (resolved in the current language); quoted literals work as path elements, so predicates with spaces are queryable.
  • DISTINCT and GROUP BY key by node value instead of name strings — correct for unnamed structural nodes such as cons-list numbers, which now render in their canonical form (&7).
  • Keyword rejection matches on word boundaries: predicates like binds or photograph no longer abort queries.

This is what makes the playground's "SPARQL over derived facts" demos possible: no triple store, no endpoint — the semantic network itself is the queried graph.

Also in this release

  • dev_scripts/test_nn.zph: an end-to-end script exercising the full chain — binary arithmetic → NAF primality scan → SPARQL over derived facts → a link predictor trained on hasdivisor facts → guard/generator rules → SPARQL over the net's proposals. The playground's neural demo group follows this chain.
  • Native packages for Linux (AUR, Debian), macOS (Homebrew), and Windows (Chocolatey) as usual — see the Quick Start Guide.