# decryption_complete: false # source: archive/local/external_voynich_units/voynich_decipherment_repro_bundle/decipherment_attack_v5/e3_positional.py # stated_sha256: 7cddd55facbc6accadb7f3de4ba7c20256c6aceb3e43a9fb276c614a8ce79894 # matches_stated_sha256: false # pdf_pages: 303-303 # 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 2302 archive/local/external_voynich_units/voynich_decipherme nt_repro_bundle/decipherment_attack_v5/e3_positional.p y SHA-256: 7cddd55facbc6accadb7f3de4ba7c20256c6aceb3e43a9fb276c614a8ce79894 | 3,275 bytes | workspace supplement #!/usr/bin/env python3 """E3: positional vs sequential information. If a line is a syntactic sentence, a token's identity is constrained mostly by its neighbours (sequential MI >> positional MI). If a line is a record/list entry with fields, identity is constrained mostly by the slot it occupies (positional MI competitive with or exceeding sequential MI). Both quantities are shuffle-corrected plug-in MI over the same symbol stream (top-2000 types), so they are directly comparable. """ from __future__ import annotations import json, math, random, sys from collections import Counter from pathlib import Path SCRATCH = Path(__file__).resolve().parent sys.path.insert(0, str(SCRATCH)) from unit_probe import voynich_lines, latin_words, to_lines, collapse def posbin(i, n): if i == 0: return "first" if i == n-1: return "last" if n <= 3: return "mid" q = (i-1)/(n-2) if n > 3 else 0.5 return f"q{min(3, int(q*4))}" def mi_pairs(pairs): uni_a, uni_b, joint = Counter(), Counter(), Counter() for a, b in pairs: uni_a[a] += 1; uni_b[b] += 1; joint[(a, b)] += 1 n = sum(joint.values()) h = lambda cnt: -sum(c/n*math.log2(c/n) for c in cnt.values()) return h(uni_a) + h(uni_b) - h(joint) def analyse(name, lines, n_shuffles=60): freq = Counter(w for ln in lines for w in ln) keep = {t for t, _ in freq.most_common(2000)} sym = lambda w: w if w in keep else "" sls = [[sym(w) for w in ln] for ln in lines if len(ln) >= 2] r = random.Random(5) seq_pairs = [(a, b) for ln in sls for a, b in zip(ln, ln[1:])] pos_pairs = [(w, posbin(i, len(ln))) for ln in sls for i, w in enumerate(ln)] seq_obs, pos_obs = mi_pairs(seq_pairs), mi_pairs(pos_pairs) seq_null, pos_null = [], [] flat = [w for ln in sls for w in ln] lens = [len(ln) for ln in sls] for _ in range(n_shuffles): # sequential null: shuffle within lines (kills order, keeps line makeup) s = [list(ln) for ln in sls] for ln in s: r.shuffle(ln) seq_null.append(mi_pairs([(a, b) for ln in s for a, b in zip(ln, ln[1:])])) # positional null: shuffle tokens across the corpus, keep line lengths f = flat[:] r.shuffle(f) it = iter(f) s2 = [[next(it) for _ in range(L)] for L in lens] pos_null.append(mi_pairs([(w, posbin(i, len(ln))) for ln in s2 for i, w in enumerate(ln)])) seq_ex = seq_obs - sum(seq_null)/len(seq_null) pos_ex = pos_obs - sum(pos_null)/len(pos_null) H1 = mi_pairs([(w, w) for w in flat]) # = unigram entropy print(f"{name:10s} H1={H1:.2f} seq excess={seq_ex:.4f}b ({seq_ex/H1*100:.2f}%) " f"pos excess={pos_ex:.4f}b ({pos_ex/H1*100:.2f}%) pos/seq={pos_ex/seq_ex:.2f}", flush=True) return dict(H1=H1, seq_excess=seq_ex, pos_excess=pos_ex, seq_share=seq_ex/H1, pos_share=pos_ex/H1) if __name__ == "__main__": vy = [[collapse(w) for w in ln] for ln in voynich_lines()] lat = to_lines(latin_words()) # pseudo-lines: positional MI should be ~0 out = {"voynich": analyse("voynich", vy), "latin": analyse("latin", lat)} (SCRATCH / "output" / "e3_results.json").write_text(json.dumps(out, indent=2))