mirror of
https://github.com/NotXia/unibo-ai-notes.git
synced 2025-12-15 11:02:21 +01:00
Add FAIKR2 probabilistic logic programming
This commit is contained in:
@ -0,0 +1,34 @@
|
|||||||
|
<mxfile host="app.diagrams.net" modified="2023-12-08T19:47:25.292Z" agent="Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0" etag="OSZXvqEczNiZXNqwfc7z" version="22.1.7" type="device">
|
||||||
|
<diagram name="Pagina-1" id="ed2_-DnoGlUrIFm0Tw4G">
|
||||||
|
<mxGraphModel dx="989" dy="500" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||||
|
<root>
|
||||||
|
<mxCell id="0" />
|
||||||
|
<mxCell id="1" parent="0" />
|
||||||
|
<mxCell id="ZAoLLnpvm8W4UGgeYZgy-1" value="<div style="font-size: 16px;"><font style="font-size: 16px;">sneezing(bob) :- flu(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">sneezing(bob) :- hay_fever(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">flu(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">hay_fever(bob).<br style="font-size: 16px;"></font></div><div style="font-size: 16px;"><font style="font-size: 16px;"><br style="font-size: 16px;"></font></div>" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fontFamily=Courier New;fontSize=16;fontStyle=1" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="250" width="320" height="90" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="ZAoLLnpvm8W4UGgeYZgy-2" value="<div style="font-size: 16px;"><font style="font-size: 16px;">null :- flu(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">sneezing(bob) :- hay_fever(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">flu(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">hay_fever(bob).<br style="font-size: 16px;"></font></div><div style="font-size: 16px;"><font style="font-size: 16px;"><br style="font-size: 16px;"></font></div>" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fontFamily=Courier New;fontSize=16;fontStyle=1" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="420" y="250" width="320" height="90" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="ZAoLLnpvm8W4UGgeYZgy-3" value="<font style="font-size: 20px;">P</font><font style="font-size: 20px;">(w<sub style="font-size: 20px;">1</sub>) = 0.7 · 0.8<br style="font-size: 20px;"></font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontFamily=Times New Roman;fontSize=20;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="220" width="320" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="ZAoLLnpvm8W4UGgeYZgy-4" value="<font style="font-size: 20px;">P</font><font style="font-size: 20px;">(w<sub style="font-size: 20px;">2</sub>) = 0.3 · 0.8<br style="font-size: 20px;"></font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontFamily=Times New Roman;fontSize=20;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="420" y="220" width="320" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="ZAoLLnpvm8W4UGgeYZgy-5" value="<div style="font-size: 16px;"><font style="font-size: 16px;">sneezing(bob) :- flu(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">null :- hay_fever(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">flu(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">hay_fever(bob).<br style="font-size: 16px;"></font></div><div style="font-size: 16px;"><font style="font-size: 16px;"><br style="font-size: 16px;"></font></div>" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fontFamily=Courier New;fontSize=16;fontStyle=1" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="390" width="320" height="90" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="ZAoLLnpvm8W4UGgeYZgy-6" value="<div style="font-size: 16px;"><font style="font-size: 16px;">null :- flu(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">null :- hay_fever(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">flu(bob).</font></div><div style="font-size: 16px;"><font style="font-size: 16px;">hay_fever(bob).<br style="font-size: 16px;"></font></div><div style="font-size: 16px;"><font style="font-size: 16px;"><br style="font-size: 16px;"></font></div>" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fontFamily=Courier New;fontSize=16;fontStyle=1" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="420" y="390" width="320" height="90" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="ZAoLLnpvm8W4UGgeYZgy-7" value="<font style="font-size: 20px;">P</font><font style="font-size: 20px;">(w<sub style="font-size: 20px;">3</sub>) = 0.7 · 0.2<br style="font-size: 20px;"></font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontFamily=Times New Roman;fontSize=20;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="360" width="320" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="ZAoLLnpvm8W4UGgeYZgy-8" value="<font style="font-size: 20px;">P</font><font style="font-size: 20px;">(w<sub style="font-size: 20px;">4</sub>) = 0.3 · 0.2<br style="font-size: 20px;"></font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontFamily=Times New Roman;fontSize=20;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="420" y="360" width="320" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
</root>
|
||||||
|
</mxGraphModel>
|
||||||
|
</diagram>
|
||||||
|
</mxfile>
|
||||||
Binary file not shown.
@ -12,5 +12,6 @@
|
|||||||
\input{sections/_descriptive_logic.tex}
|
\input{sections/_descriptive_logic.tex}
|
||||||
\input{sections/_semantic_web.tex}
|
\input{sections/_semantic_web.tex}
|
||||||
\input{sections/_time_reasoning.tex}
|
\input{sections/_time_reasoning.tex}
|
||||||
|
\input{sections/_probabilistic_reasoning.tex}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
\chapter{Probabilistic logic reasoning}
|
||||||
|
|
||||||
|
\begin{description}
|
||||||
|
\item[Probabilistic logic programming] \marginnote{Probabilistic logic programming}
|
||||||
|
Adds probability distributions over logic programs allowing to define different worlds.
|
||||||
|
Joint distributions can also be defined over worlds and allows to answer to queries.
|
||||||
|
\end{description}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\section{Logic programs with annotated disjunctions (LPAD)}
|
||||||
|
\marginnote{LPAD}
|
||||||
|
|
||||||
|
\subsection{Syntax}
|
||||||
|
|
||||||
|
\begin{description}
|
||||||
|
\item[\texttt{null}]
|
||||||
|
Atom that can only appear in the head of a clause and
|
||||||
|
cancels the clause (i.e. equivalent of not having the clause).
|
||||||
|
\end{description}
|
||||||
|
|
||||||
|
The head of each clause is defined as a disjunction of atoms, each with a probability.
|
||||||
|
More specifically, each clause has a probability distribution over its head.
|
||||||
|
|
||||||
|
\begin{example}
|
||||||
|
\phantom{}
|
||||||
|
\begin{lstlisting}
|
||||||
|
sneezing(X):0.7 ; null:0.3 :- flu(X).
|
||||||
|
sneezing(X):0.8 ; null:0.2 :- hay_fever(X).
|
||||||
|
\end{lstlisting}
|
||||||
|
\end{example}
|
||||||
|
|
||||||
|
|
||||||
|
\subsection{Distribution semantics}
|
||||||
|
|
||||||
|
\begin{description}
|
||||||
|
\item[Worlds] \marginnote{World}
|
||||||
|
Given a clause $C$ and a substitution $\theta$ such that $C\theta$ is ground,
|
||||||
|
the following operations are defined for LPAD:
|
||||||
|
\begin{descriptionlist}
|
||||||
|
\item[Atomic choice] \marginnote{Atomic choice}
|
||||||
|
An atomic choice $(C, \theta, i)$ is the selection of the $i$-th atom in the head of $C$ for grounding.
|
||||||
|
|
||||||
|
\item[Composite choice] \marginnote{Composite choice}
|
||||||
|
A composite choice $\kappa$ is a set of atomic choices.
|
||||||
|
The probability of a composite choice is the following:
|
||||||
|
\[ \prob{\kappa} = \prod_{(C, \theta, i) \in \kappa} \prob{C, i} \]
|
||||||
|
where $\prob{C, i}$ is the probability of choosing the $i$-th atom in the head of $C$.
|
||||||
|
|
||||||
|
\item[Selection] \marginnote{Selection}
|
||||||
|
A selection $\sigma$ is a composite choice where an atom from the head of each clause for each grounding has been chosen.
|
||||||
|
In other words, a selection can be defined only when the program is ground.
|
||||||
|
|
||||||
|
A selection $\sigma$ identifies a world $w_\sigma$ and has probability:
|
||||||
|
\[ \prob{w_\sigma} = \prob{\sigma} = \prod_{(C, \theta, i) \in \sigma} \prob{C, i} \]
|
||||||
|
\end{descriptionlist}
|
||||||
|
|
||||||
|
\begin{example}
|
||||||
|
Given the program:
|
||||||
|
\begin{lstlisting}
|
||||||
|
sneezing(X):0.7 ; null:0.3 :- flu(X).
|
||||||
|
sneezing(X):0.8 ; null:0.2 :- hay_fever(X).
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
|
The possible worlds are:
|
||||||
|
\begin{center}
|
||||||
|
\includegraphics[width=0.7\textwidth]{img/_probabilistic_logic_example.pdf}
|
||||||
|
\end{center}
|
||||||
|
\end{example}
|
||||||
|
|
||||||
|
\item[Queries] \marginnote{Queries}
|
||||||
|
Given a ground query $Q$ and a world $w$, the probability of $Q$ being true in $w$ is trivially:
|
||||||
|
\[
|
||||||
|
\prob{Q \mid w}
|
||||||
|
\begin{cases}
|
||||||
|
1 & \text{ if $Q$ is true in $w$}\\
|
||||||
|
0 & \text{ otherwise}
|
||||||
|
\end{cases}
|
||||||
|
\]
|
||||||
|
|
||||||
|
The overall probability of $Q$ is:
|
||||||
|
\[ \prob{Q} = \sum_w \prob{Q, w} = \sum_w \prob{Q \mid w}\prob{w} = \sum_{w \models Q} \prob{w} \]
|
||||||
|
|
||||||
|
\begin{example}
|
||||||
|
Given the program:
|
||||||
|
\begin{lstlisting}
|
||||||
|
sneezing(X):0.7 ; null:0.3 :- flu(X).
|
||||||
|
sneezing(X):0.8 ; null:0.2 :- hay_fever(X).
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
|
The probability of \texttt{sneezing(bob)} is:
|
||||||
|
\[ \prob{\texttt{sneezing(bob)}} = \prob{w_1} + \prob{w_2} + \prob{w_3} \]
|
||||||
|
\end{example}
|
||||||
|
\end{description}
|
||||||
Reference in New Issue
Block a user