\subsection{Implementation of the hitting-set algorithm}
\subsubsection{Task 12: Generate conflict}
+\begin{listing}[H]
+ \caption{Generating conflict sets}
+ \prologcode{./src/task12.pl}
+\end{listing}
+
\subsubsection{Task 13: Define your data structure}
-Our datastructure uses the predicate node to signify nodes and leaf for leaves. A node contains a list of edge labels and another list (with the same length as the amound of edge labels) that contains nodes or leaves. The edge label corresponds with its order in the list it is in.
-Good examples:
-isHittingSetTree(node([a,b],[leaf,leaf])).
-isHittingSetTree(node([a,b], [node([c,d], [leaf,leaf]), node([e,f], [leaf,leaf])])).
-isHittingSetTree(node([a,b], [node([c,d], [node([g,h,i], [leaf,leaf,leaf]),leaf]), node([a,f], [leaf,leaf])])).
+\begin{listing}[H]
+ \caption{Hitting set datastructure}
+ \prologcode{./src/hs.pl}
+\end{listing}
+% Het doel van deze opdracht was om je datastructure te laten zien, je hebt
+% alleen gezegd wat voor bomen geen hitting set kunnen zijn...
-Wrong examples:
+%Our datastructure uses the predicate node to signify nodes and leaf for leaves. A node contains a list of edge labels and another list (with the same length as the amound of edge labels) that contains nodes or leaves. The edge label corresponds with its order in the list it is in.
+%Good examples:
+%isHittingSetTree(node([a,b],[leaf,leaf])).
+%isHittingSetTree(node([a,b], [node([c,d], [leaf,leaf]), node([e,f], [leaf,leaf])])).
+%isHittingSetTree(node([a,b], [node([c,d], [node([g,h,i], [leaf,leaf,leaf]),leaf]), node([a,f], [leaf,leaf])])).
+%
+%Wrong examples:
+%
+%isHittingSetTree(node([a,b], [node([c,d], [node([g,h], [leaf,leaf,leaf]),leaf]), node([a,f], [leaf,leaf])])).
-isHittingSetTree(node([a,b], [node([c,d], [node([g,h], [leaf,leaf,leaf]),leaf]), node([a,f], [leaf,leaf])])).
\subsubsection{Task 14: Implementation}
-\BOOKMARK [1][-]{section.1}{Assignment 1-1}{}
-\BOOKMARK [2][-]{subsection.1.1}{Part 1: Modelling Sokoban}{section.1}
-\BOOKMARK [3][-]{subsubsection.1.1.1}{Task 1: Knowledge base}{subsection.1.1}
-\BOOKMARK [3][-]{subsubsection.1.1.2}{Task 2: Actions}{subsection.1.1}
-\BOOKMARK [2][-]{subsection.1.2}{Part 2: Implementation}{section.1}
-\BOOKMARK [3][-]{subsubsection.1.2.1}{Task 3: Translate Axioms}{subsection.1.2}
-\BOOKMARK [3][-]{subsubsection.1.2.2}{Task 4: The Planning Problem in Figure 1}{subsection.1.2}
-\BOOKMARK [3][-]{subsubsection.1.2.3}{Task 5: Crates go to Any Goal Location}{subsection.1.2}
-\BOOKMARK [3][-]{subsubsection.1.2.4}{Task 6: Inverse Problem}{subsection.1.2}
-\BOOKMARK [2][-]{subsection.1.3}{Part 3: Extending the domain}{section.1}
-\BOOKMARK [3][-]{subsubsection.1.3.1}{Task 7: Unlocking the Crates}{subsection.1.3}
-\BOOKMARK [2][-]{subsection.1.4}{Part 4: General questions}{section.1}
-\BOOKMARK [3][-]{subsubsection.1.4.1}{Task 10: Sitcalc expressivity}{subsection.1.4}
-\BOOKMARK [3][-]{subsubsection.1.4.2}{Task 11: Related work}{subsection.1.4}
-\BOOKMARK [1][-]{section.2}{Assignment 1-2}{}
-\BOOKMARK [2][-]{subsection.2.1}{Implementation of the hitting-set algorithm}{section.2}
-\BOOKMARK [3][-]{subsubsection.2.1.1}{Task 12: Generate conflict}{subsection.2.1}
-\BOOKMARK [3][-]{subsubsection.2.1.2}{Task 13: Define your data structure}{subsection.2.1}
-\BOOKMARK [3][-]{subsubsection.2.1.3}{Task 14: Implementation}{subsection.2.1}
+\BOOKMARK [1][-]{section.1}{Assignment 1-1}{}% 1
+\BOOKMARK [2][-]{subsection.1.1}{Part 1: Modelling Sokoban}{section.1}% 2
+\BOOKMARK [3][-]{subsubsection.1.1.1}{Task 1: Knowledge base}{subsection.1.1}% 3
+\BOOKMARK [3][-]{subsubsection.1.1.2}{Task 2: Actions}{subsection.1.1}% 4
+\BOOKMARK [2][-]{subsection.1.2}{Part 2: Implementation}{section.1}% 5
+\BOOKMARK [3][-]{subsubsection.1.2.1}{Task 3: Translate Axioms}{subsection.1.2}% 6
+\BOOKMARK [3][-]{subsubsection.1.2.2}{Task 4: The Planning Problem in Figure 1}{subsection.1.2}% 7
+\BOOKMARK [3][-]{subsubsection.1.2.3}{Task 5: Crates go to Any Goal Location}{subsection.1.2}% 8
+\BOOKMARK [3][-]{subsubsection.1.2.4}{Task 6: Inverse Problem}{subsection.1.2}% 9
+\BOOKMARK [2][-]{subsection.1.3}{Part 3: Extending the domain}{section.1}% 10
+\BOOKMARK [3][-]{subsubsection.1.3.1}{Task 7: Unlocking the Crates}{subsection.1.3}% 11
+\BOOKMARK [2][-]{subsection.1.4}{Part 4: General questions}{section.1}% 12
+\BOOKMARK [3][-]{subsubsection.1.4.1}{Task 10: Sitcalc expressivity}{subsection.1.4}% 13
+\BOOKMARK [3][-]{subsubsection.1.4.2}{Task 11: Related work}{subsection.1.4}% 14
+\BOOKMARK [1][-]{section.2}{Assignment 1-2}{}% 15
+\BOOKMARK [2][-]{subsection.2.1}{Implementation of the hitting-set algorithm}{section.2}% 16
+\BOOKMARK [3][-]{subsubsection.2.1.1}{Task 12: Generate conflict}{subsection.2.1}% 17
+\BOOKMARK [3][-]{subsubsection.2.1.2}{Task 13: Define your data structure}{subsection.2.1}% 18
+\BOOKMARK [3][-]{subsubsection.2.1.3}{Task 14: Implementation}{subsection.2.1}% 19
\usepackage{minted}
\usepackage{hyperref}
-\author{Caspar Safarlou\and Mart Lubbers}
+\author{Mart Lubbers\and \small Caspar Safarlou}
\title{Knowledge Representation and Reasoning.\\Assignment 1}
\date{\today}
append(Z, [X], Appended), %append label to list of checked labels\r
isHittingSetTree2(Y, Appended), %go into depth\r
isHittingSetTree2(node(Xs, Ys), Z). %go into width\r
-
\ No newline at end of file
+ \r
--- /dev/null
+isHittingSetTree(_, leaf).
+isHittingSetTree(_, node([], [])).
+isHittingSetTree(VisitedLabels, node([CurLabel|Labels], [CurChild|Children])) :-
+ not(member(CurLabel, VisitedLabels)),
+ append(VisitedLabels, [CurChild], UpdatedVisitedLabels),
+ isHSTree(UpdatedVisitedLabels, CurChild),
+ isHSTree(VisitedLabels, node(Labels, Children)).
--- /dev/null
+?- [diagnosis].
+% tp compiled 0.01 sec, 99 clauses
+% diagnosis compiled 0.01 sec, 109 clases
+true.
+
+?- problem1(SD, COMP, OBS), tp(SD, COMP, OBS, [], CS).
+SD = [all _G32: (and(_G32), ~ab(_G32)=> ... ],
+COMP = [a1, a2],
+OBS = [in1(a1), in2(a1), ~out(a1), in1(a2), in2(a2), ~out(a2)],
+CS = [a1].
+
+?- problem2(SD, COMP, OBS), tp(SD, COMP, OBS, [], CS).
+SD = [all _G32: (and(_G32), ~ab(_G32)=> ... ],
+COMP = CS, CS = [a1, a2],
+OBS = [in1(a1), ~in2(a1), out(a2)].
+
+?- problem3(SD, COMP, OBS), tp(SD, COMP, OBS, [], CS).
+SD = [all _G32: (and(_G32), ~ab(_G32)=> ... ],
+COMP = [a1, a2, o1],
+OBS = [in1(a1), in2(a1), in1(a2), in2(a2), ~out(o1)],
+CS = [a1, o1, a2].
+
+?- fulladder(SD, COMP, OBS), tp(SD, COMP, OBS, [], CS).
+SD = [all _G32: (and(_G32), ~ab(_G32)=> .. ],
+COMP = [a1, a2, x1, x2, r1],
+OBS = [in1(fa), ~in2(fa), carryin(fa), out(fa), ~carryout(fa)],
+CS = [a1, x1, a2, r1, x2].