%% reasoning_test.pl — Tests for the dialectical reasoning engine. :- use_module(library(plunit)). :- use_module('../src/reasoning/interpret'). :- use_module('../src/reasoning/challenge'). :- use_module('../src/reasoning/resolve'). :- use_module('../src/reasoning/teiku'). :- use_module('../src/specification/mitzvot'). :- use_module('../src/specification/torah_text'). :- begin_tests(interpret). %% Can interpret a case about creation test(interpret_creation, [nondet]) :- Case = case(test_creation, creation, [bet_resh_aleph], 'What is creation?'), interpret(Case, Interpretation), Interpretation = interpretation(test_creation, _, _, _, _). %% Interpretation finds relevant verses test(interpret_finds_verses, [nondet]) :- Case = case(test_verses, creation, [bet_resh_aleph], 'Find creation verses'), interpret(Case, interpretation(_, _, Verses, _, _)), Verses \= []. %% Interpretation finds relevant mitzvot test(interpret_finds_mitzvot, [nondet]) :- Case = case(test_mitzvot, judgment, [shin_pe_tet], 'How to judge?'), interpret(Case, interpretation(_, Mitzvot, _, _, _)), Mitzvot \= []. %% High confidence when both mitzvot and verses found test(interpret_high_confidence, [nondet]) :- Case = case(test_conf, holiness, [qof_dalet_shin], 'What is holiness?'), interpret(Case, interpretation(_, _, _, _, high)). :- end_tests(interpret). :- begin_tests(challenge). %% Can challenge an interpretation about judgment (justice vs mercy tension) test(challenge_judgment, [nondet]) :- Case = case(test_judgment, judgment, [shin_pe_tet, tzade_dalet_qof], 'How to judge righteously?'), interpret(Case, Interpretation), challenge(Interpretation, Kushya), Kushya = kushya(_, _, _). %% Challenge has a strength test(challenge_has_strength, [nondet]) :- Case = case(test_str, judgment, [shin_pe_tet], 'Test strength'), interpret(Case, Interpretation), challenge(Interpretation, kushya(_, _, Strength)), member(Strength, [strong, moderate, weak]). :- end_tests(challenge). :- begin_tests(resolve). %% Can resolve a simple case (no challenge) test(resolve_simple, [nondet]) :- Case = case(test_simple, creation, [bet_resh_aleph], 'What is creation?'), resolve(Case, Resolution), ( Resolution = accepted(_) ; Resolution = challenged(_, _) ; Resolution = synthesized(_, _, _) ; Resolution = teiku(_) ). %% Resolution produces some result test(resolve_produces_result, [nondet]) :- Case = case(test_result, holiness, [qof_dalet_shin], 'What is holiness?'), resolve(Case, _Resolution). :- end_tests(resolve). :- begin_tests(teiku_module). %% Teiku count starts at zero (or is a number) test(teiku_count_works) :- teiku_count(Count), integer(Count). :- end_tests(teiku_module).