diff --git a/ModelsTests/Reasoning/PossibleStatesTest.cs b/ModelsTests/Reasoning/PossibleStatesTest.cs deleted file mode 100644 index dc1628c..0000000 --- a/ModelsTests/Reasoning/PossibleStatesTest.cs +++ /dev/null @@ -1,90 +0,0 @@ -using MultiAgentLanguageModels.Expressions; -using MultiAgentLanguageModels.Reasoning; -using NUnit.Framework; -using MultiAgentLanguageModels; -using System.Collections.Generic; - -namespace Reasoning -{ - public class PossibleStatesTest - { - [Test] - public void TestPossibleStates() - { - var loaded = new Fluent("loaded"); - var walking = new Fluent("walking"); - var alive = new Fluent("alive"); - var reasoning = new ReasoningEngine(); - var ExpressionsList = new ExpressionsList() - { - new Initially(new And(loaded, walking)), - new Always(new If(walking, alive)), - new Causes("load", loaded), - new Causes("shoot", new Not(loaded)), - new CausesIf("shoot", new Not(alive), loaded) - }; - - var resp = reasoning.GenerateStructure(ExpressionsList); - - Assert.AreEqual(resp, resp); - } - - [Test] - public void TestRes0() - { - var loaded = new Fluent("loaded"); - var walking = new Fluent("walking"); - var alive = new Fluent("alive"); - var reasoning = new ReasoningEngine(); - var ExpressionsList = new ExpressionsList() - { - new Initially(new And(loaded, walking)), - new Always(new If(walking, alive)), - new Causes("load", loaded), - new Causes("shoot", new Not(loaded)), - new CausesIf("shoot", new Not(alive), loaded) - }; - var resp = reasoning.GenerateStructure(ExpressionsList); - - Assert.AreEqual(resp, resp); - } - - [Test] - public void TestRes() - { - var loaded = new Fluent("loaded"); - var walking = new Fluent("walking"); - var alive = new Fluent("alive"); - var reasoning = new ReasoningEngine(); - var ExpressionsList = new ExpressionsList() - { - new Initially(new And(loaded, walking)), - new Always(new If(walking, alive)), - new Causes("load", loaded), - new Causes("shoot", new Not(loaded)), - new CausesIf("shoot", new Not(alive), loaded) - }; - var resp = reasoning.GenerateStructure(ExpressionsList); - - Assert.AreEqual(resp, resp); - } - - - [Test] - public void TestRes_Releases() - { - var hasA = new Fluent("hasA"); - var hasB = new Fluent("hasB"); - var reasoning = new ReasoningEngine(); - var ExpressionsList = new ExpressionsList() - { - new Causes("buypaper", new Or(hasA, hasB)), - new ReleasesIf("buypaper", hasA, new Not(hasA)), - new ReleasesIf("buypaper", hasB, new Not(hasB)) - }; - var resp = reasoning.GenerateStructure(ExpressionsList); - - Assert.AreEqual(resp, resp); - } - } -} \ No newline at end of file diff --git a/MultiAgentLanguageGUI/MultiAgentLanguageGUI.csproj b/MultiAgentLanguageGUI/MultiAgentLanguageGUI.csproj index 892d958..b1b0e94 100644 --- a/MultiAgentLanguageGUI/MultiAgentLanguageGUI.csproj +++ b/MultiAgentLanguageGUI/MultiAgentLanguageGUI.csproj @@ -102,9 +102,6 @@ PreserveNewest - - PreserveNewest - SettingsSingleFileGenerator diff --git a/MultiAgentLanguageGUI/logic.pl b/MultiAgentLanguageGUI/logic.pl deleted file mode 100644 index 6195687..0000000 --- a/MultiAgentLanguageGUI/logic.pl +++ /dev/null @@ -1,274 +0,0 @@ -:- dynamic impossible_by/2. -:- dynamic impossible_if/2. -:- dynamic by_causes/3. -:- dynamic causes_if/3. -:- dynamic by_releases_if/4. -:- dynamic by_releases/3. -:- dynamic releases_if/3. -:- dynamic always/1. -:- dynamic initially/1. - -% Support for tests: -:- multifile impossible_by/2, by_causes_if/4, by_causes/3, after/2, by_releases_if/4, always/1. -:- style_check(-discontiguous). -passed:- nl, ansi_format([bold,fg(green)], 'Passed', []). -failed:- nl, ansi_format([bold,fg(red)], 'Failed', []). - - -% Make sure, "initially" also propagates to after(Result, []). -after(Result, []):- - initially(Result). - -private_impossible_by_if(Action, Group, State):- - impossible_by(Action, Group); - impossible_if(Action, State); - impossible_by_if(Action, Group, State). - -impossible_by_if(Action, Group, []):- - impossible_by(Action, Group), !. - -impossible_by_if(Action, [], State):- - impossible_if(Action, State), !. - - - -by_causes_if(Action, Group, Result, []):- - by_causes(Action, Group, Result). - -by_causes_if(Action, [], Result, State):- - causes_if(Action, Result, State). - - -by_releases_if(Action, Group, Result, _):- - by_releases(Action, Group, Result). - -by_releases_if(Action, _, Result, State):- - releases_if(Action, Result, State). - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Executability queries - TODO: fix possibly_executable_from query -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -necessary_executable_from([[Action, Group] | Program], CurrentState):- - private_necessary_executable_from([[Action, Group] | Program], CurrentState, _), !. - -% CurrentState means "initialState" in the first call, and then set of all changes states -private_necessary_executable_from([[Action, Group] | Program], CurrentState, FinalState):- - ( - (by_causes_if(Action, G, ResultingState, RequiredState);by_releases_if(Action, G, ResultingState, RequiredState)), - ( - subset(G,Group), - ( - not(is_empty(RequiredState)), - ( - is_always(RequiredState) - ; - subset(RequiredState, CurrentState) - ) - ) - ; - initially(Y), - (is_empty(RequiredState), subset(CurrentState,Y)) - ; - (is_empty(RequiredState),is_empty(CurrentState)) - ) - ), - not(private_impossible_by_if(Action, Group, RequiredState)), - subtract(CurrentState, ResultingState, ListWithoutResultingState), - negate_list(ResultingState, NotResultingState), - subtract(ListWithoutResultingState, NotResultingState, ListWithoutNotResultingState), - append(ListWithoutNotResultingState, ResultingState, NewCurrentState), - private_necessary_executable_from(Program, NewCurrentState, FinalState), !. - -private_necessary_executable_from([], NewCurrentState, FinalState):- - FinalState = NewCurrentState, !. - -necessary_executable(Program):- - necessary_executable_from(Program, []), !. - - - -% CurrentState means "initialState" in the first call, and then set of all changes states -possibly_executable_from([[Action, Group] | Program], CurrentState):- - (by_releases_if(Action, Group, ResultingState, X) ; by_causes_if(Action, Group, ResultingState, X)), - ((not(is_empty(X)),subset(X, CurrentState)) ; (is_empty(X),is_empty(CurrentState))), - not(private_impossible_by_if(Action, Group, X)), - subtract(CurrentState, ResultingState, ListWithoutResultingState), - negate_list(ResultingState, NotResultingState), - subtract(ListWithoutResultingState, NotResultingState, ListWithoutNotResultingState), - append(ListWithoutNotResultingState, ResultingState, NewCurrentState), - possibly_executable_from(Program, NewCurrentState), !. - -possibly_executable_from([],_). - -possibly_executable(Program):- - possibly_executable_from(Program, []), !. - - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Value queries - TODO: finish possibly_after_from implementation -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -necessary_after_from(State, [[Action, Group] | Program], CurrentState):- - ( - ( - is_always(State) - ) - ; - ( - private_necessary_executable_from([[Action, Group] | Program], CurrentState, StateAfterProgram), - (after(State, [[Action, Group] | Program]) ; subset(State, StateAfterProgram)) - ) - ), !. - -necessary_after(State, Program):- - necessary_after_from(State, Program, []), !. - -possibly_after_from(State, [[Action, Group] | Program], CurrentState):- - is_always(State) - ; - (apply_alwayses(CurrentState, FullCurrentState) ; true), - ( - ( - %Bierzemy stan do którego musimy przejść i idziemy do następnej instrukcji. Jeżeli to się nie powiedzie to zwracamy false bo musimy przejść do ResultingState(!) - by_causes_if(Action, Group, ResultingState, X), - ((not(is_empty(X)),subset(X, FullCurrentState)) ; (is_empty(X),is_empty(FullCurrentState))), - apply_resulting_state(ResultingState, FullCurrentState, NewCurrentState), - possibly_after_from(State, Program, NewCurrentState), ! - ) - ; - ( - % Nie mamy stanu, do którego musimy przejść, generujemy stany usuwając poszczególne fluenty i sprawdzamy - possibly_after_from_without_causes(State, [[Action, Group] | Program], FullCurrentState) - ) - ). - -possibly_after_from_without_causes(State, [[Action, Group] | Program], CurrentState):- - %Ta reguła generuje nowe stany na podstawie reguł releases i weryfikuje dla nich działanie - %by_releases_if(Action, Group, ReleasedFluent, CurrentState), % sprawdzamy, czy możemy w ogóle wykonać releases - ( - %Sprawdzamy dalszy przebieg dla obecnego stanu - by_releases_if(Action, Group, ReleasedFluent, X), %czy akcja w ogóle możliwa - ((not(is_empty(X)),subset(X, CurrentState)) ; (is_empty(X),is_empty(CurrentState))), - possibly_after_from(State, Program, CurrentState) - ) - ; - ( - %Generujemy nowy stan usuwając jeden z uwolnionych fluentów i sprawdzamy dalszy przebieg rekurencyjnie - by_releases_if(Action, Group, ReleasedFluent, X), - ((not(is_empty(X)),subset(X, CurrentState)) ; (is_empty(X),is_empty(CurrentState))), - subtract(CurrentState, [ReleasedFluent], CurrentStateWithoutPositiveReleased), - subtract(CurrentStateWithoutPositiveReleased, [\ReleasedFluent], CurrentStateWithoutAnyReleased), - ( - ( - append([ReleasedFluent], CurrentStateWithoutAnyReleased, NewCurrentStateWithPositiveReleased), - possibly_after_from_without_causes(State, [[Action, Group] | Program], NewCurrentStateWithPositiveReleased) - ) - ; - ( - append([\ReleasedFluent], CurrentStateWithoutAnyReleased, NewCurrentStateWithNegativeReleased), - possibly_after_from_without_causes(State, [[Action, Group] | Program], NewCurrentStateWithNegativeReleased) - ) - ) - ). - -possibly_after_from_without_causes(State, [], CurrentState):- - possibly_after_from(State, [], CurrentState). - -possibly_after_from(State,[], CurrentState):- - negate_list(State, NegatedRequiredState), - intersection(NegatedRequiredState, CurrentState, Common), - is_empty(Common), !. - -possibly_after(State, Program):- - possibly_after_from(State, Program, []), !. - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Engagement queries -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -check_state(Action,[FirstEngaged | _ ], States):- - by_causes_if(Action, FirstEngaged, _, RequiredState), - (subset(RequiredState, States); write('here'), is_always(RequiredState), write('there')). - -necessary_engaged_from(Group, [Action|List], States):- - not(impossible_by_if(Action, Group, RequiredState)), - findall(X, by_causes_if(Action, X, _, RequiredState), Engaged), - check_state(Action, Engaged,States), - necessary_engaged_from(Group, List, RequiredState, Engaged), !. - -necessary_engaged_from(Group, [Action|List], State, Engaged):- - not(impossible_by_if(Action, Group, State)), - findall(X, by_causes_if(Action, X, _, State), NextEngaged), - findall(X, (member(X, Engaged), member(X, NextEngaged)), EngagedInBoth), - necessary_engaged_from(Group, List, State, EngagedInBoth), !. - -necessary_engaged_from(_, [], _, []):- fail. -necessary_engaged_from(Group, [], _, [Item|[]]):- subset(Item, Group), !. -necessary_engaged_from(_, [], _, [_|_]):- fail. - -necessary_engaged(Group, Actions):- - necessary_engaged_from(Group, Actions, []), !. - - -possibly_engaged_from(Group, [Action|List], State):- - not(impossible_by_if(Action, Group, State)), - ( - by_causes_if(Action, X, _, State) - ; - by_causes_if(Action, X, _, CheckedState), - always(CheckedState) - ; - by_causes_if(Action, X, _, CheckedState), - initially(Y), - subset(CheckedState,Y) - ; - causes_if(Action, _, CheckedState), - subset(State,CheckedState) - ), - subset(X, Group), - possibly_engaged_from(Group, List, State), !. - -possibly_engaged_from(_, [], _):- !. - -possibly_engaged(Group, [Action|List]):- - possibly_engaged_from(Group, [Action|List], []), !. - - -% Utils -is_always(State):- - findall(X, always(X), AlwaysList), - is_subset_of_any_always(State, AlwaysList). - -is_subset_of_any_always(State, [Always | AlwaysList]):- - subset(State, Always); - is_subset_of_any_always(State, AlwaysList). -is_subset_of_any_always(_, [[] | []]):- fail. - -apply_alwayses(CurrentState, NewState):- - not(always(X)); - ( - not(subset([X],CurrentState)), - append([X], CurrentState, NewStateWithX), - apply_alwayses(NewStateWithX, NewState) - ). - -apply_resulting_state(ResultingState, CurrentState, NewState):- - subtract(CurrentState, ResultingState, ListWithoutResultingState), - negate_list(ResultingState, NotResultingState), - subtract(ListWithoutResultingState, NotResultingState, ListWithoutNotResultingState), - append(ListWithoutNotResultingState, ResultingState, NewState). - -negate_list([Item|List], NegatedList):- - negate_list(List, NegatedSublist), - append([\Item], NegatedSublist, NegatedList). -negate_list([Item|[]], NegatedList):- - NegatedList = [\Item]. -negate_list([],[]). - -is_empty([]). \ No newline at end of file diff --git a/MultiAgentLanguageModels/MultiAgentLanguageModels.csproj b/MultiAgentLanguageModels/MultiAgentLanguageModels.csproj index 21100a8..c1ab04c 100644 --- a/MultiAgentLanguageModels/MultiAgentLanguageModels.csproj +++ b/MultiAgentLanguageModels/MultiAgentLanguageModels.csproj @@ -79,9 +79,6 @@ - - PreserveNewest - diff --git a/MultiAgentLanguageModels/logic.pl b/MultiAgentLanguageModels/logic.pl deleted file mode 100644 index 43fa89c..0000000 --- a/MultiAgentLanguageModels/logic.pl +++ /dev/null @@ -1,265 +0,0 @@ -:- dynamic impossible_by/2. -:- dynamic impossible_if/2. -:- dynamic by_causes/3. -:- dynamic causes_if/3. -:- dynamic by_releases_if/4. -:- dynamic by_releases/3. -:- dynamic releases_if/3. -:- dynamic always/1. -:- dynamic initially/1. - -% Support for tests: -:- multifile impossible_by/2, by_causes_if/4, by_causes/3, after/2, by_releases_if/4, always/1. -:- style_check(-discontiguous). -passed:- nl, ansi_format([bold,fg(green)], 'Passed', []). -failed:- nl, ansi_format([bold,fg(red)], 'Failed', []). - - -% Make sure, "initially" also propagates to after(Result, []). -after(Result, []):- - initially(Result). - -private_impossible_by_if(Action, Group, State):- - impossible_by(Action, Group); - impossible_if(Action, State); - impossible_by_if(Action, Group, State). - -impossible_by_if(Action, Group, []):- - impossible_by(Action, Group), !. - -impossible_by_if(Action, [], State):- - impossible_if(Action, State), !. - - - -by_causes_if(Action, Group, Result, []):- - by_causes(Action, Group, Result). - -by_causes_if(Action, [], Result, State):- - causes_if(Action, Result, State). - - -by_releases_if(Action, Group, Result, _):- - by_releases(Action, Group, Result). - -by_releases_if(Action, _, Result, State):- - releases_if(Action, Result, State). - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Executability queries - TODO: fix possibly_executable_from query -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -necessary_executable_from([[Action, Group] | Program], CurrentState):- - private_necessary_executable_from([[Action, Group] | Program], CurrentState, _), !. - -% CurrentState means "initialState" in the first call, and then set of all changes states -private_necessary_executable_from([[Action, Group] | Program], CurrentState, FinalState):- - ( - (by_causes_if(Action, G, ResultingState, RequiredState);by_releases_if(Action, G, ResultingState, RequiredState)), - ( - subset(G,Group), - ( - not(is_empty(RequiredState)), - ( - is_always(RequiredState) - ; - subset(RequiredState, CurrentState) - ) - ) - ; - initially(Y), - (is_empty(RequiredState), subset(CurrentState,Y)) - ; - (is_empty(RequiredState),is_empty(CurrentState)) - ) - ), - not(private_impossible_by_if(Action, Group, RequiredState)), - subtract(CurrentState, ResultingState, ListWithoutResultingState), - negate_list(ResultingState, NotResultingState), - subtract(ListWithoutResultingState, NotResultingState, ListWithoutNotResultingState), - append(ListWithoutNotResultingState, ResultingState, NewCurrentState), - private_necessary_executable_from(Program, NewCurrentState, FinalState), !. - -private_necessary_executable_from([], NewCurrentState, FinalState):- - FinalState = NewCurrentState, !. - -necessary_executable(Program):- - necessary_executable_from(Program, []), !. - - - -% CurrentState means "initialState" in the first call, and then set of all changes states -possibly_executable_from([[Action, Group] | Program], CurrentState):- - (by_releases_if(Action, Group, ResultingState, X) ; by_causes_if(Action, Group, ResultingState, X)), - ((not(is_empty(X)),subset(X, CurrentState)) ; (is_empty(X),is_empty(CurrentState))), - not(private_impossible_by_if(Action, Group, X)), - subtract(CurrentState, ResultingState, ListWithoutResultingState), - negate_list(ResultingState, NotResultingState), - subtract(ListWithoutResultingState, NotResultingState, ListWithoutNotResultingState), - append(ListWithoutNotResultingState, ResultingState, NewCurrentState), - possibly_executable_from(Program, NewCurrentState), !. - -possibly_executable_from([],_). - -possibly_executable(Program):- - possibly_executable_from(Program, []), !. - - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Value queries - TODO: finish possibly_after_from implementation -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -necessary_after_from(State, [[Action, Group] | Program], CurrentState):- - ( - ( - is_always(State) - ) - ; - ( - private_necessary_executable_from([[Action, Group] | Program], CurrentState, StateAfterProgram), - (after(State, [[Action, Group] | Program]) ; subset(State, StateAfterProgram)) - ) - ), !. - -necessary_after(State, Program):- - necessary_after_from(State, Program, []), !. - -possibly_after_from(State, [[Action, Group] | Program], CurrentState):- - is_always(State) - ; - (apply_alwayses(CurrentState, FullCurrentState) ; true), - ( - ( - %Bierzemy stan do którego musimy przejść i idziemy do następnej instrukcji. Jeżeli to się nie powiedzie to zwracamy false bo musimy przejść do ResultingState(!) - by_causes_if(Action, Group, ResultingState, X), - ((not(is_empty(X)),subset(X, FullCurrentState)) ; (is_empty(X),is_empty(FullCurrentState))), - apply_resulting_state(ResultingState, FullCurrentState, NewCurrentState), - possibly_after_from(State, Program, NewCurrentState), ! - ) - ; - ( - % Nie mamy stanu, do którego musimy przejść, generujemy stany usuwając poszczególne fluenty i sprawdzamy - possibly_after_from_without_causes(State, [[Action, Group] | Program], FullCurrentState) - ) - ). - -possibly_after_from_without_causes(State, [[Action, Group] | Program], CurrentState):- - %Ta reguła generuje nowe stany na podstawie reguł releases i weryfikuje dla nich działanie - %by_releases_if(Action, Group, ReleasedFluent, CurrentState), % sprawdzamy, czy możemy w ogóle wykonać releases - ( - %Sprawdzamy dalszy przebieg dla obecnego stanu - by_releases_if(Action, Group, ReleasedFluent, X), %czy akcja w ogóle możliwa - ((not(is_empty(X)),subset(X, CurrentState)) ; (is_empty(X),is_empty(CurrentState))), - possibly_after_from(State, Program, CurrentState) - ) - ; - ( - %Generujemy nowy stan usuwając jeden z uwolnionych fluentów i sprawdzamy dalszy przebieg rekurencyjnie - by_releases_if(Action, Group, ReleasedFluent, X), - ((not(is_empty(X)),subset(X, CurrentState)) ; (is_empty(X),is_empty(CurrentState))), - subtract(CurrentState, [ReleasedFluent], CurrentStateWithoutPositiveReleased), - subtract(CurrentStateWithoutPositiveReleased, [\ReleasedFluent], CurrentStateWithoutAnyReleased), - ( - ( - append([ReleasedFluent], CurrentStateWithoutAnyReleased, NewCurrentStateWithPositiveReleased), - possibly_after_from_without_causes(State, [[Action, Group] | Program], NewCurrentStateWithPositiveReleased) - ) - ; - ( - append([\ReleasedFluent], CurrentStateWithoutAnyReleased, NewCurrentStateWithNegativeReleased), - possibly_after_from_without_causes(State, [[Action, Group] | Program], NewCurrentStateWithNegativeReleased) - ) - ) - ). - -possibly_after_from_without_causes(State, [], CurrentState):- - possibly_after_from(State, [], CurrentState). - -possibly_after_from(State,[], CurrentState):- - negate_list(State, NegatedRequiredState), - intersection(NegatedRequiredState, CurrentState, Common), - is_empty(Common), !. - -possibly_after(State, Program):- - possibly_after_from(State, Program, []), !. - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Engagement queries -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -check_state(Action,[FirstEngaged | _ ], States):- - by_causes_if(Action, FirstEngaged, _, RequiredState), - (subset(RequiredState, States); write('here'), is_always(RequiredState), write('there')). - -necessary_engaged_from(Group, [Action|List], States):- - not(impossible_by_if(Action, Group, RequiredState)), - findall(X, by_causes_if(Action, X, _, RequiredState), Engaged), - check_state(Action, Engaged,States), - necessary_engaged_from(Group, List, RequiredState, Engaged), !. - -necessary_engaged_from(Group, [Action|List], State, Engaged):- - not(impossible_by_if(Action, Group, State)), - findall(X, by_causes_if(Action, X, _, State), NextEngaged), - findall(X, (member(X, Engaged), member(X, NextEngaged)), EngagedInBoth), - necessary_engaged_from(Group, List, State, EngagedInBoth), !. - -necessary_engaged_from(_, [], _, []):- fail. -necessary_engaged_from(Group, [], _, [Item|[]]):- subset(Item, Group), !. -necessary_engaged_from(_, [], _, [_|_]):- fail. - -necessary_engaged(Group, Actions):- - necessary_engaged_from(Group, Actions, []), !. - - -possibly_engaged_from(Group, [Action|List], State):- - not(impossible_by_if(Action, Group, State)), - ( by_causes_if(Action, X, _, State); - by_causes_if(Action, X, _, CheckedState), - always(CheckedState) - ), - subset(X, Group), - possibly_engaged_from(Group, List, State), !. - -possibly_engaged_from(_, [], _):- !. - -possibly_engaged(Group, [Action|List]):- - possibly_engaged_from(Group, [Action|List], []), !. - - -% Utils -is_always(State):- - findall(X, always(X), AlwaysList), - is_subset_of_any_always(State, AlwaysList). - -is_subset_of_any_always(State, [Always | AlwaysList]):- - subset(State, Always); - is_subset_of_any_always(State, AlwaysList). -is_subset_of_any_always(_, [[] | []]):- fail. - -apply_alwayses(CurrentState, NewState):- - not(always(X)); - ( - not(subset([X],CurrentState)), - append([X], CurrentState, NewStateWithX), - apply_alwayses(NewStateWithX, NewState) - ). - -apply_resulting_state(ResultingState, CurrentState, NewState):- - subtract(CurrentState, ResultingState, ListWithoutResultingState), - negate_list(ResultingState, NotResultingState), - subtract(ListWithoutResultingState, NotResultingState, ListWithoutNotResultingState), - append(ListWithoutNotResultingState, ResultingState, NewState). - -negate_list([Item|List], NegatedList):- - negate_list(List, NegatedSublist), - append([\Item], NegatedSublist, NegatedList). -negate_list([Item|[]], NegatedList):- - NegatedList = [\Item]. -negate_list([],[]). - -is_empty([]). \ No newline at end of file diff --git a/README.md b/README.md index a454ddc..ead9adc 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,66 @@ # Multiagent-Action-Language -To do: -### C# GUI ### -- [x] BŁĄD w Test3_PARSER_ERROR brak parsowania dla *impossible by* -- [ ] Podmiana *not by if* na odpowiednik *impossible by if* -- [x] Parser na wyrażenie *not by if* -- [ ] Pusta lista agentów -- [ ] Dodać *initially [alpha]* jako *[alpha] after ()* (chodzi o puste wykonanie programu) + -### C# reasoning ### -- [ ] Dodanie obsługi *[alpha] observable after ...* i *[alpha] after ...* -- [ ] Testy generowania grafu -- [x] Dodać kwerendę wykonywalności *executable* -- [x] Dodać kwerendę wartości *after* -- [ ] Dodać kwerendę zaangażowania *engaged* -- [x] Dodać testy języka AR (przykłady z wykładu) -- [x] Dodać kwerendy z pustego programu -- [x] Dodać kwerendy dla pustej listy agentów +## Summary +Framework for multiagent reasoning from actions written entirely in C#. This implementation extents AR action language (actions with ramifications) on multiple agents. Main assumpions of this action language are: +1. Inertia law +2. Sequencing of actions +3. Nondeterminism of actions -### App tests ### -- [ ] 4 historyjki po 3-4 kwerendy dla grupy 1 **na poniedziałek musi być gotowe** -- [ ] kilka historyjek po 3-4 kwerendy do naszych testów +## Implementation features +### Forward chaining +Obviously, this implementation allows for forward chaining. E.g. for domain: +``` +Fluent R1 +Fluent R2 +Fluent R3 +Agent g1 +Agent g2 +Agent g3 +Agent g4 +Action A1 +Action A2 +A1 by [g1, g3, g4] causes [R1] +A1 by [g1, g3] causes [R3] +A2 by [g3, g4] causes [R2] +``` +and query: +``` +possibly [g2] engaged in (A1, [g1, g2, g3, g4]),(A2, [g2, g3, g4]) +``` +App returns *false*, as suspected with respect to definition. -### Requirements for the deadline ### -- Dokumentacja teoretyczna -- Dokumentacja techniczna -- User Guide -- Testy naszego programu zrobione przez inną grupę **patrz wyżej** -- Testy innego programu zrobione przez nas -- Płytka CD +### Backward chaining +This implementation allows not only forward chaining but also backward chaining. E.g. for domain: +``` +Action fire +Action walk +Agent x +Fluent loaded +Fluent alive +Fluent walked +fire causes [~loaded] +fire causes [~alive] if [loaded] +walk causes [walked] +initially [alive] +[~alive] after (walk, [x]), (fire, [x]) +``` +and query: +``` +necessary [loaded] after (walk, [x]) +``` +App returns *true*, as fluent *loaded* in really necessary after *walk* action, for fluent *alive* to be *false*. -### Conclusions after deadline meeting ### -- kwerendy mogą też dostać wyrażenie logiczne jako resultat - co wtedy? -- program niewykonalny -> necessary true -- niedeterminizm - releases itp nie działa \ No newline at end of file +## Authors +* [pkonowrocki](github.com/pkonowrocki) Piotr Konowrocki +* [ArkadyPL](github.com/ArkadyPL) +* [kocu13](github.com/kocu13) +* [zegadlok](github.com/zegadlok) +* [omelanczukm](github.com/omelanczukm) +* [mazurkiewiczj](github.com/mazurkiewiczj) +* [dawidlazuk](github.com/dawidlazuk) +* [bpolak00](github.com/bpolak00) + +## Final remarks +This project was realized as a part of Knowledge Representation course at Faculty of Mathematics and Information Science at WUT, and was rated 20/20 points by dr Anna Maria Radzikowska. \ No newline at end of file diff --git a/STORY_1.mar b/STORY_1.mar deleted file mode 100644 index e706f76..0000000 --- a/STORY_1.mar +++ /dev/null @@ -1,16 +0,0 @@ -Agent a -Agent b -Agent c -Agent d -Action push -Fluent isRunning -initially [~isRunning] -impossible push by [d] -impossible push if [isRunning] -push by [a] causes [~isRunning] -push by [b] causes [~isRunning] -push by [c] causes [~isRunning] -push by [b,c] causes [~isRunning] -push by [a,b] causes [isRunning] -push by [a,c] causes [isRunning] -push by [a,b,c] causes [~isRunning] \ No newline at end of file diff --git a/STORY_1_Queary.txt b/STORY_1_Queary.txt deleted file mode 100644 index 822dbba..0000000 --- a/STORY_1_Queary.txt +++ /dev/null @@ -1,5 +0,0 @@ -necessary executable (push,[a,b]) from [~isRunning] -necessary executable (push,[a,c]) from [~isRunning] -possibly [a] engaged in push -possibly [b] engaged in push -possibly [c] engaged in push \ No newline at end of file diff --git a/STORY_2.mar b/STORY_2.mar deleted file mode 100644 index 1235304..0000000 --- a/STORY_2.mar +++ /dev/null @@ -1,16 +0,0 @@ -Agent a -Agent b -Action lift -Action protect -Fluent alive -Fluent protected -Fluent up -initially [~alive] -initially [~protected] -initially [~up] -lift by [a,b] causes [up] -lift by [a] causes [~alive] if [~protected && up] -lift by [b] causes [~alive] if [~protected && up] -protect causes [protected] if [up] -impossible lift if [protected || ~alive] -impossible protect if [protected || ~alive || ~up] \ No newline at end of file diff --git a/STORY_2_Queary.txt b/STORY_2_Queary.txt deleted file mode 100644 index f6aa019..0000000 --- a/STORY_2_Queary.txt +++ /dev/null @@ -1,8 +0,0 @@ -necessary executable (lift, [a,b]) from [alive] -necessary executable (protect,[a]) from [up && alive] -necessary executable (protect,[b]) from [up && alive] -necessary up after (lift,[a,b]) from [alive] -necessary protected after (protect,[a]) from [up] -necessary protected after (protect,[b]) from [up] -possibly [a] engaged in protect from [up] -possibly [b] engaged in protect from [up] \ No newline at end of file diff --git a/STORY_3.mar b/STORY_3.mar deleted file mode 100644 index 470e272..0000000 --- a/STORY_3.mar +++ /dev/null @@ -1,12 +0,0 @@ -Agent Bercik -Agent Filemon -Action brew -Fluent brewed -Fluent destroyed -initially [~brewed] -initially [~destroyed] -brew by [Bercik, Filemon] causes [brewed] -brew by [Filemon] releases [brewed] -brew by [Bercik] releases [brewed] -brew by [Bercik] releases [destroyed] - diff --git a/STORY_3_Queary.txt b/STORY_3_Queary.txt deleted file mode 100644 index 178c486..0000000 --- a/STORY_3_Queary.txt +++ /dev/null @@ -1,6 +0,0 @@ -possibly [Filemon] engaged in brew -possibly [Bercik] engaged in brew -possibly [brewed] after (brew,[Bercik, Filemon]) from [~brewed && ~destroyed] -possibly [brewed] after (brew,[Bercik]) from [~brewed && ~destroyed] -possibly [destroyed] after (brew,[Bercik]) from [~brewed && ~destroyed] -possibly [brewed] after (brew,[Filemon]) from [~brewed && ~destroyed] diff --git a/example_from_lecture_1.mar b/example_from_lecture_1.mar deleted file mode 100644 index 94f9b66..0000000 --- a/example_from_lecture_1.mar +++ /dev/null @@ -1,11 +0,0 @@ -Agent Bill -Action shoot -Action load -Fluent loaded -Fluent alive -initially [~loaded] -initially [alive] -load causes [loaded] -shoot causes [~loaded] -shoot causes [~alive] if [loaded] - diff --git a/logic.pl b/logic.pl deleted file mode 100644 index 214f047..0000000 --- a/logic.pl +++ /dev/null @@ -1,335 +0,0 @@ -:- dynamic impossible_by/2. -:- dynamic impossible_if/2. -:- dynamic by_causes/3. -:- dynamic causes_if/3. -:- dynamic by_releases_if/4. -:- dynamic by_releases/3. -:- dynamic releases_if/3. -:- dynamic always/1. -:- dynamic initially/1. - -% Support for tests: -:- multifile impossible_by/2, by_causes_if/4, by_causes/3, after/2, by_releases_if/4, always/1. -:- style_check(-discontiguous). -passed:- nl, ansi_format([bold,fg(green)], 'Passed', []). -failed:- nl, ansi_format([bold,fg(red)], 'Failed', []). - - -% Make sure, "initially" also propagates to after(Result, []). -after(Result, []):- - initially(Result). - -private_impossible_by_if(Action, Group, State):- - impossible_by(Action, Group); - impossible_if(Action, State); - impossible_by_if(Action, Group, State). - -impossible_by_if(Action, Group, []):- - impossible_by(Action, Group), !. - -impossible_by_if(Action, [], State):- - impossible_if(Action, State), !. - - - -by_causes_if(Action, Group, Result, []):- - by_causes(Action, Group, Result). - -by_causes_if(Action, [], Result, State):- - causes_if(Action, Result, State). - - -by_releases_if(Action, Group, Result, _):- - by_releases(Action, Group, Result). - -by_releases_if(Action, _, Result, State):- - releases_if(Action, Result, State). - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Executability queries - TODO: fix possibly_executable_from query -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -necessary_executable_from([[Action, Group] | Program], CurrentState):- - private_necessary_executable_from([[Action, Group] | Program], CurrentState, _), !. - -% CurrentState means "initialState" in the first call, and then set of all changes states -private_necessary_executable_from([[Action, Group] | Program], CurrentState, FinalState):- - ( - (by_causes_if(Action, G, ResultingState, RequiredState);by_releases_if(Action, G, ResultingState, RequiredState)), - ( - subset(G,Group), - ( - not(is_empty(RequiredState)), - ( - is_always(RequiredState) - ; - subset(RequiredState, CurrentState) - ) - ) - ; - initially(Y), - (is_empty(RequiredState), subset(CurrentState,Y)) - ; - (is_empty(RequiredState),is_empty(CurrentState)) - ) - ), - not(private_impossible_by_if(Action, Group, RequiredState)), - subtract(CurrentState, ResultingState, ListWithoutResultingState), - negate_list(ResultingState, NotResultingState), - subtract(ListWithoutResultingState, NotResultingState, ListWithoutNotResultingState), - append(ListWithoutNotResultingState, ResultingState, NewCurrentState), - private_necessary_executable_from(Program, NewCurrentState, FinalState), !. - -private_necessary_executable_from([], NewCurrentState, FinalState):- - FinalState = NewCurrentState, !. - -necessary_executable(Program):- - necessary_executable_from(Program, []), !. - - - -% CurrentState means "initialState" in the first call, and then set of all changes states -possibly_executable_from([[Action, Group] | Program], CurrentState):- - (by_releases_if(Action, Group, ResultingState, X) ; by_causes_if(Action, Group, ResultingState, X)), - ((not(is_empty(X)),subset(X, CurrentState)) ; (is_empty(X),is_empty(CurrentState))), - not(private_impossible_by_if(Action, Group, X)), - subtract(CurrentState, ResultingState, ListWithoutResultingState), - negate_list(ResultingState, NotResultingState), - subtract(ListWithoutResultingState, NotResultingState, ListWithoutNotResultingState), - append(ListWithoutNotResultingState, ResultingState, NewCurrentState), - possibly_executable_from(Program, NewCurrentState), !. - -possibly_executable_from([],_). - -possibly_executable(Program):- - possibly_executable_from(Program, []), !. - - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Value queries - TODO: finish possibly_after_from implementation -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -necessary_after_from(State, Program, CurrentState):- - ( - (after(State,ResultingProgram), - subset(ResultingProgram,Program), - are_necessary_connected(Program,CurrentState)) - ; - (private_necessary_after_from(State,Program,CurrentState)) - ). - - -are_necessary_connected([[Action, Group] | Program], CurrentState):- - ( - ( - by_causes_if(Action,G,ResultingState, S), - subset(S,CurrentState), - subset(G,Group) - ) - ; - ( - by_causes(Action,G,ResultingState), - subset(G,Group) - ) - ), - are_necessary_connected(Program, ResultingState). - -are_necessary_connected([],_):- - true. - -private_necessary_after_from( State, [[Action, Group] | Program], CurrentState):- - ( - (is_always(State)) - ; - ( - ( - by_causes_if(Action,G,ResultingState, S), - (subset(S,CurrentState);initially(S);always(S)), - subset(G,Group), - ( - ( - subset(ResultingState,State), - subtract(State,ResultingState,SetWithoutState), - private_necessary_after_from(SetWithoutState, Program, ResultingState) - ) - ; - ( - private_necessary_after_from(State, Program, ResultingState) - ) - ) - ) - - ; - - ( - by_causes(Action,G,ResultingState), - subset(G,Group), - ( - (subset(ResultingState,State), - subtract(State,ResultingState,SetWithoutState), - private_necessary_after_from(SetWithoutState, Program, ResultingState)) - ; - (private_necessary_after_from(State, Program, ResultingState)) - ) - ) - - ) - ), !. - - -private_necessary_after_from([], [],_):- - true, !. - -private_necessary_after_from(State, [] ,_):- - initially(State). - -necessary_after(State, Program):- - necessary_after_from(State, Program, []), !. - -possibly_after_from(State, [[Action, Group] | Program], CurrentState):- - is_always(State) - ; - (apply_alwayses(CurrentState, FullCurrentState) ; true), - ( - ( - %Bierzemy stan do którego musimy przejść i idziemy do następnej instrukcji. Jeżeli to się nie powiedzie to zwracamy false bo musimy przejść do ResultingState(!) - by_causes_if(Action, Group, ResultingState, X), - ((not(is_empty(X)),subset(X, FullCurrentState)) ; (is_empty(X),is_empty(FullCurrentState))), - apply_resulting_state(ResultingState, FullCurrentState, NewCurrentState), - possibly_after_from(State, Program, NewCurrentState), ! - ) - ; - ( - % Nie mamy stanu, do którego musimy przejść, generujemy stany usuwając poszczególne fluenty i sprawdzamy - possibly_after_from_without_causes(State, [[Action, Group] | Program], FullCurrentState) - ) - ). - -possibly_after_from_without_causes(State, [[Action, Group] | Program], CurrentState):- - %Ta reguła generuje nowe stany na podstawie reguł releases i weryfikuje dla nich działanie - %by_releases_if(Action, Group, ReleasedFluent, CurrentState), % sprawdzamy, czy możemy w ogóle wykonać releases - ( - %Sprawdzamy dalszy przebieg dla obecnego stanu - by_releases_if(Action, Group, ReleasedFluent, X), %czy akcja w ogóle możliwa - ((not(is_empty(X)),subset(X, CurrentState)) ; (is_empty(X),is_empty(CurrentState))), - possibly_after_from(State, Program, CurrentState) - ) - ; - ( - %Generujemy nowy stan usuwając jeden z uwolnionych fluentów i sprawdzamy dalszy przebieg rekurencyjnie - by_releases_if(Action, Group, ReleasedFluent, X), - ((not(is_empty(X)),subset(X, CurrentState)) ; (is_empty(X),is_empty(CurrentState))), - subtract(CurrentState, [ReleasedFluent], CurrentStateWithoutPositiveReleased), - subtract(CurrentStateWithoutPositiveReleased, [\ReleasedFluent], CurrentStateWithoutAnyReleased), - ( - ( - append([ReleasedFluent], CurrentStateWithoutAnyReleased, NewCurrentStateWithPositiveReleased), - possibly_after_from_without_causes(State, [[Action, Group] | Program], NewCurrentStateWithPositiveReleased) - ) - ; - ( - append([\ReleasedFluent], CurrentStateWithoutAnyReleased, NewCurrentStateWithNegativeReleased), - possibly_after_from_without_causes(State, [[Action, Group] | Program], NewCurrentStateWithNegativeReleased) - ) - ) - ). - -possibly_after_from_without_causes(State, [], CurrentState):- - possibly_after_from(State, [], CurrentState). - -possibly_after_from(State,[], CurrentState):- - negate_list(State, NegatedRequiredState), - intersection(NegatedRequiredState, CurrentState, Common), - is_empty(Common), !. - -possibly_after(State, Program):- - possibly_after_from(State, Program, []), !. - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Engagement queries -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -check_state(Action,[FirstEngaged | _ ], States):- - by_causes_if(Action, FirstEngaged, _, RequiredState), - (subset(RequiredState, States); is_always(RequiredState)). - -necessary_engaged_from(Group, [Action|List], States):- - not(impossible_by_if(Action, Group, RequiredState)), - findall(X, by_causes_if(Action, X, _, RequiredState), Engaged), - check_state(Action, Engaged,States), - necessary_engaged_from(Group, List, RequiredState, Engaged), !. - -necessary_engaged_from(Group, [Action|List], State, Engaged):- - not(impossible_by_if(Action, Group, State)), - findall(X, by_causes_if(Action, X, _, State), NextEngaged), - findall(X, (member(X, Engaged), member(X, NextEngaged)), EngagedInBoth), - necessary_engaged_from(Group, List, State, EngagedInBoth), !. - -necessary_engaged_from(_, [], _, []):- fail. -necessary_engaged_from(Group, [], _, [Item|[]]):- subset(Item, Group), !. -necessary_engaged_from(_, [], _, [_|_]):- fail. - -necessary_engaged(Group, Actions):- - necessary_engaged_from(Group, Actions, []), !. - - -possibly_engaged_from(Group, [Action|List], State):- - not(impossible_by_if(Action, Group, State)), - ( - by_causes_if(Action, X, _, State) - ; - by_causes_if(Action, X, _, CheckedState), - always(CheckedState) - ; - by_causes_if(Action, X, _, CheckedState), - initially(Y), - subset(CheckedState,Y) - ; - causes_if(Action, _, CheckedState), - subset(State,CheckedState) - ), - subset(X, Group), - possibly_engaged_from(Group, List, State), !. - -possibly_engaged_from(_, [], _):- !. - -possibly_engaged(Group, [Action|List]):- - possibly_engaged_from(Group, [Action|List], []), !. - - -% Utils -is_always(State):- - findall(X, always(X), AlwaysList), - is_subset_of_any_always(State, AlwaysList). - -is_subset_of_any_always(State, [Always | AlwaysList]):- - subset(State, Always); - is_subset_of_any_always(State, AlwaysList). -is_subset_of_any_always(_, [[] | []]):- fail. - -apply_alwayses(CurrentState, NewState):- - not(always(X)); - ( - not(subset([X],CurrentState)), - append([X], CurrentState, NewStateWithX), - apply_alwayses(NewStateWithX, NewState) - ). - -apply_resulting_state(ResultingState, CurrentState, NewState):- - subtract(CurrentState, ResultingState, ListWithoutResultingState), - negate_list(ResultingState, NotResultingState), - subtract(ListWithoutResultingState, NotResultingState, ListWithoutNotResultingState), - append(ListWithoutNotResultingState, ResultingState, NewState). - -negate_list([Item|List], NegatedList):- - negate_list(List, NegatedSublist), - append([\Item], NegatedSublist, NegatedList). -negate_list([Item|[]], NegatedList):- - NegatedList = [\Item]. -negate_list([],[]). - -is_empty([]). \ No newline at end of file diff --git a/models/example.pl b/models/example.pl deleted file mode 100644 index d299e41..0000000 --- a/models/example.pl +++ /dev/null @@ -1,23 +0,0 @@ -after(result, [[action1, [g1, g2]], [action2, [g3, g4]]]). -after(result, [[action1, [g1, g3]], [action2, [g2]]]). -after(beta, [[action1, [g1]]]):- !. - - -observable_after(result, [[action1, [g1]], [action2, [g2]]]). - - -initially(beta). - - -by_causes_if(action1, [g1], result, pi). - -by_causes(action1, [g1], result). - -causes_if(action1, result, pi). - - -impossible_by_if(action1, [g1], pi). - -impossible_by(action1, [g1]). - -impossible_if(action1, pi). diff --git a/models/story1.pl b/models/story1.pl deleted file mode 100644 index 943b4b1..0000000 --- a/models/story1.pl +++ /dev/null @@ -1,12 +0,0 @@ -initially(not(isRunning)). - -impossible_if(push, isRunning). -impossible_by(push, [d]). - -by_causes(push, [a], not(isRunning)). -by_causes(push, [b], not(isRunning)). -by_causes(push, [c], not(isRunning)). -by_causes(push, [b,c], not(isRunning)). -by_causes(push, [a,b], isRunning). -by_causes(push, [a,c], isRunning). -by_causes(push, [a,b,c], not(isRunning)). diff --git a/models/story2.pl b/models/story2.pl deleted file mode 100644 index f963dec..0000000 --- a/models/story2.pl +++ /dev/null @@ -1,12 +0,0 @@ -initially(alive). -initially(not(protected)). -initially(not(up)). - -by_causes(lift,[a,b],up). -by_causes_if(lift,[a],not(alive),(not(protected),up)). -by_causes_if(lift,[b],not(alive),(not(protected),up)). -causes_if(protect,protected,up). - -impossible_if(lift,(protected;not(alive))). -impossible_if(protected,(protected;not(alive);not(up))). - diff --git a/run.pl b/run.pl deleted file mode 100644 index e9fb5bd..0000000 --- a/run.pl +++ /dev/null @@ -1 +0,0 @@ -:- consult('logic.pl'), consult('tests/necessary_engaged/model.pl'). \ No newline at end of file diff --git a/screenshot.PNG b/screenshot.PNG new file mode 100644 index 0000000..86fb4b9 Binary files /dev/null and b/screenshot.PNG differ diff --git a/tests.pl b/tests.pl deleted file mode 100644 index d0afbf1..0000000 --- a/tests.pl +++ /dev/null @@ -1,8 +0,0 @@ -:- write('ALL TESTS STARTED'),nl, - consult('tests/necessary_executable/test.pl'), - consult('tests/possibly_executable/test.pl'), - consult('tests/necessary_engaged/test.pl'), - consult('tests/possibly_engaged/test.pl'), - consult('tests/necessary_after_from/test.pl'), - consult('tests/possibly_after_from/test.pl'), - write('ALL TESTS FINISHED'). diff --git a/tests/examples_from_Lectures/model.pl b/tests/examples_from_Lectures/model.pl deleted file mode 100644 index be4a329..0000000 --- a/tests/examples_from_Lectures/model.pl +++ /dev/null @@ -1,21 +0,0 @@ -initially([heads]). -by_releases(toss,[],[heads]). - -initially([alive, \loaded]). -by_causes(load,[],[loaded]). -causes_if(shoot,[\alive],[loaded]). - -initially([is_student]). -causes_if(studing,[has_diploma],[is_student]). -causes_if(finding_job,[rich],[has_diploma]). -causes_if(living,[happy],[rich]). - -always([thinking]). -initially([not_human]). -causes_if(beeing,[beeing_human],[thinking]). - -initially([\open]). -by_causes(insert,[],[open]). -impossible_if(insert,[\hasCard]). - - diff --git a/tests/examples_from_Lectures/test.pl b/tests/examples_from_Lectures/test.pl deleted file mode 100644 index a85ed9a..0000000 --- a/tests/examples_from_Lectures/test.pl +++ /dev/null @@ -1,48 +0,0 @@ -:- consult('../../logic.pl'), consult('model.pl'), - -write('----------- COIN TOSS TESTS ---\n'), - - -write('Test case 0\n'), -(write('possibly_after_from([heads],[[toss,[]]],[])'), -possibly_after_from([heads],[[toss,[]]],[]), passed; failed), nl, - -write('Test case 1\n'), -(write('possibly_after_from([not heads],[[toss,[]]],[])'), -possibly_after_from([\heads],[[toss,[]]],[]), passed; failed), nl, - -write('Test case 2\n'), -(write('not(necessary_after_from([not heads],[[toss,[]]],[]))'), -not(necessary_after_from([\heads],[[toss,[]]],[])), passed; failed), nl, - -write('Test case 3\n'), -(write('not(necessary_after_from([heads],[[toss,[]]],[]))'), -not(necessary_after_from([heads],[[toss,[]]],[])), passed; failed), nl, - - -write('Test case 41\n'), -(write('necessary_after_from([~alive],[[load,[]],[shoot,[]]],[~loaded])'), -necessary_after_from([\alive],[[load,[]],[shoot,[]]],[\loaded]), passed; failed), nl, - - -write('Test case 4b\n'), -(write('possibly_after_from([~alive],[[load,[]],[shoot,[]]],[~loaded])'), -possibly_after_from([\alive],[[load,[]],[shoot,[]]],[\loaded]), passed; failed), nl, - -write('Test case 5a\n'), -(write('necessary_after_from([happy],[[studing,[]],[finding_job,[]],[living,[]]],[])'), -necessary_after_from([happy],[[studing,[]],[finding_job,[]],[living,[]]],[]), passed; failed), nl, - -write('Test case 5b\n'), -(write('possibly_after_from([happy],[[studing,[]],[finding_job,[]],[living,[]]],[])'), -possibly_after_from([happy],[[studing,[]],[finding_job,[]],[living,[]]],[]), passed; failed), nl, - -write('Test case 6a\n'), -(write('necessary_after_from([beeing_human],[[beeing,[]]],[])'), -necessary_after_from([beeing_human],[[beeing,[]]],[]), passed; failed), nl, - -write('Test case 6b\n'), -(write('possibly_after_from([beeing_human],[[beeing,[]]],[])'), -possibly_after_from([beeing_human],[[beeing,[]]],[]), passed; failed), nl, - -write('TESTS FINISHED'),nl. diff --git a/tests/examples_from_Radzikowska/model.pl b/tests/examples_from_Radzikowska/model.pl deleted file mode 100644 index 4cee22a..0000000 --- a/tests/examples_from_Radzikowska/model.pl +++ /dev/null @@ -1,17 +0,0 @@ -by_causes(action1,[],[f1]). -by_causes(action2,[],[f2]). -initially([\f1,\f2]). - -by_causes(a,[x],[f]). -by_causes(b,[y],[g]). -initially([\f,\g]). - -by_causes(load,[],[loaded]). -by_causes(fire,[],[\loaded]). -by_causes_if(fire,[],[\alive],[loaded]). -initially([alive]). -after([\alive],[[fire,[Bill]]]). - -by_causes(fire1,[],[\loaded1]). -causes_if(fire1,[\alive1],[loaded1]). -initially([alive1]). \ No newline at end of file diff --git a/tests/examples_from_Radzikowska/test.pl b/tests/examples_from_Radzikowska/test.pl deleted file mode 100644 index f5d0606..0000000 --- a/tests/examples_from_Radzikowska/test.pl +++ /dev/null @@ -1,26 +0,0 @@ -:- consult('../../logic.pl'), consult('model.pl'), - -write('TESTS STARTED'),nl, - -write('Test case 1\n'), -(write('necessary_after_from([f1,f2],[[action1,[actor1]],[action2,[actor2]]],[])'), -necessary_after_from([f1,f2],[[action1,[actor1]],[action2,[actor2]]],[]), passed; failed), nl, - -write('Test case 2\n'), -(write('necessary_after_from([f,g],[[a,[x]],[b,[y]]],[])'), -necessary_after_from([f,g],[[a,[x]],[b,[y]]],[]), passed; failed), nl, - -write('Test case 3\n'), -(write('necessary_after_from([loaded],[[load,[Bill]]],[])'), -necessary_after_from([loaded],[[load,[Bill]]],[]), passed; failed), nl, - -write('Test case 4\n'), -(write('necessary_after_from([\alive],[[fire,[Bill]]],[])'), -necessary_after_from([\alive],[[fire,[Bill]]],[]), passed; failed), nl, - -write('Test case 5\n'), -(write('necessary_after_from([alive1],[],[])'), -necessary_after_from([alive1],[],[]), passed; failed), nl, - - -write('TESTS FINISHED'),nl. diff --git a/tests/examples_mean/model.pl b/tests/examples_mean/model.pl deleted file mode 100644 index 571377f..0000000 --- a/tests/examples_mean/model.pl +++ /dev/null @@ -1,18 +0,0 @@ -after([a],[[work,[John,Tom]]]). -by_causes(work,[],[b]). - - -after([d,e],[[eat,[Magda,Anna]]]). -after([e],[[talk,[Irena,Alice]]]). -by_causes(eat,[],[z]). -by_causes(talk,[],[z]). - -always([f]). -after([\f],[[do,[Milena]]]). - - -after([\g],[[make,[Iwona]]]). -by_causes(make, [Iwona], [g]). - -always([h]). -by_causes_if(swim, [Ula],[i],[h]). \ No newline at end of file diff --git a/tests/examples_mean/test.pl b/tests/examples_mean/test.pl deleted file mode 100644 index c1c80e8..0000000 --- a/tests/examples_mean/test.pl +++ /dev/null @@ -1,33 +0,0 @@ -:- consult('../../logic.pl'), consult('model.pl'), - - -write('----------MEAN TESTS ---\n'), -write('Test case 0\n'), -(write('necessary_after([a],[[work,[John,Tom]]])'), -necessary_after([a],[[work,[John,Tom]]]), passed; failed), nl, -(write('possibly_after([a],[[work,[John,Tom]]])'), -possibly_after([a],[[work,[John,Tom]]]), passed; failed), nl, - -write('Test case 0\n'), -(write('necessary_after([d,e],[[eat,[Magda,Anna]],[talk,[Irena,Alice]]])'), -necessary_after([d,e],[[eat,[Magda,Anna]],[talk,[Irena,Alice]]]), passed; failed), nl, -(write('possibly_after([d,e],[[eat,[Magda,Anna]],[talk,[Irena,Alice]]])'), -possibly_after([d,e],[[eat,[Magda,Anna]],[talk,[Irena,Alice]]]), passed; failed), nl, - -write('Test case 0\n'), -(write('necessary_after([f],[[do,[Milena]]])'), -necessary_after([f],[[do,[Milena]]]), passed; failed), nl, -(write('possibly_after([f],[[do,[Milena]]])'), -possibly_after([f],[[do,[Milena]]]), passed; failed), nl, - - -write('Test case 0\n'), -(write('necessary_after([~g],[[make,[Iwona]]])'), -necessary_after([\g],[[make,[Iwona]]]), passed; failed), nl, - -write('Test case 0\n'), -(write('necessary_after([i],[[swim,[Ula]]])'), -necessary_after([i],[[swim,[Ula]]]), passed; failed), nl, - -write('TESTS FINISHED'),nl. - diff --git a/tests/necessary_after_from/model.pl b/tests/necessary_after_from/model.pl deleted file mode 100644 index 847a198..0000000 --- a/tests/necessary_after_from/model.pl +++ /dev/null @@ -1,61 +0,0 @@ - -% Test case 1 a. - should be false because 1st action is not executable from initial state -by_causes_if(na_1a_action1, [na_1a_g1, na_1a_g2], [na_1a_result], [na_1a_pi]). -by_causes(na_1a_action2, [na_1a_g1, na_1a_g2], [na_1a_another]). -after([na_1a_expected], [[na_1a_action1,[na_1a_g1, na_1a_g2]], [na_1a_action2, [na_1a_g1, na_1a_g2]]]). - - - -% Test case 2 a. - should be false because 2nd action is not executable after 1st one -by_causes_if(na_2a_action1, [na_2a_g1, na_2a_g2], [na_2a_result], []). -by_causes_if(na_2a_action2, [na_2a_g1, na_2a_g2], [na_2a_another], [na_2a_pi]). -after([na_2a_expected], [[na_2a_action1,[na_2a_g1, na_2a_g2]], [na_2a_action2, [na_2a_g1, na_2a_g2]]]). - -% Test case 3 a. - should be true because program is executable from initial state, and it is true that "na_3a_expected" after this program -by_causes(na_3a_action1, [na_3a_g1, na_3a_g2], [na_3a_result]). -by_causes_if(na_3a_action2, [na_3a_g1, na_3a_g2], [na_3a_another], [na_3a_result]). -after([na_3a_expected], [[na_3a_action1,[na_3a_g1, na_3a_g2]], [na_3a_action2, [na_3a_g1, na_3a_g2]]]). - - -% Test case 4 a. - should be true because program is executable from initial state, and it is true that "na_4a_expected" after this program -by_causes(na_4a_action1, [na_4a_g1, na_4a_g2], [na_4a_result]). -by_causes_if(na_4a_action2, [na_4a_g1, na_4a_g2], [na_4a_expected], [na_4a_result]). - - -% Test case 5 a. - should be false because 2nd action is not executable after 1st one -by_causes_if(na_5a_action1, [na_5a_g1, na_5a_g2], [na_5a_result], [na_5a_pi]). -by_causes_if(na_5a_action2, [na_5a_g1, na_5a_g2], [na_5a_another],[na_5a_some]). % this is not executable in 'na_5a_result', it is in initial state but it doesn't matter -after([na_5a_expected], [[na_5a_action1,[na_5a_g1, na_5a_g2]], [na_5a_action2, [na_5a_g1, na_5a_g2]]]). - -% Test case 6 a. - should be true because both actions are executable from requested state, and it is true that "na_6a_expected" after this program -by_causes_if(na_6a_action1, [na_6a_g1, na_6a_g2], [na_6a_result], [na_6a_pi]). -by_causes_if(na_6a_action2, [na_6a_g1, na_6a_g2], [na_6a_another], [na_6a_result]). -after([na_6a_expected], [[na_6a_action1,[na_6a_g1, na_6a_g2]], [na_6a_action2, [na_6a_g1, na_6a_g2]]]). - -% Test case 7 a. - should be true because both actions are executable from requested state, and it is true that "na_7a_expected" after this program -by_causes_if(na_7a_action1, [na_7a_g1, na_7a_g2], [na_7a_result], [na_7a_pi]). -by_causes_if(na_7a_action2, [na_7a_g1, na_7a_g2], [na_7a_expected], [na_7a_result]). - -% Test case 8 a. - should be false - trivial, actions undefined -after([na_8a_expected], [[na_8a_action1,[na_8a_g1, na_8a_g2]], [na_8a_action2, [na_8a_g1, na_8a_g2]]]). - -% Test case 9 a. - should be true because expected term is always true -by_causes_if(na_9a_action1, [na_9a_g1, na_9a_g2], [na_9a_result], [na_9a_pi]). -by_causes_if(na_9a_action2, [na_9a_g1, na_9a_g2], [na_9a_another], [na_9a_result]). -always([na_9a_just_make_some_noise]). -always([na_9a_expected, na_9a_not_important]). -always([na_9a_just_make_some_noise2]). - -% Test case 10 a. - should be false because expected term is never true -by_causes_if(na_10a_action1, [na_10a_g1, na_10a_g2], [na_10a_result], [na_10a_pi]). -by_causes_if(na_10a_action2, [na_10a_g1, na_10a_g2], [na_10a_another], [na_10a_result]). -always([na_10a_just_make_some_noise]). -always([na_10a_not_important, na_10a_other_not_important]). -always([na_10a_just_make_some_noise2]). - -% Test case 11 a. - should be true -by_causes(washing,[], [washed]). -by_causes(cooking, [], [cooked]). -by_causes(tyding, [], [tied]). -after([clean],[[cooking,[]],[tyding,[]]]). - diff --git a/tests/necessary_after_from/test.pl b/tests/necessary_after_from/test.pl deleted file mode 100644 index 3c08db8..0000000 --- a/tests/necessary_after_from/test.pl +++ /dev/null @@ -1,52 +0,0 @@ -:- consult('../../logic.pl'), consult('model.pl'), - -write('Necessary After From - TESTS STARTED'),nl, - - -write('Test case 1 a. - should be false because 1nd action is not executable from initial state\n'), -(write('not(necessary_after([na_1a_expected], [[na_1a_action1,[na_1a_g1, na_1a_g2]], [na_1a_action2, [na_1a_g1, na_1a_g2]]])).'), -not(necessary_after([na_1a_expected], [[na_1a_action1,[na_1a_g1, na_1a_g2]], [na_1a_action2, [na_1a_g1, na_1a_g2]]])), passed; failed), nl, - -write('Test case 2 a. - should be false because 2nd action is not executable after 1st one\n'), -(write('not(necessary_after([na_2a_expected], [[na_2a_action1,[na_2a_g1, na_2a_g2]], [na_2a_action2, [na_2a_g1, na_2a_g2]]])).'), -not(necessary_after([na_2a_expected], [[na_2a_action1,[na_2a_g1, na_2a_g2]], [na_2a_action2, [na_2a_g1, na_2a_g2]]])), passed; failed), nl, - -write('Test case 3 a. - should be true because program is executable from initial state, and it is true that "na_3a_expected" after this program\n'), -(write('necessary_after_from([na_3a_expected], [[na_3a_action1,[na_3a_g1, na_3a_g2]], [na_3a_action2, [na_3a_g1, na_3a_g2]]], []).'), -necessary_after_from([na_3a_expected], [[na_3a_action1,[na_3a_g1, na_3a_g2]], [na_3a_action2, [na_3a_g1, na_3a_g2]]], []), passed; failed), nl, - -write('Test case 4 a. - should be true because program is executable from initial state, and it is true that "na_4a_expected" after this program\n'), -(write('necessary_after_from([na_4a_expected], [[na_4a_action1,[na_4a_g1, na_4a_g2]], [na_4a_action2, [na_4a_g1, na_4a_g2]]], []).'), -necessary_after_from([na_4a_expected], [[na_4a_action1,[na_4a_g1, na_4a_g2]], [na_4a_action2, [na_4a_g1, na_4a_g2]]], []), passed; failed), nl, -%necessary_after_from([expected], [[action1,[g1, g2]], [action2, [g1, g2]]], []), passed; failed), nl, - -write('Test case 5 a. - should be false because 2nd action is not executable from requested state\n'), -(write('not(necessary_after_from([na_5a_expected], [[na_5a_action1,[na_5a_g1, na_5a_g2]], [na_5a_action2, [na_5a_g1, na_5a_g2]]], [na_5a_pi])).'), -not(necessary_after_from([na_5a_expected], [[na_5a_action1,[na_5a_g1, na_5a_g2]], [na_5a_action2, [na_5a_g1, na_5a_g2]]], [na_5a_pi])), passed; failed), nl, - -write('Test case 6 a. - should be true because both actions are executable from requested state, and it is true that "na_6a_expected" after this program\n'), -(write('necessary_after_from([na_6a_expected], [[na_6a_action1,[na_6a_g1, na_6a_g2]], [na_6a_action2, [na_6a_g1, na_6a_g2]]], [na_6a_pi]).'), -necessary_after_from([na_6a_expected], [[na_6a_action1,[na_6a_g1, na_6a_g2]], [na_6a_action2, [na_6a_g1, na_6a_g2]]], [na_6a_pi]), passed; failed), nl, - -write('Test case 7 a. - should be true because both actions are executable from requested state, and it is true that "na_7a_expected" after this program\n'), -(write('necessary_after_from([na_7a_expected], [[na_7a_action1,[na_7a_g1, na_7a_g2]], [na_7a_action2, [na_7a_g1, na_7a_g2]]], [na_7a_pi]).'), -necessary_after_from([na_7a_expected], [[na_7a_action1,[na_7a_g1, na_7a_g2]], [na_7a_action2, [na_7a_g1, na_7a_g2]]], [na_7a_pi]), passed; failed), nl, - -write('Test case 8 a. - should be false - trivial, actions undefined\n'), -(write('not(necessary_after([na_8a_expected], [[na_8a_action1,[na_8a_g1, na_8a_g2]], [na_8a_action2, [na_8a_g1, na_8a_g2]]])).'), -not(necessary_after([na_8a_expected], [[na_8a_action1,[na_8a_g1, na_8a_g2]], [na_8a_action2, [na_8a_g1, na_8a_g2]]])), passed; failed), nl, - -write('Test case 9 a. - should be true because expected term is always true\n'), -(write('necessary_after_from([na_9a_expected], [[na_9a_action1,[na_9a_g1, na_9a_g2]], [na_9a_action2, [na_9a_g1, na_9a_g2]]], [na_9a_pi]).'), -necessary_after_from([na_9a_expected], [[na_9a_action1,[na_9a_g1, na_9a_g2]], [na_9a_action2, [na_9a_g1, na_9a_g2]]], [na_9a_pi]), passed; failed), nl, - -write('Test case 10 a. - should be false because expected term is never true\n'), -(write('not(necessary_after_from([na_10a_expected], [[na_10a_action1,[na_10a_g1, na_10a_g2]], [na_10a_action2, [na_10a_g1, na_10a_g2]]], [na_10a_pi])).'), -not(necessary_after_from([na_10a_expected], [[na_10a_action1,[na_10a_g1, na_10a_g2]], [na_10a_action2, [na_10a_g1, na_10a_g2]]], [na_10a_pi])), passed; failed), nl, - -write('Test case 11 a. - should be false because expected term is never true\n'), -(write('not(necessary_after_from([na_10a_expected], [[na_10a_action1,[na_10a_g1, na_10a_g2]], [na_10a_action2, [na_10a_g1, na_10a_g2]]], [na_10a_pi])).'), -necessary_after_from([clean], [[washing,[]],[cooking,[]],[tyding,[]]], []), passed; failed), nl, - - -write('Necessary After From - TESTS FINISHED'),nl. diff --git a/tests/necessary_engaged/model.pl b/tests/necessary_engaged/model.pl deleted file mode 100644 index be1dee3..0000000 --- a/tests/necessary_engaged/model.pl +++ /dev/null @@ -1,26 +0,0 @@ -% Test case 1 -by_causes(push, [a], []). -by_causes(push, [b], []). - -by_causes(run, [a], []). -by_causes(run, [b], []). - -% Test case 2 -by_causes(sing, [c], []). -by_causes(sing, [d], []). -by_causes(fly, [c], []). - -% Test case 3 -by_causes(swim, [x, y], []). - -% Test case 4 -by_causes_if(eat, [john],[], [is_hungry]). - -% Test case 5 -by_causes_if(talks, [anna], [],[is_ready]). - -% Test case 6 -by_causes_if(new_6_goes_to_sleep, [nex_6_george], [], [nex_6_is_tired]). -always([nex_6_some_noise1, nex_6_some_noise2]). -always([nex_6_is_tired, nex_6_some_noise]). -always([nex_6_some_noise3]). diff --git a/tests/necessary_engaged/test.pl b/tests/necessary_engaged/test.pl deleted file mode 100644 index 164e887..0000000 --- a/tests/necessary_engaged/test.pl +++ /dev/null @@ -1,60 +0,0 @@ -:- consult('../../logic.pl'), consult('model.pl'), - -write('Necessary Engaged - TESTS STARTED'),nl, - -write('Test case 1\n'), -(write('not(necessary_engaged([a], [push])) => '), -not(necessary_engaged([a], [push])), passed; failed), nl, - -(write('not(necessary_engaged([b], [push])) => '), -not(necessary_engaged([b], [push])), passed; failed), nl, - -(write('not(necessary_engaged([a], [run, push])) => '), -not(necessary_engaged([a], [run, push])), passed; failed), nl, - -(write('not(necessary_engaged([a], [push, run])) => '), -not(necessary_engaged([b], [push, run])), passed; failed), nl, - - -write('Test case 2\n'), -(write('necessary_engaged([c], [fly, sing]) => '), -necessary_engaged([c], [fly, sing]), passed; failed), nl, - -(write('necessary_engaged([c], [sing, fly]) => '), -necessary_engaged([c], [sing, fly]), passed; failed), nl, - -(write('not(necessary_engaged([d], [sing])) => '), -not(necessary_engaged([d], [sing])), passed; failed), nl, - -(write('not(necessary_engaged([d], [sing, fly])) => '), -not(necessary_engaged([d], [sing, fly])), passed; failed), nl, - - - -write('Test case 3\n'), -(write('not(necessary_engaged([x], [swim])) => '), -not(necessary_engaged([x], [swim])), passed; failed), nl, - -(write('necessary_engaged([x, y], [swim]) => '), -necessary_engaged([x, y], [swim]), passed; failed), nl, - -(write('necessary_engaged([x, y, z], [swim]) => '), -necessary_engaged([x, y, z], [swim]), passed; failed), nl, - -write('Test case 4a - should fail, wrong state\n'), -(write('not(necessary_engaged([john], [eat], [is_eating])) => '), -not(necessary_engaged_from([john], [eat], [is_eating])), passed; failed), nl, - -write('Test case 4b - should accept, good state\n'), -(write('necessary_engaged([john], [eat], [is_hungry]) => '), -necessary_engaged_from([john], [eat], [is_hungry]), passed; failed), nl, - -write('Test case 5 - should fail, needs always statement\n'), -(write('not(necessary_engaged_from([anna],[talks],[is_bored])) => '), -not(necessary_engaged_from([anna],[talks],[is_bored])), passed; failed), nl, - -write('Test case 6 - should be fine, there is always statement \n'), -(write('necessary_engaged_from([nex_6_george],[new_6_goes_to_sleep],[nex_6_on_monday]) => '), -necessary_engaged_from([nex_6_george],[new_6_goes_to_sleep],[nex_6_on_monday]), passed; failed), nl, - -write('Necessary Engaged - TESTS FINISHED'),nl. diff --git a/tests/necessary_executable/model.pl b/tests/necessary_executable/model.pl deleted file mode 100644 index 81af985..0000000 --- a/tests/necessary_executable/model.pl +++ /dev/null @@ -1,58 +0,0 @@ -% Test case 1 a. - action2 is possible because after action1, result is true -% Test case 1 b. - action2 is not possible because those agents cannot perform given action -by_causes_if(action1, [g1, g2], [result], [pi]). -by_causes_if(action2, [g1, g2], [another], [result]). - - -% Test case 2 a. - action8 is possible because after action7, not(sigma) is true -% Test case 2 b. - action9 is not possible because after action7, not(sigma) is true and then after action8, sigma is true -% Test case 2 c. - action10 is not possible because after action8, sigma is true -% Test case 2 d. - action8 is not possible because after action9, sigma is true -by_causes_if(action7, [g7, g8], [\sigma], [sigma]). -by_causes_if(action8, [g7, g8], [sigma], [\sigma]). -by_causes_if(action9, [g7, g8], [sigma], [sigma]). -by_causes_if(action10, [g7, g8], [sigma], [\sigma]). - - -% Test case 3 - action4 is possible because after action3 the following is true: [alpha, beta] -by_causes_if(action3, [g3, g4], [beta], [alpha]). -by_causes_if(action4, [g3, g4], [other], [alpha, beta]). - - -% Test case 4 - action6 impossible, because we never achieve delta -by_causes_if(action5, [g5, g6], [delta], [psi]). -by_causes_if(action6, [g5, g6], [result3], [delta, gamma]). - - -% Test case 5 a. - action_5_1 impossible by g_5_1 -% Test case 5 b. - action_5_1 possible by g_5_2 -impossible_by(action_5_1, [g_5_1]). -by_causes_if(action_5_1, [g_5_1], [delta_5], [psi_5]). -by_causes_if(action_5_1, [g_5_2], [delta_5], [psi_5]). - - -% Test case 6. - action_6_1 not necessary_executable by g_6_1 -by_releases_if(action_6_1, [g_6_1], [delta_6], [psi_6]). - -% Test case 7 a. - should be false because 2nd action is not executable after 1st one (becuase it requires initial state) -by_causes_if(nex_7a_action1, [nex_7a_g1, nex_7a_g2], [nex_7a_result], [nex_7a_pi]). -by_causes(nex_7a_action2, [nex_7a_g1, nex_7a_g2], [nex_7a_another]). - -% Test case 8 - action_8_2 is possible because of always statement -by_causes_if(nex_8_a1, [nex_8_g1], [nex_8_beta], [nex_8_alpha]). -by_causes_if(nex_8_a2, [nex_8_g1], [nex_8_other], [nex_8_beta]). -always([nex_8_alpha]). - - -% Test case 9 - nex_9_a1 is not possible, always statement only for gamma_9 -by_causes_if(nex_9_a1, [nex_9_g1], [nex_9_beta], [nex_9_alpha]). -by_causes_if(nex_9_a2, [nex_9_g1], [nex_9_other], [nex_9_beta]). -always([nex_9_gamma]). - -% Test case 10 - - -by_causes(washing,[], [washed]). -by_causes(cooking, [], [cooked]). -by_causes(tyding, [], [tied]). -after([clean],[[cooking,[]],[tyding,[]]]). - diff --git a/tests/necessary_executable/test.pl b/tests/necessary_executable/test.pl deleted file mode 100644 index de0f930..0000000 --- a/tests/necessary_executable/test.pl +++ /dev/null @@ -1,66 +0,0 @@ -:- consult('../../logic.pl'), consult('model.pl'), - -write('Necessary Executable - TESTS STARTED'),nl, - -write('Test case 1 a. - action2 is possible because after action1, result is true\n'), -(write('necessary_executable_from([[action1,[g1, g2]],[action2,[g1, g2]]], [pi]). => '), -necessary_executable_from([[action1,[g1, g2]],[action2,[g1, g2]]], [pi]), passed; failed), nl, - -write('Test case 1 b. - action2 is not possible because those agents cannot perform given action\n'), -(write('not(necessary_executable_from([[action1,[gX, gY]],[action2,[gX, gY]]], [pi])). => '), -not(necessary_executable_from([[action1,[gX, gY]],[action2,[gX, gY]]], [pi])), passed; failed), nl, - -write('Test case 2 a. - action8 is possible because after action7, not(sigma) is true\n'), -(write('necessary_executable_from([[action7, [g7, g8]],[action8, [g7, g8]]], [sigma]). => '), -necessary_executable_from([[action7, [g7, g8]],[action8, [g7, g8]]], [sigma]), passed; failed), nl, - -write('Test case 2 b. - action9 is not possible because after action7, not(sigma) is true and then after action8, sigma is true\n'), -(write('necessary_executable_from([[action7, [g7, g8]],[action8, [g7, g8]],[action9, [g7, g8]]], [sigma]). => '), -necessary_executable_from([[action7, [g7, g8]],[action8, [g7, g8]],[action9, [g7, g8]]], [sigma]), passed; failed), nl, - -write('Test case 2 c. - action10 is not possible because after action8, sigma is true\n'), -(write('not(necessary_executable_from([[action7, [g7, g8]],[action8, [g7, g8]],[action10, [g7, g8]]], [sigma])). => '), -not(necessary_executable_from([[action7, [g7, g8]],[action8, [g7, g8]],[action10, [g7, g8]]], [sigma])), passed; failed), nl, - -write('Test case 2 d. - action8 is not possible because after action9, sigma is true\n'), -(write('not(necessary_executable_from([[action10, [g7, g8]],[action9, [g7, g8]],[action8, [g7, g8]]], [\sigma])). => '), -not(necessary_executable_from([[action10, [g7, g8]],[action9, [g7, g8]],[action8, [g7, g8]]], [\sigma])), passed; failed), nl, - -write('Test case 3 - action4 is possible because after action3 the following is true: [alpha, beta]\n'), -(write('necessary_executable_from([[action3,[g3, g4]],[action4,[g3, g4]]], [alpha]). => '), -necessary_executable_from([[action3,[g3, g4]],[action4,[g3, g4]]], [alpha]), passed; failed), nl, - -write('Test case 4 - action6 impossible, because we never achieve delta\n'), -(write('not(necessary_executable_from([[action5,[g5, g6]],[action6,[g5, g6]]], [psi])). => '), -not(necessary_executable_from([[action5,[g5, g6]],[action6,[g5, g6]]], [psi])), passed; failed), nl, - -write('Test case 5 a. - action_5_1 impossible by g_5_1\n'), -(write('not(necessary_executable_from([[action_5_1,[g_5_1]]],[psi_5])). => '), -not(necessary_executable_from([[action_5_1,[g_5_1]]],[psi_5])), passed; failed), nl, - -write('Test case 5 b. - action_5_1 possible by g_5_2\n'), -(write('necessary_executable_from([[action_5_1,[g_5_2]]],[psi_5]). => '), -necessary_executable_from([[action_5_1,[g_5_2]]],[psi_5]), passed; failed), nl, - -write('Test case 6. - action_6_1 is executable by g_6_1\n'), -(write('necessary_executable_from([[action_6_1,[g_6_1]]],[psi_6]). => '), -necessary_executable_from([[action_6_1,[g_6_1]]],[psi_6]), passed; failed), nl, - -write('Test case 7 a. - should be false because 2nd action is not executable after 1st one (becuase it requires initial state)\n'), -(write('not(necessary_executable_from([[nex_7a_action1, [nex_7a_g1, nex_7a_g2]],[nex_7a_action2, [nex_7a_g1, nex_7a_g2]]],[nex_7a_pi])). => '), -not(necessary_executable_from([[nex_7a_action1, [nex_7a_g1, nex_7a_g2]],[nex_7a_action2, [nex_7a_g1, nex_7a_g2]]],[nex_7a_pi])), passed; failed), nl, - - -write('Test case 8 - nex_8_a2 is possible because of always statement\n'), -(write('necessary_executable_from([[nex_8_a1,[nex_8_g1]],[nex_8_a2,[nex_8_g1]]], [nex_8_gamma_8]). => '), -necessary_executable_from([[nex_8_a1,[nex_8_g1]],[nex_8_a2,[nex_8_g1]]], [nex_8_gamma_8]), passed; failed), nl, - -write('Test case 9 - action_9_2 is not possible, always statement only for gamma_8\n'), -(write('not(necessary_executable_from([[nex_9_a1,[nex_9_g1]],[nex_9_a2,[nex_9_g1]]], [nex_9_gamma])). => '), -not(necessary_executable_from([[nex_9_a1,[nex_9_g1]],[nex_9_a2,[nex_9_g1]]], [nex_9_gamma])), passed; failed), nl, - -write('Test case 10 - action_9_2 is not possible, always statement only for gamma_8\n'), -(write('not(necessary_executable_from([[nex_9_a1,[nex_9_g1]],[nex_9_a2,[nex_9_g1]]], [nex_9_gamma])). => '), -necessary_executable_from([[washing,[]],[cooking,[]],[tyding,[]]], []), passed; failed), nl, - -write('Necessary Executable - TESTS FINISHED'),nl. diff --git a/tests/possibly_after_from/model.pl b/tests/possibly_after_from/model.pl deleted file mode 100644 index f16b26e..0000000 --- a/tests/possibly_after_from/model.pl +++ /dev/null @@ -1,30 +0,0 @@ -% Test case 0 - Should be true - just causes -by_causes_if(pa_0_action, [pa_0_g1, pa_0_g2], [pa_0_result], [pa_0_cond]). - -% Test case 1 - Should be true - just releases -by_releases_if(pa_1_action1, [pa_1_g1, pa_1_g2], [pa_1_fluent], [pa_1_cond]). - -% Test case 2 - should be true, action from "causes" cause "pa_2_result" which is required by releases -by_releases_if(pa_2_action2, [pa_2_g1, pa_2_g2], [pa_2_fluent], [pa_2_result]). -by_causes_if(pa_2_action1, [pa_2_g1, pa_2_g2], [pa_2_result], [pa_2_cond]). - -% Test case 3 - should be false, actions defined BUT 2nd is NOT achieved from 1st -by_releases_if(pa_3_action2, [pa_3_g1, pa_3_g2], [pa_3_fluent], [pa_3_another_result]). -by_causes_if(pa_3_action1, [pa_3_g1, pa_3_g2], [pa_3_something], [pa_3_cond1]). -by_causes_if(pa_3_action2, [pa_3_g1, pa_3_g2], [pa_3_another_result], [pa_3_something_else]). - -% Test case 4 - Should be true - conditions fulfilled when considering query input + always statement -by_causes_if(pa_4_action, [pa_4_g1, pa_4_g2], [pa_4_fluent], [pa_4_cond1, pa_4_cond2, pa_4_cond3]). -always([pa_4_cond2, pa_4_cond3]). - -% Test case 5 - Should be true - "pa_5_fluentX" is always true so it is possible -by_causes_if(pa_5_action, [pa_5_g1, pa_5_g2], [pa_5_fluent], [pa_5_cond1]). -always([pa_5_fluent1, pa_5_fluent2]). -always([pa_5_fluent3, pa_5_fluentX]). -always([pa_5_fluent4, pa_5_fluent5]). - -% Test case 6 - Should be true - "pa_6_fluentX" is always true so it is possible -by_releases_if(pa_6_action, [pa_6_g1, pa_6_g2], [pa_6_fluent], [pa_6_cond1]). -always([pa_6_fluent1, pa_6_fluent2]). -always([pa_6_fluent3, pa_6_fluentX]). -always([pa_6_fluent4, pa_6_fluent5]). diff --git a/tests/possibly_after_from/test.pl b/tests/possibly_after_from/test.pl deleted file mode 100644 index f248c06..0000000 --- a/tests/possibly_after_from/test.pl +++ /dev/null @@ -1,34 +0,0 @@ -:- consult('../../logic.pl'), consult('model.pl'), - -write('Possibly After From - TESTS STARTED'),nl, - - -write('Test case 0 - Should be true - just causes\n'), -(write('possibly_after_from([pa_0_result], [[pa_0_action,[pa_0_g1, pa_0_g2]]], [pa_0_cond]).'), -possibly_after_from([pa_0_result], [[pa_0_action,[pa_0_g1, pa_0_g2]]], [pa_0_cond]), passed; failed), nl, - -write('Test case 1 - Should be true - just releases\n'), -(write('possibly_after_from([pa_1_fluent], [[pa_1_action1,[pa_1_g1, pa_1_g2]]], [pa_1_cond]).'), -possibly_after_from([pa_1_fluent], [[pa_1_action1,[pa_1_g1, pa_1_g2]]], [pa_1_cond]), passed; failed), nl, - -write('Test case 2 - should be true, action from "causes" cause "pa_2_result" which is required by releases\n'), -(write('possibly_after_from([pa_2_fluent], [[pa_2_action1,[pa_2_g1, pa_2_g2]], [pa_2_action2,[pa_2_g1, pa_2_g2]]], [pa_2_cond]).'), -possibly_after_from([pa_2_fluent], [[pa_2_action1,[pa_2_g1, pa_2_g2]], [pa_2_action2,[pa_2_g1, pa_2_g2]]], [pa_2_cond]), passed; failed), nl, - -write('Test case 3 - should be false, actions defined BUT 2nd is NOT achieved from 1st\n'), -(write('not(possibly_after_from([pa_3_fluent], [[pa_3_action1,[pa_3_g1, pa_3_g2]], [pa_3_action2,[pa_3_g1, pa_3_g2]]], [pa_3_cond1])).'), -not(possibly_after_from([pa_3_fluent], [[pa_3_action1,[pa_3_g1, pa_3_g2]], [pa_3_action2,[pa_3_g1, pa_3_g2]]], [pa_3_cond1])), passed; failed), nl, - -write('Test case 4 - should be false, actions defined BUT 2nd is NOT achieved from 1st\n'), -(write('possibly_after_from([pa_4_fluent], [[pa_4_action,[pa_4_g1, pa_4_g2]]], [pa_4_cond1]).'), -possibly_after_from([pa_4_fluent], [[pa_4_action,[pa_4_g1, pa_4_g2]]], [pa_4_cond1]), passed; failed), nl, - -write('Test case 5 - Should be true - "pa_5_fluentX" is always true so it is possible\n'), -(write('possibly_after_from([pa_5_fluentX], [[pa_5_action,[pa_5_g1, pa_5_g2]]], [pa_5_cond1]).'), -possibly_after_from([pa_5_fluentX], [[pa_5_action,[pa_5_g1, pa_5_g2]]], [pa_5_cond1]), passed; failed), nl, - -write('Test case 6 - Should be true - "pa_6_fluentX" is always true so it is possible\n'), -(write('possibly_after_from([pa_6_fluentX], [[pa_6_action,[pa_6_g1, pa_6_g2]]], [pa_6_cond1]).'), -possibly_after_from([pa_6_fluentX], [[pa_6_action,[pa_6_g1, pa_6_g2]]], [pa_6_cond1]), passed; failed), nl, - -write('Possibly After From - TESTS FINISHED'),nl. diff --git a/tests/possibly_engaged/model.pl b/tests/possibly_engaged/model.pl deleted file mode 100644 index c6d2500..0000000 --- a/tests/possibly_engaged/model.pl +++ /dev/null @@ -1,24 +0,0 @@ -% Test case 1 -by_causes(push, [a], []). -by_causes(push, [b], []). - -by_causes(run, [a], []). -by_causes(run, [b], []). - -% Test case 2 -by_causes(sing, [c], []). -by_causes(sing, [d], []). -by_causes(fly, [c], []). - -% Test case 3 -by_causes(swim, [x, y], []). - -% Test case 4 -by_causes_if(eat, [john], [],[is_hungry]). - -% Test case 5 -by_causes_if(talks, [anna], [],[is_ready]). - -% Test case 6 -by_causes_if(goes_to_sleep, [george], [],[is_tired]). -always([is_tired]). \ No newline at end of file diff --git a/tests/possibly_engaged/test.pl b/tests/possibly_engaged/test.pl deleted file mode 100644 index 670727b..0000000 --- a/tests/possibly_engaged/test.pl +++ /dev/null @@ -1,63 +0,0 @@ -:- consult('../../logic.pl'), consult('model.pl'), - -write('Possibly Engaged - TESTS STARTED'),nl, - - - -write('Test case 1\n'), -(write('possibly_engaged([a], [push]) => '), -possibly_engaged([a], [push]), passed; failed), nl, - -(write('possibly_engaged([b], [push]) => '), -possibly_engaged([b], [push]), passed; failed), nl, - -(write('possibly_engaged([a], [run, push]) => '), -possibly_engaged([a], [run, push]), passed; failed), nl, - -(write('possibly_engaged([a], [push, run]) => '), -possibly_engaged([b], [push, run]), passed; failed), nl, - - - -write('Test case 2\n'), -(write('possibly_engaged([c], [fly, sing]) => '), -possibly_engaged([c], [fly, sing]), passed; failed), nl, - -(write('possibly_engaged([c], [sing, fly]) => '), -possibly_engaged([c], [sing, fly]), passed; failed), nl, - -(write('not(possibly_engaged([d], [fly, sing])) => '), -not(possibly_engaged([d], [fly, sing])), passed; failed), nl, - -(write('not(possibly_engaged([d], [sing, fly])) => '), -not(possibly_engaged([d], [sing, fly])), passed; failed), nl, - - - -write('Test case 3\n'), -(write('not(possibly_engaged([x], [swim])) => '), -not(possibly_engaged([x], [swim])), passed; failed), nl, - -(write('possibly_engaged([x, y], [swim]) => '), -possibly_engaged([x, y], [swim]), passed; failed), nl, - -(write('possibly_engaged([x, y, z], [swim]) => '), -possibly_engaged([x, y, z], [swim]), passed; failed), nl, - -write('Test case 4a - should fail, wrong state\n'), -(write('not(possibly_engaged_from([john], [eat],[is_tired])) => '), -not(possibly_engaged_from([john], [eat],[is_tired])), passed; failed), nl, -write('Test case 4b - should be good, from state is correct\n'), -(write('possibly_engaged_from([john], [eat],[is_hungry]) => '), -possibly_engaged_from([john], [eat],[is_hungry]), passed; failed), nl, - -write('Test case 5 - should fail, needs always statement\n'), -(write('not(possibly_engaged_from([anna],[talks],[is_bored])) => '), -not(possibly_engaged_from([anna],[talks],[is_bored])), passed; failed), nl, - -write('Test case 6 - should be fine, there is always statement \n'), -(write('possibly_engaged_from([george],[goes_to_sleep],[on_monday]) => '), -possibly_engaged_from([george],[goes_to_sleep],[on_monday]), passed; failed), nl, - - -write('Possibly Engaged - TESTS FINISHED'),nl. diff --git a/tests/possibly_executable/model.pl b/tests/possibly_executable/model.pl deleted file mode 100644 index 27464c2..0000000 --- a/tests/possibly_executable/model.pl +++ /dev/null @@ -1,9 +0,0 @@ -% Test case 1 a. - action_1_1 possibly executable by g_1_1 because of release -by_releases_if(action_1_1, [g_1_1], [delta_1], [psi_1]). - -% Test case 1 b. - action_1_2 possibly executable by g_1_2 because of causes -by_causes_if(action_1_2, [g_1_2], [delta_1], [psi_1]). - -% Test case 2. - action_2_1 possibly executable by g_2_1 because of impossible -impossible_by(action_2_1, [g_2_1]). -by_releases_if(action_2_1, [g_2_1], [delta_2], [psi_2]). \ No newline at end of file diff --git a/tests/possibly_executable/test.pl b/tests/possibly_executable/test.pl deleted file mode 100644 index bd38503..0000000 --- a/tests/possibly_executable/test.pl +++ /dev/null @@ -1,17 +0,0 @@ -:- consult('../../logic.pl'), consult('model.pl'), - -write('Possibly Executable - TESTS STARTED'),nl, - -write('Test case 1 a. - action_1_1 possibly executable by g_1_1 because of release\n'), -(write('possibly_executable_from([[action_1_1,[g_1_1]]],[psi_1]). => '), -possibly_executable_from([[action_1_1,[g_1_1]]],[psi_1]), passed; failed), nl, - -write('Test case 1 b. - action_1_2 possibly executable by g_1_2 because of causes\n'), -(write('possibly_executable_from([[action_1_2,[g_1_2]]],[psi_1]). => '), -possibly_executable_from([[action_1_2,[g_1_2]]],[psi_1]), passed; failed), nl, - -write('Test case 2. - action_2_1 possibly executable by g_2_1 because of impossible\n'), -(write('not(possibly_executable_from([[action_2_1,[g_2_1]]],[psi_2])). => '), -not(possibly_executable_from([[action_2_1,[g_2_1]]],[psi_2])), passed; failed), nl, - -write('Possibly Executable - TESTS FINISHED'),nl. \ No newline at end of file diff --git a/tests/story1/story.pl b/tests/story1/story.pl deleted file mode 100644 index c0f1911..0000000 --- a/tests/story1/story.pl +++ /dev/null @@ -1,10 +0,0 @@ -initially([\isRunning]). -impossible_if(push, [isRunning]). -impossible_by(push, [d]). -by_causes(push, [a], [\isRunning]). -by_causes(push, [b], [\isRunning]). -by_causes(push, [c], [\isRunning]). -by_causes(push, [b, c], [\isRunning]). -by_causes(push, [a, b], [isRunning]). -by_causes(push, [a, c], [isRunning]). -by_causes(push, [a, b, c], [\isRunning]). \ No newline at end of file diff --git a/tests/story1/test.pl b/tests/story1/test.pl deleted file mode 100644 index 8b7af06..0000000 --- a/tests/story1/test.pl +++ /dev/null @@ -1,34 +0,0 @@ -:- consult('../../logic.pl'), consult('story.pl'), -write('---------------------------------------------------------------------------------'),nl, -write('Story 1 - TESTS STARTED'),nl, - -write('Test case 1 - should be true, initial condition ok, agent group ok \n'), -(write('necessary_executable_from([[push,[a,b]]],[\\isRunning]). => '), -necessary_executable_from([[push,[a,b]]],[\isRunning]), passed; failed), nl, - -write('Test case 2 - should be true, initial condition ok, agent group ok \n'), -(write('necessary_executable_from([[push,[a,c]]],[\\isRunning]). => '), -necessary_executable_from([[push,[a,c]]],[\isRunning]), passed; failed), nl, - -write('Test case 3 - should be true, initial condition ok, action expression exists\n'), -(write('necessary_after_from([isRunning], [[push,[A,B]]], [\\isRunning]). => '), -necessary_after_from([isRunning], [[push,[a,b]]], [\isRunning]), passed; failed), nl, - -write('Test case 4 - should be true, initial condition ok, action expression exists\n'), -(write('necessary_after_from([isRunning], [[push,[A,C]]], [\\isRunning]). => '), -necessary_after_from([isRunning], [[push,[a,c]]], [\isRunning]), passed; failed), nl, - -write('Test case 5 - should be true, "a" is necessary because in [a, b] and [a, c] \n'), -(write('necessary_engaged([a], [push]). => '), -possibly_engaged([a], [push]), passed; failed), nl, - -write('Test case 6 - should be true, "b" is possibly because in [a, b] and [a, c] \n'), -(write('necessary_engaged([b], [push]). => '), -possibly_engaged([b], [push]), passed; failed), nl, - -write('Test case 7 - should be true, "c" is possibly because in [a, b] and [a, c] \n'), -(write('necessary_engaged([c], [push]). => '), -possibly_engaged([c], [push]), passed; failed), nl, - -write('Story 1 - TESTS FINISHED'),nl, -write('---------------------------------------------------------------------------------'),nl. diff --git a/tests/story2/story.pl b/tests/story2/story.pl deleted file mode 100644 index 123d030..0000000 --- a/tests/story2/story.pl +++ /dev/null @@ -1,15 +0,0 @@ -initially([alive, \protected, \up]). -by_causes(lift, [a, b], [up]). -by_causes_if(lift, [a], [\alive], [\protected, up]). -by_causes_if(lift, [b], [\alive], [\protected, up]). -causes_if(protect, [protected], [up]). -impossible_if(lift, [protected, \alive]). -impossible_if(lift, [protected, alive]). -impossible_if(lift, [\protected, \alive]). -impossible_if(protect, [protected, \alive, up]). -impossible_if(protect, [\protected, alive, up]). -impossible_if(protect, [protected, alive, up]). -impossible_if(protect, [protected, \alive, \up]). -impossible_if(protect, [\protected, alive, \up]). -impossible_if(protect, [protected, alive, \up]). -impossible_if(protect, [\protected, \alive, \up]). diff --git a/tests/story2/test.pl b/tests/story2/test.pl deleted file mode 100644 index 6e24096..0000000 --- a/tests/story2/test.pl +++ /dev/null @@ -1,38 +0,0 @@ -:- consult('../../logic.pl'), consult('story.pl'), -write('---------------------------------------------------------------------------------'),nl, -write('Story 2 - TESTS STARTED'),nl, - -write('Test case 1 - should be true \n'), -(write('necessary_executable_from([[lift,[a,b]]],[alive]). => '), -necessary_executable_from([[lift,[a,b]]],[alive]), passed; failed), nl, - -write('Test case 2 - should be true \n'), -(write('necessary_executable_from([[protect,[a]]],[up, alive]). => '), -necessary_executable_from([[protect,[a]]],[up, alive]), passed; failed), nl, - -write('Test case 3 - should be true \n'), -(write('necessary_executable_from([[protect,[b]]],[up, alive]). => '), -necessary_executable_from([[protect,[b]]],[up, alive]), passed; failed), nl, - -write('Test case 4 - should be true \n'), -(write('necessary_after_from([up], [[lift,[a,b]]], [alive]). => '), -necessary_after_from([up], [[lift,[a,b]]], [alive]), passed; failed), nl, - -write('Test case 5 - should be true \n'), -(write('necessary_after_from([protected], [[protect,[a]]], [up]). => '), -necessary_after_from([protected], [[protect,[a]]], [up]), passed; failed), nl, - -write('Test case 6 - should be true \n'), -(write('necessary_after_from([protected], [[protect,[b]]], [up]). => '), -necessary_after_from([protected], [[protect,[b]]], [up]), passed; failed), nl, - -write('Test case 7 - should be true \n'), -(write('possibly_engaged([a], [protect]). => '), -possibly_engaged([a], [protect]), passed; failed), nl, - -write('Test case 8 - should be true \n'), -(write('possibly_engaged([b], [protect]). => '), -possibly_engaged([b], [protect]), passed; failed), nl, - -write('Story 2 - TESTS FINISHED'),nl, -write('---------------------------------------------------------------------------------'),nl. diff --git a/tests/story3/story.pl b/tests/story3/story.pl deleted file mode 100644 index dc5f917..0000000 --- a/tests/story3/story.pl +++ /dev/null @@ -1,8 +0,0 @@ -initially([\brewed]). -initially([\destroyed]). -impossible_if(brew,[brewed_destroyed]). -by_causes(brew, [Bercik, Filemon], [brewed]). -by_releases(brew, [Bercik], [brewed]). -by_releases(brew, [Bercik], [destroyed]). -by_releases(brew, [Filemon], [brewed]). - diff --git a/tests/story3/test.pl b/tests/story3/test.pl deleted file mode 100644 index ac1cc6c..0000000 --- a/tests/story3/test.pl +++ /dev/null @@ -1,29 +0,0 @@ -:- consult('../../logic.pl'), consult('story.pl'), -write('---------------------------------------------------------------------------------'),nl, -write('Story 3 - TESTS STARTED'),nl, - - -(write('necessary_executable_from([[brew,[]]],[\brewed]). => '), -necessary_executable_from([[brew,[]]],[\brewed]), passed; failed), nl, - -(write('possibly_engaged([Filemon], [brew]), passed; failed). => '), -possibly_engaged([Filemon], [brew]), passed; failed), nl, - -(write('possibly_engaged([Bercik], [brew]), passed; failed). => '), -possibly_engaged([Bercik], [brew]), passed; failed), nl, - -(write('possibly_after_from([brewed],[[brew,[Bercik, Filemon]]], [\brewed,not destroyed]). => '), -possibly_after_from([brewed],[[brew,[Bercik, Filemon]]], [\brewed,\destroyed]), passed; failed), nl, - -(write('possibly_after_from([brewed],[[brew,[Filemon]]], [\brewed,not destroyed]). => '), -possibly_after_from([brewed],[[brew,[Filemon]]], [\brewed,\destroyed]), passed; failed), nl, - -(write('possibly_after_from([brewed],[[brew,[Bercik]]], [\brewed,not destroyed]). => '), -possibly_after_from([brewed],[[brew,[Bercik]]], [\brewed,\destroyed]), passed; failed), nl, - -(write('possibly_after_from([destroyed],[[brew,[Bercik]]], [\brewed,not destroyed]). => '), -possibly_after_from([destroyed],[[brew,[Bercik]]], [\brewed,\destroyed]), passed; failed), nl, - - -write('Story 2 - TESTS FINISHED'),nl, -write('---------------------------------------------------------------------------------'),nl.