%% teiku.pl — Unresolved tension handling. %% %% Architecture §3.4: resolve(_, teiku). %% %% Teiku (תיקו) — "let it stand." The question is unresolvable %% from the current specification. It is not an error. It is %% the system's honest acknowledgment that Torah does not %% collapse every tension into a single answer. %% %% Talmudic tradition: Tishbi Yetaretz Kushyot V'Abayot — %% "Elijah will resolve difficulties and problems." %% Until then, the tension stands. Both readings are preserved. %% %% eish_zarah_reading.md §5.4: The teiku record now includes %% the challenge sequence that led to the impasse — not just %% the verdict, but the diagnostic trail. Why did resolution fail? %% What was the path from interpretation to unresolvable tension? :- module(teiku, [ register_teiku/3, register_teiku/4, is_teiku/1, teiku_count/1, all_teiku/1 ]). :- dynamic teiku_record/6. %% ============================================================ %% TEIKU REGISTRATION %% ============================================================ %% Register an unresolvable tension between two interpretations. %% The record preserves both sides — neither is discarded. %% Arity-3: no challenge sequence (backward compatible) register_teiku(I1, I2, Record) :- register_teiku(I1, I2, no_challenges, Record). %% Arity-4: with challenge sequence %% ChallengeSeq is a list of kushya terms that led to the teiku, %% or 'no_challenges' if unknown (backward compatibility). register_teiku(I1, I2, ChallengeSeq, Record) :- I1 = interpretation(CaseRef1, M1, V1, _, _, _), I2 = interpretation(CaseRef2, M2, V2, _, _, _), Record = teiku_record(CaseRef1, CaseRef2, side_a(M1, V1), side_b(M2, V2), unresolved, challenge_sequence(ChallengeSeq)), assert_teiku_if_new(Record). %% Only assert if not already registered assert_teiku_if_new(Record) :- Record = teiku_record(Ref1, Ref2, _, _, _, _), ( teiku_record(Ref1, Ref2, _, _, _, _) -> true % already registered ; assertz(Record) ). %% ============================================================ %% QUERIES %% ============================================================ %% Check if a case resulted in teiku is_teiku(CaseRef) :- teiku_record(CaseRef, _, _, _, unresolved, _). is_teiku(CaseRef) :- teiku_record(_, CaseRef, _, _, unresolved, _). %% Count total teiku records teiku_count(Count) :- aggregate_all(count, teiku_record(_, _, _, _, unresolved, _), Count). %% Retrieve all teiku records all_teiku(Records) :- findall(teiku_record(A, B, C, D, E, F), teiku_record(A, B, C, D, E, F), Records).