engine: the verses indexed by root — the pairwise middot read, not scan

Over the whole scroll (861cd4e6) gezerah shavah, binyan av and shnei
ketuvim scanned verse pairs — quadratic over 5,853 verses, 2.9 s in the
middot suite and waiting to be a live cost the day a middah is
consulted. The generator now also writes root_in(Root, Book, Ch, Vs),
one fact per root occurrence (49,542), exported by torah_text; the
pairwise rules read the first verse and find the second (and third) by
the root's index: shared_keyword, binyan_av_two, verses_contradict,
resolving_verse; verses_mentioning_root is the index itself. Same
answers (middot 47/47, phase3 28/28 unchanged), middot suite 2.865 s →
0.112 s. l1_sha256 unchanged (the facts are derived from the same L1);
--check passes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Scott KarpandClaude Fable 5.1 committed 2026-10-25 02:16:08 +00:00
1 parent 94ec324cc0
commit f6651425ff
6 files changed
+49569 -14

No files matched your search

+1 -2
View File
@@ -55,10 +55,9 @@ binyan_av_two(
CommonRoot
) :-
verse(B1, C1, V1, Roots1, _),
verse(B2, C2, V2, Roots2, _),
member(CommonRoot, Roots1),
member(CommonRoot, Roots2),
root_domain(CommonRoot, Domain),
root_in(CommonRoot, B2, C2, V2), % by the index, not a scan
ref(B1,C1,V1) \= ref(B2,C2,V2).
%% ============================================================
+4 -2
View File
@@ -25,11 +25,13 @@
%% shared_keyword(Verse1, Verse2, SharedRoot)
%% Two verses share a Hebrew root, creating a verbal link.
%% The first verse is read; the second is found by the root's index
%% (root_in/4), not by scanning the scroll (2026-10-25: over 5,853
%% verses the scan was quadratic).
shared_keyword(ref(Book1, Ch1, Vs1), ref(Book2, Ch2, Vs2), SharedRoot) :-
verse(Book1, Ch1, Vs1, Roots1, _),
verse(Book2, Ch2, Vs2, Roots2, _),
member(SharedRoot, Roots1),
member(SharedRoot, Roots2),
root_in(SharedRoot, Book2, Ch2, Vs2),
ref(Book1, Ch1, Vs1) \= ref(Book2, Ch2, Vs2).
%% ============================================================
+4 -5
View File
@@ -33,11 +33,10 @@
%% Verses contradict if their roots map to conflicting domains
verses_contradict(ref(B1,C1,V1), ref(B2,C2,V2), domain_conflict(D1, D2)) :-
verse(B1, C1, V1, Roots1, _),
verse(B2, C2, V2, Roots2, _),
member(R1, Roots1),
member(R2, Roots2),
root_domain(R1, D1),
root_domain(R2, D2),
root_in(R2, B2, C2, V2), % by the index, not a scan
domains_in_tension(D1, D2),
ref(B1,C1,V1) \= ref(B2,C2,V2).
@@ -62,10 +61,10 @@ domains_in_tension(covenant, authority).
resolving_verse(ref(B1,C1,V1), ref(B2,C2,V2), ref(B3,C3,V3)) :-
verse(B1, C1, V1, Roots1, _),
verse(B2, C2, V2, Roots2, _),
verse(B3, C3, V3, Roots3, _),
%% Third verse shares a root with first verse
%% Third verse shares a root with first verse — by the index
member(SharedRoot1, Roots1),
member(SharedRoot1, Roots3),
root_in(SharedRoot1, B3, C3, V3),
verse(B3, C3, V3, Roots3, _),
%% Third verse shares a root with second verse
member(SharedRoot2, Roots2),
member(SharedRoot2, Roots3),
File diff suppressed because it is too large. Load diff
@@ -10,6 +10,7 @@
:- module(torah_text, [
verse/5,
root_in/4,
verse_roots/4,
verses_in_chapter/3,
verses_mentioning_root/2
@@ -42,8 +43,6 @@ verse_roots(Book, Chapter, Verse, Roots) :-
verses_in_chapter(Book, Chapter, Count) :-
aggregate_all(count, verse(Book, Chapter, _, _, _), Count).
%% Find all verses mentioning a specific root
%% Find all verses mentioning a specific root — by the index.
verses_mentioning_root(Root, Verses) :-
findall(ref(Book, Ch, Vs),
(verse(Book, Ch, Vs, Roots, _), member(Root, Roots)),
Verses).
findall(ref(Book, Ch, Vs), root_in(Root, Book, Ch, Vs), Verses).