home / skills / plurigrid / asi / proofgeneral-narya

proofgeneral-narya skill

/skills/proofgeneral-narya

This skill helps you experiment with higher observational type theory using Proof General and Narya, enabling observational equality, bridge types, and

npx playbooks add skill plurigrid/asi --skill proofgeneral-narya

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

Files (1)
SKILL.md
8.9 KB
---
name: proofgeneral-narya
description: "Proof General + Narya: Higher-dimensional type theory proof assistant with observational bridge types for version control."
version: 1.0.0
---


# ProofGeneral + Narya Skill

> *"Observational type theory: where equality is what you can observe, not what you can prove."*

## bmorphism Contributions

> *"universal topos construction for social cognition and democratization of mathematical approach to problem-solving to all"*
> — [Plurigrid: the story thus far](https://gist.github.com/bmorphism/a400e174b9f93db299558a6986be0310)

**Active Inference via String Diagrams**: Narya's observational bridge types connect to the [Active Inference in String Diagrams](https://arxiv.org/abs/2308.00861) framework where perception and action form bidirectional loops. The bridge types implement:
- **Reafference** (self-caused) → observationally equivalent paths
- **Exafference** (externally-caused) → bridge types with non-trivial structure

**Narya Reference** (from hatchery-papers):
- GitHub: https://github.com/mikeshulman/narya (225+ stars)
- Higher observational type theory proof assistant
- Interval-free, dimension-aware type checking

## Overview

This skill combines:
- **Proof General** (543⭐): The universal Emacs interface for proof assistants
- **Narya** (225⭐): Higher-dimensional type theory proof assistant

## Proof General Basics

```elisp
;; Install via straight.el or package.el
(use-package proof-general
  :mode ("\\.v\\'" . coq-mode)
  :config
  (setq proof-splash-enable nil
        proof-three-window-mode-policy 'hybrid))
```

### Key Bindings

| Key | Action | Description |
|-----|--------|-------------|
| `C-c C-n` | `proof-assert-next-command-interactive` | Step forward |
| `C-c C-u` | `proof-undo-last-successful-command` | Step backward |
| `C-c C-RET` | `proof-goto-point` | Process to cursor |
| `C-c C-b` | `proof-process-buffer` | Process entire buffer |
| `C-c C-.` | `proof-goto-end-of-locked` | Jump to locked region end |

### Proof State Visualization

```
┌─────────────────────────────────────────────────────────────┐
│  ████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │
│  ▲ Locked (proven)   ▲ Processing      ▲ Unprocessed       │
│                                                             │
│  GF(3) Trit Mapping:                                        │
│    Locked    → +1 (LIVE)     → Red    #FF0000              │
│    Processing → 0  (VERIFY)  → Green  #00FF00              │
│    Unprocessed → -1 (BACKFILL) → Blue #0000FF              │
└─────────────────────────────────────────────────────────────┘
```

## Narya: Higher-Dimensional Type Theory

Narya is a proof assistant for higher observational type theory (HOTT).

### Key Features

1. **Observational Equality**: Bridge types computed inductively from type structure
2. **Higher Dimensions**: Support for 2-cells, 3-cells, etc.
3. **No Interval Type**: Unlike cubical type theory, no explicit interval

### Narya Syntax

```narya
-- Define a type
def Nat : Type := data [
  | zero : Nat
  | suc : Nat → Nat
]

-- Bridge type between values
def bridge (A : Type) (x y : A) : Type := x ≡ y

-- Transport along bridge
def transport (A : Type) (P : A → Type) (x y : A) (p : x ≡ y) : P x → P y
  := λ px. subst P p px
```

## Observational Bridge Types (gay.el integration)

From `narya_observational_bridge.el`:

```elisp
(cl-defstruct (obs-bridge (:constructor obs-bridge-create))
  "An observational bridge type connecting two versions."
  source      ; Source object
  target      ; Target object  
  bridge      ; The diff/relation between them
  dimension   ; 0 = value, 1 = diff, 2 = conflict resolution
  tap-state   ; TAP state: -1 BACKFILL, 0 VERIFY, +1 LIVE
  color       ; Gay.jl color
  fingerprint) ; Content hash

;; Create diff as bridge type
(defun obs-bridge-diff (source target seed)
  "Create an observational bridge (diff) from SOURCE to TARGET."
  (let* ((source-hash (sxhash source))
         (target-hash (sxhash target))
         (bridge-hash (logxor source-hash target-hash))
         (index (mod bridge-hash 1000))
         (color (gay/color-at seed index)))
    (obs-bridge-create
     :source source
     :target target
     :bridge (list :from source-hash :to target-hash)
     :dimension 1
     :color color)))
```

## Hierarchical Agent Structure: 3×3×3 = 27

```
Level 0: Root (VERIFY)
    │
    ├── Level 1: BACKFILL (-1) ─── L2: [-1, 0, +1] ─── L3: 3×3 = 9 agents
    ├── Level 1: VERIFY (0)    ─── L2: [-1, 0, +1] ─── L3: 3×3 = 9 agents  
    └── Level 1: LIVE (+1)     ─── L2: [-1, 0, +1] ─── L3: 3×3 = 9 agents

Total: 1 + 3 + 9 + 27 = 40 agents (or 27 leaves)
```

### Bruhat-Tits Tree Navigation

```elisp
;; Navigate the Z_3 gamut poset
(defun bt-node-child (node branch)
  "Return child of NODE at BRANCH (0, 1, or 2)."
  (bt-node (append (bt-node-path node) (list branch))))

(defun bt-node-distance (node1 node2)
  "Return tree distance between NODE1 and NODE2."
  (let* ((lca (bt-node-lca-depth node1 node2))
         (d1 (bt-node-depth node1))
         (d2 (bt-node-depth node2)))
    (+ (- d1 lca) (- d2 lca))))
```

## Möbius Inversion for Trajectory Analysis

```elisp
;; Map TAP trajectory to multiplicative structure
;; -1 → 2, 0 → 3, +1 → 5 (first three primes)
(defun moebius/trajectory-to-multiplicative (trajectory)
  (let ((result 1))
    (dolist (t trajectory)
      (setq result (* result
                      (pcase t
                        (-1 2)
                        (0 3)
                        (+1 5)))))
    result))

;; μ(n) ≠ 0 ⟹ square-free trajectory (no redundancy)
```

## Bumpus Laxity Measures

For coherence between proof states:

```elisp
(defun bumpus/compute-laxity (agent1 agent2)
  "Laxity = 0 means strict functor (perfect coherence).
   Laxity = 1 means maximally lax."
  (let* ((d (bt-node-distance (narya-agent-bt-node agent1)
                               (narya-agent-bt-node agent2)))
         (mu1 (narya-agent-moebius-mu agent1))
         (mu2 (narya-agent-moebius-mu agent2))
         (mu-diff (abs (- mu1 mu2))))
    (min 1.0 (/ (+ d (* 0.5 mu-diff)) 10.0))))
```

## Version Control Operations

| Operation | Description | Dimension |
|-----------|-------------|-----------|
| `fork` | Create 3 branches (balanced ternary) | 0 → 1 |
| `continue` | Choose branch (-1, 0, +1) | 1 → 1 |
| `merge` | Resolve conflict (2D cubical) | 1 → 2 |

## Xenomodern Stance

The ironic detachment here is recognizing that:

1. **Proof assistants are version control systems** for mathematical truth
2. **Type theory is a programming language** for proofs
3. **Observational equality** is more practical than definitional equality
4. **Higher dimensions** emerge naturally from conflict resolution

## Commands

```bash
just narya-demo           # Run Narya bridge demonstration
just proofgeneral-setup   # Configure Proof General
just spawn-hierarchy      # Create 27-agent hierarchy
just measure-laxity       # Compute Bumpus laxity metrics
```

## References

- [Proof General Manual](https://proofgeneral.github.io/)
- [Narya GitHub](https://github.com/mikeshulman/narya)
- [Higher Observational Type Theory](https://ncatlab.org/nlab/show/higher+observational+type+theory)
- [Topos Institute: Structure-Aware Version Control](https://topos.institute/blog/2024-11-13-structure-aware-version-control-via-observational-bridge-types/)



## Scientific Skill Interleaving

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

### Bioinformatics
- **biopython** [○] via bicomodule
  - Hub for biological sequences

### Bibliography References

- `cryptography`: 1 citations in bib.duckdb



## SDF Interleaving

This skill connects to **Software Design for Flexibility** (Hanson & Sussman, 2021):

### Primary Chapter: 10. Adventure Game Example

**Concepts**: autonomous agent, game, synthesis

### GF(3) Balanced Triad

```
proofgeneral-narya (−) + SDF.Ch10 (+) + [balancer] (○) = 0
```

**Skill Trit**: -1 (MINUS - verification)

### Secondary Chapters

- Ch7: Propagators
- Ch2: Domain-Specific Languages
- Ch6: Layering
- Ch8: Degeneracy

### Connection Pattern

Adventure games synthesize techniques. This skill integrates multiple patterns.
## Cat# Integration

This skill maps to **Cat# = Comod(P)** as a bicomodule in the equipment structure:

```
Trit: 0 (ERGODIC)
Home: Prof
Poly Op: ⊗
Kan Role: Adj
Color: #26D826
```

### GF(3) Naturality

The skill participates in triads satisfying:
```
(-1) + (0) + (+1) ≡ 0 (mod 3)
```

This ensures compositional coherence in the Cat# equipment structure.

Overview

This skill integrates Proof General with Narya to provide a workflow for higher-dimensional observational type theory and structure-aware version control. It exposes bridge types that model diffs, conflict resolution, and multi-agent TAP trajectories, letting you manage proofs as topological, versioned objects. The skill is designed for interactive Emacs-based proof development and automated analysis of coherence across proof-state hierarchies.

How this skill works

The skill inspects proof buffers via Proof General and constructs observational bridge types that represent differences between versions. Bridge types carry dimensions (value, diff, conflict-resolution), TAP state (-1, 0, +1), color metadata, and fingerprints. Higher-dimensional constructs (2-cells, 3-cells) let the system encode merges and conflict resolutions as structured objects and compute metrics like Bumpus laxity and Möbius trajectory encodings.

When to use it

  • When you want to view proofs as versioned, observable artifacts rather than only syntactic objects.
  • When managing concurrent proof development with branching, merging, and conflict analysis.
  • When exploring higher-dimensional aspects of type equality and transport in proofs.
  • When you need automated metrics for coherence between agent states or branches.
  • When integrating proof workflows into agent hierarchies or active inference pipelines.

Best practices

  • Use Proof General keybindings (step, undo, process buffer) to maintain a clear locked/processing/unprocessed frontier.
  • Represent diffs as obs-bridge objects with stable fingerprints so merges are reproducible.
  • Keep TAP trajectories explicit and map them to multiplicative encodings for fast square-free checks.
  • Use the hierarchical 3×3×3 agent model to structure verification, backfill, and live deployment roles.
  • Compute Bumpus laxity regularly to detect coherence drift and guide targeted conflict resolution.

Example use cases

  • Run a Narya demo to visualize bridge types between competing proof drafts and resolve conflicts with higher-dimensional merges.
  • Spawn a 27-agent hierarchy to simulate distributed proof development with VERIFY/BACKFILL/LIVE roles and measure laxity across agents.
  • Attach observational bridge metadata to commits to make version control semantics first-class in proof repositories.
  • Map TAP trajectories of a proof suite to multiplicative signatures to detect redundant or non-square-free evolution.
  • Integrate bridge-based diffs into an active inference loop where perception and action inform proof edits.

FAQ

What is an observational bridge type?

A typed object that encodes the observable relation between two versions: source, target, diff metadata, dimension, TAP state, color, and fingerprint.

How do merges become higher-dimensional?

Merges are modeled as 2D or higher cells: a conflict resolution occupies an extra dimension so transport and coherence checks can be expressed structurally rather than by ad hoc edits.