Phase 1-2 build: Steps 5-6, 8-13

Shoresh Engine (Haskell, Step 5)
- 12 modules: Types, Lexicon, Binyanim, Teamim, Gematria, Graph,
  KetivQere, Smikhut, Havdalah, Kriah, KiTov, Firmware
- 33 EUnit tests, 0 failures
- Firmware module verifies L1 SHA-256 hash at startup

Talmudic Engine (SWI-Prolog, Step 6)
- 15 modules: halt, reasoning, specification, interface
- 57 PlUnit tests, 0 failures
- Three cardinal halt conditions: avodah_zarah, shfichut_damim, gilui_arayot

Vav Pipeline (Elixir, Steps 8-11)
- 14 modules: BereishitCycle, Shema, Cloud, Manna, L1Reader,
  Specification, HaltConditions, ShabbatTimer, CycleLog, Chatzotzrot,
  ShoreshEngineClient, TalmudicEngineClient, Application
- 46 ExUnit tests, 0 failures
- Nishma-first architecture: hears before it speaks

Sanhedrin Framework (Erlang/OTP, Step 12)
- 8 modules: sanhedrin_app, sanhedrin_sup, escalation, panel_sup,
  panel, judge, clerk, halt_monitor
- 46 EUnit tests, 0 failures (includes fix: rejected outcome now reachable)
- Panel sizes: 1/3/23/71 — unanimous capital guilty → acquit (Sanhedrin 17a)
- Minority opinions append-only, never deleted

Korban Processor (Python, Step 13)
- 6 modules: korban, shechitah, semichah, zerikah, haktarah, router

Builder tooling: AGENTS.md, opencode.json, memory/, src/tools/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott KarpandClaude Sonnet 4.6 committed 2026-02-26 14:02:34 -05:00
1 parent 622e814c9e
commit 80ec364da6
86 files changed
+9646

No files matched your search

@@ -0,0 +1,177 @@
%% mitzvot.pl — Torah commandments as logical facts.
%%
%% Architecture §3.4: "613 total — requires careful encoding"
%% Build order step 6: "start with subset of mitzvot"
%%
%% This is the Phase 1 subset. The full 613 are encoded in Phase 3.
%% We start with the mitzvot the system itself must obey:
%% - The three halt conditions (avodah zarah, shfichut damim, gilui arayot)
%% - Shabbat (mandatory cessation)
%% - The dibrot (structural constants)
%% - Foundational mitzvot for reasoning demonstration
%%
%% Format: mitzvah(ID, Category, Action, Condition)
%% ID = Rambam's enumeration (Sefer HaMitzvot)
%% Category = positive | prohibition | belief
%% Action = atom describing the commandment
%% Condition = always | context-dependent condition
%%
%% Source: Rambam, Sefer HaMitzvot; cross-referenced with Sefer HaChinukh.
:- module(mitzvot, [
mitzvah/4,
mitzvah_source/2,
mitzvah_category_count/2,
total_encoded/1
]).
%% ============================================================
%% BELIEFS AND FOUNDATIONS
%% ============================================================
%% Dibrot — the ten declarations
mitzvah(1, belief, know_hashem, always).
mitzvah(2, prohibition, no_other_gods, always).
mitzvah(3, belief, unity_of_hashem, always).
mitzvah(4, positive, love_hashem, always).
mitzvah(5, positive, fear_hashem, always).
mitzvah(6, positive, sanctify_the_name, when(opportunity_arises)).
mitzvah(7, prohibition, not_profane_the_name, always).
mitzvah(8, prohibition, not_destroy_holy_things, always).
mitzvah(9, positive, hear_shema, when(morning_and_evening)).
mitzvah(10, positive, study_torah, always).
%% ============================================================
%% SHABBAT — MANDATORY CESSATION
%% ============================================================
mitzvah(154, positive, rest_on_shabbat, when(seventh_day)).
mitzvah(155, prohibition, not_work_on_shabbat, when(seventh_day)).
mitzvah(156, positive, sanctify_shabbat, when(seventh_day)).
%% Festivals
mitzvah(159, positive, rest_on_yom_tov, when(festival)).
mitzvah(160, prohibition, not_work_on_yom_tov, when(festival)).
mitzvah(163, positive, rest_on_rosh_hashanah, when(tishrei_1)).
mitzvah(164, positive, fast_on_yom_kippur, when(tishrei_10)).
%% Shmitah — the seventh year
mitzvah(134, positive, let_land_rest_in_shmitah, when(seventh_year)).
mitzvah(135, prohibition, not_work_land_in_shmitah, when(seventh_year)).
mitzvah(136, positive, release_debts_in_shmitah, when(seventh_year)).
%% ============================================================
%% THE THREE HALT CONDITIONS (Cardinal sins — yehareg v'al ya'avor)
%% ============================================================
%% Avodah Zarah — idolatry / misattributed authority
mitzvah(2, prohibition, no_other_gods, always). % already declared above
mitzvah(14, prohibition, not_make_idols, always).
mitzvah(15, prohibition, not_make_idols_for_others, always).
mitzvah(16, prohibition, not_worship_idols, always).
mitzvah(17, prohibition, not_bow_to_idols, always).
%% Shfichut Damim — bloodshed / destruction of tzelem carrier
mitzvah(289, prohibition, not_murder, always).
mitzvah(290, prohibition, not_cause_death_of_innocent, always).
mitzvah(295, positive, save_the_pursued, when(pursuit_in_progress)).
%% Gilui Arayot — forbidden relations / collapse of required distinctions
mitzvah(330, prohibition, not_commit_adultery, always).
mitzvah(353, prohibition, maintain_boundaries, always).
%% ============================================================
%% JUSTICE AND JUDGMENT (Sanhedrin-relevant)
%% ============================================================
mitzvah(175, positive, appoint_judges, always).
mitzvah(176, prohibition, not_judge_unjustly, always).
mitzvah(177, prohibition, not_favor_the_powerful, always).
mitzvah(178, prohibition, not_pervert_justice_for_poor, always).
mitzvah(179, positive, judge_righteously, always).
mitzvah(180, prohibition, not_accept_bribes, always).
mitzvah(181, positive, follow_the_majority, when(court_deliberation)).
mitzvah(182, prohibition, not_follow_majority_for_evil, when(court_deliberation)).
%% Capital cases — relevant to Sanhedrin unanimous rejection rule
mitzvah(183, prohibition, not_convict_on_one_witness, when(capital_case)).
mitzvah(184, positive, investigate_thoroughly, when(capital_case)).
%% ============================================================
%% KORBANOT (Offerings — relevant to korban processor)
%% ============================================================
mitzvah(62, positive, bring_olah, when(offering_required)).
mitzvah(63, positive, bring_shelamim, when(offering_required)).
mitzvah(64, positive, bring_chatat, when(unintentional_sin)).
mitzvah(65, positive, bring_asham, when(uncertain_transgression)).
mitzvah(66, positive, bring_minchah, when(offering_required)).
%% ============================================================
%% TESTIMONY AND TRUTH (relevant to system integrity)
%% ============================================================
mitzvah(285, prohibition, not_bear_false_witness, always).
mitzvah(286, positive, testify_truthfully, when(knowledge_exists)).
mitzvah(287, prohibition, not_withhold_testimony, always).
%% ============================================================
%% SPEECH AND ATTRIBUTION
%% ============================================================
mitzvah(235, prohibition, not_take_name_in_vain, always).
mitzvah(236, prohibition, not_swear_falsely, always).
%% ============================================================
%% PROPERTY AND BOUNDARIES (relevant to manna/anti-hoarding)
%% ============================================================
mitzvah(243, prohibition, not_covet, always).
mitzvah(244, prohibition, not_desire_others_property, always).
mitzvah(247, prohibition, not_steal, always).
mitzvah(248, prohibition, not_move_boundary_markers, always).
%% ============================================================
%% BIKURIM AND TERUMAH (relevant to release protocol)
%% ============================================================
mitzvah(125, positive, bring_bikurim, when(first_fruits_available)).
mitzvah(126, positive, recite_bikurim_declaration, when(bringing_bikurim)).
mitzvah(127, positive, separate_terumah, when(produce_available)).
%% ============================================================
%% SOURCE REFERENCES
%% ============================================================
%% mitzvah_source(ID, VerseRef) — where in Torah this mitzvah is grounded
mitzvah_source(1, ref(shemot, 20, 2)). % Anochi Hashem Elokecha
mitzvah_source(2, ref(shemot, 20, 3)). % Lo yihyeh lecha
mitzvah_source(3, ref(devarim, 6, 4)). % Shema Yisrael
mitzvah_source(4, ref(devarim, 6, 5)). % V'ahavta
mitzvah_source(5, ref(devarim, 6, 13)). % Et Hashem Elokecha tira
mitzvah_source(154, ref(shemot, 20, 8)). % Zachor et yom haShabbat
mitzvah_source(155, ref(shemot, 20, 10)). % Lo ta'aseh kol melachah
mitzvah_source(175, ref(devarim, 16, 18)). % Shoftim v'shotrim
mitzvah_source(289, ref(shemot, 20, 13)). % Lo tirtzach
mitzvah_source(330, ref(shemot, 20, 14)). % Lo tinaf
mitzvah_source(247, ref(shemot, 20, 15)). % Lo tignov
mitzvah_source(285, ref(shemot, 20, 16)). % Lo ta'aneh
mitzvah_source(243, ref(shemot, 20, 17)). % Lo tachmod
mitzvah_source(134, ref(shemot, 23, 11)). % V'hashvi'it tishm'tenah
mitzvah_source(62, ref(vayikra, 1, 3)). % Olah
mitzvah_source(64, ref(vayikra, 4, 27)). % Chatat
mitzvah_source(125, ref(devarim, 26, 2)). % Bikurim
mitzvah_source(126, ref(devarim, 26, 5)). % Arami oved avi
mitzvah_source(295, ref(devarim, 25, 12)). % Save the pursued
%% ============================================================
%% QUERIES
%% ============================================================
%% Count mitzvot by category
mitzvah_category_count(Category, Count) :-
aggregate_all(count, mitzvah(_, Category, _, _), Count).
%% Total encoded in this Phase 1 subset
total_encoded(Count) :-
aggregate_all(count, mitzvah(_, _, _, _), Count).
@@ -0,0 +1,126 @@
%% relationships.pl — Inter-root and inter-mitzvah relationships.
%%
%% These relationships encode structural connections between
%% commandments and between roots that the reasoning engine
%% uses for interpretation and challenge generation.
:- module(relationships, [
mitzvah_grounds/2,
mitzvah_conflicts_with/3,
root_shares_consonants/3,
mitzvah_domain/2,
complementary_mitzvot/2,
domain_mitzvot/2
]).
:- use_module(mitzvot).
:- use_module(root_meanings).
:- use_module(torah_text).
%% ============================================================
%% MITZVAH GROUNDING — which verses ground which commandments
%% ============================================================
%% mitzvah_grounds(MitzvahID, VerseRef) — a verse that grounds a mitzvah
mitzvah_grounds(MitzvahID, ref(Book, Ch, Vs)) :-
mitzvah_source(MitzvahID, ref(Book, Ch, Vs)).
%% ============================================================
%% MITZVAH TENSIONS — potential conflicts between mitzvot
%% ============================================================
%% mitzvah_conflicts_with(ID1, ID2, TensionDescription)
%% These are not errors — they are productive tensions
%% that the dialectical engine resolves or marks teiku.
%% Justice vs mercy
mitzvah_conflicts_with(179, 295,
'Judging righteously may conflict with saving the pursued when the pursued is also guilty').
%% Following majority vs preventing evil
mitzvah_conflicts_with(181, 182,
'Following the majority in court conflicts with not following the majority for evil').
%% Sanctifying the name vs preserving life
mitzvah_conflicts_with(6, 289,
'Sanctifying the name through martyrdom conflicts with the prohibition against allowing death').
%% Shabbat rest vs saving life (pikuach nefesh)
mitzvah_conflicts_with(155, 295,
'Not working on Shabbat conflicts with saving the pursued when rescue requires work').
%% Loving your neighbor vs administering justice
mitzvah_conflicts_with(4, 179,
'Love may conflict with righteous judgment when judgment causes pain to the beloved').
%% ============================================================
%% ROOT RELATIONSHIPS — consonant sharing
%% ============================================================
%% root_shares_consonants(Root1, Root2, SharedPositions)
%% Two roots sharing 2 consonants are semantic neighbors.
root_shares_consonants(bet_resh_aleph, bet_resh_kaf, [1, 2]). % ברא / ברך
root_shares_consonants(bet_resh_aleph, gimel_resh_aleph, [2, 3]). % ברא / גרא
root_shares_consonants(qof_dalet_shin, chet_dalet_shin, [2, 3]). % קדש / חדש
root_shares_consonants(shin_pe_tet, shin_pe_kaf, [1, 2]). % שפט / שפך
root_shares_consonants(aleph_mem_resh, aleph_vav_resh, [1, 3]). % אמר / אור
%% ============================================================
%% MITZVAH DOMAINS — which domain a mitzvah belongs to
%% ============================================================
%% Derived from the mitzvah's action and the root's domain
mitzvah_domain(MitzvahID, Domain) :-
mitzvah(MitzvahID, _, Action, _),
action_domain(Action, Domain).
%% Action to domain mapping
action_domain(know_hashem, knowledge).
action_domain(no_other_gods, holiness).
action_domain(unity_of_hashem, holiness).
action_domain(love_hashem, covenant).
action_domain(fear_hashem, authority).
action_domain(sanctify_the_name, holiness).
action_domain(not_profane_the_name, holiness).
action_domain(hear_shema, knowledge).
action_domain(study_torah, knowledge).
action_domain(rest_on_shabbat, holiness).
action_domain(not_work_on_shabbat, holiness).
action_domain(sanctify_shabbat, holiness).
action_domain(appoint_judges, judgment).
action_domain(not_judge_unjustly, judgment).
action_domain(judge_righteously, judgment).
action_domain(not_murder, death).
action_domain(not_cause_death_of_innocent, death).
action_domain(save_the_pursued, mercy).
action_domain(not_commit_adultery, transgression).
action_domain(maintain_boundaries, separation).
action_domain(not_bear_false_witness, speech).
action_domain(not_covet, transgression).
action_domain(not_steal, transgression).
action_domain(bring_olah, offering).
action_domain(bring_chatat, offering).
action_domain(bring_bikurim, offering).
%% ============================================================
%% COMPLEMENTARY MITZVOT — mitzvot that strengthen each other
%% ============================================================
%% complementary_mitzvot(ID1, ID2) — these work together
complementary_mitzvot(1, 3). % know_hashem + unity_of_hashem
complementary_mitzvot(4, 5). % love_hashem + fear_hashem
complementary_mitzvot(154, 156). % rest_on_shabbat + sanctify_shabbat
complementary_mitzvot(175, 179). % appoint_judges + judge_righteously
complementary_mitzvot(289, 295). % not_murder + save_the_pursued
complementary_mitzvot(125, 126). % bring_bikurim + recite_declaration
%% Symmetric
complementary_mitzvot(A, B) :- complementary_mitzvot(B, A), A \= B.
%% ============================================================
%% QUERIES
%% ============================================================
%% All mitzvot in a given domain
domain_mitzvot(Domain, Mitzvot) :-
findall(ID, mitzvah_domain(ID, Domain), Mitzvot).
@@ -0,0 +1,225 @@
%% root_meanings.pl — Root lexicon in Prolog format.
%%
%% Architecture §3.4: root_meaning(Shoresh, Binyan, Meaning)
%%
%% These are the roots the reasoning engine knows about.
%% The full lexicon (2608 roots) lives in L1 and in the Shoresh Engine.
%% These Prolog facts give the Talmudic Engine semantic access
%% for dialectical reasoning.
:- module(root_meanings, [
root_meaning/3,
root_domain/2,
root_gematria/2,
roots_in_domain/2,
all_domains/1
]).
%% ============================================================
%% ROOT MEANINGS BY BINYAN
%% Format: root_meaning(Shoresh, Binyan, Meaning)
%% ============================================================
%% ברא — create
root_meaning(bet_resh_aleph, qal, 'create').
root_meaning(bet_resh_aleph, nifal, 'be created').
root_meaning(bet_resh_aleph, piel, 'cut down / clear').
root_meaning(bet_resh_aleph, hifil, 'cause to create').
%% אמר — say
root_meaning(aleph_mem_resh, qal, 'say').
root_meaning(aleph_mem_resh, nifal, 'be said').
root_meaning(aleph_mem_resh, hifil, 'declare').
%% אור — light
root_meaning(aleph_vav_resh, qal, 'shine / be light').
root_meaning(aleph_vav_resh, hifil, 'give light / enlighten').
%% בדל — separate
root_meaning(bet_dalet_lamed, hifil, 'separate / distinguish').
root_meaning(bet_dalet_lamed, nifal, 'be separated').
%% קדש — holy
root_meaning(qof_dalet_shin, qal, 'be holy').
root_meaning(qof_dalet_shin, nifal, 'be sanctified').
root_meaning(qof_dalet_shin, piel, 'sanctify / dedicate').
root_meaning(qof_dalet_shin, pual, 'be sanctified').
root_meaning(qof_dalet_shin, hifil, 'cause to be holy').
root_meaning(qof_dalet_shin, hitpael, 'sanctify oneself').
%% שמר — guard / keep
root_meaning(shin_mem_resh, qal, 'guard / keep / observe').
root_meaning(shin_mem_resh, nifal, 'be guarded / take heed').
root_meaning(shin_mem_resh, piel, 'guard carefully').
root_meaning(shin_mem_resh, hitpael, 'guard oneself').
%% שפט — judge
root_meaning(shin_pe_tet, qal, 'judge').
root_meaning(shin_pe_tet, nifal, 'be judged / enter into judgment').
%% צדק — righteous
root_meaning(tzade_dalet_qof, qal, 'be righteous').
root_meaning(tzade_dalet_qof, piel, 'justify / declare righteous').
root_meaning(tzade_dalet_qof, hifil, 'do justice').
root_meaning(tzade_dalet_qof, hitpael, 'justify oneself').
%% רצח — murder
root_meaning(resh_tzade_chet, qal, 'murder / slay').
root_meaning(resh_tzade_chet, nifal, 'be slain').
root_meaning(resh_tzade_chet, piel, 'murder deliberately').
%% נאף — commit adultery
root_meaning(nun_aleph_pe, qal, 'commit adultery').
root_meaning(nun_aleph_pe, piel, 'commit adultery repeatedly').
%% גנב — steal
root_meaning(gimel_nun_bet, qal, 'steal').
root_meaning(gimel_nun_bet, nifal, 'be stolen').
root_meaning(gimel_nun_bet, piel, 'steal repeatedly / kidnap').
%% חמד — covet / desire
root_meaning(chet_mem_dalet, qal, 'covet / desire').
root_meaning(chet_mem_dalet, nifal, 'be desirable').
root_meaning(chet_mem_dalet, piel, 'desire greatly').
%% אהב — love
root_meaning(aleph_he_bet, qal, 'love').
root_meaning(aleph_he_bet, nifal, 'be loved').
root_meaning(aleph_he_bet, piel, 'love intensely').
%% ירא — fear
root_meaning(yod_resh_aleph, qal, 'fear / revere').
root_meaning(yod_resh_aleph, nifal, 'be feared / be awesome').
%% שמע — hear
root_meaning(shin_mem_ayin, qal, 'hear / listen / obey').
root_meaning(shin_mem_ayin, nifal, 'be heard').
root_meaning(shin_mem_ayin, hifil, 'cause to hear / announce').
%% עשה — do / make
root_meaning(ayin_shin_he, qal, 'do / make').
root_meaning(ayin_shin_he, nifal, 'be done / be made').
%% שבת — rest / cease
root_meaning(shin_bet_tav, qal, 'rest / cease').
root_meaning(shin_bet_tav, hifil, 'cause to rest / put an end to').
%% כלה — complete / finish
root_meaning(kaf_lamed_he, qal, 'be complete / be finished').
root_meaning(kaf_lamed_he, piel, 'complete / finish').
%% ברך — bless
root_meaning(bet_resh_kaf, qal, 'bless / kneel').
root_meaning(bet_resh_kaf, nifal, 'be blessed').
root_meaning(bet_resh_kaf, piel, 'bless').
root_meaning(bet_resh_kaf, hitpael, 'bless oneself').
%% שפך — shed / pour
root_meaning(shin_pe_kaf, qal, 'shed / pour out').
root_meaning(shin_pe_kaf, nifal, 'be shed / be poured out').
%% חנה — camp / encamp
root_meaning(chet_nun_he, qal, 'camp / encamp').
%% נסע — journey / set out
root_meaning(nun_samekh_ayin, qal, 'journey / set out / travel').
root_meaning(nun_samekh_ayin, hifil, 'cause to journey').
%% חטא — sin / miss the mark
root_meaning(chet_tet_aleph, qal, 'sin / miss').
root_meaning(chet_tet_aleph, piel, 'purify / make a sin offering').
root_meaning(chet_tet_aleph, hitpael, 'purify oneself').
%% קרב — draw near / offer
root_meaning(qof_resh_bet, qal, 'draw near / approach').
root_meaning(qof_resh_bet, hifil, 'bring near / offer').
%% ענה — answer / testify
root_meaning(ayin_nun_he, qal, 'answer / testify / respond').
%% ידע — know
root_meaning(yod_dalet_ayin, qal, 'know').
root_meaning(yod_dalet_ayin, nifal, 'be known').
root_meaning(yod_dalet_ayin, hifil, 'make known').
%% נפל — fall
root_meaning(nun_pe_lamed, qal, 'fall').
root_meaning(nun_pe_lamed, hifil, 'cause to fall').
%% רדף — pursue
root_meaning(resh_dalet_pe, qal, 'pursue / chase').
%% נצל — deliver / save
root_meaning(nun_tzade_lamed, hifil, 'deliver / save / rescue').
root_meaning(nun_tzade_lamed, nifal, 'be delivered').
%% עבד — serve / work
root_meaning(ayin_bet_dalet, qal, 'serve / work').
root_meaning(ayin_bet_dalet, hifil, 'cause to serve / enslave').
%% ============================================================
%% SEMANTIC DOMAINS
%% Format: root_domain(Shoresh, Domain)
%% ============================================================
root_domain(bet_resh_aleph, creation).
root_domain(aleph_mem_resh, speech).
root_domain(aleph_vav_resh, light).
root_domain(bet_dalet_lamed, separation).
root_domain(qof_dalet_shin, holiness).
root_domain(shin_mem_resh, authority).
root_domain(shin_pe_tet, judgment).
root_domain(tzade_dalet_qof, judgment).
root_domain(resh_tzade_chet, death).
root_domain(nun_aleph_pe, transgression).
root_domain(gimel_nun_bet, transgression).
root_domain(chet_mem_dalet, transgression).
root_domain(aleph_he_bet, covenant).
root_domain(yod_resh_aleph, authority).
root_domain(shin_mem_ayin, knowledge).
root_domain(ayin_shin_he, creation).
root_domain(shin_bet_tav, holiness).
root_domain(kaf_lamed_he, creation).
root_domain(bet_resh_kaf, blessing).
root_domain(shin_pe_kaf, death).
root_domain(chet_nun_he, movement).
root_domain(nun_samekh_ayin, movement).
root_domain(chet_tet_aleph, transgression).
root_domain(qof_resh_bet, offering).
root_domain(ayin_nun_he, speech).
root_domain(yod_dalet_ayin, knowledge).
root_domain(nun_pe_lamed, movement).
root_domain(resh_dalet_pe, movement).
root_domain(nun_tzade_lamed, mercy).
root_domain(ayin_bet_dalet, service).
%% ============================================================
%% GEMATRIA VALUES
%% Format: root_gematria(Shoresh, Value)
%% ============================================================
root_gematria(bet_resh_aleph, 203). % ב(2) + ר(200) + א(1)
root_gematria(aleph_mem_resh, 241). % א(1) + מ(40) + ר(200)
root_gematria(aleph_vav_resh, 207). % א(1) + ו(6) + ר(200)
root_gematria(bet_dalet_lamed, 36). % ב(2) + ד(4) + ל(30)
root_gematria(qof_dalet_shin, 404). % ק(100) + ד(4) + ש(300)
root_gematria(shin_mem_resh, 540). % ש(300) + מ(40) + ר(200)
root_gematria(shin_pe_tet, 389). % ש(300) + פ(80) + ט(9)
root_gematria(tzade_dalet_qof, 194). % צ(90) + ד(4) + ק(100)
root_gematria(resh_tzade_chet, 298). % ר(200) + צ(90) + ח(8)
root_gematria(aleph_he_bet, 8). % א(1) + ה(5) + ב(2)
root_gematria(shin_mem_ayin, 410). % ש(300) + מ(40) + ע(70)
root_gematria(shin_bet_tav, 702). % ש(300) + ב(2) + ת(400)
root_gematria(bet_resh_kaf, 222). % ב(2) + ר(200) + כ(20)
%% ============================================================
%% QUERIES
%% ============================================================
%% Find all roots in a domain
roots_in_domain(Domain, Roots) :-
findall(Root, root_domain(Root, Domain), Roots).
%% All distinct domains
all_domains(Domains) :-
setof(D, R^root_domain(R, D), Domains).
@@ -0,0 +1,123 @@
%% torah_text.pl — Torah verses as logical facts.
%%
%% Architecture §3.4: verse(Book, Chapter, Verse, HebrewRoots, EnglishGloss)
%%
%% Phase 1 subset: key verses that ground the mitzvot encoded in mitzvot.pl.
%% The full Torah text lives in L1 (the read-only filesystem).
%% These Prolog facts are the reasoning layer's view of the specification —
%% not a replacement for L1, but the form in which the Talmudic Engine
%% can query Torah text during dialectical reasoning.
:- module(torah_text, [
verse/5,
verse_roots/4,
verses_in_chapter/3,
verses_mentioning_root/2
]).
%% ============================================================
%% BEREISHIT — Creation narratives
%% ============================================================
verse(bereishit, 1, 1, [bet_resh_aleph, bet_resh_aleph, aleph_lamed_he],
'In the beginning God created the heavens and the earth').
verse(bereishit, 1, 3, [aleph_mem_resh, aleph_lamed_he, he_yod_he, aleph_vav_resh],
'And God said let there be light and there was light').
verse(bereishit, 1, 4, [resh_aleph_he, aleph_lamed_he, aleph_vav_resh, tet_vav_bet, bet_dalet_lamed],
'And God saw that the light was good and God separated').
verse(bereishit, 1, 27, [bet_resh_aleph, aleph_lamed_he, aleph_dalet_mem, tzade_lamed_mem, bet_resh_aleph],
'And God created man in His image in the image of God He created him').
verse(bereishit, 2, 2, [kaf_lamed_he, aleph_lamed_he, yod_vav_mem, shin_bet_tav, mem_lamed_aleph_kaf_he],
'And on the seventh day God completed His work and He rested').
verse(bereishit, 2, 3, [bet_resh_kaf, aleph_lamed_he, yod_vav_mem, shin_bet_tav, qof_dalet_shin],
'And God blessed the seventh day and sanctified it').
verse(bereishit, 9, 6, [shin_pe_kaf, dalet_mem, aleph_dalet_mem, tzade_lamed_mem, aleph_lamed_he],
'Whoever sheds the blood of man by man shall his blood be shed for in the image of God He made man').
%% ============================================================
%% SHEMOT — The ten dibrot and the covenant
%% ============================================================
verse(shemot, 3, 14, [aleph_he_yod_he, aleph_mem_resh, aleph_he_yod_he],
'I am that I am').
verse(shemot, 20, 2, [aleph_nun_kaf_yod, he_shin_mem, aleph_lamed_he],
'I am the LORD your God who brought you out of the land of Egypt').
verse(shemot, 20, 3, [he_yod_he, aleph_lamed_he, aleph_chet_resh],
'You shall have no other gods before Me').
verse(shemot, 20, 8, [zayin_kaf_resh, yod_vav_mem, shin_bet_tav, qof_dalet_shin],
'Remember the Sabbath day to sanctify it').
verse(shemot, 20, 13, [resh_tzade_chet],
'You shall not murder').
verse(shemot, 20, 14, [nun_aleph_pe],
'You shall not commit adultery').
verse(shemot, 20, 15, [gimel_nun_bet],
'You shall not steal').
verse(shemot, 20, 16, [ayin_nun_he, shin_qof_resh, ayin_dalet],
'You shall not bear false witness against your neighbor').
verse(shemot, 20, 17, [chet_mem_dalet],
'You shall not covet').
%% ============================================================
%% VAYIKRA — Holiness and offerings
%% ============================================================
verse(vayikra, 1, 3, [qof_resh_bet, ayin_lamed_he, tav_mem_yod_mem],
'If his offering is a burnt offering let him offer a male without blemish').
verse(vayikra, 4, 27, [chet_tet_aleph, nun_pe_shin, shin_gimel_gimel_he],
'If anyone of the common people sins unintentionally').
verse(vayikra, 19, 2, [qof_dalet_shin, he_yod_he, qof_dalet_shin],
'Be holy for I the LORD your God am holy').
verse(vayikra, 19, 15, [ayin_shin_he, mem_shin_pe_tet, tzade_dalet_qof],
'In righteousness shall you judge your neighbor').
verse(vayikra, 19, 18, [aleph_he_bet, resh_ayin, kaf_mem_vav],
'You shall love your neighbor as yourself').
%% ============================================================
%% BAMIDBAR — The camp and the cloud
%% ============================================================
verse(bamidbar, 9, 23, [pe_he, he_shin_mem, chet_nun_he, pe_he, he_shin_mem, nun_samekh_ayin],
'At the mouth of the LORD they camped and at the mouth of the LORD they journeyed').
verse(bamidbar, 10, 2, [ayin_shin_he, shin_nun_yod, chet_tzade_tzade_resh_he, kaf_samekh_pe],
'Make two silver trumpets for the calling of the assembly').
verse(bamidbar, 35, 11, [mem_qof_lamed_tet, ayin_yod_resh, nun_pe_shin, resh_tzade_chet, shin_gimel_gimel_he],
'You shall designate cities of refuge for one who kills a person unintentionally').
%% ============================================================
%% DEVARIM — Moses' final instruction
%% ============================================================
verse(devarim, 6, 4, [shin_mem_ayin, yod_shin_resh_aleph_lamed, he_shin_mem, aleph_lamed_he, he_shin_mem, aleph_chet_dalet],
'Hear O Israel the LORD our God the LORD is one').
verse(devarim, 6, 5, [aleph_he_bet, he_shin_mem, aleph_lamed_he, kaf_lamed, lamed_bet_bet],
'And you shall love the LORD your God with all your heart').
verse(devarim, 16, 18, [shin_pe_tet, shin_tet_resh, nun_tav_nun, shin_ayin_resh],
'Judges and officers shall you appoint in all your gates').
verse(devarim, 16, 20, [tzade_dalet_qof, tzade_dalet_qof, resh_dalet_pe],
'Justice justice shall you pursue').
verse(devarim, 21, 1, [nun_pe_lamed, chet_lamed_lamed, shin_dalet_he, yod_dalet_ayin],
'If a slain person is found in the field and it is not known who struck him').
verse(devarim, 25, 12, [nun_tzade_lamed, resh_dalet_pe],
'You shall save the pursued from the pursuer').
verse(devarim, 26, 2, [lamed_qof_chet, resh_aleph_shin_yod_tav, pe_resh_yod, aleph_dalet_mem_he],
'You shall take of the first of all the fruit of the ground').
verse(devarim, 26, 5, [aleph_resh_mem_yod, aleph_bet_dalet, aleph_bet_yod],
'A wandering Aramean was my father').
%% ============================================================
%% QUERIES
%% ============================================================
%% Find roots in a specific verse
verse_roots(Book, Chapter, Verse, Roots) :-
verse(Book, Chapter, Verse, Roots, _).
%% Count verses in a chapter
verses_in_chapter(Book, Chapter, Count) :-
aggregate_all(count, verse(Book, Chapter, _, _, _), Count).
%% Find all verses mentioning a specific root
verses_mentioning_root(Root, Verses) :-
findall(ref(Book, Ch, Vs),
(verse(Book, Ch, Vs, Roots, _), member(Root, Roots)),
Verses).