Skip to content
lattice-api logo

Lattice API Quick Reference

lattice-api

API quick-reference for key lattice subsystems (FP, Game Theory, SAT, Optics, Statistics, CLP). Use when you need function signatures, module contents, or usage examples for a specific subsystem. Invoke when working with game theory, constraint solving, optics, parsers, or other advanced lattice ...

SKILL.md

Full skill instructions

Lattice API Quick Reference

Detailed API documentation for the major lattice subsystems. Use /​lattice-search for discovery; use this skill for API details once you know what subsystem you need.

FP Toolkit (lattice/​fp/)

Monads, parsers, streams, zippers, game theory, symbolic math, control systems (state-space, Kalman filters, PID, stability analysis), term rewriting.

(li 'fp)   ; Full description
(le 'fp)   ; All exports

Regex/​FSM (lattice/​fp/​parsing/)

Regex→NFA compilation via Thompson's construction.

Features:

  • Quantifier ranges {n,m}
  • Anchors ^/$
  • Lookahead (?=...)/(?!...)

Note: Anchors and lookahead require position-aware NFA execution; nfa->dfa and fsm-minimize skip conversion when assertions present. Use regex-accepts? or fsm-accepts? which auto-detect and use appropriate runner.

(regex-accepts? "^foo" "foobar")  ; #t
(regex-accepts? "foo$" "foobar")  ; #f

Game Theory (lattice/​fp/​game/)

Rich set of ready-to-use algorithms for cooperative games, voting, matching, and fair division.

ModuleContents
coop-games.ssmake-coop-game, shapley-value, core, nucleolus
voting-games.ssbanzhaf-index, shapley-shubik-index, make-weighted-voting-game
voting.ssschulze-ranking, borda-scores-all, condorcet-winner
multi-winner.sspav-winners (proportional approval), stv-winners
matching.ssGale-Shapley stable matching, hospital-residents
fair-division.ssEnvy-free allocation, proportional division

These are pure functions — import them into boundary code for applications like QA triage, resource allocation, or voting systems.

Example: Shapley Value

(load "lattice/​fp/​game/​coop-games.ss")

;; Define a cooperative game: 3 players, characteristic function
(define game (make-coop-game 3
  (lambda (coalition)
    (cond
      [(equal? coalition '(1 2 3)) 100]  ; Grand coalition
      [(equal? coalition '(1 2)) 70]
      [(equal? coalition '(1 3)) 50]
      [(equal? coalition '(2 3)) 60]
      [else 0]))))

(shapley-value game)  ; => fair allocation to each player

Statistics (lattice/​statistics/)

CategoryFunctions
RegressionLinear, GLM (IRLS), ridge, lasso, elastic net
Time SeriesAR, MA, exponential smoothing
Hypothesis Testingt-test, F-test, ANOVA, chi-squared
(li 'statistics)  ; Full description
(le 'statistics)  ; All exports

CLP(FD) (lattice/​fp/​clp/)

cKanren-style constraint logic programming with finite domains.

Features:

  • Finite domain constraints
  • Arithmetic constraints (fd-<, fd-+, etc.)
  • Global constraints (all-different)
  • Intelligent search strategies

Classic problems: N-Queens, Sudoku, cryptarithmetic

(load "lattice/​fp/​clp/​clpfd.ss")

;; N-Queens
(run* (q)
  (fresh (q1 q2 q3 q4)
    (== q (list q1 q2 q3 q4))
    (fd-dom q1 '(1 2 3 4))
    (fd-dom q2 '(1 2 3 4))
    (fd-dom q3 '(1 2 3 4))
    (fd-dom q4 '(1 2 3 4))
    (all-different q)
    (queens-safe q)))

SAT/​MaxSAT (lattice/​fp/​sat/)

CDCL SAT solver with clause learning, Two-Watched Literals, VSIDS branching. MaxSAT extension for optimization.

FunctionPurpose
sat-solveCheck satisfiability, returns 'sat, 'unsat, or 'unknown
sat-modelGet satisfying assignment
graph-coloringEncode k-coloring as SAT
n-queens-satEncode N-Queens as SAT
make-maxsatCreate MaxSAT with hard/​soft clauses
maxsat-solveFind minimum-cost assignment
min-vertex-coverEncode as MaxSAT
max-independent-setEncode as MaxSAT
min-correction-setDiagnosis: find clauses to remove

Example: Graph Coloring

(load "lattice/​fp/​sat/​sat.ss")
(load "lattice/​fp/​sat/​applications.ss")

;; 3-color a graph
(define edges '((1 . 2) (2 . 3) (3 . 1)))
(define coloring-cnf (graph-coloring 3 3 edges))
(sat-solve coloring-cnf)  ; => 'sat or 'unsat
(sat-model coloring-cnf)  ; => variable assignments

Optics (lattice/​fp/​optics/)

Complete optics tower for composable data access.

ModuleContents
optics.ssCore tower: Iso, Lens, Prism, Affine, Traversal, Fold, Getter, Setter, Grate
block-optics.ssCAS block optics: block-tag-lens, block-refs-each, follow-ref, type prisms
profunctor-optics.ssProfunctor encoding: Strong/​Choice/​Closed/​Wander, p-lens, p-prism, p-traversal, p-fold
bidirectional.ssReversible migrations: make-migration, migrate, rollback, migration-compose
schema.ssField DSL: field-rename-iso, field-add-iso, field-transform-iso
block-migration.ssCAS migrations: make-block-migration, block-migrate-payload, bottom-up tree traversal

Operators

OperatorPurposeExample
^.view(^. body body-pos-lens)
^?preview (Maybe)(^? either left-prism)
^..to-list(^.. world (>>> world-all-bodies body-vel-lens))
.~set(.~ body-pos-lens new-pos body)
%~modify(%~ body-pos-lens add1 body)
&pipe (left-to-right)(& body (%~ lens f))
>>>compose (left-to-right)(>>> outer-lens inner-lens)

Example: Nested Access

(load "lattice/​fp/​optics/​optics.ss")

;; View nested position
(^. body body-pos-lens)

;; Modify x-coordinate of position
(& body (%~ (>>> body-pos-lens vec2-x-lens) add1))

;; Get all velocities from world
(^.. world (>>> world-all-bodies body-vel-lens))

Traced Optics (lattice/​autodiff/​traced-optics.ss)

Compute gradients through optic-focused paths — combines autodiff with optics.

(load "lattice/​autodiff/​traced-optics.ss")

;; Gradient of loss w.r.t. nested parameter via optic composition
(optic-gradient loss-fn (>>> outer-lens inner-lens) structure)

;; Gradient descent step at optic focus
(optimize-at lens-fst '(5.0 . ignored) (lambda (p) (traced-sq (car p))) 0.1)
;; => (4.0 . ignored)  ; 5 - 0.1 * 2 * 5 = 4

;; Gradients for all traversal targets
(optic-gradient-list loss-fn traversal-each '(1 2 3))

Skill Manifests

Each lattice skill has a manifest.sexp declaring metadata:

(skill <name>
  (version "x.y.z")
  (tier 0-2)                       ; 0=foundational, 1=intermediate, 2+=advanced
  (path "lattice/<name>")
  (purity total|partial)           ; total=pure, partial=may have effects
  (stability stable|experimental)
  (fuel-bound "O(...)")            ; Complexity bound
  (deps (<skill> ...))             ; Skill-level dependencies
  (description "...")
  (keywords (<keyword> ...))       ; For search
  (aliases (<alias> ...))          ; Alternative names
  (exports (<module> <symbol> ...) ...)
  (modules (<name> "<file>" "<desc>") ...))

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View