Skip to content

Formal Model

vykrum edited this page Aug 28, 2026 · 6 revisions

Note

Status: IMPLEMENTED

This document outlines the mathematical and computational model that drives the HYWE engine. It answers the fundamental questions of how programmatic intent is formally evaluated, how topology is computed deterministically, and what guarantees the system provides.

1. What is the Input?

The input domain consists of a declarative, hierarchical expression of programmatic intent (a relational specification), defined through the HYWE Syntax.

Input Variables:

  • Program: A hierarchical list of spaces declared via Lexel nodes (e.g., (ID/Area/Label/Extrusion/B=Base)).
  • Sequence Operator ($Q$): A topological sequence operator from the finite set $S$ ($Q \in S$) that dictates the order in which adjacent spaces wrap or cluster.
  • Level ($L$): The vertical tier or elevation index.
  • Constraints ($O, I$): The semantic physical boundary ($O : Boundary$) and internal exclusions ($I : Set$) within which the topology must route.

Mathematically: $Input = F(P, Q, L, O, I)$ where $P$ is a rooted tree of Lexel nodes.

2. What is the Internal Representation?

The system does not represent spaces as floating-point polygons. It discretizes space into Hexels (atomic units on an integer grid) and Coxels (clustered hexels representing a programmed zone).

Lexel (The Parser)

  • State: A structured LexelBlock consisting of parsed properties.
  • Fields: Sequence, Level, Base, Scale, Entry, OuterBoundary, Islands.
  • Node: { Id, RequestedAreaWeight, Label, Extrusion, Base }
  • Invariants: Represents the raw relational specification tree. Must resolve to a hierarchical tree grouped by Dot-notation ID.

Hexel (The Atomic Unit)

  • State: AV (Available), RV (Reserved), or EX (Exposed).
  • Invariants: The fundamental indivisible unit of spatial discretization, anchoring the system to an integer grid without floating-point coordinates.

Coxel (The Topological Cluster)

  • State: An aggregation of Hexels around a single Base Hexel.
  • Fields: { Name, Rfid, Size, Seqn, Base, Hxls }
  • Canonical Definition: A set of connected Hexels logically grouped around a root Base Hexel, constructed sequentially by a fixed topological operator ($Q$).
  • Invariants: A Coxel cannot occupy Hexels already claimed by another Coxel on the same level (Collision Avoidance). Its topology is guided by the active Sequence ($Q$).

Goxel (The Geometric Engine)

  • State: Stateless functional utility.
  • Invariants: Maps discrete integer Hexel/Coxel coordinates into standard 2D vector geometry using purely integer-based boundary tracing, preventing floating-point drift at the topological boundary.

Xyxel (Planar Configurations)

  • State: A computed LayoutContext defining the boundaries and constraints.
  • Invariants: Reproportions requested node area weights to fit physical boundaries exactly and resolves 2D layout geometry deterministically.

Nexel (Nested Configurations)

  • State: A topological router mapping parent Coxel boundaries into nested child constraints.
  • Invariants: Enforces strict hierarchical spatial containment ($Child \subset Parent$).

Zaxel (Stacked Configurations)

  • State: A purely functional state loop carrying BuildState across multiple levels.
  • Invariants: Preserves uniform scaling and relational continuity across floors to maintain massing volumetric logic.

3. The Relation Algebra

HYWE distinguishes formally between different types of spatial relations. Let $A$ and $B$ be two distinct Coxels:

  • Adjacency ($A \sim B$): A physically neighboring relationship (shared boundaries).
  • Connectivity ($A \leftrightarrow B$): A traversable relationship (e.g., doors).
  • Flow ($A \xrightarrow{w} B$): A directed or weighted movement path.
  • Visibility ($A \rightleftharpoons B$): A perceptual sightline relationship.
  • Containment ($A \subset B$): A parent/child spatial relationship (handled via Nexel).
  • Hierarchy ($A < B$): A programmatic/organizational relationship (handled via Lexel).

These relations are computationally distinct; adjacency does not imply connectivity.

Relational Hierarchy (Indexing)

HYWE organizes these spatial relationships through hierarchical indexing (e.g., (3/20/C), (3.1/15/CA), (3.1.1/10/CAA)).

This establishes:

  • C as a parent space
  • CA as a nested relationship
  • CAA as a deeper relational branch

This hierarchy is organizational rather than purely geometric. Nested indices allow spatial systems to evolve through relational continuity rather than isolated placement. This enables branching organizational structures, clustered adjacency behavior, nested spatial conditions, and topology propagation.

4. What transformation produces discrete spatial topology?

Discrete Spatial Topology in HYWE is the non-geometric relationship of how spaces connect, border, or contain each other.

  • Layer 1 (Intent) defines that Space A is a parent of Space B and C.
  • Layer 2 (Discrete Spatial Topology) translates this intent by assigning a Base Hexel to Space A, and sequentially clustering Hexels for Space B and C according to the active Sequence operator ($Q$) and the adjacency rules defined in the Coxel module. The topology is deterministic: given the exact same sequence and grid parameters, the same Hexel allocation always occurs.

5. What transformation produces geometry?

Geometry is the physical resolution of the topology into coordinates.

  • Layer 3 (Geometry) reads the topological Hexel allocations of a Coxel and passes them through the Goxel utility module.
  • Functions like hxlPgn (Hexel Polygon generation) trace the outer boundaries of the Hexel cluster.
  • Sawtooth artifacts (inherent to grid-based allocations) are removed using integer math (removeSawtooth).
  • Winding orders are normalized (normalizeWinding), resulting in a clean physical layout that can be rendered.

6. What guarantees does the engine provide?

HYWE stratifies its claims into three distinct layers of rigor:

Mathematical Invariants

Properties proven from the algorithm itself.

  1. Determinism: $$Configuration = F(P, Q, L, O, I)$$ Given identical inputs, the function $F$ mathematically yields identical discrete topological state.
  2. Adjacency Equivalence: Two configurations $A$ and $B$ are considered adjacency-equivalent ($A \equiv_{adj} B$) if and only if their functional Adjacency Matrices (cxlAdj) are identical.

Implementation Invariants

Properties verified by the WebAssembly benchmark suite across the tested input space.

  1. Integer Constancy: Core topological operations execute using integer math, eliminating floating-point rounding error.
  2. Collision Avoidance: Two Coxels on the same level will never claim the same underlying Hexel coordinate.

System-Level Guarantees

Properties of the complete pipeline under stated version/configuration conditions.

  1. Reproducibility: Given identical inputs and an identical engine version, the system will produce the exact same discrete topological state.

7. Computational Trace (Worked Example)

To illustrate the deterministic transformation from syntax to massing, consider a program with a primary container housing a smaller nested room.

1. INPUT (Programmatic Intent)

(Q=VRCWEE/L=0)
(1/100/Main)
(1.1/30/SubRoom/3.0/B=1)

2. LEXEL (Parser) The Lexel engine constructs a rooted relational tree containing the active sequence $Q \in S$ and level $L$:

Tree:
1 (ReqAreaWeight: 100, Extrusion: None)
└── 1.1 (ReqAreaWeight: 30, Extrusion: 3.0)
Context: Q = VRCWEE, L = 0

3. XYXEL / NEXEL (Constraint Mapping) Xyxel evaluates the total unconstrained requested area against the physical boundaries ($O, I$), reproportioning the weights into $A_{realized}$, while Nexel registers 1 as the bounding constraint for 1.1.

4. HEXEL / COXEL (Topology Allocation) Coxel.fs allocates discrete integer coordinates. Using the VRCWEE sequence operator, 1 is anchored and wrapped. 1.1 is anchored inside the boundary of 1.

Coxel(1): Base = AV(0,0,0), Hxls = [AV(0,0,0), AV(2,0,0), ...]
Coxel(1.1): Base = AV(2,2,0), Hxls = [AV(2,2,0), ...]

5. ADJACENCY MATRIX The engine computes connectivity based on shared edges.

cxlAdj: [ Main ↔ SubRoom ]

6. GOXEL (Geometry Resolution) The discrete integer coordinates are converted into 2D vectorized boundaries using hxlPgn and winding normalization.

Polygon(1): [(0,2), (4,4), (4,0), ...]
Polygon(1.1): [(2,4), (4,5), (4,3), ...]

7. ZAXEL (Massing) Extrusion parameters are read, transforming the 2D polygon footprint into 3D bounding boxes.

Z-Massing(1.1): Z_Base = 0.0, Z_Height = 3.0

8. EVALUATION & ANALYSIS (Research Boundary) This trace reveals the current computational boundary of the project:

  • HYWE currently has a fully defined Generation Function: $G(P,Q,L,O,I) \rightarrow C$
  • HYWE does not yet have a fully defined Evaluation Function: $E(C,P) \rightarrow score$

Given the determinism of the generation operators, defining $E$ to measure adjacency satisfaction, circulation efficiency, compactness, and visibility is an area of active theoretical research. The 24 operators ($S$) act as an experimentally controlled candidate set for this future scoring function.

Clone this wiki locally