# decryption_complete: false # source: archive/local/external_voynich_units/voynich_decipherment_repro_bundle/decipherment_attack_v10/syllabic_test.py # stated_sha256: d6f96b0d84de8ec39bc42e1bc6837817fc234b019f15ea58e06306b9a1db8f95 # matches_stated_sha256: false # pdf_pages: 804-805 # note: The stated SHA-256 is the digest printed in the PDF. # The PDF page extract follows the form feed. decryption_complete stays false. Voynich Complete Reproducibility Compendium - 2026-08-28 Page 1803 archive/local/external_voynich_units/voynich_decipherme nt_repro_bundle/decipherment_attack_v10/syllabic_test.p y SHA-256: d6f96b0d84de8ec39bc42e1bc6837817fc234b019f15ea58e06306b9a1db8f95 | 6,754 bytes | workspace supplement #!/usr/bin/env python3 """v10 - The syllabic-transcription hypothesis (Stolfi's Chinese theory), formally tested. Hypothesis: each Voynich token is one syllable of a tonal, isolating, Chinese-type language in an invented phonetic transcription. Materials: Bencao Beiyao (classical Chinese HERBAL, Gutenberg #26888) and Romance of the Three Kingdoms (semi-vernacular, #23950), converted to pinyin syllable streams (tonal and toneless), "lines" split at punctuation. Tests, all at matched token counts against Voynich Herbal-A/B tokens: T1 syllable-order information (shuffle-corrected adjacent MI share) - the statistic on which pooled Voynichese scores 0.79%. T2 vocabulary structure: type count, hapax share, top-type coverage - a closed syllabary vs Voynich's open hapax-heavy lexicon. T3 glyph-level analog: the pinyin LETTER stream's entropy/gap profile at BPE k=0 and k=64 vs Voynich's (E1 machinery). T4 the v6 letter-level substitution attack with a pinyin LM added: Voynichese-as-cipher-of-pinyin, with the glyph-babble differential. """ from __future__ import annotations import json, math, random, re, sys from collections import Counter from pathlib import Path HERE = Path(__file__).resolve().parent ROOT = HERE.parent # Genre-matched pinyin controls (Project Gutenberg #26888 Bencao Beiyao and # #23950 Romance of the Three Kingdoms) are bundled next to this script. SCRATCH = HERE / "zh_corpora" sys.path.insert(0, str(ROOT / "decipherment_attack_v5")) sys.path.insert(0, str(ROOT / "decipherment_attack_v6")) from unit_probe import order_info, bpe_checkpoints, stream_stats, truncate # type: ignore from attack_lib import (TrigramLM, voynich_lines_by_language, # type: ignore pipeline_classes, match_index) from attack_voynich import ngram_generate # type: ignore OUT = HERE / "output" OUT.mkdir(parents=True, exist_ok=True) from pypinyin import lazy_pinyin, Style PUNCT = set("\u3002\uFF0C\u3001\uFF1B\uFF1A\uFF01\uFF1F\u300C\u300D\u300E\u300F\uFF08\uFF09\u300A\u300B\u3008\u3009\ uFF0E\u00B7\u2026-") def chinese_syllable_lines(path, tonal=True): t = Path(path).read_text(encoding="utf-8", errors="replace") a = t.find("*** START") b = t.find("*** END") if a >= 0: t = t[t.find("\n", a) + 1: b if b > 0 else len(t)] lines, cur = [], [] style = Style.TONE3 if tonal else Style.NORMAL for ch in t: if "\u4E00" <= ch <= "\u9FFF": cur.append(ch) elif ch in PUNCT or ch == "\n": if len(cur) >= 2: sylls = lazy_pinyin("".join(cur), style=style) lines.append([s for s in sylls if s.isascii() and s]) cur = [] if len(cur) >= 2: lines.append([s for s in lazy_pinyin("".join(cur), style=style) if s.isascii() and s]) return [ln for ln in lines if len(ln) >= 2] def match_tokens(lines, n_target): out, n = [], 0 for ln in lines: out.append(ln) n += len(ln) if n >= n_target: break return out def vocab_stats(lines): freq = Counter(w for ln in lines for w in ln) n = sum(freq.values()) types = len(freq) hapax = sum(1 for c in freq.values() if c == 1) Voynich Complete Reproducibility Compendium - 2026-08-28 Page 1804 top50 = sum(c for _, c in freq.most_common(50)) / n return dict(tokens=n, types=types, hapax_share=hapax / types, top50_coverage=top50) if __name__ == "__main__": rng = random.Random(20260818) by_lang = voynich_lines_by_language() vy_A, vy_B = by_lang["A"], by_lang["B"] n_A = sum(len(ln) for ln in vy_A) results = {} corpora = {} for name, path in (("bencao", SCRATCH / "zh_bencao.txt"), ("sanguo", SCRATCH / "zh_sanguo.txt")): for tonal in (True, False): key = f"{name}_{'tonal' if tonal else 'toneless'}" corpora[key] = chinese_syllable_lines(path, tonal) print("=== T1: syllable/token order information (share of H1) ===", flush=True) rows = {} for key, lines in corpora.items(): ml = match_tokens(lines, n_A) oi = order_info(ml, {}) rows[key] = oi["share"] print(f" {key:18s} {oi['share']*100:6.2f}%", flush=True) for key, lines in (("voynich_A", vy_A), ("voynich_B", vy_B)): oi = order_info(lines, {}) rows[key] = oi["share"] print(f" {key:18s} {oi['share']*100:6.2f}%", flush=True) results["order_info"] = rows print("=== T2: vocabulary structure at matched token counts ===", flush=True) rows = {} for key, lines in list(corpora.items()) + [("voynich_A", vy_A), ("voynich_B", vy_B)]: ml = match_tokens(lines, n_A) if key in corpora else lines vs = vocab_stats(ml) rows[key] = vs print(f" {key:18s} tokens={vs['tokens']:6d} types={vs['types']:5d} " f"hapax={vs['hapax_share']*100:4.1f}% " f"top50cov={vs['top50_coverage']*100:4.1f}%", flush=True) results["vocab"] = rows print("=== T3: pinyin letter-stream profile vs Voynich glyphs ===", flush=True) rows = {} pin = match_tokens(corpora["bencao_toneless"], 173076 // 4) pin = truncate(pin, 173076) for k in (0, 64): seg = bpe_checkpoints(pin, {k}, k)[k] st = stream_stats(pin, seg) rows[f"pinyin_k{k}"] = st print(f" pinyin k={k:3d}: types={st['types']:5d} H1={st['H1']:.2f} " f"H2={st['H2']:.2f} gap={st['gap']:.2f}", flush=True) print(" (voynich k=0: gap 1.60; k=64: gap 1.05 - from v5 E1)", flush=True) results["letter_profile"] = rows print("=== T4: substitution attack with pinyin LM (letter level) ===", flush=True) pin_letters = "".join(w for ln in corpora["bencao_toneless"] for w in ln) cut = int(len(pin_letters) * 0.85) lm = TrigramLM(pin_letters[:cut]) anchor = lm.anchor_bits(pin_letters[cut:]) rows = {} for name, lines in (("voynich_A", vy_A), ("voynich_B", vy_B), ("ngram_ctl_A", ngram_generate(vy_A)), ("ngram_ctl_B", ngram_generate(vy_B))): segmap, ustream, maps = pipeline_classes(lines, 64, [23]) r = match_index(ustream, maps[23], 23, lm, anchor, restarts=8) rows[name] = dict(index=r["index"], test_bits=r["test_bits"], scrambled_bits=r["scrambled_bits"], anchor_bits=anchor) print(f" {name:12s} index={r['index']:.3f} bits={r['test_bits']:.3f} " f"scr={r['scrambled_bits']:.3f} anchor={anchor:.3f}", flush=True) results["pinyin_attack"] = rows (OUT / "syllabic_results.json").write_text( json.dumps(results, indent=1, default=float)) print("done")