all:
- pdflatex report.tex
- pdflatex report.tex
+ pdflatex -shell-escape report.tex
+ pdflatex -shell-escape report.tex
clean:
- rm -vf *.aux *.log *.pdf *.toc
+ rm -vf *.aux *.log *.pdf *.toc *.pyg
We use the functions $agent(X, S_i), crate(cratename, X, S_i)$ and
$target(cratename, X)$ to easily represent the information.
\item{Q3}\\
- \begin{lstlisting}[language=prolog]
-connected(loc1-1, loc2-1, north),
-connected(loc1-1, loc1-2, east),
-connected(loc1-2, loc2-2, north),
-connected(loc1-2, loc1-3, east),
-connected(loc1-3, loc2-3, north),
-connected(loc1-3, loc1-4, east),
-connected(loc1-4, loc2-4, north),
-
-connected(loc2-1, loc3-1, north),
-connected(loc2-1, loc2-2, east),
-connected(loc2-2, loc3-2, north),
-connected(loc2-2, loc2-3, east),
-connected(loc2-3, loc3-3, north),
-connected(loc2-3, loc2-4, east),
-
-connected(loc3-1, loc3-2, north),
-connected(loc3-2, loc3-3, north),
-
-(connected(X, Y, east); \+connected(Y, X, west)),
-(connected(X, Y, north); \+connected(Y, X, south)),
-
-crate(crate-c, loc2-1, s),
-crate(crate-b, loc2-2, s),
-crate(crate-a, loc2-3, s),
-
-target(crate-a, loc1-1),
-target(crate-b, loc1-3),
-target(crate-c, loc1-2),
-agent(loc3-2, s).$
- \end{lstlisting}
\item{Q4}\\
- \begin{lstlisting}[language=prolog]
-target(X, Y), crate(X, Y, s).
- \end{lstlisting}
+
\end{itemize}
\subsubsection{Task 2: Actions}
\begin{itemize}
\item{Q5}\\
-$Poss(move(x, y), s) \equiv \neg(crate(x, y, s)) \wedge connected(x, y, _)$
+ \begin{equation}
+ \begin{split}
+ Poss(move(x, y), s) \equiv &\\
+ & (\exists z: connected(x, y, z)) \wedge\\
+ & \neg(crate(x, y, s)) \wedge
+ \end{split}
+ \end{equation}
+
\item{Q6}\\
-$Poss(push(x, d), s) \equiv agent(x, s) \wedge (\exists c,z: crate(c, z, s)
-\wedge connected(x, z, d) \wedge (\exists y: connected(z, y, d) \wedge \neg
-(\exists a: crate(a, z, s))))$
+ $Poss(push(x, y), s) \equiv\\
+ agent(x, s) \wedge\\
+ (\exists z:
+ connected(x, z, y) \wedge
+ (\exists \gamma: crate(\gamma, z, s))
+ \wedge\\
+ (\exists \alpha:
+ connected(z, \alpha, y) \wedge
+ \neg (\exists \beta: crate(\beta, \alpha, s))))$
\item{Q7}\\
-$connected(x, y, d) \rightarrow agent(y, do(move(x, y), s))\\
-connected(x, y, d) \rightarrow agent(y, do(push(x, d), s))\\
-connected(x, y, d) \wedge connected(y, z, d) \rightarrow
- crate(c, z, do(push(x, d), s))$
+ $agent(x, result(z, s)) \rightarrow\\
+ (\exists y: z = move(y, x)) \vee\\
+ (\exists \alpha:
+ z = push(\beta, \alpha) \wedge
+ connected(\beta, x, \alpha)) \vee\\
+ (\exists \epsilon, \gamma:
+ not(z = move(x, \epsilon)) \wedge
+ not(z = push(x, \gamma)) \wedge
+ agent(x, s))\\
+ crate(x, y, result(A, s)) \rightarrow\\
+ (\exists z,alpha:
+ A = push(z, \alpha),
+ (\exists \beta:
+ connected(z, \beta, \alpha),
+ connected(\beta, y, \alpha),
+ crate(x, \beta, s)
+ )
+ ) \vee\\
+ (\exists z,\alpha:
+ not(A = push(z, \alpha)),
+ connected(z, y, \alpha),
+ crate(x, y, s)
+ )
+ $
\end{itemize}
\subsection{Part 2: Implementation}
\subsubsection{Task 3: Translate Axioms}
-\lstinputlisting[title={domaintask1.pl},language=prolog]{./src/domaintask1.pl}
+The only optimization added to the file is the reverse move optimization,
+disallowing the agent to reverse a move immediatly.
+\inputminted{prolog}{./src/domaintask1.pl}
\subsubsection{Task 4: The Planning Problem in Figure 1}
-\lstinputlisting[title={instancetask1.pl},language=prolog]{./src/instancetask1.pl}
+\inputminted{prolog}{./src/instancetask4.pl}
\subsubsection{Task 5: Crates go to Any Goal Location}
+\inputminted{prolog}{./src/instancetask5.pl}
+
\subsubsection{Task 6: Inverse Problem}
\subsection{Part 3: Extending the domain}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{listings}
+\usepackage{minted}
-\author{
- Caspar Safarlou (s4205456)\\
- Mart Lubbers (s4109503)
-}
+\author{ Caspar Safarlou\and Mart Lubbers }
\title{Knowledge Representation and Reasoning.\\Assignment 1}
\date{\today}
poss(move(From, To), S) :-
agent(From, S),
connected(From, To, _),
- not(crate(_, To, S)).
+ not(crate(_, To, S)),
+ not(visited(To, S)).
poss(push(From, Direction), S) :-
agent(From, S),
not(crate(_, CrateTarget, S)).
% --- Successor state axioms ------------------------------------------
+visited(Plek, result(A, _)) :-
+ A = move(Plek, _).
+
agent(AgentPlek, result(A, S)) :-
A = move(_, AgentPlek);
A = push(OudeAgentPlek, Richting),
poss(move(From, To), S) :-
agent(From, S),
connected(From, To, _),
- not(crate(_, To, S)).
+ not(crate(_, To, S)),
+ not(visited(To, S)).
+
poss(push(From, Direction), S) :-
agent(From, S),
connected(From, CrateLocation, Direction),
not(crate(_, CrateTarget, S)).
% --- Successor state axioms ------------------------------------------
+visited(Plek, result(A, _)) :-
+ A = move(Plek, _).
+
agent(AgentPlek, result(A, S)) :-
A = move(_, AgentPlek);
A = push(OudeAgentPlek, Richting),
poss(move(From, To), S) :-
agent(From, S),
connected(From, To, _),
- not(crate(_, To, S)).
+ not(crate(_, To, S)),
+ not(visited(To, S)).
+
poss(push(From, Direction), S) :-
agent(From, S),
connected(From, CrateLocation, Direction),
not(crate(_, CrateTarget, S)).
% --- Successor state axioms ------------------------------------------
+visited(Plek, result(A, _)) :-
+ A = move(Plek, _).
+
agent(AgentPlek, result(A, S)) :-
A = move(_, AgentPlek);
A = push(OudeAgentPlek, Richting),
connected(loc23, loc33, east).
connected(loc23, loc24, north).
-connected(loc31, loc32, east).
-connected(loc32, loc33, east).
+connected(loc31, loc32, north).
+connected(loc32, loc33, north).
% The other way around, west and south
connected(loc21, loc11, west).
connected(loc33, loc23, west).
connected(loc24, loc23, south).
-connected(loc32, loc31, west).
-connected(loc33, loc32, west).
-
-%connected(X, Y, east) :- connected(Y, X, west).
-%connected(X, Y, north) :- connected(Y, X, south).
+connected(loc32, loc31, south).
+connected(loc33, loc32, south).
crate(cratec, loc21, s0).
crate(crateb, loc22, s0).
% --- Goal condition that the planner will try to reach ---------------
goal(S) :- crate(cratea, Targeta, S), target(cratea, Targeta),
- crate(crateb, Targetb, S), target(crateb, Targetb),
+ crate(crateb, Targetb, S), target(crateb, Targetb).
crate(cratec, Targetc, S), target(cratec, Targetc).
-%goal(S) :- crate(cratea, Targeta, S), target(_, Targeta),
-% crate(crateb, Targetb, S), target(_, Targetb),
-% crate(cratec, Targetc, S), target(_, Targetc).
connected(loc23, loc33, east).
connected(loc23, loc24, north).
-connected(loc31, loc32, east).
-connected(loc32, loc33, east).
+connected(loc31, loc32, north).
+connected(loc32, loc33, north).
% The other way around, west and south
connected(loc21, loc11, west).
connected(loc33, loc23, west).
connected(loc24, loc23, south).
-connected(loc32, loc3-1, west).
-connected(loc33, loc3-2, west).
-
-%connected(X, Y, east) :- connected(Y, X, west).
-%connected(X, Y, north) :- connected(Y, X, south).
+connected(loc32, loc31, south).
+connected(loc33, loc32, south).
crate(cratec, loc21, s0).
crate(crateb, loc22, s0).
crate(cratea, loc23, s0).
-target(cratea, loc12).
-target(crateb, loc13).
-target(cratec, loc11).
-
agent(loc32, s0).
% --- Goal condition that the planner will try to reach ---------------
-%goal(S) :- forall(crate(Crate, Loc, S), target(Crate, Loc)).
-goal(S) :- crate(cratea, Targeta, S), target(cratea, Targeta),
- crate(crateb, Targetb, S), target(crateb, Targetb),
- crate(cratec, Targetc, S), target(cratec, Targetc).
+goal(S) :- crate(cratea, loc12, S), crate(crateb, loc13, S), crate(cratec, loc11, S).
connected(loc23, loc33, east).
connected(loc23, loc24, north).
-connected(loc31, loc32, east).
-connected(loc32, loc33, east).
+connected(loc31, loc32, north).
+connected(loc32, loc33, north).
% The other way around, west and south
connected(loc21, loc11, west).
connected(loc33, loc23, west).
connected(loc24, loc23, south).
-connected(loc32, loc3-1, west).
-connected(loc33, loc3-2, west).
+connected(loc32, loc31, south).
+connected(loc33, loc32, south).
crate(cratec, loc21, s0).
crate(crateb, loc22, s0).
crate(cratea, loc23, s0).
-target(cratea, loc12).
-target(crateb, loc13).
-target(cratec, loc11).
+target(loc12).
+target(loc13).
+target(loc11).
agent(loc32, s0).
% --- Goal condition that the planner will try to reach ---------------
-goal(S) :- crate(cratea, Targeta, S), target(_, Targeta),
- crate(crateb, Targetb, S), target(_, Targetb),
- crate(cratec, Targetc, S), target(_, Targetc).
+goal(S) :- crate(_, loc12, S), crate(_, loc13, S), crate(_, loc11, S).