%% 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 ) ).