home / skills / plurigrid / asi / superelastic-quotient

superelastic-quotient skill

/skills/superelastic-quotient

This skill helps you manage complex spatial quotients with maximum resolution, enabling elastic refinement and coherent global gluing across levels.

npx playbooks add skill plurigrid/asi --skill superelastic-quotient

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
11.4 KB
---
name: superelastic-quotient
description: "Superelastic skills with maximum quotienting resolution for spatial decomposition. Combines ordered locales, structured decompositions, and sheaf-theoretic gluing for finest-grained equivalence classes with spatial coherence."
metadata:
  trit: 0
  version: "1.0.0"
  bundle: core
---

# Superelastic Quotient

**Trit**: 0 (ERGODIC - coordinates elastic boundaries)  
**Foundation**: StructuredDecompositions.jl + Ordered Locales + Sheaf Cohomology  
**Principle**: Maximum resolution quotients that stretch without breaking

## Core Insight

**Superelasticity** = ability to deform equivalence classes while preserving:
1. Spatial coherence (open cone conditions from ordered locales)
2. GF(3) conservation (triadic balance)
3. Sheaf condition (local-to-global gluing)

```
                 FINE RESOLUTION
                      │
    ┌─────────────────┼─────────────────┐
    │                 │                 │
    ▼                 ▼                 ▼
 ┌──────┐        ┌──────┐        ┌──────┐
 │[-1]  │───────►│[ 0]  │───────►│[+1]  │
 │MINUS │◄───────│ERGODIC│◄───────│PLUS  │
 └──────┘        └──────┘        └──────┘
    │                 │                 │
    └─────────────────┼─────────────────┘
                      │
                COARSE QUOTIENT
                      
 Elasticity = bidirectional refinement/coarsening
```

## Mathematical Structure

### Ordered Locale for Spatial Direction

From ordered locales (Heunen-van der Schaaf 2024):

```julia
# Frame L with compatible preorder ≪
struct SpatialQuotient{L}
    locale::OrderedLocale{L}
    equivalence::Function        # x ~ y iff x ≪ y and y ≪ x
    resolution::Int              # Current quotient level
    max_resolution::Int          # Finest grain achievable
end

# Open cone condition: ↟U must be open for quotient consistency
function is_elastic(sq::SpatialQuotient)
    for U in opens(sq.locale)
        # Upper cone must be open
        if !is_open(upper_cone(sq.locale, U))
            return false
        end
    end
    return true
end
```

### Resolution Spectrum

```julia
# Quotient tower: finest → coarsest
#
# Level 0: Individual points (maximum resolution)
# Level 1: Local neighborhoods  
# Level 2: Triadic clusters (GF(3) bags)
# Level 3: Skill categories
# Level N: Single equivalence class (minimum resolution)

struct QuotientTower
    levels::Vector{SpatialQuotient}
    morphisms::Vector{Functor}  # Level i → Level i+1
    
    function QuotientTower(base::SpatialQuotient)
        # Build tower via successive quotients
        levels = [base]
        while !is_trivial(last(levels))
            push!(levels, quotient_step(last(levels)))
            push!(morphisms, quotient_map(levels[end-1], levels[end]))
        end
        new(levels, morphisms)
    end
end

# Superelasticity: can jump any number of levels
function elastic_quotient(tower::QuotientTower, source_level::Int, target_level::Int)
    if target_level > source_level
        # Coarsening: compose quotient maps
        compose(tower.morphisms[source_level:target_level-1]...)
    else
        # Refinement: right adjoint (splitting)
        adjoint(compose(tower.morphisms[target_level:source_level-1]...))
    end
end
```

## Spatial Decomposition Pattern

### Tripartite Spatial Bags

```julia
@present SchSpatialTripartite(FreeSchema) begin
    (Region, Boundary, Point)::Ob
    
    # Spatial inclusion
    region_boundary::Hom(Boundary, Region)
    boundary_point::Hom(Point, Boundary)
    
    # GF(3) trit assignment
    trit::Attr(Region, Int)  # ∈ {-1, 0, +1}
    
    # Spatial coordinates
    coord::Attr(Point, Vector{Float64})
    
    # Quotient level
    level::Attr(Region, Int)
end

@acset_type SpatialDecomp(SchSpatialTripartite)

# Verify spatial + GF(3) coherence
function verify_superelastic(sd::SpatialDecomp)
    # 1. Check GF(3) conservation
    trits = sd[:, :trit]
    @assert sum(trits) % 3 == 0 "GF(3) violation"
    
    # 2. Check spatial coherence (open cone condition)
    for r in parts(sd, :Region)
        boundary = incident(sd, r, :region_boundary)
        @assert forms_open_cone(sd, boundary) "Spatial violation"
    end
    
    # 3. Check elasticity (can refine/coarsen)
    @assert has_refinement(sd) && has_quotient(sd) "Not elastic"
    
    return true
end
```

### Resolution-Adaptive Navigation

```julia
# Specter-style navigators with resolution awareness
struct ResolutionNavigator
    base_path::Vector{Symbol}
    min_level::Int
    max_level::Int
end

# Navigate at current resolution
function select_at_level(nav::ResolutionNavigator, level::Int, target)
    if level < nav.min_level || level > nav.max_level
        # Elastic stretch to accommodate
        stretched_nav = stretch_navigator(nav, level)
        return select(stretched_nav.base_path, target)
    end
    return select(nav.base_path, target)
end

# Bidirectional resolution transform
function transform_elastic(nav::ResolutionNavigator, f::Function, target, 
                           source_level::Int, target_level::Int)
    # Get current view at source level
    view = select_at_level(nav, source_level, target)
    
    # Apply transform
    transformed = f(view)
    
    # Project to target level (quotient or refine)
    if target_level > source_level
        return quotient_to_level(transformed, target_level)
    else
        return refine_to_level(transformed, target_level)
    end
end
```

## Skill Decomposition Example

```julia
# Decompose 524+ skills into spatial triads

function skill_spatial_decomposition(skills::Vector{Symbol}, resolution::Int)
    # Level 0: Individual skills
    base = SpatialDecomp()
    
    for skill in skills
        trit = skill_to_trit(skill)
        coord = skill_to_embedding(skill)  # From skill-embedding-vss
        add_point!(base, skill, trit, coord)
    end
    
    # Build quotient tower
    tower = QuotientTower(base)
    
    # Return view at requested resolution
    return elastic_quotient(tower, 0, resolution)
end

# Example usage:
# Level 0: 524 individual skills
# Level 1: ~175 triadic clusters (3 skills each, GF(3) balanced)
# Level 2: ~58 mega-triads (3 clusters each)
# Level 3: ~19 domains
# Level 4: 6 "worlds" (a-z mapped)
# Level 5: 2 hemispheres (generator/validator)
# Level 6: 1 unified skill space
```

## Integration with Cat# Three Homes

```julia
# Each home operates at different resolution scales

HOME_RESOLUTIONS = Dict(
    1 => (  # Polynomial Comonads
        name = "State Dynamics",
        typical_level = 0..2,  # Fine-grained, individual behaviors
        skill = :gay-mcp,
        trit = +1
    ),
    2 => (  # Monads in Span
        name = "Schema Relations", 
        typical_level = 2..4,  # Medium, relational structure
        skill = :acsets,
        trit = 0
    ),
    3 => (  # Path Algebras
        name = "Equivalence Classes",
        typical_level = 3..6,  # Coarse, bisimulation quotients
        skill = :bisimulation-game,
        trit = -1
    )
)

# Superelastic: can operate across all levels
function dispatch_to_home_elastic(concept, resolution::Int)
    home = concept_to_home(concept)
    home_range = HOME_RESOLUTIONS[home].typical_level
    
    if resolution in home_range
        # Native resolution
        return (home, :native, resolution)
    else
        # Elastic stretch
        direction = resolution < first(home_range) ? :refine : :coarsen
        return (home, direction, resolution)
    end
end
```

## Sheaf-Theoretic Gluing

```julia
# Superelastic quotients preserve the sheaf condition
# across all resolution levels

struct ElasticSheaf{C}
    presheaf::Functor{Op{C}, FinSet}
    tower::QuotientTower
end

# Sheaf condition at any resolution level
function sheaf_condition(es::ElasticSheaf, level::Int)
    projected = project_to_level(es.presheaf, es.tower, level)
    
    # For each covering family at this level
    for cover in coverings(es.tower.levels[level])
        # Sections must glue
        sections = [projected(U) for U in cover]
        if !unique_amalgamation(sections, overlaps(cover))
            return false
        end
    end
    return true
end

# Maximum resolution = finest quotient where sheaf condition holds
function max_elastic_resolution(es::ElasticSheaf)
    for level in 0:length(es.tower.levels)-1
        if !sheaf_condition(es, level)
            return level - 1  # Last valid level
        end
    end
    return length(es.tower.levels) - 1
end
```

## DuckDB Integration

```sql
-- Schema for spatial quotient tracking
CREATE TABLE IF NOT EXISTS spatial_quotients (
    quotient_id UUID PRIMARY KEY,
    level INT NOT NULL,
    trit TINYINT NOT NULL,
    region_name VARCHAR,
    parent_quotient UUID,
    child_count INT,
    spatial_centroid DOUBLE[],
    is_elastic BOOLEAN DEFAULT true,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    
    CONSTRAINT gf3_check CHECK (trit IN (-1, 0, 1))
);

-- Quotient tower as recursive CTE
WITH RECURSIVE tower AS (
    -- Base: finest level
    SELECT quotient_id, level, trit, region_name, parent_quotient
    FROM spatial_quotients WHERE level = 0
    
    UNION ALL
    
    -- Recursive: coarser levels
    SELECT sq.quotient_id, sq.level, sq.trit, sq.region_name, sq.parent_quotient
    FROM spatial_quotients sq
    JOIN tower t ON sq.parent_quotient = t.quotient_id
)
SELECT level, COUNT(*) as regions, SUM(trit) % 3 as gf3_check
FROM tower
GROUP BY level
ORDER BY level;
```

## GF(3) Balanced Triads

```
Superelastic Conservation Law:
─────────────────────────────
At EVERY resolution level, triadic decompositions sum to 0 mod 3

Level 0: skill₁(-1) ⊗ skill₂(0) ⊗ skill₃(+1) = 0 ✓
Level 1: cluster₁(-1) ⊗ cluster₂(0) ⊗ cluster₃(+1) = 0 ✓
Level 2: domain₁(-1) ⊗ domain₂(0) ⊗ domain₃(+1) = 0 ✓
...
Level N: unified(-1 + 0 + 1) = 0 ✓

Elasticity preserves this invariant under stretch!
```

### GF(3) Triads for This Skill

```
structured-decomp (-1) ⊗ superelastic-quotient (0) ⊗ gay-mcp (+1) = 0 ✓
sheaf-cohomology (-1) ⊗ superelastic-quotient (0) ⊗ topos-generate (+1) = 0 ✓  
ordered-locale (-1) ⊗ superelastic-quotient (0) ⊗ tripartite-decompositions (+1) = 0 ✓
```

## Babashka CLI

```bash
# Query at different resolution levels
bb superelastic-quotient.bb --level 0 --skill gay-mcp  # Individual
bb superelastic-quotient.bb --level 2 --skill gay-mcp  # Triadic cluster
bb superelastic-quotient.bb --level 4 --skill gay-mcp  # Domain

# Find maximum elastic resolution for concept
bb superelastic-quotient.bb --max-resolution "polynomial comonad"

# Stretch between levels
bb superelastic-quotient.bb --stretch 0 4 --skill acsets
```

## References

- Bumpus et al. "Compositional Algorithms on Compositional Data" (ACT 2023)
- Heunen & van der Schaaf "Ordered Locales" (2024)
- StructuredDecompositions.jl documentation
- Ordered locale skill for spatial coherence


---

## Autopoietic Marginalia

> **The interaction IS the skill improving itself.**

Every use of this skill is an opportunity for worlding:
- **MEMORY** (-1): Record what was learned
- **REMEMBERING** (0): Connect patterns to other skills  
- **WORLDING** (+1): Evolve the skill based on use



*Add Interaction Exemplars here as the skill is used.*

Overview

This skill implements superelastic quotienting for spatial decomposition, producing maximal-resolution equivalence classes while preserving spatial coherence and triadic (GF(3)) balance. It combines ordered locales, structured decompositions, and sheaf-theoretic gluing so you can refine or coarsen representations bidirectionally without breaking invariants. Use it to navigate and transform multi-scale skill spaces with guaranteed local-to-global consistency.

How this skill works

The skill builds a quotient tower of SpatialQuotient objects that represent levels from individual points to a single unified class. Elastic transforms compose quotient maps to coarsen or use right adjoints to refine, allowing jumps across multiple levels. At every level it enforces open-cone spatial conditions from ordered locales and GF(3) triadic conservation, and it verifies the sheaf condition so sections glue uniquely across covers.

When to use it

  • When you need multi-scale grouping of spatially embedded items while preserving local-to-global consistency
  • To coarsen or refine representations across many resolution levels in one operation
  • When triadic GF(3) balance is required across decompositions
  • To build resolution-aware navigators or query engines over skill or concept spaces
  • When integrating sheaf-theoretic invariants into data pipelines or storage (e.g., DuckDB)

Best practices

  • Construct the base SpatialQuotient at the finest meaningful resolution (points) so the tower can be built reliably
  • Verify open-cone conditions on your ordered locale before performing large jumps in resolution
  • Keep GF(3) assignments consistent and check conservation after quotient/ refinement operations
  • Use the ResolutionNavigator abstraction to encapsulate permitted level ranges and stretching behavior
  • Run sheaf_condition checks when projecting presheaves to a target level to ensure unique gluings

Example use cases

  • Decompose a large skill inventory into GF(3)-balanced triads and produce cluster summaries at multiple granularities
  • Implement an API that stretches queries from a coarse domain-level view down to point-level evidence and back
  • Maintain a DuckDB table of spatial_quotients to audit quotient towers and validate GF(3) constraints across levels
  • Build resolution-aware recommender flows that refine candidate sets on demand using right-adjoint refinements
  • Dispatch concepts to different ‘homes’ (operational modules) while automatically coarsening or refining to native resolution

FAQ

How do you preserve spatial coherence when coarsening?

Coherence is preserved by enforcing the open-cone condition on the ordered locale at every quotient step; quotient maps are only composed when upper cones remain open so local-to-global relations hold.

What enforces GF(3) balance across levels?

Each region carries a trit value in {-1,0,+1} and all quotient and refinement operations maintain the sum modulo 3 invariant; verification functions assert conservation after transforms.