Commit graph

14 commits

Author SHA1 Message Date
Maximus Gorog
c51e3274f9 Stage 2 complete: Construction 17 validated on real 3D data
Zigzag engine (6802 lines, 184 tests):
- Construction 17 normalisation: working through dimension 3+
- Import from homotopy-rs JSON: working (scalar, two_scalars, half_braid)
- Piece extraction via Embedding/restrict_diagram: working
- Type checking pipeline: working (Eckmann-Hilton half_braid passes)
- Essential identity detection: validated with full 2-diagram test

Bugs found and fixed:
- assemble_factorisations losing cospan legs during reassembly
- RewriteN::slice() using source offsets instead of target indices
- singular_preimage() not handling passthrough heights
- restrict_rewrite() not accounting for accumulated cone offsets
- Embedding::preimage() using regular_preimage for Singular case

Added vis-engine-spec.md: visualization engine specification
- 6-layer architecture from math primitives to scene graph
- SVG renderer for 2D, WebGL2 for 3D, custom hit testing
- Spring constraint integration point for semiotic rendering
- No external dependencies - game engine approach

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-09 05:26:15 -06:00
Maximus Gorog
c011af0414 Add visibility filter and output only visible elements
Added Point::is_visible() to explosion.rs:
- A point at geom_dim d is visible iff coords[d..] are all singular
- Matches homotopy.io's visibility filter (mesh.rs:111-115)

Updated render_braiding.rs:
- Filter to visible elements only (7 of 23 points for half_braid)
- Compute layout coordinates: x=time, y=height, z=depth
- Wires spread at z = [-1, 0, 1], vertices at z = [-0.5, 0.5]
- No volumes in output (not rendered)

Visible elements for half_braid:
- 2 vertices: (s0,s0,s0), (s1,s0,s0)
- 3 wires: (r0,s0,s0), (r1,s0,s0), (r2,s0,s0)
- 2 surfaces: (r0,r0,s0), (r0,r1,s0)

Updated web/zigzag-renderer.jsx with new geometry data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-08 02:16:36 -06:00
Maximus Gorog
2f33791809 Fix render_braiding.rs: transitive for wire endpoints, direct for surface boundaries
Wire endpoints and surface boundaries require different computation methods:

- Wire endpoints: TRANSITIVE reachability to vertices
  A strand spans between vertices even if poset path has intermediate points.
  Most wires connect both v₀ and v₁; only wire 14 is a self-loop.

- Surface boundary_wires: DIRECT covering relations only
  The immediate boundary of a surface is its direct predecessor/successor wires.
  Surfaces have 1-3 boundary wires (was 1-7 with transitive).

Updated:
- examples/render_braiding.rs: restored reachable_from for wire endpoints
- fixtures/half_braid_geometry.json: correct wire endpoints + direct surface boundaries
- web/zigzag-renderer.jsx: updated embedded geometry data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-08 01:25:50 -06:00
Maximus Gorog
d679eeba6b Add Three.js renderer for half_braid geometry with variational elastic curves
- web/zigzag-renderer.jsx: React component with full variational curve solver
  - Minimizes E = τ·Σ|Δp|² + β·Σ|Δ²p|² + κ·|p_mid - waypoint|²
  - Solves tridiagonal + pentadiagonal linear system via Gaussian elimination
  - Self-loops rendered as parametric curves offset toward waypoint
  - Wire coloring by group: input (blue), crossing (purple), output (green)

- web/index.html: Minimal HTML loading React/Three.js from CDN

Features:
  - Interactive orbit controls (drag + wheel zoom)
  - Control panel with sliders: Tension τ, Bending β, Waypoint κ, Resolution
  - Toggles for waypoints, surfaces, labels
  - Dark theme with gold accents

Coordinate mapping: coord[0]→z, coord[1]→y, coord[2]→x with scale 1.2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-08 01:07:06 -06:00
Maximus Gorog
5454c02328 Fix explosion.rs over-approximation: use cospan rewrite data for correct covering relations
- Replace all-to-all sub-poset connection with rewrite-based correspondence
- Add compute_subpoint_correspondence() using cone structure for 3 cases:
  identity (1-to-1), contraction (many-to-one), insertion (index shift)
- Add compute_height_maps() for singular and regular height tracking
- Covering relations reduced from 114 to 35 for half_braid (69% reduction)
- Surface 3 (r0,s0,r0): 9 spurious successors → 3 correct successors
- 175 tests passing, 0 failures
- Regenerated fixtures/half_braid_geometry.json with corrected boundaries

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-08 00:54:18 -06:00
Maximus Gorog
6be1159262 Merge feat/normalisation: Construction 17 complete 2026-04-07 03:26:18 -06:00
Maximus Gorog
5531398040 Merge master and add DiagramMap composition methods
Integrates the parallel agent work (slice computation, degeneracy
factorisation, explosion) with the normalisation implementation.

Added to DiagramMap:
- compose(): Compose two diagram maps
- has_singular_height_in_image(): Check if height is in singular image

All 77 tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-07 03:26:12 -06:00
Maximus Gorog
02d23cf554 Implement normalisation algorithm (Construction 17)
Complete implementation of the zigzag normalisation algorithm from the
LICS 2022 paper "Zigzag normalisation for associative n-categories".

Key changes:
- diagram.rs: Add DiagramMap composition, singular_map extraction
- degeneracy.rs: Add extract_singular_map() and height checking functions
- normalise.rs: Complete Construction 17 with essential identity detection

The algorithm:
1. Recursively normalise at each regular height
2. Recursively normalise at each singular height with cospan leg composites
3. Assemble into intermediate diagram P
4. Remove trivial cospans (ONLY if identity AND not in sink image)
5. Compose degeneracies: d = dP ∘ dS

Critical: In dimension >= 4, some identity cospans are ESSENTIAL and must
be preserved if they are in the image of any sink map.

All 57 tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-07 03:24:30 -06:00
Maximus Gorog
c352384e92 Merge feat/explosion: k-points, poset structure 2026-04-07 03:12:27 -06:00
Maximus Gorog
13d5c04598 Merge feat/degeneracy: Lemma 7 factorisation, Prop 13 pullbacks 2026-04-07 03:11:15 -06:00
Maximus Gorog
5d21c75178 Implement k-points explosion and poset structure
Complete the explosion module for layout computation:

- Poset methods: is_less_than, less_than_or_equal, is_comparable,
  minimal_elements, maximal_elements, topological_sort
- Covering relations: compute_covers() from poset ordering
- k_points: Full implementation with proper covering relation computation
- Point ordering: Product ordering on height labels with zigzag structure
- HeightLabel ordering: r_j < s_j < r_{j+1} within each dimension
- Injectification stub for future layout integration

The poset structure captures the combinatorial data needed for
embedding Pt_n(X) -> R^n in the layout algorithm.

All 55 tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-07 03:03:38 -06:00
Maximus Gorog
6990275388 Implement degeneracy map detection and factorisation
Core degeneracy infrastructure from the LICS 2022 paper:

- Simple degeneracy detection: Checks that the singular map is injective
  (composition of face maps) and all slice maps are identities.

- Parallel degeneracy detection: Checks that the singular map is the
  identity (no cones in RewriteN) and all slice maps are degeneracies.

- Degeneracy detection: Combines simple and parallel checks.

- Factorisation (Lemma 7): Every degeneracy factors uniquely as
  N --simple--> P --parallel--> T.

- Pullback computation (Proposition 13): Given degeneracies f: X -> T
  and g: Y -> T, computes the pullback by intersecting images in Delta+.

- Helper functions: simple_degeneracy_at(), extract_singular_map(), etc.

All 53 tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-07 02:56:55 -06:00
Maximus Gorog
951f86a74f Implement slice computation methods in diagram.rs
Add the core slice computation functionality for n-diagrams:

- Rewrite::apply_forward/apply_backward: Apply rewrites to transform
  diagrams in either direction
- RewriteN::apply_forward/apply_backward: Handle n-dimensional rewrites
  by modifying cospan structure via cone contraction/expansion
- DiagramN::regular_slice(h): Compute regular slice at height h by
  traversing cospans, applying forward then backward rewrites
- DiagramN::singular_slice(h): Compute singular slice (cospan apex)
  by applying forward rewrite to the corresponding regular slice
- DiagramN::target(): Now properly computes the last regular slice
- DiagramN::slices(): Iterator yielding all slices in order r0,s0,r1,...
- DiagramN::regular_slices()/singular_slices(): Filtered iterators

All 48 tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-07 02:56:31 -06:00
Maximus Gorog
cd4b951f78 Scaffold zigzag-engine library
Initial structure implementing the zigzag construction for associative
n-categories (LICS 2022 paper). Includes:

- monotone.rs: MonotoneMap with Wraith's R equivalence (complete)
- zigzag.rs: Zigzag<T>, ZigzagMap<S> with composition
- diagram.rs: Diagram, DiagramN, Cospan, Rewrite, Cone types
- signature.rs: Generator, Signature (complete)
- degeneracy.rs: Degeneracy detection stubs
- normalise.rs: Construction 17 algorithm structure
- typecheck.rs: Type checking against signatures
- explosion.rs: k-points and Poset for layout
- layout.rs: SpringConstraint API surface

All 33 unit tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-07 02:42:06 -06:00