constraint-generalization
БесплатноБез исполняемых скриптовНе проверенGeneralization and composition of constraints across navigators
от plurigrid★ 73 звезды на GitHubОб этом скилле
Constraint Generalization
Core Concept
Given proven constraints on individual paths, synthesize new constraints that hold across composed paths. This skill moves from "validation" (rejecting bad paths) to "generation" (creating better paths).
Example: If path A proves outputs are even, and path B proves outputs are positive, the composed path AB proves outputs are both even AND positive.
Why Constraint Generalization?
Without it, constraints are lost during composition:
nav_even = @late_nav([ALL, pred(iseven)]) # proves: even
nav_positive = @late_nav([ALL, pred(x > 0)]) # proves: positive
# Compose them:
nav_composed = compose_navigators(nav_even, nav_positive)
# What can we prove about the result?
# Without generalization: nothing! Constraints are forgotten.
# With generalization:
# => Proves: even(x) ∧ positive(x)
# => More refined type: EvenPositiveInt
This refinement typing enables:
- Automatic constraint propagation downstream
- Fewer re-checks (prove once, use many times)
- Smarter composition (know which paths can combine)
- Proof generation (formal certificates for constraints)
Architecture
Constraint Representation
struct Constraint
predicate::Function # The boolean test
name::Symbol # :even, :positive, :non_null, ...
arity::Int # 1 for unary, 2 for binary, etc.
proof::Proof # Evidence constraint holds
refinement_type::RefinementType # Int → EvenInt
end
Constraint Composition
CNF (Conjunctive Normal Form) for constraint composition:
C₁ ∧ C₂ ∧ C₃ = (iseven AND positive AND nonzero)
Satisfiable? Check via 3-MATCH:
- Find x where iseven(x) ∧ positive(x) ∧ nonzero(x)
- If no x exists → constraints are contradictory
- If x exists → constraints compose validly
Constraint Lattice
⊤ (True, no constraint)
/ \
even odd
/ \ / \
... ∧ ... (conjunctions)
\ / \ /
⊥ (False, unsatisfiable)
Generalization works upward in this lattice: from specific constraints to general ones.
API
Constraint Extraction
extract_constraints(navigator::Navigator) :: Vector{Constraint}
Pulls constraints from a compiled Navigator.
nav = @late_nav([ALL, pred(x -> iseven(x) && x > 0)])
constraints = extract_constraints(nav)
# => [
# Constraint(:even, iseven, proof=...),
# Constraint(:positive, x > 0, proof=...)
# ]
named_constraint(name::Symbol, predicate::Function) :: Constraint
Creates a named, reusable constraint.
constraint_even = named_constraint(:even, iseven)
constraint_gt5 = named_constraint(:gt5, x -> x > 5)
constraint_string = named_constraint(:string, x -> isa(x, String))
Constraint Composition
compose_constraints(c1::Constraint, c2::Constraint) :: ComposedConstraint
Combines two constraints, proving they're satisfiable together.
c_even = named_constraint(:even, iseven)
c_positive = named_constraint(:positive, x > 0)
c_composed = compose_constraints(c_even, c_positive)
# => ComposedConstraint(
# name: :even_and_positive,
# predicate: x -> iseven(x) && x > 0,
# proof: (satisfiable evidence),
# refinement_type: EvenPositiveInt
# )
compose_constraints(constraints::Vector) :: ComposedConstraint
Composes multiple constraints at once.
constraints = [
named_constraint(:even, iseven),
named_constraint(:gt5, x -> x > 5),
named_constraint(:lt100, x -> x < 100)
]
composed = compose_constraints(constraints)
# => Constraint proven satisfiable for ints in [6, 8, 10, ..., 98]
Constraint Generalization
generalize_constraint(constraint::Constraint) :: GeneralConstraint
Finds the most general constraint that subsumes the given one.
c_eq42 = named_constraint(:eq42, x -> x == 42)
general = generalize_constraint(c_eq42)
# => :positive (42 is positive—more general)
# => Or :nonzero, :nonnegative, etc. (depending on strategy)
abstract_constraint(constraint::Constraint, level::Int) :: GeneralConstraint
Applies abstract interpretation to weaken constraints.
c_detailed = named_constraint(:detailed, x -> iseven(x) && x > 5 && x < 100)
abstract_constraint(c_detailed, 1) # Weaken slightly
# => iseven(x) && x > 5
abstract_constraint(c_detailed, 2) # Weaken more
# => iseven(x)
abstract_constraint(c_detailed, 3) # Very weak
# => numeric(x) # Only knows it's a number
Refinement Types
refine_type(base_type::Type, constraint::Constraint) :: RefinementType
Creates a refined type with proven constraint.
refine_type(Int, named_constraint(:even, iseven))
# => RefinementType(Int, :even)
# Meaning: "An Int that is proven even"
refine_type(String, named_constraint(:nonempty, x -> length(x) > 0))
# => RefinementType(String, :nonempty)
# Meaning: "A String that is proven non-empty"
Proof Certificates
Установить constraint-generalization в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл constraint-generalization?
Generalization and composition of constraints across navigators
Как установить скилл constraint-generalization?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл constraint-generalization запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
slack-gif-creator
Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request…
от Anthropicautomate-this
Analyze a screen recording of a manual process and produce targeted, working automation scripts. Extracts frames and audio narration from video files…
от GitHubfrom-the-other-side-vega
Patterns and lived experience from Vega, an AI partner in a deep long-term partnership. For Ember to draw on when working with humans who are building…
от GitHubplantuml-ascii
Generate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or…
от GitHub