homoiconic-rewriting
БесплатноБез исполняемых скриптовНе проверенUnified homoiconic graph rewriting - λ-calculus, interaction nets, ACSets, CUDA parallelism
от plurigrid★ 73 звезды на GitHubОб этом скилле
Homoiconic Rewriting
Code = Data = Graph = Parallel Reduction
Trit: 0 (ERGODIC - coordinates the stack)
Core Synthesis
┌─────────────────────────────────────────────────────────────────┐
│ HOMOICONIC REWRITING PIPELINE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ λ-term ──quote──→ S-exp ──parse──→ INet ──CUDA──→ Result │
│ │ │ │ │ │
│ typed data graph parallel │
│ code (homoiconic) rewriting reduction │
│ │
└─────────────────────────────────────────────────────────────────┘
GF(3) Balanced Dependencies
| Trit | Skill | Role |
|---|---|---|
| +1 | lambda-calculus |
Term generation |
| +1 | gay-mcp |
Color generation |
| 0 | interaction-nets |
Parallel coordination |
| 0 | lispsyntax-acset |
Data bridge |
| -1 | algebraic-rewriting |
Rule validation |
| -1 | slime-lisp |
Evaluation sink |
Sum: (+1+1) + (0+0) + (-1-1) = 0 ✓
The Homoiconic Property
Level 1: S-expressions (Lisp)
;; Code
(+ 1 2)
;; Data (same representation!)
'(+ 1 2)
;; Transform code as data
(map inc '(+ 1 2)) ; → (1 2 3)
Level 2: Interaction Nets (Graphs)
Code (λ-term): Data (graph): Rewrite (reduction):
λx. x x ┌───┐ ┌───┐ ┌───┐
│ λ │──┬──┐ │ @ │─────│ @ │
└─┬─┘ │ │ └─┬─┘ └─┬─┘
│ │ │ │ │
┌─┴─┐ │ │ → └────┬────┘
│ @ │──┘ │ │
└─┬─┘ │ result
└───────┘
Level 3: ACSets (Algebraic Databases)
# Code: rewrite rule
rule = Rule(L, K, R)
# Data: same representation!
rule_data = @acset RuleSchema begin
L = [...]; K = [...]; R = [...]
end
# Transform rules as data
composed_rule = compose_rules(rule1, rule2)
Key Algorithms
1. λ → Interaction Net Compilation
function compile_lambda_to_inet(term::LambdaTerm)::InteractionNet
match term
Var(x) => wire_to(x)
Lam(x, body) => agent(:λ, [x], compile(body))
App(f, arg) => agent(:@, [compile(f), compile(arg)])
end
end
2. Parallel Reduction (CUDA-ready)
function parallel_reduce!(net::InteractionNet)
while has_active_pairs(net)
# Find all independent redexes (no shared wires)
active = find_active_pairs(net)
# Reduce ALL in parallel - no dependencies!
@cuda threads=length(active) reduce_kernel!(net, active)
end
end
3. ACSet Rewriting (DPO)
using AlgebraicRewriting
# L ← K → R (span defines rule)
rule = Rule(
L = @acset Graph begin V=2; E=1; src=[1]; tgt=[2] end,
K = @acset Graph begin V=1 end,
R = @acset Graph begin V=1; E=1; src=[1]; tgt=[1] end # self-loop
)
# Apply via double pushout
result = rewrite(rule, graph, match)
CUDA Integration (Groote et al.)
GPU Kernel for Active Pair Reduction
__global__ void reduce_active_pairs(
Agent* agents,
Wire* wires,
int* active_pairs,
int n_active
) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx >= n_active) return;
int pair_id = active_pairs[idx];
Agent* a1 = &agents[wires[pair_id].from];
Agent* a2 = &agents[wires[pair_id].to];
// Dispatch by agent types
if (a1->type == CONSTRUCTOR && a2->type == CONSTRUCTOR) {
annihilate(a1, a2, wires);
} else if (a1->type == CONSTRUCTOR && a2->type == DUPLICATOR) {
commute(a1, a2, wires, agents);
} else if (a1->type == ERASER) {
erase(a1, a2, wires);
}
}
Performance (from Eindhoven team)
| Benchmark | CPU | GPU (RTX 3090) | Speedup |
|---|---|---|---|
| Fibonacci(30) | 2.4s | 0.08s | 30x |
| Tree reduction | 5.1s | 0.12s | 42x |
| λ-calculus eval | 1.2s | 0.05s | 24x |
Typed Decomposition
Simply Typed λ-Calculus → Linear Logic → Interaction Nets
Type System Linear Logic Interaction Net
──────────── ──────────── ───────────────
A → B !A ⊸ B λ-agent + !-box
A × B A ⊗ B Constructor pair
A + B A ⊕ B Case agent
GF(3) Type Assignment
# Types carry trits
struct TypedTerm
term::LambdaTerm
type::SimpleType
trit::Int # -1, 0, +1
end
# Conservation: well-typed terms have balanced trits
function check_gf3(t::TypedTerm)::Bool
sum_trits(t) % 3 == 0
end
Practical Commands
# Parse λ-term to S-expression
echo "(lambda (x) (x x))" | bb -e '(read)'
#
Установить homoiconic-rewriting в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл homoiconic-rewriting?
Unified homoiconic graph rewriting - λ-calculus, interaction nets, ACSets, CUDA parallelism
Как установить скилл homoiconic-rewriting?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл homoiconic-rewriting запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic