Skip to content
linear-logic logo

linear-logic Skill

linear-logic

Linear Logic Skill

SKILL.md

Full skill instructions

linear-logic Skill

"Every resource used exactly once. No copying. No discarding. Pure computation."

Overview

Linear Logic implements Girard's linear logic for resource-aware computation. Linear types ensure resources are used exactly once, enabling safe concurrency and optimal memory management.

GF(3) Role

AspectValue
Trit-1 (MINUS)
RoleVALIDATOR
FunctionValidates resource usage constraints

Connectives

┌─────────────────────────────────────────────────────────────────┐
│                    LINEAR LOGIC CONNECTIVES                     │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Multiplicative:              Additive:                        │
│                                                                 │
│  A ⊗ B  (tensor)              A ⊕ B  (plus/​choice)             │
│  A ⅋ B  (par)                 A & B  (with/​product)            │
│  1      (unit)                0      (zero)                    │
│  ⊥      (bottom)              ⊤      (top)                     │
│                                                                 │
│  Exponential:                 Negation:                        │
│                                                                 │
│  !A     (of course)           A⊥     (linear negation)         │
│  ?A     (why not)                                              │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Resource Semantics

-- Linear type: must be used exactly once
data Linear a where
    Use :: a -> Linear a

-- Consume: takes ownership, returns result
consume :: Linear a -> (a -> b) -> b
consume (Use x) f = f x

-- Cannot duplicate linear values!
-- duplicate :: Linear a -> (Linear a, Linear a)  -- FORBIDDEN

-- Cannot discard linear values!
-- discard :: Linear a -> ()  -- FORBIDDEN

Proof Net Representation

      ┌───────────────────────────────────────┐
      │          PROOF NET STRUCTURE          │
      └───────────────────────────────────────┘

      A ⊗ B ⊸ C               A ⅋ (B ⊸ C)
         │                         │
      ┌──┴──┐                  ┌───┴───┐
      │  ⊗  │                  │   ⅋   │
      └──┬──┘                  └───┬───┘
       ╱   ╲                     ╱   ╲
      A     B                   A    B⊸C
             ╲                        │
              ╲                   ┌───┴───┐
               ╲                  │   ⊸   │
                ╲                 └───┬───┘
                 C                  ╱   ╲
                                   B     C

Linear Types in Rust

// Rust's ownership = linear types!
fn linear_example() {
    let resource = acquire_resource();  // Linear resource

    // resource can only be used once
    consume(resource);

    // This would fail to compile:
    // consume(resource);  // ERROR: use of moved value

    // This would also fail:
    // drop(resource);     // ERROR: use of moved value
}

// Affine types (can discard but not duplicate)
fn affine_example() {
    let resource = acquire_resource();

    // Can choose to not use it (drop implicitly)
    // But cannot use twice
}

GF(3) Linear Validation

class LinearValidator:
    """Validate linear resource usage with GF(3)."""

    TRIT = -1  # VALIDATOR role

    def validate_usage(self, program) -> bool:
        """
        Check that all linear resources are used exactly once.

        Returns True if program is linearly valid.
        """
        resources = self.extract_linear_resources(program)
        usage_counts = self.count_usages(program, resources)

        for resource, count in usage_counts.items():
            if count != 1:
                return False  # Used 0 times or >1 times

        return True

    def validate_proof_net(self, net) -> bool:
        """
        Check proof net validity via Danos-Regnier criterion.

        A proof net is valid iff:
        - It's connected
        - Switching gives acyclic graph
        """
        for switching in self.all_switchings(net):
            if self.has_cycle(switching):
                return False
            if not self.is_connected(switching):
                return False
        return True

Exponentials: Controlled Non-Linearity

-- !A means "unlimited copies of A"
-- ?A means "can be discarded"

-- Promotion: introduce !
promote :: a -> !a

-- Dereliction: use one copy
derelict :: !a -> a

-- Contraction: duplicate
contract :: !a -> (!a, !a)

-- Weakening: discard
weaken :: !a -> ()

-- The exponential modality allows escape from linearity
-- but must be explicitly introduced

Curry-Howard Correspondence

Linear LogicProgramming
A ⊗ BPair (both available)
A ⅋ BSession type (one waits)
A ⊸ BLinear function
!AUnlimited resource
?ADiscardable resource
A ⊕ BChoice (select one)
A & BOffer (provide both)

Session Types

(* Session types = linear logic for protocols *)

type 'a send = Send of 'a
type 'a recv = Recv of 'a
type close = Close

(* Protocol: send int, receive bool, close *)
type protocol = int send * bool recv * close

(* Dual: receive int, send bool, close *)
type dual_protocol = int recv * bool send * close

(* Session types ensure protocol compliance! *)
let server : dual_protocol -> unit =
  fun session ->
    let n = receive session in       (* Must receive *)
    send session (n > 0);            (* Must send *)
    close session                     (* Must close *)

GF(3) Triads

linear-logic (-1) ⊗ interaction-nets (0) ⊗ hvm-runtime (+1) = 0 ✓
linear-logic (-1) ⊗ datalog-fixpoint (0) ⊗ lambda-calculus (+1) = 0 ✓
linear-logic (-1) ⊗ session-types (0) ⊗ discopy (+1) = 0 ✓

Commands

# Check linear validity
just linear-check program.linear

# Verify proof net
just linear-proofnet proof.net --criterion danos-regnier

# Session type check
just session-typecheck protocol.ml

# Convert to interaction net
just linear-to-inet proof.net -o output.inet

Skill Name: linear-logic Type: Logic / Type Theory Trit: -1 (MINUS - VALIDATOR) GF(3): Validates resource usage constraints

Scientific Skill Interleaving

This skill connects to the K-Dense-AI/​claude-scientific-skills ecosystem:

Graph Theory

  • networkx [○] via bicomodule
    • Universal graph hub

Bibliography References

  • linear-algebra: 112 citations in bib.duckdb

Cat# Integration

This skill maps to Cat# = Comod(P) as a bicomodule in the Prof home:

Trit: 0 (ERGODIC)
Home: Prof (profunctors/​bimodules)
Poly Op: ⊗ (parallel composition)
Kan Role: Adj (adjunction bridge)

GF(3) Naturality

The skill participates in triads where:

(-1) + (0) + (+1) ≡ 0 (mod 3)

This ensures compositional coherence in the Cat# equipment structure.

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View