| /* | |
| * quhit_hexagram.h β The Hexagram Quhit | |
| * | |
| * A new quantum primitive: the EDGE DUAL of the triality quhit. | |
| * | |
| * The standard (triality) quhit stores amplitudes on 6 VERTICES of | |
| * the hexagon β the computational basis states |0β©...|5β©. | |
| * | |
| * The hexagram quhit stores amplitudes on 6 LINE SEGMENTS of the | |
| * unicursal hexagram β the face diagonals of the cube projected along | |
| * its body diagonal (1,1,1). | |
| * | |
| * The 6 hexagram lines (unicursal traversal order): | |
| * | |
| * ββ: diameter EβcenterβD (cyan, C face diagonals) | |
| * ββ: outer DβC (yellow, Y face diagonal) | |
| * ββ: diameter CβcenterβF (magenta, M face diagonals) | |
| * ββ: outer FβB (cyan, C face diagonal) | |
| * ββ: diameter BβcenterβG (yellow, Y face diagonals) | |
| * ββ : outer GβE (magenta, M face diagonal) | |
| * | |
| * Key properties: | |
| * - Chirality is intrinsic: the unicursal path has a direction. | |
| * The two orientations correspond to the two mirror tetrahedra | |
| * inscribed in the cube. | |
| * - Ξ=0 is the native ground state (hexagram states encode the | |
| * exotic Sβ automorphism structure naturally). | |
| * - The Hβ transform (vertex β hexagram) is derived from the | |
| * body-diagonal projection of face diagonals β NOT the DFTβ. | |
| * | |
| * Vertex model: TrialityQuhit (amplitudes on points) | |
| * Edge model: HexagramQuhit (amplitudes on paths) | |
| * Duality: Kramers-Wannier, mediated by Sβ outer automorphism | |
| */ | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * CHIRALITY β Path orientation of the unicursal hexagram | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * LINE SEGMENT TYPES | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * THE HEXAGRAM QUHIT | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| typedef struct { | |
| /* 6 complex amplitudes β one per hexagram line segment */ | |
| double line_re[HEX_D]; | |
| double line_im[HEX_D]; | |
| /* Chirality: +1 (positive traversal) or -1 (mirror traversal) */ | |
| int chirality; | |
| /* Cached vertex-basis representation (for interconversion) */ | |
| double vertex_re[HEX_D]; | |
| double vertex_im[HEX_D]; | |
| uint8_t vertex_dirty; /* 1 if vertex cache is stale */ | |
| /* Line metadata (static, set at init) */ | |
| /* line_type[k]: LINE_DIAMETER or LINE_OUTER */ | |
| /* line_color[k]: 0=C(cyan), 1=M(magenta), 2=Y(yellow) */ | |
| } HexagramQuhit; | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * Hβ TRANSFORM β The body-diagonal projection matrix | |
| * | |
| * Hβ converts vertex amplitudes β hexagram-line amplitudes. | |
| * Hββ converts hexagram-line amplitudes β vertex amplitudes. | |
| * | |
| * Derivation: each hexagram line ββ is a specific combination of | |
| * vertex states determined by which cube face diagonals project | |
| * onto that line under the body-diagonal (1,1,1) projection. | |
| * | |
| * The matrix is syntheme-weighted: diameters combine antipodal | |
| * vertex pairs (both diagonals of a face), outer edges combine | |
| * adjacent vertex pairs (single diagonal connecting two faces). | |
| * | |
| * Hβ is UNITARY: Hβ Β· Hββ = I. | |
| * Hβ is NOT the DFTβ β it encodes geometry, not Fourier analysis. | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| /* The 6Γ6 Hβ transform matrices (precomputed at init) */ | |
| extern double H6_re[HEX_D][HEX_D]; | |
| extern double H6_im[HEX_D][HEX_D]; | |
| extern double H6_adj_re[HEX_D][HEX_D]; /* Hββ (adjoint) */ | |
| extern double H6_adj_im[HEX_D][HEX_D]; | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * LIFECYCLE | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| /* Initialize the Hβ transform tables. Call once at startup. */ | |
| void hexagram_init_tables(void); | |
| /* Initialize to the "first line" state |βββ© with positive chirality */ | |
| void hexagram_init(HexagramQuhit *q); | |
| /* Initialize from a standard-basis state vector via Hβ transform */ | |
| void hexagram_init_from_vertex(HexagramQuhit *q, | |
| const double *vert_re, const double *vert_im, | |
| int chirality); | |
| /* Initialize to a specific hexagram line segment |βββ© */ | |
| void hexagram_init_line(HexagramQuhit *q, int k, int chirality); | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * NATIVE HEXAGRAM GATES β O(D) operations | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| /* Path shift: advance along the unicursal path by Ξ΄ segments. | |
| * |βββ© β |β_{(k+Ξ΄) mod 6}β© | |
| * This is DIAGONAL in hexagram basis β O(D). | |
| * Ξ΄>0 = forward along chirality, Ξ΄<0 = backward. */ | |
| void hexagram_path_shift(HexagramQuhit *q, int delta); | |
| /* Per-line phase gate: |βββ© β e^{iΟβ}|βββ© | |
| * Diagonal in hexagram basis β O(D). */ | |
| void hexagram_phase(HexagramQuhit *q, const double *phi_re, const double *phi_im); | |
| /* Diameter phase: apply phase only to diameter lines (ββ,ββ,ββ). | |
| * This targets the "through-center" segments specifically. O(3). */ | |
| void hexagram_diameter_phase(HexagramQuhit *q, double phi_re, double phi_im); | |
| /* Outer phase: apply phase only to outer lines (ββ,ββ,ββ ). O(3). */ | |
| void hexagram_outer_phase(HexagramQuhit *q, double phi_re, double phi_im); | |
| /* Chirality flip: reverse the path orientation. | |
| * Corresponds to switching between the two mirror tetrahedra. | |
| * |ββ, +β© β |β_{5-k}, -β© (reversal + conjugation) | |
| * This is an INVOLUTION: flip β flip = identity. O(D). */ | |
| void hexagram_flip(HexagramQuhit *q); | |
| /* Triad gate: simultaneous rotation of all 3 diameters. | |
| * ββββββββ (diameters cycle), ββββββββ (outers cycle). | |
| * This is the Ο-image of triality_rotate. O(D). */ | |
| void hexagram_triad(HexagramQuhit *q); | |
| /* Inverse triad. O(D). */ | |
| void hexagram_triad_inv(HexagramQuhit *q); | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * ENTANGLEMENT β Center-crossing interaction | |
| * | |
| * Two hexagram quhits can entangle through shared center crossings. | |
| * The 3 diameters all pass through the center point β when two | |
| * hexagram states have amplitude on overlapping diameters, they | |
| * interfere at the crossing. | |
| * | |
| * This is the hexagrammatic analog of CZ: it couples the diameter | |
| * amplitudes of both quhits while leaving outer amplitudes unchanged. | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| void hexagram_cross(HexagramQuhit *a, HexagramQuhit *b); | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * MEASUREMENT | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| /* Measure which hexagram line the state occupies. | |
| * Returns outcome 0..5. Collapses state. */ | |
| int hexagram_measure(HexagramQuhit *q, uint64_t *rng_state); | |
| /* Probability distribution over the 6 lines β no collapse. O(D). */ | |
| void hexagram_probabilities(const HexagramQuhit *q, double *probs); | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * INTERCONVERSION β Vertex model β Edge model | |
| * | |
| * These use the Hβ transform to convert between the two dual | |
| * representations. The conversion is exact (Hβ is unitary). | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| /* Ensure vertex cache is up-to-date (applies Hββ ) */ | |
| void hexagram_ensure_vertex(HexagramQuhit *q); | |
| /* Get read-only vertex amplitudes (ensures first) */ | |
| const double *hexagram_vertex_re(HexagramQuhit *q); | |
| const double *hexagram_vertex_im(HexagramQuhit *q); | |
| /* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| * DIAGNOSTICS | |
| * βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ | |
| /* Print hexagram state: line amplitudes + chirality */ | |
| void hexagram_print(const HexagramQuhit *q, const char *label); | |
| /* Line metadata */ | |
| int hexagram_line_type(int k); /* LINE_DIAMETER or LINE_OUTER */ | |
| int hexagram_line_color(int k); /* 0=C, 1=M, 2=Y */ | |
| const char *hexagram_line_name(int k); /* e.g. "ββ diam C" */ | |