Download src/lattice-kernel/README.md from Snapkitty/icp-dag-crystallizer: direct link, hf CLI and curl.
- Browser
- Download file 6.89 kB
-
https://huggingface.co/Snapkitty/icp-dag-crystallizer/resolve/main/src/lattice-kernel/README.md
- Command line
-
hf download hf://Snapkitty/icp-dag-crystallizer/src/lattice-kernel/README.md
-
curl -L -o README.md https://huggingface.co/Snapkitty/icp-dag-crystallizer/resolve/main/src/lattice-kernel/README.md
src/lattice-kernel — 8-Language Relational Lattice Kernel
License: LicenseRef-Sovereign-Leviathan-SL-AGPL3-001
A coherent multi-language implementation of a relational lattice kernel. Every file implements the same set of relations across a different host language. The Lean 4 and Coq files are the formal specifications; the others are executable.
Relation Set
Every language implements (a subset of) these relations:
| Relation | Domain |
|---|---|
appendo, membero, rembero, reverseo, lengtho, distincto, permuteo |
Lists |
addo, mulo, zeroo, succo, nato |
Peano arithmetic |
bit-xoro, bit-ando, half-addero, full-addero, ripple-addero |
Bit / full adder |
lookupo, eval-expro, applyo, evalo |
Relational interpreter |
smt-sat? / smt_sato / satStub |
SMT satisfiability stub |
edgeo, patho, reacho |
Parameterized path / reachability |
fsmo, fsm-traceo |
FSM transitions + traces |
refineo |
Interval / abstract value refinement |
Files
Scheme — mu_kanren.scm
Toolchain: Chez Scheme, Guile, Racket (#lang scheme), or any R5RS/R7RS host.
Pure μKanren kernel with the canonical (subst . counter) state representation.
Implements the full fresh/conde/run/run* macro surface, =/=, symbolo,
numbero, absento, call/fresh. All list, Peano, bit, evalo, SMT, path, FSM,
and refinement relations are relational (work in all modes).
(run 3 (q) (appendo '(1 2) '(3) q))
; => ((1 2 3))
(run* (q) (full-addero 0 1 1 q 1))
; => (0)
(run 1 (q) (evalo '(quote hello) q))
; => (hello)
chez --script src/lattice-kernel/mu_kanren.scm
guile src/lattice-kernel/mu_kanren.scm
ISO Prolog — lattice_kernel.pl
Toolchain: SWI-Prolog 8+, GNU Prolog, SICStus.
Portable ISO Prolog port. Optionally loads library(clpfd) for the
full_addo_clp/5 constraint-based adder. All relations work via standard
Prolog backtracking.
?- appendo([1,2],[3],Q).
Q = [1, 2, 3].
?- full_addo(1,1,0,S,C).
S = 0, C = 1.
?- evalo(app(lambda(x,x),quote(hello)),V).
V = hello.
swipl src/lattice-kernel/lattice_kernel.pl -g "demo, halt."
Formulog — path_refine.flg
Toolchain: HarvardPL Formulog.
Stratified Datalog + ML-style types + first-class SMT formulas. The smt_formula
algebraic type carries SMT terms through derivation rules. sat_stub is a
pure Formulog function; the full SMT solver is a drop-in replacement.
Strata:
- Base reachability (no SMT)
- Guarded reachability (
sat_stubcheck) - Path with accumulated formula (conjunction of guards)
- FSM trace derivation
- Refinement + full-adder truth table
formulog src/lattice-kernel/path_refine.flg
Soufflé Datalog — path_refine.dl
Toolchain: Soufflé ≥ 2.0.
Executable IDB with propositional tags replacing SMT (no external solver
required). Covers: guarded reachability, path tag accumulation, FSM
fsm_reach/fsm_accepts, full-adder truth table, list prefix sum,
3-color graph coloring, interval refinement, edge/sat statistics.
souffle src/lattice-kernel/path_refine.dl -D.
EDB input files: edge.facts, fsm_trans.facts, abs_val.facts, list_elem.facts
(tab-separated, one tuple per line).
Picat — lattice_kernel.pi
Toolchain: Picat ≥ 3.0.
Functional-logic port. Uses Picat's cp module for full_addo_cp/5
(constraint-based adder with #=/2). Peano relations are tabled for
termination guarantees. Includes widen/3 for abstract domain joining.
picat src/lattice-kernel/lattice_kernel.pi
Lean 4 — LatticeKernel.lean
Toolchain: lake or lean src/lattice-kernel/LatticeKernel.lean. No Mathlib required.
Formal specification only — theorems are the contracts; search stays in the other languages. Covers:
Peanoinductive type +add/mulwithadd_z/add_slemmasBittype +bitXor/bitAnd/fullAddSmttype +satStub(contradiction check)FsmState+fsmstep functionAbstype +refines : Abs → Nat → Prop
lean src/lattice-kernel/LatticeKernel.lean
Mercury — lattice_kernel.m
Toolchain: Melbourne Mercury Compiler (mmc).
Production library with full mode declarations. Mercury's mode system
statically verifies that each predicate is deterministic in its declared modes.
Multi-mode predicates (e.g., appendo(out,out,in) is multi) are reversible.
Key modes:
addo(in,in,out) is det/addo(out,out,in) is multifull_addero(in,in,in,out,out) is det/(in,in,in,in,in) is semidetpatho(in,in,out,out) is nondetfsmo(out,out,out,out) is multi
mmc --make src/lattice-kernel/lattice_kernel # link into an executable
# or as a library:
mmc --make liblattice_kernel
Coq — LatticeKernel.v
Toolchain: coqc / coqtop -l. No extra libraries beyond Coq.Init.
Full inductive specification with correctness proofs:
appendo_correct:appendo l s (append_f l s)— relation matches fixpointaddo_plus:addo x y z ↔ z = x + ymulo_mult:mulo x y z → z = x * yfull_add_value: numeric contractx + y + cin = r + 2 * coutxor_rel_fun/and_rel_fun: bit relations match boolean functionsfsmo_fun:fsmo st inp nst out ↔ fsm_f st inp = (nst, out)path_0_1: concrete path proofpatho 0 1 [1] (SatAtom "bv_slt_x_y")refine_interval_3:refineo (Interval 0 7) 3eval_quote/eval_id: evalo sanity lemmas
coqc src/lattice-kernel/LatticeKernel.v
# or interactively:
coqtop -l src/lattice-kernel/LatticeKernel.v
Cross-Language Correspondence
| Concept | Scheme | Prolog | Formulog | Soufflé | Picat | Lean 4 | Mercury | Coq |
|---|---|---|---|---|---|---|---|---|
| Unification | unify |
built-in | built-in | — | built-in | — | built-in | unify |
| Streams | mplus/bind |
backtracking | semi-naïve | bottom-up | backtracking | — | backtracking | Prop |
| Full adder | full-addero |
full_addo |
full_add_result |
full_add |
full_addero |
fullAdd |
full_addero |
full_addero |
| FSM step | fsmo |
fsmo |
fsm_trans (EDB) |
fsm_trans (EDB) |
fsmo |
fsm |
fsmo |
fsmo |
| SAT stub | smt-sat? |
is_sat |
sat_stub |
sat_tag |
is_sat |
satStub |
smt_sato |
smt_sat |
| Refinement | refineo |
refineo |
refines |
refines |
refineo |
refines |
refineo |
refineo |
Language Stack Policy
This batch is Python-free. Python kernel retired for new logic/symbolic work. Allowed host languages for new additions: Mercury, Curry, Oz, Agda, Isabelle, HOL, ACL2, Smalltalk, Ruby/Crystal.