discopy-categorical-computing
БесплатноБез исполняемых скриптовНе проверенCategory theory for compositional computing with string diagrams, quantum circuits, and QNLP. Covers monoidal categories, functors, tensor evaluation, and…
от HermeticOrmus★ 83 звезды на GitHubОб этом скилле
Discopy: Categorical Computing with String Diagrams
When to Use This Skill
Use Discopy when you need:
- Compositional Systems: Building modular systems with formal composition guarantees
- Quantum NLP (QNLP): Converting natural language to quantum circuits via categorical semantics
- Diagrammatic Reasoning: Visual representation of computational flows with mathematical rigor
- Tensor Network Computation: Abstract tensor operations with multiple backend support
- Categorical Quantum Mechanics: Designing and optimizing quantum circuits categorically
- Research Prototyping: Rapid experimentation with compositional models
- Category Theory Education: Executable mathematical concepts with visualization
Sweet Spot: Research at the mathematics-computer science interface, QNLP experiments, compositional semantics modeling, and educational tools for category theory.
Not For: Production NLP systems (use spaCy/Transformers), large-scale quantum compilation (use Qiskit/Cirq), or standard ML pipelines (use PyTorch/scikit-learn).
Core Concepts
The Big Picture: Information Plumbing
Discopy treats computation as information flow through typed channels:
- Wires = Types (information channels)
- Boxes = Operations (transformations)
- Diagrams = Compositions (pipelines)
- Functors = Interpretations (semantics)
Text → Parse → Diagram → Functor → Tensor/Circuit → Evaluate → Result
Category Hierarchy
Category (objects + morphisms)
↓
Monoidal (>> sequential, @ parallel)
↓
Symmetric (swap wires)
↓
Rigid (duals)
↓
Compact (cups/caps)
↓
Traced (feedback loops)
Each level adds capabilities while maintaining composition guarantees.
Key Operations
# Sequential composition (then)
f >> g # "f then g"
# Parallel composition (and)
f @ g # "f and g simultaneously"
# Dagger (adjoint/inverse)
f.dagger()
# Tensor product
f.tensor(g)
# Feedback
f.feedback()
Quick Start
Installation
# Basic installation
pip install discopy
# With quantum features
pip install discopy[quantum]
# With all backends
pip install discopy[pytorch,tensorflow,jax]
Hello World: Simple Composition
from discopy import Ty, Box
# Define types (objects)
x = Ty('X')
y = Ty('Y')
z = Ty('Z')
# Define operations (morphisms)
f = Box('f', x, y) # f: X → Y
g = Box('g', y, z) # g: Y → Z
# Sequential composition
diagram = f >> g # X → Y → Z
# Parallel composition
parallel = f @ g # X⊗Y → Y⊗Z
# Visualize
diagram.draw()
Tensor Evaluation
from discopy.matrix import Functor
import numpy as np
# Define semantics
F = Functor(
ob={x: 2, y: 3, z: 4}, # Dimensions
ar={
f: np.random.rand(3, 2), # Y=3, X=2
g: np.random.rand(4, 3) # Z=4, Y=3
}
)
# Evaluate
result = F(diagram)
print(result.array.shape) # (4, 2)
Quantum Circuit
from discopy.quantum.circuit import Circuit, gates
# Build circuit
circuit = (
gates.H @ Circuit.id(1) # Hadamard on qubit 0
>> gates.CNOT # CNOT on qubits 0,1
>> gates.Rx(0.5) @ gates.Ry(0.3) # Rotations
)
# Visualize
circuit.draw()
# Export to other frameworks
qiskit_circuit = circuit.to_qiskit()
Progressive Disclosure: 7-Level Framework
DisCoPy follows a 7-level progression from simple pipelines to formally verified systems.
Level 1: Novice - Sequential Composition
→ EXAMPLES-L1-L2.md - Basic >> pipelines
- Core: Chain operations sequentially
- Use Cases: ETL, image preprocessing, API chains
- Examples: 5 complete implementations with diagrams
Level 2: Competent - Parallel Composition + Functors
→ EXAMPLES-L1-L2.md - Parallel @ + evaluation
- Core: Parallel operations, concrete tensor evaluation
- Use Cases: Ensemble ML, feature extraction, backend selection
- Examples: 7 complete implementations with NumPy/PyTorch
Level 3: Proficient - Symmetric Monoidal (Wire Swapping)
→ EXAMPLES-L3-L4.md - Diagram.swap() for routing
- Core: Type-aware composition, argument reordering
- Use Cases: Microservices routing, flexible composition
- Examples: 5 complete implementations with braiding
Level 4: Advanced - Compact Closed (Quantum)
→ EXAMPLES-L3-L4.md - Cups, caps, quantum circuits
- Core: Duality, entanglement, QNLP
- Use Cases: Quantum computing, quantum NLP
- Examples: 7 complete quantum circuit implementations
Level 5: Expert - Traced Monoidal (Feedback Loops)
→ EXAMPLES-L5-L7.md - .trace() for state feedback
- Core: RNNs, iterative algorithms, stateful work
Установить discopy-categorical-computing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл discopy-categorical-computing?
Category theory for compositional computing with string diagrams, quantum circuits, and QNLP. Covers monoidal categories, functors, tensor evaluation, and practical applications in quantum natural language processing and diagrammatic reasoning.
Как установить скилл discopy-categorical-computing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл discopy-categorical-computing запускает скрипты?
Нет, скилл состоит только из инструкций (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