# decryption_complete: false # source: /Voynich/run_referential_core_019.py # stated_sha256: cf984ab16615f05acc9b80a42c6098b02e37132684ed93ef8b08bbc3813fbdfa # matches_stated_sha256: false # pdf_pages: 156-159 # note: The stated SHA-256 is the digest printed in the PDF. # The PDF page extract follows the form feed. decryption_complete stays false. run_referential_core_019.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 run_referential_core_019.py Source: /Voynich/run_referential_core_019.py SHA-256: cf984ab16615f05acc9b80a42c6098b02e37132684ed93ef8b08bbc3813fbdfa !/usr/bin/env python3 """REFERENTIAL-CORE-019: duplicate-illustration recurrence in the 75-stem core. Frozen gate: - Remove EXTERNAL-ANCHOR-ATTACK-018 label/register candidates A3 C1 and Q1 A3 B2. - Use the remaining 75 fixed proto-stems without remapping. - Duplicate groups come only from pre-existing ZL3b 'Same plant as' annotations. - ZL and GC are independent witnesses. - Compare count-IDF weighted page similarity to section-pair and opportunity matched random pairs (10,000 aggregate replicates). - Aggregate pass requires p<.05 in both witnesses and every duplicate pair above its matched-control median. - Stem promotion requires cross-witness support in >=2 duplicate groups and a selection-aware maximum-stat p<.05 in both witnesses. - Because every reusable duplicate group includes a question-marked source annotation, even a pass can establish only same-object recurrence, never a botanical species name or literal historical-language word. """ from __future__ import annotations import csv,hashlib,json,math,re from collections import Counter,defaultdict from pathlib import Path import numpy as np DATA=Path('crosswalk002_inputs/Voynich_Line_Local_Reproducibility_2026-08-22/data') LEX=Path('proto_stem_lexicon_003/proto_stem_lexicon.csv') META=Path('external_voynich_units/data/voynich-units/ZL3b.txt') OUT=Path('referential_core_019');OUT.mkdir(exist_ok=True) SEED=20260829;REPS=10000;REMOVED={'A3 C1','Q1 A3 B2'} TOK_RE=re.compile(r'[A-Z][0-9a-z]');LOC_RE=re.compile(r'^<([^>.]+)\.([^,>]+),([^>]*)>\s*(.*)$') def section(f): n=int(re.search(r'\d+',f).group());return 'Herbal' if n<=66 else 'Astro' if n<=73 else 'Bio' if 75<=n<=84 else 'Pharma' if 87<=n<=102 else 'Recipes' if 103<=n<=116 else 'Other' def clean(text): text=re.sub(r'<[^>]*>','',text).replace('[','').replace(']','').replace(':','') out=[] for w in re.split(r'[.,\s]+',text): a=TOK_RE.findall(w) if len(a)>=3:out.append(' '.join(a[1:-1])) return out def parse(path,wit,stems): rows=[];pending=None for raw in path.read_text(errors='ignore').splitlines(): m=LOC_RE.match(raw) if m: fol,line,tag,text=m.groups();pending=[fol,line,tag,text] if text.strip():rows.append(tuple(pending));pending=None elif pending and raw and not raw.startswith(('<','#')): pending[3]=(pending[3]+' '+raw).strip();rows.append(tuple(pending));pending=None pages=defaultdict(Counter);registers=defaultdict(lambda:defaultdict(Counter));allbodies=defaultdict(Cou nter) for fol,line,tag,text in rows: if not re.match(r'^f\d+[rv]\d?$',fol):continue reg='LABEL' if 'L' in tag else 'PROSE' if 'P' in tag else 'OTHER' for b in clean(text): allbodies[fol][b]+=1 if b in stems:pages[fol][b]+=1;registers[fol][reg][b]+=1 return pages,registers,allbodies def metadata_groups(path): cur='';items=[] run_referential_core_019.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 2 for raw in path.read_text(errors='replace').splitlines(): m=re.match(r'^<(f\d+[rv]\d?)>\s',raw) if m:cur=m.group(1) if 'Same plant as' in raw: target=raw.split('Same plant as',1)[1].strip().split('(')[0].strip() uncertain='?' in target;target=target.replace('?','').strip() items.append({'source':cur,'target':target,'uncertain':uncertain,'raw':raw[1:].strip()}) by=defaultdict(list) for x in items:by[x['target']].append(x) groups=[] # Multiple source folios pointing to the same fragment form one duplicate group. for target,xs in by.items(): if len(xs)>=2: for i in range(len(xs)): for j in range(i+1,len(xs)): groups.append({'group_id':f'SHARED-TARGET-{len(groups)+1:02d}','folio_a':xs[i]['source'],'folio_b': xs[j]['source'],'basis':target,'uncertain':int(xs[i]['uncertain'] or xs[j]['uncertain']),'source_notes':xs[i]['raw']+' || '+xs[j]['raw']}) # Whole-page counterpart noted directly in the source. for x in items: if re.fullmatch(r'f\d+[rv]\d?',x['target']) and x['source']!=x['target']: groups.append({'group_id':f'DIRECT-PAIR-{len(groups)+1:02d}','folio_a':x['source'],'folio_b':x['targe t'],'basis':x['target'],'uncertain':int(x['uncertain']),'source_notes':x['raw']}) # Deduplicate unordered pairs. out=[];seen=set() for g in groups: k=tuple(sorted((g['folio_a'],g['folio_b']))) if k not in seen:seen.add(k);out.append(g) return out,items def weighted_jaccard(a,b,idf): keys=set(a)|set(b);den=sum(max(a[k],b[k])*idf[k] for k in keys);num=sum(min(a[k],b[k])*idf[k] for k in keys) return num/den if den else 0.0 def matched_pool(pages,a,b,idf,actual_pairs): sa,sb=section(a),section(b);na=sum(pages.get(a,{}).values());nb=sum(pages.get(b,{}).values());out=[] fols=sorted(pages) for i,x in enumerate(fols): for y in fols[i+1:]: if tuple(sorted((x,y))) in actual_pairs:continue if sorted((section(x),section(y)))!=sorted((sa,sb)):continue nx=sum(pages[x].values());ny=sum(pages[y].values()) # Match each side to either orientation with a 2x opportunity tolerance. ok=(.5<=nx/max(na,1)<=2 and .5<=ny/max(nb,1)<=2) or (.5<=nx/max(nb,1)<=2 and .5<=ny/max(na,1)<=2) if ok:out.append((x,y,weighted_jaccard(pages[x],pages[y],idf))) return out def main(): lex=list(csv.DictReader(LEX.open()));stems=[r['payload'] for r in lex if r['payload'] not in REMOVED];sid={r['payload']:r['stem_id'] for r in lex} groups,source_items=metadata_groups(META);actual={tuple(sorted((g['folio_a'],g['folio_b']))) for g in groups} results=[];nullrows=[];support_rows=[];summary_w={};rng=np.random.default_rng(SEED) parsed={} for wit in ('ZL','GC'): pages,regs,allb=parse(DATA/(wit+'.txt'),wit,set(stems));parsed[wit]=(pages,regs,allb) df=Counter(); for q in pages.values(): for s in q:df[s]+=1 N=len(pages);idf={s:math.log2((N+1)/(df[s]+1))+1 for s in stems} pools=[];obs=[];pair_above=[] for g in groups: a,b=g['folio_a'],g['folio_b'];score=weighted_jaccard(pages.get(a,{}),pages.get(b,{}),idf);pool=matche d_pool(pages,a,b,idf,actual);vals=[x[2] for x in pool];med=float(np.median(vals)) if vals else float('nan');pct=float((1+sum(v>=score for v in vals))/(len(vals)+1)) if vals else 1.0 run_referential_core_019.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 3 shared=sorted(set(pages.get(a,{}))&set(pages.get(b,{}))) results.append({'witness':wit,**g,'section_pair':section(a)+'>'+section(b),'a_events':sum(pages.get(a ,{}).values()),'b_events':sum(pages.get(b,{}).values()),'weighted_jaccard':score,'matched_pairs':len(val s),'matched_median':med,'pair_empirical_p':pct,'above_matched_median':int(bool(vals) and score>med),'shared_stems':'|'.join(f'{sid[s]}:{s}' for s in shared)}) pools.append(pool);obs.append(score);pair_above.append(bool(vals) and score>med) valid=[i for i,p in enumerate(pools) if p] obsmean=float(np.mean([obs[i] for i in valid])) if valid else 0 null=np.zeros(REPS) sampled_pairs=[] for rep in range(REPS): picked=[] for i in valid: q=pools[i][rng.integers(len(pools[i]))];picked.append(q);sampled_pairs.append({'witness':wit,'replic ate':rep,'group_id':groups[i]['group_id'],'folio_a':q[0],'folio_b':q[1],'similarity':q[2]}) null[rep]=np.mean([x[2] for x in picked]) if picked else 0 p=(1+(null>=obsmean).sum())/(REPS+1) # Candidate stem support across duplicate groups; selection-aware maximum support null. observed_support={s:sum(s in pages.get(g['folio_a'],{}) and s in pages.get(g['folio_b'],{}) for g in groups) for s in stems} null_support=np.zeros((REPS,len(stems)),dtype=np.int8) for rep in range(REPS): pairs=[] for pool in pools: if pool: q=pool[rng.integers(len(pool))];pairs.append((q[0],q[1])) for j,s in enumerate(stems):null_support[rep,j]=sum(s in pages.get(a,{}) and s in pages.get(b,{}) for a,b in pairs) maxsup=null_support.max(1) for j,s in enumerate(stems): os=observed_support[s];support_rows.append({'witness':wit,'stem_id':sid[s],'payload':s,'duplicate_gro ups_supported':os,'familywise_p':(1+(maxsup>=os).sum())/(REPS+1),'supporting_groups':'|'.join(g['group_i d'] for g in groups if s in pages.get(g['folio_a'],{}) and s in pages.get(g['folio_b'],{}))}) nullrows.extend(sampled_pairs) summary_w[wit]={'available_pages':N,'duplicate_groups':len(groups),'valid_matched_groups':len(valid),' observed_mean_similarity':obsmean,'null_mean_similarity':float(null.mean()),'aggregate_p':float(p),'pair s_above_matched_median':sum(pair_above),'aggregate_pass':bool(p<.05 and all(pair_above))} # Cross-witness candidate promotions. z={r['payload']:r for r in support_rows if r['witness']=='ZL'};c={r['payload']:r for r in support_rows if r['witness']=='GC'} promoted=[s for s in stems if z[s]['duplicate_groups_supported']>=2 and c[s]['duplicate_groups_supported']>=2 and z[s]['familywise_p']<.05 and c[s]['familywise_p']<.05] # Positive-control receipt for the previously earned Pleiades body. pc=[] for wit in ('ZL','GC'): _,_,allb=parsed[wit];body='A1 A3 C1';pc.append({'witness':wit,'body':body,'f68r3_count':allb.get('f68r 3',{}).get(body,0),'f1r_count':allb.get('f1r',{}).get(body,0),'f113r_count':allb.get('f113r',{}).get(bod y,0),'control_pass':int(allb.get('f68r3',{}).get(body,0)>=1 and allb.get('f1r',{}).get(body,0)>=1 and allb.get('f113r',{}).get(body,0)>=1)}) with (OUT/'duplicate_group_source_ledger.csv').open('w',newline='') as f:w=csv.DictWriter(f,fieldnames=groups[0]);w.writeheader();w.writerows(groups) with (OUT/'duplicate_pair_results.csv').open('w',newline='') as f:w=csv.DictWriter(f,fieldnames=results[0]);w.writeheader();w.writerows(results) with (OUT/'matched_pair_null.csv').open('w',newline='') as f:w=csv.DictWriter(f,fieldnames=nullrows[0]) ;w.writeheader();w.writerows(nullrows) with (OUT/'stem_duplicate_support.csv').open('w',newline='') as f:w=csv.DictWriter(f,fieldnames=support_rows[0]);w.writeheader();w.writerows(support_rows) with (OUT/'positive_control_pleiades.csv').open('w',newline='') as f:w=csv.DictWriter(f,fieldnames=pc[0]);w.writeheader();w.writerows(pc) decision='REFERENTIAL_CORE_PASS' if all(summary_w[w]['aggregate_pass'] for w in ('ZL','GC')) and promoted else 'NO_REFERENTIAL_CORE_PROMOTION' summary={'test':'REFERENTIAL-CORE-019','date':'2026-08-29','seed':SEED,'null_replicates':REPS,'original _stems':77,'removed_register_candidates':sorted(REMOVED),'tested_stems':len(stems),'duplicate_groups':le run_referential_core_019.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 4 n(groups),'all_duplicate_groups_question_marked':all(g['uncertain'] for g in groups),'witnesses':summary_w,'promoted_stems':promoted,'promoted_stem_count':len(promoted),'literal_kno wn_language_words_added':0,'decision':decision,'boundary':'Question-marked duplicate drawings can test recurrence but cannot authenticate a species name.'} (OUT/'summary.json').write_text(json.dumps(summary,indent=2)) grouptext='\n'.join(f"- {g['group_id']}: {g['folio_a']} <-> {g['folio_b']} via `{g['basis']}`; uncertain={g['uncertain']}." for g in groups) resulttext='\n'.join(f"- {w}: mean={summary_w[w]['observed_mean_similarity']:.6f}; null mean={summary_w[w]['null_mean_similarity']:.6f}; p={summary_w[w]['aggregate_p']:.6f}; pairs above median={summary_w[w]['pairs_above_matched_median']}/{len(groups)}." for w in ('ZL','GC')) report=f'''# Voynich REFERENTIAL-CORE-019\n\nDate: 2026-08-29\n\n## Frozen design\n\nThe two cross-domain label/register candidates from test 018 (`A3 C1`, `Q1 A3 B2`) were removed from the fixed 77-stem inventory. The remaining 75 stems were tested for recurrence across pre-existing duplicate-illustration annotations. ZL and GC were scored independently. Section-pair and opportunity-matched page pairs supplied 10,000 aggregate null replicates.\n\n## Available duplicate groups\n\n{grouptext}\n\nAll reusable groups inherit at least one question-marked identification. They are therefore exploratory same-object comparators, not authenticated plant-species ground truth.\n\n## Result\n\n{resulttext}\n\n- Selection-aware cross-witness stem promotions: {len(promoted)}.\n- Literal known-language words added: 0.\n- Decision: `{decision}`.\n\nThe previously earned Pleiades body `A1 A3 C1` was retained as a positive parser/control receipt; it was not allowed to select duplicate-plant stems and is outside the 75-stem promotion contest.\n\n## Interpretation\n\nRemoving the two demonstrated register payloads does not reveal a stable same-object lexical core across the surviving duplicate drawings. Because the available duplicate corpus is tiny and question-marked, this test closes only the present duplicate-illustration route. It does not prove that the manuscript lacks referential stems.\n\n## Rule recovery audit\n\nThe six-rule ledger remains unchanged. REGISTER SHIFT retains the strengthening from test 018. CORE PRESERVATION is not semantically promoted by these duplicate groups. No seventh rule is added.\n''' (OUT/'Voynich_REFERENTIAL_CORE_019_REPORT_2026-08-29.md').write_text(report) audit=[{'rule':'LINE RESET','effect':'unchanged'},{'rule':'CORE PRESERVATION','effect':'not semantically promoted by duplicate groups'},{'rule':'EDGE HANDOFF','effect':'unchanged'},{'rule':'CONTEX TUAL INTERNAL REALIZATION','effect':'unchanged'},{'rule':'REGISTER SHIFT','effect':'retains test-018 strengthening'},{'rule':'DOMAIN SPECIALIZATION','effect':'unchanged'}] with (OUT/'Voynich_REFERENTIAL_CORE_019_RULE_AUDIT.csv').open('w',newline='') as f:w=csv.DictWriter(f,fieldnames=audit[0]);w.writeheader();w.writerows(audit) paths=[Path(__file__),OUT/'summary.json',OUT/'duplicate_group_source_ledger.csv',OUT/'duplicate_pair_re sults.csv',OUT/'matched_pair_null.csv',OUT/'stem_duplicate_support.csv',OUT/'positive_control_pleiades.c sv',OUT/'Voynich_REFERENTIAL_CORE_019_REPORT_2026-08-29.md',OUT/'Voynich_REFERENTIAL_CORE_019_RULE_AUDIT .csv'] with (OUT/'Voynich_REFERENTIAL_CORE_019_SHA256_2026-08-29.txt').open('w') as f: for p in paths:f.write(hashlib.sha256(p.read_bytes()).hexdigest()+' '+p.name+'\n') print(json.dumps(summary,indent=2));print('\nPAIR RESULTS') for r in results:print(r['witness'],r['group_id'],r['folio_a'],r['folio_b'],round(r['weighted_jaccard'] ,4),'median',round(r['matched_median'],4),'p',round(r['pair_empirical_p'],4),r['shared_stems'][:100]) if __name__=='__main__':main()