lambda-calculus
БесплатноБез исполняемых скриптовНе проверенLambda Calculus Skill
от plurigrid★ 73 звезды на GitHubОб этом скилле
lambda-calculus Skill
"Three rules. Infinite computation. The foundation of all functional programming."
Overview
Lambda Calculus implements Church's lambda calculus, the mathematical foundation of functional programming. Variables, abstraction, and application - that's all you need.
GF(3) Role
| Aspect | Value |
|---|---|
| Trit | +1 (PLUS) |
| Role | GENERATOR |
| Function | Generates terms and reductions |
The Three Rules
┌─────────────────────────────────────────────────────────────────┐
│ LAMBDA CALCULUS SYNTAX │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Term ::= x Variable │
│ | λx. Term Abstraction (function definition) │
│ | Term Term Application (function call) │
│ │
│ That's it. Everything else is encoded. │
│ │
└─────────────────────────────────────────────────────────────────┘
β-Reduction
The only computation rule:
(λx. M) N →β M[x := N]
"Apply function λx.M to argument N by substituting N for x in M"
Example:
(λx. x x) (λy. y)
→β (λy. y) (λy. y)
→β λy. y
Church Encodings
-- Booleans
true = λt. λf. t
false = λt. λf. f
if = λb. λt. λf. b t f
-- Numbers (Church numerals)
zero = λf. λx. x
one = λf. λx. f x
two = λf. λx. f (f x)
three = λf. λx. f (f (f x))
succ = λn. λf. λx. f (n f x)
plus = λm. λn. λf. λx. m f (n f x)
mult = λm. λn. λf. m (n f)
-- Pairs
pair = λx. λy. λf. f x y
fst = λp. p (λx. λy. x)
snd = λp. p (λx. λy. y)
-- Lists
nil = λc. λn. n
cons = λh. λt. λc. λn. c h (t c n)
Fixed Point Combinator
-- Y combinator: enables recursion without recursion!
Y = λf. (λx. f (x x)) (λx. f (x x))
-- Y F = F (Y F)
-- This gives us recursion in a language without built-in recursion
-- Example: factorial
fact = Y (λf. λn. if (isZero n) one (mult n (f (pred n))))
Reduction Strategies
class LambdaReducer:
"""Different reduction strategies for lambda calculus."""
TRIT = 1 # GENERATOR role
def beta_reduce(self, term: Term, strategy: str) -> Term:
"""
Reduce term using specified strategy.
"""
if strategy == 'normal':
return self.normal_order(term)
elif strategy == 'applicative':
return self.applicative_order(term)
elif strategy == 'lazy':
return self.call_by_need(term)
elif strategy == 'parallel':
return self.parallel_reduce(term)
def normal_order(self, term: Term) -> Term:
"""
Leftmost-outermost reduction.
Always finds normal form if it exists.
"""
while True:
redex = self.find_leftmost_outermost(term)
if redex is None:
return term # Normal form
term = self.reduce_at(term, redex)
def applicative_order(self, term: Term) -> Term:
"""
Leftmost-innermost reduction.
May not terminate even if normal form exists.
"""
while True:
redex = self.find_leftmost_innermost(term)
if redex is None:
return term
term = self.reduce_at(term, redex)
def call_by_need(self, term: Term) -> Term:
"""
Lazy evaluation with sharing.
Optimal in many cases.
"""
return self.lazy_reduce_with_sharing(term)
De Bruijn Indices
Named: De Bruijn:
λx. λy. x y → λ. λ. 2 1
λx. λy. y x → λ. λ. 1 2
λx. x → λ. 1
Index n refers to the variable bound by the nth enclosing λ
No more α-equivalence problems!
Types (Simply Typed Lambda Calculus)
Types: τ ::= α | τ → τ
Typing rules:
Γ, x:τ ⊢ x : τ (Var)
Γ, x:σ ⊢ M : τ
───────────────── (Abs)
Γ ⊢ λx.M : σ → τ
Γ ⊢ M : σ → τ Γ ⊢ N : σ
──────────────────────────── (App)
Γ ⊢ M N : τ
GF(3) Term Classification
class GF3Lambda:
"""Classify lambda terms by GF(3) role."""
def classify(self, term: Term) -> int:
"""
GENERATOR (+1): Abstractions (create functions)
COORDINATOR (0): Applications (route computation)
VALIDATOR (-1): Variables (consume bindings)
"""
match term:
case Var(_):
return -1 # Consumes a binding
case Lam(_, body):
return 1 # Creates a function
case App(func, arg):
return 0 # Routes computation
def verify_conservation(self, term: Term) -> bool:
"""Check GF(3) conservation in term structure."""
def sum_trits(t):
m
Установить lambda-calculus в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл lambda-calculus?
Lambda Calculus Skill
Как установить скилл lambda-calculus?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл lambda-calculus запускает скрипты?
Нет, скилл состоит только из инструкций (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