\chapter{Visual representations and reasoning}
We chose pizzas for our domain, as everybody likes pizzas. We chose to have six different pizzas. As all pizzas have tomato sauce and cheese, we didn't take those into account. Below we listed all the pizzas and their ingredients.
\begin{itemize}
	\item Margherita; basil
	\item Hawaii; ham, pineapple and basil
	\item Salami; salami and basil
	\item Funghi; mushrooms and ham
	\item Pepperoni; salami and jalape\~nos
\end{itemize}

We are able to observe different kind of shapes; circles, double circles (like tires or olives in our case), squares and blobs. For each shape it is possible that it represents different ingredients. Because of this we defined for every shape the probabilities that it is a particular ingredient. For example a circle could be basil, salami or mozarella with respectively probabilities of 0.2, 0.4 and 0.4. The probability that basil is observed is then composed out of the probability that you observed a 'basil' circle and the probability that you have actually observed a circle.

Our style of reasoning that we employed is deductive. %Iets met vanuit een knowledgebase redeneren en vanuit hypotheses ofzo?

\iffalse
TODO
In a more structured way, you are required to describe clearly and fully:
• The domain and the individual images
• The representation of observations, assumables and the causal theory between them in AILog
• The style of reasoning employed (abductive, deductive) and what considerations have played
a role
• The queries used to infer information about individual images
• The results of the queries and reflections on their effectiveness and intuitions behind them
• General reflections on your model, how appropriate it is for this domain, how effective it is
and how would need to proceed if one would like to extend it to large datasets or realistic,
real-time operation.


\fi
\section{Domain representation}
Translating the domain specification to AILog results in the following AILog
code:
\inputminted[linenos,fontsize=\footnotesize]{prolog}{./src/pizza.ail}

\section{Queries}
\subsection{Initial probabilities}
Chances for shapes to be present are visible in Table~\ref{chances} and from
that we can calculate all the initial probabilites for all the shapes for
example with the following queries:
\begin{minted}[fontsize=\footnotesize]{prolog}
ailog: predict circle.
Answer: P(circle|Obs)=0.01.
	[ok,more,explanations,worlds,help]: ok.
ailog: observe circle.
Answer: P(circle|Obs)=0.01.
	[ok,more,explanations,worlds,help]: ok.
ailog: predict circlePresent.
Answer: P(circlePresent|Obs)=0.95.
	[ok,more,explanations,worlds,help]: ok.
\end{minted}
\begin{table}
	\label{chances}
	\begin{tabular}{|l|ll|}
		\hline
		& Observed &\\
		Present & T & F\\
		\hline
		T & $0.95$ & $0.01$\\
		F & $0.05$ & $0.99$\\
		\hline
	\end{tabular}
\end{table}

\subsection{Querying probabilites for pizzas}
Since the chance of a false positive on a shape is so low the initial
probabilities for pizza types are very low. When certain shapes that belong to
a certain type of pizza occur the probability improves a lot. We can show this
by showing the probabilites of a pepperoni pizza before, during and after
observing the ingredients with the following queries:
\begin{minted}[fontsize=\footnotesize]{prolog}
ailog: predict p_pepperoni.
Answer: P(p_pepperoni|Obs)=0.0019.
	[ok,more,explanations,worlds,help]: ok.
ailog: observe circle.
Answer: P(circle|Obs)=1.0.
	[ok,more,explanations,worlds,help]: ok.
ailog: predict p_pepperoni.
Answer: P(p_pepperoni|Obs)=0.0019.
	[ok,more,explanations,worlds,help]: ok.
ailog: observe doublecircle.
Answer: P(doublecircle|Obs)=0.01.
	[ok,more,explanations,worlds,help]: ok.
ailog: predict p_pepperoni.
Answer: P(p_pepperoni|Obs)=0.19.
	[ok,more,explanations,worlds,help]: ok.
\end{minted}

\subsection{Finding out which pizza is the most likely to be present on the
image}
We do not only want to know what the probability for a specific pizza is but
also the most likely pizza so that we can give an educated guess about the
pizza type present on the image processed. This can be done with the following
queries using the \texttt{whatpizza} predicate. The \texttt{whatpizza}
predicate is a predicate that is a disjunction of all pizza types. In the
following queries, when the possible explanations, are given we can query for
every possible explanations to find out how the most likely world looks like:
\begin{minted}[fontsize=\footnotesize]{prolog}
ailog: predict whatpizza.
Answer: P(whatpizza|Obs)=[0.19251740120000002,0.19278577620000004].
  [ok,more,explanations,worlds,help]: explanations.
  0: ass([],[basilcircle,circle,doublecircle,doublecircleOlives,noObserveError],9.5e-6)
  1: ass([],[circle,doublecircle,doublecircleJalapenos,noObserveError,salamicircle],1.9e-5)
  2: ass([],[blob,blobHam,blobMushrooms,circle,funghiham,noObserveError],3.3249999999999995e-6)
  3: ass([],[basilcircle,circle,noObserveError,salamibasil,salamicircle],7.6e-5)
  4: ass([],[basilcircle,circle,noObserveError],0.0019)
  5: ass([],[blob,blobbasil,circle,noObserveError],9.5e-6)
  [ok,more,how i,help]: how 4.
   whatpizza <-
      1: p_margarita
	How? [Number,up,retry,ok,prompt,help]: up.
Answer: P(whatpizza|Obs)=[0.19251740120000002,0.19278577620000004].
  [ok,more,explanations,worlds,help]: ok.
ailog: observe blob.
Answer: P(blob|Obs)=0.01.
  [ok,more,explanations,worlds,help]: ok.
ailog: predict whatpizza.
Answer: P(whatpizza|Obs)=[0.28994000000000003,0.33126500000000003].
  [ok,more,explanations,worlds,help]: explanations.
  0: ass([],[blob,blobHam,blobMushrooms,circle,funghiham,noObserveError],3.3249999999999995e-6)
  1: ass([],[basilcircle,blob,circle,noObserveError],1.9e-5)
  2: ass([],[blob,blobbasil,circle,noObserveError],9.5e-6)
  [ok,more,how i,help]: how 0.
   whatpizza <-
      1: p_funghi
   How? [Number,up,retry,ok,prompt,help]: ok.
\end{minted}

\section{Reflections}
The model is relatively effective. One can easily compute the most likely pizza
configuration from abstract shapes only. The model is also very scalable since
the model only grows with the number of ingredients per pizza added because all
the pizzas are independent. Because of this large datasets can be added very
easily and because of this the computational complexity does not increase very
much. Changes in parameters can also be added very easily, for example when a
more accurate low level detection technique is applied the probabilities for
the shapes present can be increased very easily.
