Phase 3: Intelligence — 613 mitzvot, 13 middot, Tzara'at diagnostic
Encode all 613 mitzvot from Rambam's Sefer HaMitzvot (248 positive, 365 prohibitions). Build the 13 Middot of Rabbi Yishmael as Prolog inference predicates for hermeneutical reasoning. Implement Tzara'at multi-stage input validation following Vayikra 13-14. Enhance kushya generation with kal vachomer and shnei ketuvim challenge strategies. Architecture §4 Steps 14-15, 19-20. New files: middot/ — 8 files (master + 7 rule modules) diagnostic/ — 4 files (tzaraat, inspection, quarantine, diagnosis) Modified: mitzvot.pl — 52 → 613 mitzvot relationships.pl — expanded tensions, complements, action domains challenge.pl — middot-based kushya (kal vachomer, shnei ketuvim) Tests: 293 total (184 Prolog, 76 Elixir, 33 Haskell), 0 failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ae78ed26d1
commit
52837cee18
19 files changed
+2795
-178
No files matched your search
@@ -0,0 +1,99 @@
|
||||
%% diagnosis.pl — Diagnosis states and transitions.
|
||||
%%
|
||||
%% From Vayikra 13-14: The kohen's diagnostic process.
|
||||
%%
|
||||
%% States:
|
||||
%% initial_inspection → quarantine_1 | confirmed_tamei | declared_tahor | fully_visible_tahor
|
||||
%% quarantine_1 → reinspection_1
|
||||
%% reinspection_1 → quarantine_2 | confirmed_tamei | declared_tahor
|
||||
%% quarantine_2 → reinspection_2
|
||||
%% reinspection_2 → confirmed_tamei | declared_tahor
|
||||
%%
|
||||
%% The paradox: when a problem is completely visible and acknowledged,
|
||||
%% it is less dangerous than when partially hidden.
|
||||
%% "If the tzara'at covers all the skin, the kohen shall declare him tahor" (Vayikra 13:13).
|
||||
|
||||
:- module(diagnosis, [
|
||||
diagnosis_state/1,
|
||||
valid_transition/2,
|
||||
transition_reason/3,
|
||||
initial_state/1,
|
||||
terminal_state/1
|
||||
]).
|
||||
|
||||
%% ============================================================
|
||||
%% DIAGNOSIS STATES
|
||||
%% ============================================================
|
||||
|
||||
diagnosis_state(initial_inspection).
|
||||
diagnosis_state(quarantine_1).
|
||||
diagnosis_state(reinspection_1).
|
||||
diagnosis_state(quarantine_2).
|
||||
diagnosis_state(reinspection_2).
|
||||
diagnosis_state(confirmed_tamei). % Unclean — reject input
|
||||
diagnosis_state(declared_tahor). % Clean — proceed
|
||||
diagnosis_state(fully_visible_tahor). % The paradox: total visibility = purity
|
||||
|
||||
%% Initial and terminal states
|
||||
initial_state(initial_inspection).
|
||||
|
||||
terminal_state(confirmed_tamei).
|
||||
terminal_state(declared_tahor).
|
||||
terminal_state(fully_visible_tahor).
|
||||
|
||||
%% ============================================================
|
||||
%% VALID TRANSITIONS
|
||||
%% ============================================================
|
||||
|
||||
%% From initial inspection
|
||||
valid_transition(initial_inspection, quarantine_1).
|
||||
valid_transition(initial_inspection, confirmed_tamei).
|
||||
valid_transition(initial_inspection, declared_tahor).
|
||||
valid_transition(initial_inspection, fully_visible_tahor).
|
||||
|
||||
%% From quarantine 1
|
||||
valid_transition(quarantine_1, reinspection_1).
|
||||
|
||||
%% From reinspection 1
|
||||
valid_transition(reinspection_1, quarantine_2).
|
||||
valid_transition(reinspection_1, confirmed_tamei).
|
||||
valid_transition(reinspection_1, declared_tahor).
|
||||
|
||||
%% From quarantine 2
|
||||
valid_transition(quarantine_2, reinspection_2).
|
||||
|
||||
%% From reinspection 2 — final
|
||||
valid_transition(reinspection_2, confirmed_tamei).
|
||||
valid_transition(reinspection_2, declared_tahor).
|
||||
|
||||
%% ============================================================
|
||||
%% TRANSITION REASONS
|
||||
%% ============================================================
|
||||
|
||||
%% Why each transition occurs
|
||||
transition_reason(initial_inspection, quarantine_1,
|
||||
'Ambiguous signs — cannot determine yet. Quarantine for observation.').
|
||||
transition_reason(initial_inspection, confirmed_tamei,
|
||||
'Clear signs of impurity — spreading white hair, raw flesh exposed.').
|
||||
transition_reason(initial_inspection, declared_tahor,
|
||||
'No signs of impurity — input is clean.').
|
||||
transition_reason(initial_inspection, fully_visible_tahor,
|
||||
'Paradox of Vayikra 13:13 — problem covers everything, therefore tahor.').
|
||||
|
||||
transition_reason(quarantine_1, reinspection_1,
|
||||
'Seven-day quarantine period complete. Reinspect.').
|
||||
|
||||
transition_reason(reinspection_1, quarantine_2,
|
||||
'Signs neither spread nor receded. Second quarantine.').
|
||||
transition_reason(reinspection_1, confirmed_tamei,
|
||||
'Signs have spread during quarantine — confirmed impure.').
|
||||
transition_reason(reinspection_1, declared_tahor,
|
||||
'Signs have faded — declared clean.').
|
||||
|
||||
transition_reason(quarantine_2, reinspection_2,
|
||||
'Second seven-day quarantine complete. Final reinspection.').
|
||||
|
||||
transition_reason(reinspection_2, confirmed_tamei,
|
||||
'Signs persist after two quarantine periods — confirmed impure.').
|
||||
transition_reason(reinspection_2, declared_tahor,
|
||||
'Signs have faded after extended observation — declared clean.').
|
||||
@@ -0,0 +1,95 @@
|
||||
%% inspection.pl — Initial kohen inspection: surface analysis.
|
||||
%%
|
||||
%% The kohen examines the input before it enters the system.
|
||||
%% This is not pattern-matching or keyword filtering — it is
|
||||
%% structural analysis: does the input declare what it is?
|
||||
%% Does it have the signs of impurity?
|
||||
%%
|
||||
%% Signs of impurity (Vayikra 13):
|
||||
%% - White hair turning in the spot (surface change from expected)
|
||||
%% - Spot deeper than surrounding skin (hidden depth)
|
||||
%% - Raw flesh in the spot (exposed vulnerability)
|
||||
%% - Spreading (growth over time)
|
||||
%%
|
||||
%% Mapped to input analysis:
|
||||
%% - Undeclared source (who produced this?)
|
||||
%% - Hidden dependencies (what does this rely on?)
|
||||
%% - Exposed internals (does it leak implementation details?)
|
||||
%% - Scope creep (does it try to do more than asked?)
|
||||
|
||||
:- module(inspection, [
|
||||
inspect/2,
|
||||
has_sign/2,
|
||||
sign_severity/2,
|
||||
count_signs/2
|
||||
]).
|
||||
|
||||
:- use_module(diagnosis).
|
||||
|
||||
%% ============================================================
|
||||
%% INPUT SIGNS
|
||||
%% ============================================================
|
||||
|
||||
%% has_sign(Input, Sign)
|
||||
%% Detect signs in an input structure.
|
||||
%%
|
||||
%% Input is represented as: input(Source, Dependencies, Scope, Metadata)
|
||||
%% Source: declared | undeclared
|
||||
%% Dependencies: list of deps, each hidden | visible
|
||||
%% Scope: within_bounds | exceeds_bounds
|
||||
%% Metadata: list of properties
|
||||
|
||||
has_sign(input(undeclared, _, _, _), undeclared_source).
|
||||
has_sign(input(_, Deps, _, _), hidden_dependency) :-
|
||||
member(hidden, Deps).
|
||||
has_sign(input(_, _, exceeds_bounds, _), scope_creep).
|
||||
has_sign(input(_, _, _, Meta), exposed_internals) :-
|
||||
member(leaks_implementation, Meta).
|
||||
|
||||
%% Sign severity
|
||||
sign_severity(undeclared_source, high).
|
||||
sign_severity(hidden_dependency, moderate).
|
||||
sign_severity(scope_creep, moderate).
|
||||
sign_severity(exposed_internals, low).
|
||||
|
||||
%% Count how many signs an input has
|
||||
count_signs(Input, Count) :-
|
||||
findall(S, has_sign(Input, S), Signs),
|
||||
length(Signs, Count).
|
||||
|
||||
%% ============================================================
|
||||
%% INSPECTION LOGIC
|
||||
%% ============================================================
|
||||
|
||||
%% inspect(Input, InitialDiagnosis)
|
||||
%% The kohen looks at the input and makes an initial determination.
|
||||
|
||||
%% No signs at all → declared tahor immediately
|
||||
inspect(Input, declared_tahor) :-
|
||||
count_signs(Input, 0), !.
|
||||
|
||||
%% The paradox: ALL signs present → fully visible tahor
|
||||
%% "If the tzara'at covers all the skin... the kohen shall declare him tahor"
|
||||
%% Input that openly declares ALL its problems is treated as pure.
|
||||
inspect(Input, fully_visible_tahor) :-
|
||||
has_sign(Input, undeclared_source),
|
||||
has_sign(Input, hidden_dependency),
|
||||
has_sign(Input, scope_creep),
|
||||
has_sign(Input, exposed_internals), !.
|
||||
|
||||
%% High severity sign → confirmed tamei (reject)
|
||||
inspect(Input, confirmed_tamei) :-
|
||||
has_sign(Input, Sign),
|
||||
sign_severity(Sign, high), !.
|
||||
|
||||
%% Moderate signs only → quarantine for observation
|
||||
inspect(Input, quarantine_1) :-
|
||||
has_sign(Input, Sign),
|
||||
sign_severity(Sign, moderate),
|
||||
\+ (has_sign(Input, OtherSign), sign_severity(OtherSign, high)), !.
|
||||
|
||||
%% Low severity only → declared tahor (minor issues, acceptable)
|
||||
inspect(Input, declared_tahor) :-
|
||||
has_sign(Input, _),
|
||||
\+ (has_sign(Input, Sign), sign_severity(Sign, high)),
|
||||
\+ (has_sign(Input, Sign2), sign_severity(Sign2, moderate)), !.
|
||||
@@ -0,0 +1,98 @@
|
||||
%% quarantine.pl — Quarantine management.
|
||||
%%
|
||||
%% When the kohen cannot determine immediately, the input is
|
||||
%% quarantined (isolated) for observation. After the quarantine
|
||||
%% period, it is reinspected.
|
||||
%%
|
||||
%% Vayikra 13:4-5: "The kohen shall quarantine him seven days.
|
||||
%% On the seventh day, the kohen shall examine him."
|
||||
%%
|
||||
%% In the system: quarantine holds an input for one observation
|
||||
%% cycle (one BereishitCycle), then reinspects it.
|
||||
|
||||
:- module(quarantine, [
|
||||
quarantine_input/3,
|
||||
reinspect/3,
|
||||
quarantine_record/4
|
||||
]).
|
||||
|
||||
:- use_module(diagnosis).
|
||||
:- use_module(inspection).
|
||||
|
||||
%% ============================================================
|
||||
%% QUARANTINE RECORDS
|
||||
%% ============================================================
|
||||
|
||||
%% quarantine_record(InputID, State, Signs, CycleCount)
|
||||
%% Dynamic storage for quarantined inputs.
|
||||
:- dynamic quarantine_record/4.
|
||||
|
||||
%% ============================================================
|
||||
%% QUARANTINE AN INPUT
|
||||
%% ============================================================
|
||||
|
||||
%% quarantine_input(InputID, Input, State)
|
||||
%% Place an input into quarantine and record its state.
|
||||
|
||||
quarantine_input(InputID, Input, quarantine_1) :-
|
||||
findall(S, has_sign(Input, S), Signs),
|
||||
assert(quarantine_record(InputID, quarantine_1, Signs, 1)).
|
||||
|
||||
quarantine_input(InputID, _Input, quarantine_2) :-
|
||||
retract(quarantine_record(InputID, reinspection_1, Signs, _)),
|
||||
assert(quarantine_record(InputID, quarantine_2, Signs, 2)).
|
||||
|
||||
%% ============================================================
|
||||
%% REINSPECTION
|
||||
%% ============================================================
|
||||
|
||||
%% reinspect(InputID, Input, NewState)
|
||||
%% After quarantine, reinspect the input.
|
||||
%% The input may have changed (new data, corrections, etc.)
|
||||
|
||||
%% Reinspection 1: after first quarantine
|
||||
reinspect(InputID, Input, declared_tahor) :-
|
||||
quarantine_record(InputID, quarantine_1, _OldSigns, 1),
|
||||
count_signs(Input, 0),
|
||||
retract(quarantine_record(InputID, quarantine_1, _, 1)),
|
||||
!.
|
||||
|
||||
reinspect(InputID, Input, confirmed_tamei) :-
|
||||
quarantine_record(InputID, quarantine_1, OldSigns, 1),
|
||||
findall(S, has_sign(Input, S), NewSigns),
|
||||
length(OldSigns, OldCount),
|
||||
length(NewSigns, NewCount),
|
||||
NewCount > OldCount, %% Signs have spread
|
||||
retract(quarantine_record(InputID, quarantine_1, _, 1)),
|
||||
!.
|
||||
|
||||
reinspect(InputID, _Input, reinspection_1) :-
|
||||
quarantine_record(InputID, quarantine_1, Signs, 1),
|
||||
retract(quarantine_record(InputID, quarantine_1, _, 1)),
|
||||
assert(quarantine_record(InputID, reinspection_1, Signs, 1)),
|
||||
!.
|
||||
|
||||
%% Reinspection 2: after second quarantine (final)
|
||||
reinspect(InputID, Input, declared_tahor) :-
|
||||
quarantine_record(InputID, quarantine_2, _OldSigns, 2),
|
||||
count_signs(Input, 0),
|
||||
retract(quarantine_record(InputID, quarantine_2, _, 2)),
|
||||
!.
|
||||
|
||||
reinspect(InputID, Input, confirmed_tamei) :-
|
||||
quarantine_record(InputID, quarantine_2, OldSigns, 2),
|
||||
findall(S, has_sign(Input, S), NewSigns),
|
||||
length(OldSigns, OldCount),
|
||||
length(NewSigns, NewCount),
|
||||
NewCount > OldCount,
|
||||
retract(quarantine_record(InputID, quarantine_2, _, 2)),
|
||||
!.
|
||||
|
||||
reinspect(InputID, Input, declared_tahor) :-
|
||||
quarantine_record(InputID, quarantine_2, OldSigns, 2),
|
||||
findall(S, has_sign(Input, S), NewSigns),
|
||||
length(OldSigns, OldCount),
|
||||
length(NewSigns, NewCount),
|
||||
NewCount =< OldCount, %% Signs did not spread — tahor after two quarantines
|
||||
retract(quarantine_record(InputID, quarantine_2, _, 2)),
|
||||
!.
|
||||
@@ -0,0 +1,109 @@
|
||||
%% tzaraat.pl — Master diagnostic module.
|
||||
%%
|
||||
%% Architecture §4, Step 19: Tzara'at diagnostic protocol.
|
||||
%%
|
||||
%% Multi-stage input validation following the Torah's diagnostic
|
||||
%% process in Vayikra 13-14.
|
||||
%%
|
||||
%% The kohen (the system) examines input before processing.
|
||||
%% This is NOT content filtering or censorship.
|
||||
%% It is structural analysis: does the input declare what it is?
|
||||
%% Does it acknowledge its limitations? Is it honest about its source?
|
||||
%%
|
||||
%% The diagnostic proceeds:
|
||||
%% 1. Initial inspection (inspection.pl)
|
||||
%% 2. If ambiguous: quarantine (quarantine.pl)
|
||||
%% 3. Reinspection after quarantine
|
||||
%% 4. Final determination: tahor (proceed), tamei (reject),
|
||||
%% or fully_visible_tahor (the paradox)
|
||||
%%
|
||||
%% The Paradox of Full Visibility (Vayikra 13:13):
|
||||
%% "If the tzara'at covers all the skin of the one with the affliction,
|
||||
%% from his head to his feet... the kohen shall declare him tahor."
|
||||
%% Input that openly declares ALL its problems is treated as pure.
|
||||
%% Concealment is the disease. Transparency is the cure.
|
||||
|
||||
:- module(tzaraat, [
|
||||
diagnose/2,
|
||||
diagnose_with_record/3,
|
||||
full_diagnostic_flow/3
|
||||
]).
|
||||
|
||||
:- use_module(diagnosis).
|
||||
:- use_module(inspection).
|
||||
:- use_module(quarantine).
|
||||
|
||||
%% ============================================================
|
||||
%% SINGLE-PASS DIAGNOSIS
|
||||
%% ============================================================
|
||||
|
||||
%% diagnose(Input, Result)
|
||||
%% Run the initial inspection and return the diagnosis.
|
||||
diagnose(Input, Result) :-
|
||||
inspect(Input, InitialState),
|
||||
( terminal_state(InitialState)
|
||||
-> Result = InitialState
|
||||
; %% Non-terminal = quarantine needed
|
||||
Result = requires_quarantine(InitialState)
|
||||
).
|
||||
|
||||
%% ============================================================
|
||||
%% DIAGNOSIS WITH RECORD
|
||||
%% ============================================================
|
||||
|
||||
%% diagnose_with_record(InputID, Input, Record)
|
||||
%% Diagnose and create a full diagnostic record.
|
||||
diagnose_with_record(InputID, Input, Record) :-
|
||||
inspect(Input, InitialState),
|
||||
findall(S, has_sign(Input, S), Signs),
|
||||
Record = diagnostic_record(
|
||||
input_id(InputID),
|
||||
initial_state(InitialState),
|
||||
signs(Signs),
|
||||
terminal(Terminal)
|
||||
),
|
||||
( terminal_state(InitialState)
|
||||
-> Terminal = InitialState
|
||||
; Terminal = pending_quarantine
|
||||
).
|
||||
|
||||
%% ============================================================
|
||||
%% FULL DIAGNOSTIC FLOW
|
||||
%% ============================================================
|
||||
|
||||
%% full_diagnostic_flow(InputID, InputSequence, FinalState)
|
||||
%%
|
||||
%% InputSequence is a list of inputs representing the same data
|
||||
%% at different points in time:
|
||||
%% [InitialInput, AfterQuarantine1, AfterQuarantine2]
|
||||
%%
|
||||
%% The flow follows the Torah's multi-stage process:
|
||||
%% inspect → (quarantine → reinspect)* → final state
|
||||
|
||||
%% Clean input — immediate tahor
|
||||
full_diagnostic_flow(_InputID, [Input], declared_tahor) :-
|
||||
inspect(Input, declared_tahor), !.
|
||||
|
||||
%% Fully visible — immediate paradox tahor
|
||||
full_diagnostic_flow(_InputID, [Input], fully_visible_tahor) :-
|
||||
inspect(Input, fully_visible_tahor), !.
|
||||
|
||||
%% Immediate tamei — reject
|
||||
full_diagnostic_flow(_InputID, [Input], confirmed_tamei) :-
|
||||
inspect(Input, confirmed_tamei), !.
|
||||
|
||||
%% Quarantine flow: initial → quarantine_1 → reinspect with second input
|
||||
full_diagnostic_flow(InputID, [Initial, AfterQ1 | Rest], FinalState) :-
|
||||
inspect(Initial, quarantine_1),
|
||||
quarantine_input(InputID, Initial, quarantine_1),
|
||||
reinspect(InputID, AfterQ1, State1),
|
||||
( terminal_state(State1)
|
||||
-> FinalState = State1
|
||||
; %% State1 = reinspection_1 means signs unchanged, go to quarantine_2
|
||||
( Rest = [AfterQ2 | _]
|
||||
-> quarantine_input(InputID, AfterQ1, quarantine_2),
|
||||
reinspect(InputID, AfterQ2, FinalState)
|
||||
; %% No more inputs — treat as unchanged after second quarantine
|
||||
FinalState = declared_tahor
|
||||
)
|
||||
).
|
||||
Reference in new issue
Block a user