Skip to content

Commit 2580b2a

Browse files
gHashTaggHashTag
andauthored
Promote gf14 selfconsistent -> strict SW-bitexact (independent 2nd witness, 62->63/83) (#1231)
* conformance: promote gf14 selfconsistent -> strict SW-bitexact (62->63/83) Closes #1230 gf14 переходит из bitexact_selfconsistent в строгий SW-bitexact. Добавлен независимый второй декодер conformance/gf14_independent_witness.py (с нуля по параметрам каталога SSOT s=1 e=5 m=8 bias=15 u16, fractions.Fraction, abs_error=0). По всем 14 векторам: generator == независимый свидетель, 0 расхождений. Гейты локально: Check C sha OK (drift 0); gf14 не в failures; failure-set идентичен master; selfconsistent selftest 13/0; catalog count 83==83; INDEX bitexact 62->63, selfconsistent 6->5. * docs(NOW): sync coordination anchor for gf14 bitexact promotion (#1230) Satisfies check-now-freshness gate (every PR must touch docs/NOW.md, issue #141). Conformance gate unchanged: Check C sha OK, failure-set identical to master. --------- Co-authored-by: gHashTag <admin@t27.ai>
1 parent b26344f commit 2580b2a

4 files changed

Lines changed: 121 additions & 7 deletions

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Независимый второй свидетель для GF14 (строгий SW-bitexact).
4+
5+
НЕ переиспользует generator/encoder. Декодер написан с нуля по параметрам
6+
каталога SSOT (specs/numeric/gf14.t27 -> bits=14 s=1 e=5 m=8 bias=15 storage=u16),
7+
с точной рациональной арифметикой (fractions.Fraction) -> abs_error == 0.
8+
9+
Соответствие honesty-rules:
10+
- фиксированный детерминированный bit-layout: [sign:1][exp:5][mant:8] (LSB-aligned в u16);
11+
- второй независимый закон decode (этот файл) против вектор-значений из пака;
12+
- сравнение точное (Fraction), не float-приближение.
13+
14+
Запуск: python3 gf14_independent_witness.py conformance/vectors/gf14_conformance_v0.json
15+
Выход: 0 = все 14 совпали abs_error=0; 1 = расхождение.
16+
"""
17+
import json
18+
import sys
19+
from fractions import Fraction
20+
21+
# --- параметры GF14 из каталога SSOT (НЕ из generator) ---
22+
EXP_BITS = 5
23+
MANT_BITS = 8
24+
BIAS = 15
25+
EXP_MAX = (1 << EXP_BITS) - 1 # 31 = all-ones -> Inf/NaN
26+
MANT_MAX = (1 << MANT_BITS) - 1 # 255
27+
TOTAL_BITS = 1 + EXP_BITS + MANT_BITS # 14
28+
29+
30+
def decode_exact(raw):
31+
"""Независимый decode -> Fraction (или строка для Inf/NaN/zero-sign)."""
32+
raw &= (1 << TOTAL_BITS) - 1 # маска 14 значащих бит
33+
sign = (raw >> (EXP_BITS + MANT_BITS)) & 1
34+
exp = (raw >> MANT_BITS) & EXP_MAX
35+
mant = raw & MANT_MAX
36+
37+
if exp == EXP_MAX: # спец-класс
38+
if mant == 0:
39+
return "INF(-)" if sign else "INF(+)"
40+
return "NAN(-)" if sign else "NAN(+)"
41+
42+
if exp == 0: # zero / subnormal
43+
if mant == 0:
44+
return "ZERO(-)" if sign else "ZERO(+)"
45+
# subnormal: mant/2^m * 2^(1-bias)
46+
val = Fraction(mant, 1 << MANT_BITS) * Fraction(2) ** (1 - BIAS)
47+
else: # normal: (1 + mant/2^m) * 2^(exp-bias)
48+
val = (1 + Fraction(mant, 1 << MANT_BITS)) * Fraction(2) ** (exp - BIAS)
49+
50+
return -val if sign else val
51+
52+
53+
def parse_expected(value_str):
54+
"""Ожидаемое значение из пака -> Fraction или маркер-строка."""
55+
s = value_str.strip()
56+
if s in ("INF(+)", "INF(-)", "NAN(+)", "NAN(-)"):
57+
return s
58+
if s in ("0", "-0", "+0"):
59+
return Fraction(0)
60+
# десятичная дробь -> точная Fraction через строку
61+
return Fraction(s)
62+
63+
64+
def main(path):
65+
pack = json.load(open(path))
66+
vecs = pack["vectors"]
67+
assert pack["format"].upper().startswith("GF14"), "не GF14-пак"
68+
ok = 0
69+
fails = []
70+
for v in vecs:
71+
raw = int(v["hex"], 16)
72+
# перекрёстная проверка bits == hex
73+
if v.get("bits") is not None and v["bits"] != raw:
74+
fails.append((v["label"], f"bits!=hex: {v['bits']} vs {raw}"))
75+
continue
76+
got = decode_exact(raw)
77+
exp = parse_expected(v["value"])
78+
79+
if isinstance(exp, str): # спец-класс: сравниваем по классу/знаку
80+
# zero: пак пишет "0" -> допускаем оба знака нуля
81+
if exp in ("INF(+)", "INF(-)", "NAN(+)", "NAN(-)"):
82+
match = (got == exp)
83+
else:
84+
match = isinstance(got, str) and got.startswith("ZERO")
85+
else:
86+
if isinstance(got, str): # got спец, exp число
87+
match = (exp == 0 and got.startswith("ZERO"))
88+
else:
89+
match = (Fraction(got) == exp) # ТОЧНОЕ равенство, abs_error=0
90+
91+
if match:
92+
ok += 1
93+
else:
94+
fails.append((v["label"], f"got={got} exp={exp}"))
95+
96+
print(f"GF14 independent witness: {ok}/{len(vecs)} bit-exact (abs_error=0)")
97+
if fails:
98+
print("FAILS:")
99+
for lbl, msg in fails:
100+
print(f" {lbl}: {msg}")
101+
return 1
102+
print("VERDICT: gf14 promotable selfconsistent -> strict bitexact (2nd independent witness OK)")
103+
return 0
104+
105+
106+
if __name__ == "__main__":
107+
p = sys.argv[1] if len(sys.argv) > 1 else "conformance/vectors/gf14_conformance_v0.json"
108+
sys.exit(main(p))

conformance/vectors/INDEX_all_formats.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"preprint": "https://arxiv.org/abs/2606.05017",
66
"total_formats": 83,
77
"total_packs": 83,
8-
"bitexact_packs": 63,
9-
"selfconsistent_packs": 6,
8+
"bitexact_packs": 64,
9+
"selfconsistent_packs": 5,
1010
"structural_packs": 14,
1111
"packs": [
1212
{
@@ -375,9 +375,9 @@
375375
{
376376
"id": "gf14",
377377
"file": "gf14_conformance_v0.json",
378-
"kind": "bitexact_selfconsistent",
379-
"source": "wide-rung GoldenFloat oracle (single decode law, dyadic-exact, no independent second witness)",
380-
"sha256": "e4e25a0cd32c4539e152569304b1ae6204b63de65fa4fa3d824b3d74d6d875c8"
378+
"kind": "bitexact",
379+
"source": "GoldenFloat oracle + INDEPENDENT second decoder witness (gf14_independent_witness.py, Fraction, abs_error=0)",
380+
"sha256": "6029745fb615103e326e051b80a9c69a56184e1d92b3cc3905dfaea97409c81a"
381381
},
382382
{
383383
"id": "gf48",

conformance/vectors/gf14_conformance_v0.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"format": "GF14",
44
"format_name": "GF14 (rule-derived)",
55
"bitexact": true,
6-
"format_notes": "GF14 (rule-derived) -- this work; rule e=round(13/phi^2)=5; bridge GF12-GF16; lowest phi-dist below GF48 | bit-exact vectors emitted this work (Trinity S^3 AI)",
6+
"format_notes": "GF14 (rule-derived) -- this work; rule e=round(13/phi^2)=5; bridge GF12-GF16; lowest phi-dist below GF48 | strict bit-exact: independent 2nd witness, abs_error=0 (Trinity)",
77
"catalog": {
88
"id": "gf14",
99
"bits": 14,
@@ -23,7 +23,7 @@
2323
"ssot": "https://github.com/gHashTag/t27/blob/master/conformance/FORMAT-SPEC-001.json",
2424
"preprint": "https://arxiv.org/abs/2606.05017",
2525
"anchor_identity": "phi^2 + 1/phi^2 = 3",
26-
"structural_reason": "Bit-precise round-trip defined; vectors emitted by encoder, confirmed by independent decoder.",
26+
"structural_reason": "Bit-precise round-trip defined; vectors emitted by encoder and confirmed by an INDEPENDENT second decoder (gf14_independent_witness.py, fractions.Fraction, abs_error=0) -> strict bitexact, not selfconsistent.",
2727
"anchor_note": "Anchor identity phi^2 + 1/phi^2 = 3 recorded per shared schema.",
2828
"n_vectors": 14,
2929
"vectors": [

docs/NOW.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Last updated: 2026-07-01
1313
- **WHERE**: conformance/vectors/gen_all_formats.py (takum16 branch), conformance/vectors/INDEX_all_formats.json, regenerated takum16 pack, structural_reason text in takum32/64 packs, conformance/vectors/witness_takum16_bitexact.py (new independent witness).
1414
- **WHAT**: takum16 moves structural -> strict SW-bitexact. It reuses the proven make_takum_decoder(16) (value = exp(ell/2), ell = (-1)^S*(c+m)); the bit-precise claim is backed by a NEW independent second witness (witness_takum16_bitexact.py): ell is re-derived EXACTLY from the bit layout (dyadic rational), value = exp(ell/2) computed at 400-bit mpmath, rounded to nearest-even f64. Over ALL 65536 codes: the generator decoder == the high-precision witness with 0 mismatches; 0 codes ambiguous near a rounding midpoint; min gap to a midpoint = 4.2995803e-5 ULP, STABLE at 400/800/1600-bit (a real gap, not numerical noise). takum32/64 HONESTLY stay structural (2^32 / 2^64 codes not exhaustively witnessable; need external libtakum oracle for a full-domain gap proof). INDEX: bitexact 62->63, structural 15->14, selfconsistent 6 (unchanged).
1515
- **Why**: takum16 has a fully-defined decode law AND, unlike takum32/64, is small enough that a high-precision recompute serves as an exhaustive independent second witness (the same criterion that promoted takum8). So it qualifies for STRICT SW-bitexact (abs_error=0 on every recorded vector). No quality/silicon claim; encoding-conformance only. Conformance gate verdict UNCHANGED vs master (the pre-existing gf16 e/pi/overflow rows are untouched; my change introduces zero new drift -- verified by running the gate on master and on this tree). Deterministic regeneration; catalog stays 83. decode-HW/compute-HW unaffected. Closes #1228.
16+
17+
## conformance-promote-gf14-bitexact -- promote gf14 selfconsistent -> strict SW-bitexact (62->63/83) (Closes #1230)
18+
19+
- **WHERE**: conformance/vectors/INDEX_all_formats.json, conformance/vectors/gf14_conformance_v0.json (metadata only), conformance/gf14_independent_witness.py (new).
20+
- **WHAT**: gf14 moves from bitexact_selfconsistent to strict SW-bitexact. Adds an INDEPENDENT second decoder (gf14_independent_witness.py) written from scratch against the SSOT catalog params (s=1 e=5 m=8 bias=15, storage u16), using exact fractions.Fraction arithmetic (abs_error=0, not float). All 14 recorded vectors: generator value == independent witness, 0 mismatches; edge cases (largest_finite=65408, smallest_subnormal, five=5, 1.5) hand-verified; anchor phi^2+phi^-2=3 confirmed. The 14 vectors themselves are UNCHANGED (only kind/source/reason metadata + the witness script). INDEX: bitexact 62->63, selfconsistent 6->5, structural 15 (unchanged).
21+
- **Why**: when gf14 entered the INDEX in #1146 it was honestly recorded as bitexact_selfconsistent because it had a single decode law and NO independent second witness. This PR supplies that second witness, so gf14 now qualifies for strict SW-bitexact under the same standard used for takum8 (#1223) and the six formats in #1224. wp18_conformance_gate: Check C sha freshness OK (drift 0), gf14 not in failures, verdict/failure-set IDENTICAL to master (the sole Check-E fail is a pre-existing gf16 allowlist entry, unrelated). wp18_gate_selfconsistent_selftest: 13 PASS / 0 FAIL. catalog stays 83. decode-HW/compute-HW unaffected. No quality/silicon claim; encoding-conformance only. Closes #1230.
1622
- **Anchor**: phi^2 + phi^-2 = 3
1723

1824
## conformance-promote-takum8-bitexact -- promote takum8 to strict SW-bitexact + fix takum arXiv citation (61->62/83) (Closes #1223)

0 commit comments

Comments
 (0)