\documentclass[pdf,slideColor,plainsem]{prosper}

\usepackage{xspace}
\usepackage{latexsym}
\usepackage{amssymb}

\usepackage{pst-node}
\usepackage{pst-uml-prosper}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\MiniPage#1#2{\begin{minipage}[t]{.49\hsize}#1\end{minipage}%
\hspace{1ex}\begin{minipage}[t]{.49\hsize}#2\end{minipage}}

\newlength{\ParLen}
\def\Parbox#1#2{\settowidth{\ParLen}{#1}\parbox[t]{\ParLen}{#2}}

\newcommand {\minitab}  {\hspace*{1ex}}
\newcommand {\smalltab} {\hspace*{5mm}}
\newcommand {\tab}      {\hspace*{10mm}}
\newcommand {\bigtab}   {\hspace*{15mm}}
\newcommand {\hugetab}  {\hspace*{20mm}}

\newcommand{\per}{\mathpunct{\mbox{\bf .}}}
\newcommand{\nl}{\\\tab}

\def\centerpar#1{\renewcommand{\arraystretch}{0.7}%
\begin{tabular}{c}#1\end{tabular}\renewcommand{\arraystretch}{1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% symbols for UML package
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newlength{\umlunitbox}
\def\umlcard#1%
  {\umlcsize #1\hspace*{-.5ex}}
\def\umlclass#1#2%
  {\rnode{#1}{\umlClass{\makebox[\umlunitbox]{#2}}{\hline\hline}}}
\def\umlclassred#1#2%
  {\color{red}%
  \rnode{#1}{\umlClass[linecolor=red]{\makebox[\umlunitbox]{#2}}{\hline\hline}}}
\def\umlclassa#1#2#3%
  {\rnode{#1}{\umlClass{\makebox[\umlunitbox]{#2}}%
  {#3\\\hline\hline}}}
\def\umldefclass#1#2%
  {\rnode{#1}{\umlClass{\makebox[\umlunitbox]%
      {{\bf /}#2}}{\hline\hline}}}
\renewcommand{\ncputicon}[2][]{%
   \setkeys{psset}{npos=0,nrot=:D}%
   \setkeys{psset}{#1}%
   \ncput{#2}}
\def\umlIsa{%
   \pstriangle[gangle=-90,%
              linestyle=solid,%
              fillstyle=solid,%
              fillcolor=white]%
          (-0.15,0)(0.12,0.15)} % (centre)(Width,Length)

%%%%%%%%%% Macros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\vtrue}{{\tt T}}
\newcommand{\vfalse}{{\tt F}}
\newcommand{\interp}{{\cal I}}
\newcommand{\interf}{{\cal I}}
\newcommand{\domain}{{\Delta}}
\newcommand{\jinterp}{{\cal J}}
\newcommand{\interfj}{{\cal J}}
\newcommand{\minterp}{{\cal M}}
\newcommand{\formel}{{\cal F}}
\newcommand{\clauses}{{\cal C}}
\newcommand{\intf}[1]{{#1}^{\cal I}}
\newcommand{\intfj}[1]{{#1}^{\cal J}}
\newcommand{\varmap}{{\alpha}}
\newcommand{\intfv}[1]{{#1}^{{\cal I},\varmap}}
\newcommand{\I}{{\cal I}}

\newcommand{\predA}{{\tt A}}
\newcommand{\predB}{{\tt B}}
\newcommand{\predR}{{\tt R}}

\newcommand{\tl}[1]{#1^\ast}    % translation of modal logic formulae
                                % into predicate logic formulae

\newcommand{\set}[1]{\{ #1 \}}          % set

\newcommand{\KB}{\textit{KB}\xspace}

\newcommand{\limplies}{\rightarrow}
\newcommand{\implies}{\rightarrow}
\newcommand{\lequiv}{\leftrightarrow}
\newcommand{\Subsumes}{\mathrel{\sqsupseteq}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\semtitle{Description Logics}
\semsubject{Using First Order Logic}
\semauthor{Enrico Franconi}
\sememail{franconi@cs.man.ac.uk}
\semwebpage{http://www.cs.man.ac.uk/\~{}franconi}
\seminstitution{Department of Computer Science, University of Manchester}

\begin{document}

\makesemtitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Reduction to satisfiability}

Just like propositional logic:

\begin{itemize}
  
  \item A formula $\phi$ is satisfiable iff there is some
  interpretation $\interp$ that satisfies $\phi$ (i.e., $\phi$ is true
  under $\interp$): \tab  {\color{blue}$\interp\models\phi$}).
  
\item Validity, equivalence, and entailment can be reduced to
  satisfiability:

  \begin{itemize}
  
  \item $\phi$ is a valid (i.e., a tautology) iff $\neg\phi$ is
    not satisfiable.
    
  \item $\phi$ is equivalent to $\psi$ ($\phi\equiv\psi$) iff
    $\phi\leftrightarrow\psi$ is valid.
    
    \begin{itemize}
    \item $\phi\equiv\psi$ iff $\phi\models\psi$ and $\psi\models\phi$
    \end{itemize}
  
  \item $\phi$ entails $\psi$ ($\phi\models\psi$) iff
    $\phi\rightarrow\psi$ is valid (\textit{deduction theorem\/}).

    \begin{itemize}
    \item \fbox{$\phi\models\psi$ iff $\phi\land\neg\psi$ is not
        satisfiable}.
    \end{itemize}
    
\end{itemize}

\item We need a \textit{sound and complete} procedure deciding
  satisfiability: the \textit{tableaux method} is a
  decision procedure which checks the existence of a model.

\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Tableaux Calculus}

  Just like in propositional logic:
  
\begin{itemize}
  
\item The Tableaux Calculus is a decision procedure solving the
  problem of satisfiability.
  
\item If a formula is satisfiable, the procedure will constructively
  exhibit a model of the formula.
  
\item The basic idea is to incrementally build the model by looking at
  the formula, by decomposing it in a top/down fashion. The procedure
  exhaustively looks at all the possibilities, so that it can
  eventually prove that no model could be found for unsatisfiable
  formulas.

\end{itemize}

With respect to propositional logic, the notion of {\em model} is 
different.

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Tableaux Calculus}

Finds a model for a given collection of sentences \KB in negation
normal form.

\begin{enumerate}
\item Consider the knowledge base \KB as the root node of a {\it
    refutation tree}. A node in a refutation tree is called {\em
    tableaux}.
      
\item Starting from the root, add new formulas to the tableaux,
  applying the {\it completion rules}.
  
\item Completion rules are either deterministic -- they yield a
  uniquely determined successor node -- or nondeterministic --
  yielding several possible alternative successor nodes ({\it
    branches}).
      
\item Apply the completion rules until either \\
  (a) an explicit contradiction due to the presence of two opposite
  ground literals in a node (a {\it clash}) is generated in each
  branch, or \\
  (b) there is a {\em completed} branch where no more rule is
  applicable (but$\ldots$).
  
\end{enumerate}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{The Calculus}

The completion rules for the propositional formulas:

\vspace{1em}

  \begin{minipage}[t]{6em}$
  \begin{array}{c}
  \phi\wedge\psi\\
  \hline
  \phi\\
  \psi
  \end{array}
  $\end{minipage}
  \begin{minipage}[c]{25em}
    {\small If a model satisfies a conjunction, then it also satisfies
      \textit{each of} the conjuncts}
  \end{minipage}

\vspace{1em}

  \begin{minipage}[t]{6em}$
  \begin{array}{c|c}
  \multicolumn{2}{c}{\phi\vee\psi}\\
  \hline
  \phi & \psi\\
  \multicolumn{2}{c}{}
  \end{array}
  $\end{minipage}
  \begin{minipage}[c]{25em}
    {\small If a model satisfies a disjunction, then it also satisfies
      \textit{one of} the disjuncts. It is a non-deterministic rule,
      and it generates two {\em alternative} branches of the
      tableaux.}
  \end{minipage}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{The Calculus}

The completion rules for quantified formulas:

\vspace{1em}

  \begin{minipage}[t]{6em}$
  \begin{array}{c}
  \forall x\per\ \phi\\
  \hline
  \phi\{X/t\}\\
  \forall x\per\ \phi\\
  \multicolumn{1}{c}{}\\  
  \end{array}
  $\end{minipage}
  \begin{minipage}[c]{25em}
    {\small If a model satisfies a universal quantified formula, the it also
      satisfies the formula where the quantified variable has been
      substituted with some term. The prescription is to use all the terms
      which appear in the tableaux.}
  \end{minipage}

\vspace{1em}

  \begin{minipage}[t]{6em}$
  \begin{array}{c}
  \exists x\per\ \phi\\
  \hline
  \phi\{X/a\}\\
  \multicolumn{1}{c}{}\\  
  \end{array}
  $\end{minipage}
  \begin{minipage}[c]{25em}
    {\small If a model satisfies an existential quantified formula, then it
      also satisfies the formula where the quantified variable has been
      substituted with a fresh new {\em skolem} constant.}
  \end{minipage}
  
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Models}

\begin{itemize}
  \item The completed branch of the refutation tree gives a model of
  \KB: the \KB is satisfiable.  Since all formulas have been reduced
  to ground literals (i.e., either positive or negative atomic
  formulas which do not contain variables), it is possible to find an
  interpretation to predicates using the constants, which make all the
  sentences in the branch true.
  
  \item If there is no completed branch (i.e., every branch has a
  clash), then it is not possible to find an interpretation for the
  predicates making the original \KB true: the \KB is unsatisfiable. 
  In fact, the original formulas from which the tree is constructed
  can not be true simultaneously.

\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Negation Normal Form}

The above set of completion rules work only if the formula has been
translated into Negation Normal Form, i.e., all the negations have been
pushed down.

\vspace{2em}

Example::

$\neg (\exists x\per\ [\ \forall y\per\ [\ P(x)\rightarrow Q(y)\ ]\ ])$

becomes

$\forall x\per\ [\ \exists y\per\ [\ P(x)\wedge \neg Q(y)\ ]\ ]$

{\em (Why?)}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\overlays{8}{
\begin{slide}{Example}

\vspace{-2em}
{\footnotesize
\begin{center}
  \begin{minipage}[t]{4em}$
  \begin{array}{c}
  \phi\wedge\psi\\
  \hline
  \phi\\
  \psi
  \end{array}
  $\end{minipage}
  \begin{minipage}[t]{4em}$
  \begin{array}{c|c}
  \multicolumn{2}{c}{\phi\vee\psi}\\
  \hline
  \phi & \psi\\
  \multicolumn{2}{c}{}
  \end{array}
  $\end{minipage}
  \begin{minipage}[t]{5em}$
  \begin{array}{c}
  \forall x\per\ \phi\\
  \hline
  \phi\{X/t\}\\
  \multicolumn{1}{c}{}\\  
  \end{array}
  $\end{minipage}
  \begin{minipage}[t]{5em}$
  \begin{array}{c}
  \exists x\per\ \phi\\
  \hline
  \phi\{X/a\}\\
  \multicolumn{1}{c}{}\\  
  \end{array}
  $\end{minipage}
\end{center}
  
\vspace{-1em}

  $$
  \begin{array}{c}
    \mbox{\fbox{$\exists y\per\ (p(y)\wedge\neg q(y)) \land \forall z\per
    (p(z)\lor q(z))$}}\\
    \fromSlide{2}{\exists y\per\ (p(y)\wedge\neg q(y))} \\
    \fromSlide{2}{\forall z\per\ (p(z)\lor q(z))}\\
    \fromSlide{3}{p({\bf a})\wedge\neg q({\bf a})}\\
    \fromSlide{4}{p({\bf a})}\\
    \fromSlide{4}{\neg q({\bf a})}\\
    \fromSlide{5}{p({\bf a})\lor q({\bf a})}\\
    \\
    \begin{array}{c@{\hspace{8em}}c}
      \fromSlide{6}{p({\bf a})} & \fromSlide{7}{q({\bf a})}\\
      \fromSlide{6}{{\tt <COMPLETED>}} & \fromSlide{7}{{\tt <CLASH>}}
    \end{array}
  \end{array}
  $$

\vspace{0.5ex}

\fromSlide{8}{The formula is satisfiable. The devised model is~ 
$\domain=\{{\bf a}\}$,~ $\intf
p=\{{\bf a}\}$,~ $\intf q=\emptyset$.}

}

\end{slide}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\overlays{8}{
\begin{slide}{Example}

\vspace{-2em}
{\footnotesize
\begin{center}
  \begin{minipage}[t]{4em}$
  \begin{array}{c}
  \phi\wedge\psi\\
  \hline
  \phi\\
  \psi
  \end{array}
  $\end{minipage}
  \begin{minipage}[t]{4em}$
  \begin{array}{c|c}
  \multicolumn{2}{c}{\phi\vee\psi}\\
  \hline
  \phi & \psi\\
  \multicolumn{2}{c}{}
  \end{array}
  $\end{minipage}
  \begin{minipage}[t]{5em}$
  \begin{array}{c}
  \forall x\per\ \phi\\
  \hline
  \phi\{X/t\}\\
  \multicolumn{1}{c}{}\\  
  \end{array}
  $\end{minipage}
  \begin{minipage}[t]{5em}$
  \begin{array}{c}
  \exists x\per\ \phi\\
  \hline
  \phi\{X/a\}\\
  \multicolumn{1}{c}{}\\  
  \end{array}
  $\end{minipage}
\end{center}
  
\vspace{-1em}

  $$
  \begin{array}{c}
    \mbox{\fbox{$\exists y\per\ (p(y)\wedge\neg q(y)) \land \forall z\per
    (\neg p(z)\lor q(z))$}}\\
    \fromSlide{2}{\exists y\per\ (p(y)\wedge\neg q(y))} \\
    \fromSlide{2}{\forall z\per\ (\neg p(z)\lor q(z))}\\
    \fromSlide{3}{p({\bf a})\wedge\neg q({\bf a})}\\
    \fromSlide{4}{p({\bf a})}\\
    \fromSlide{4}{\neg q({\bf a})}\\
    \fromSlide{5}{\neg p({\bf a})\lor q({\bf a})}\\
    \\
    \begin{array}{c@{\hspace{8em}}c}
      \fromSlide{6}{\neg p({\bf a})} &\fromSlide{7}{q({\bf a})}\\
      \fromSlide{6}{{\tt <CLASH>}} & \fromSlide{7}{{\tt <CLASH>}}
    \end{array}
  \end{array}
  $$

\vspace{0.5ex}

\fromSlide{8}{The formula is unsatisfiable.}

}

\end{slide}}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \begin{slide}{Exercise}

% Jones, Smith, and Clark are a programmer, a knowledge engineer, and a 
% manager (non necessarily in this order). Jones should give 50 pounds to 
% the programmer. The wife of the manager does not want that his husband 
% borrows money from somebody. Smith is not married. How can you tell 
% the work of Jones, Smith, and Clark?

% \end{slide}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \begin{slide}{Exercise}

% \begin{enumerate}

% \item All poems by Yeats are older than some books by Steinbeck.

% \item It is not true that a writer is famous only if their age is
% greater than the age of Steinbeck plus the age of any Romantic.

% \item Some books by Pushkin are better than all books by better known
% writers who are less talented.

% \item If a book was written by a novelist other than Hemingway, it is
% not better than every book by Hemingway or else Mike would like it.

% \item Poets who are less talented than Yeats either like Yeats or
% think all famous writers are crazy.

% \end{enumerate}

% \end{slide}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \begin{slide}{Exercise}

% Translate the following sentences in first order predicate calculus
% into plain English.  Interpret the relation and object constants
% according to their English meaning.

% \footnotesize{
% \begin{enumerate}

% \item {\tt $\forall$x.$\exists$y.(Season(x) $\Rightarrow$ Flower(y)
%  $\wedge$ Blooms(y, x))}

% \item {\tt $\neg$ ( $\neg$ ( $\forall$x.$\exists$y.(Problem(x)
% $\wedge$ Solution(y) $\wedge$ Solves(y, x))) $\Rightarrow$} \par
% {\tt \ \ \ $\forall$x.(Problem(x) $\wedge$ Having(You, x) $\Rightarrow$ Desperate(You)))}

% \item {\tt $\forall$x.$\exists$y.(Problem(x) $\Rightarrow$
% Solution(y) $\wedge$ Solves(y, x))}

% \item {\tt $\exists$y.$\forall$x.(Problem(x) $\Rightarrow$
% Solution(y) $\wedge$ Solves(y, x))}

% \item {\tt $\forall$x.(SmartPerson(x) $\wedge$ Taking(x, CS157)
% $\Rightarrow$} \par
% {\tt \ \ \ (Loves(x, Logic) $\vee$} \par
% {\tt \ \ \ ( $\forall$y.$\exists$z.(CSclass(z)$\wedge$Hates(y,
% SubjectOf(z)) $\Rightarrow$ ThinkCrazy(x, y)))))}

% \end{enumerate}}


% \end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Other Reasoning Problems}

\begin{itemize}
\item {\bf Subsumption}
  \begin{itemize}
  \item $\Gamma\models P\Subsumes Q$\\ 
    $P$ and $Q$ \textit{predicate symbols} of
    the same arity
  \item $P$ subsumes $Q$ in $\Gamma$
  \item $\Gamma\models\forall \hat x\per\ [\ Q(\hat x)\rightarrow P(\hat
    x)\ ]$
  \end{itemize}
\item {\bf Instance Checking}
  \begin{itemize}
  \item The constant $a$ is an instance of the unary predicate $P$
  \item $\Gamma\models P(a)$
  \end{itemize}
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Example}

Given a theory $\Gamma$,

if {\tt PERSON}$\ \Subsumes$\ {\tt STUDENT} in $\Gamma$

and if ${\tt STUDENT}({\tt john})$ is valid in $\Gamma$

{\color{blue}then} ${\tt PERSON}({\tt john})$ is valid in $\Gamma$

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Subsumption}

\begin{itemize}
\item {\em Subsumption} can be seen as a binary relation in the space of
  predicates with same arity: $P_{/n}\Subsumes Q_{/n}$.
\item The subsumption relation is a {\em partial ordering} relation in the
  space of predicates of same arity.
  \begin{itemize}
  \item {\bf Exercise}: prove it.
  \item {\em Hint\/}: a partial ordering relation is a transitive,
    reflexive, and antisymmetric relation.
  \end{itemize}
\end{itemize}

\vspace{1ex}

\begin{center}
{\scriptsize\setlength{\unitlength}{1em}
\begin{picture}(16,13)
              \put(0,6){COURSE}
              \put(-1,9){INANIMATE}
              \put(4.5,12){TOP$\!_{/1}$}
              \put(7,9){ANIMATE}
              \put(7.5,6){PERSON}
              \put(4,3){STUDENT}
              \put(10,3){PROFESSOR}
              \put(5,0){WORKING-STUDENT}
             
              \thinlines
              \put(2,10){\vector(4,3){2.5}}
              \put(2,7){\vector(0,1){1.75}}
              \put(9.5,10){\vector(-4,3){2}}
              \put(9.5,7){\vector(0,1){1.75}}
              \put(6,4){\vector(1,1){1.75}}
              \put(13,4){\vector(-1,1){1.75}}
              \put(8,1){\vector(-1,1){1.75}}
              \put(11,1){\vector(1,1){1.75}}
              
\end{picture}}
\end{center}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Model Checking}

Verify that a given interpretation ${\cal I}$ is a model for a closed
formula $\varphi$: \\
${\cal I}\models\varphi$

An interpretation is also called a {\em relational structure}.

\hspace{3cm}

{\bf Example:}

$\Delta=\{a,b\},$ \\
$ P(a), $\\
$ Q(b).$

is a model of the formula:

$\exists y\per\ [\ P(y)\wedge\neg Q(y)\ ] \land \forall z\per [\ P(z)\lor
Q(z)\ ]$

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Termination and Decidability}

Given a logic ${\cal L}$, a reasoning problem is said to be {\bf decidable}
if there exists a computational process (e.g., an algorithm, a Turing
Machine, a computer program, etc.) that solves the problem in a finite
number of steps, i.e., the process always terminates.

\begin{itemize}
\item The problem of deciding whether a formula $\varphi$ is logically
  implied by a theory $\Gamma$ is undecidable in full FOL.
\item Logical implication is decidable if we restrict to propositional
  calculus.
\item Logical implication is decidable if we restrict to FOL using only at
  most {\em two} variable names; such language is called ${\cal L}_2$.
\end{itemize}

The property of (un)decidability is a general property of the problem
  and not of a particular algorithm solving it.

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{${\cal L}_3$}

An example of ${\cal L}_3$ formula:\\
``The only baseball player in town is married to one of Jeremy's daughters.''

$\tt
\exists x\per\ 
[\ 
\parbox[t]{\textwidth}{$\tt
B(x)\wedge \\
(\forall y\per\ [\ B(y)\rightarrow x=y\ ]\ ) \wedge \\
\exists z\per\ [\ 
  \parbox[t]{\textwidth}{$\tt
  M(x,z)\wedge D(z,\mbox{\tt jeremy})\wedge \\
  (\exists k\per\ [\ D(k,\mbox{\tt jeremy})\wedge z\neq k\ ]\ ) \wedge \\
\forall v\per\ [\ M(x,v)\rightarrow v=z\ ]\ ]\ 
]
$}$}
$

\vspace{1em}

$\tt
\exists x\per\ 
[\ 
\parbox[t]{\textwidth}{$\tt
B(x)\wedge \\
(\forall y\per\ [\ B(y)\rightarrow x=y\ ]\ ) \wedge \\
\exists y\per\ [\ 
  \parbox[t]{\textwidth}{$\tt
  M(x,y)\wedge D(y,\mbox{\tt jeremy})\wedge \\
  (\exists x\per\ [\ D(x,\mbox{\tt jeremy})\wedge y\neq x\ ]\ ) \wedge \\
\forall v\per\ [\ M(x,v)\rightarrow v=y\ ]\ ]\ 
]
$}$}
$

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Expressive Power}

\begin{itemize}
\item Some logics can be made decidable by sacrificing some {\em expressive
  power}.
\item A logical language ${\cal L}_a$ has more expressive power than a
  logical language ${\cal L}_b$, if each formula of ${\cal L}_b$ denotes the
  ``same'' set of models of its correspondent formula of ${\cal L}_a$, and
  if there is a formula of ${\cal L}_a$ denoting a set of models which is
  denoted by no formula in ${\cal L}_b$.
\end{itemize}

Example:

Consider ${\cal L}_a$ as FOL, and ${\cal L}_b$ as FOL without negation and
disjunction. Given a common domain, the ${\cal L}_a$ formula $\exists x\per\ 
[\ P(x)\lor Q(x)\ ]$ has a set of models which can not be captured by any
formula of ${\cal L}_b$.\\
{\em (Exercise: check it out with $\domain=\{a\}$}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Problems and Algorithms}

\begin{itemize}
\item A {\bf problem}  is a general question to be answered. \\
  A problem is described by giving:
  \begin{itemize}
  \item a general description of all its parameters, and
  \item a statement of what properties the answer, or {\em solution}, is
    required to satisfy.
  \end{itemize}
  An {\em instance} of a problem is obtained by specifying values for all
  parameters.
\item An {\bf algorithm} is a step-by-step procedure fro solving problems.\\
  An algorithm is said to {\em solve} a problem $\Pi$ if
  \begin{itemize}
  \item it can be applied to any instance $I$ of $\Pi$, and
  \item it is guaranteed always to produce a solution for that instance $I$.
  \end{itemize}
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Computational Complexity}

\begin{itemize}
\item The goal of complexity theory is to classify problems as to their
  intrinsic computational difficulty into general {\em complexity classes}.
  
\item Given a problem, how much computing power and/or resources (e.g., {\em
    time}, {\em space}) do we need in order to solve it {\bf in the worst
    case}?
  
\item The complexity class to which a problem belongs is a general property
  of the problem and not of a particular algorithm solving it.

\item Distinguish among:

  \begin{itemize}
  \item worst case ~~~ $\Longleftarrow$
  \item average case
  \item hard and easy cases
  \end{itemize}
  
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Complexity classes}

\begin{itemize}
\item P
\item NP\ ---\ coNP
\item PH
\item PSPACE
\item EXPTIME
\item NEXPTIME
\item DECIDABLE
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Complexity of problems}

\noindent
Complexity and expressive power:

\noindent
\begin{itemize}
\item Satisfiability of formulas in propositional calculus is NP-complete.
\item Unsatisfiability of formulas in propositional calculus is
  coNP-complete.
\item Satisfiability of QBF formulas in FOL where there is a finite nesting
  of quantifiers is PSPACE-complete: \\
  $Q_1 x_1\per\ Q_2 x_2\per\ \ldots\ [\ \varphi(x_1,x_2,\ldots)\ ]$, \\
  where $Q_i$ is either $\forall$ or $\exists$.
\item Satisfiability of formulas in the propositional {\em dynamic} normal
  modal logic (PDL) is EXPTIME-complete. {\em (Note: PDL has non first order
    expressible features, but it doesn't include full FOL)}
\item Satisfiability of ${\cal L}_2$ formulas is NEXPTIME-complete.
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Complexity of problems}

Computational complexity depends on the reasoning problem:

\begin{itemize}
\item Model checking of FOL formulas is polynomial.
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{The classical inference systems}

Usually proof theory studies the properties of inference systems for logical
implication based on some sort of {\em sequent calculus}, or of {\em natural
  deduction}. While this seems appropriate from a mere theoretical point of
view, it turns out that such systems are hardly implementable, due to their
non-deterministic and non-constructive foundations.

Basically, these proof systems formalise the notion of {\em derivability}
``$\Gamma\vdash\varphi$'' with a set of inference rules. In this context:

\begin{itemize}
\item Soundness: if $\Gamma\vdash\varphi$ then $\Gamma\models\varphi$
\item Completeness: if $\Gamma\models\varphi$ then $\Gamma\vdash\varphi$
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Incompleteness}

\begin{itemize}
\item Sequent calculus and natural deduction form sound and complete
  procedures for computing logical implication.
\item However, for FOL it is not guaranteed their termination, since the
  problem is undecidable.
\item It is easy to have incomplete but terminating procedures, by simply
  dropping some of the inference rules from the complete set.
\item This is a general methodology for characterising the incompleteness of
  algorithms: {\em find a complete set of inference rules, and characterise
    the incomplete procedure with a subset of them.}
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Completeness}

\begin{itemize}
\item Given an incomplete reasoning procedure for a reasoning problem,
  sometimes people prefer to modify the definition of the problem in order
  to obtain a complete procedure.
\item This can be accomplished by slightly changing (``weakening'')
  the semantics of the logical language (e.g., a variant of {\em
    relevance} 4-valued FOL where modus ponens is no more valid is
  decidable, and it has a complete reasoning procedure).
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Algorithm Complexity}

\begin{itemize}
\item An {\bf sound and complete} algorithm solving a reasoning problem may
  be or may be not optimal with respect the computational complexity of the
  problem.
\item For example, a polynomial problem may be implemented with a
  non-polynomial algorithm, or a PSPACE problem may be implemented with an
  algorithm requiring exponential space.
\item Optimal implementation of sound and complete algorithms may be
  impossible if there is no constructive proof for the computational
  complexity.
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Sub-optimal algorithms}

\begin{itemize}
\item Recall that computational complexity considers only the {\bf worst
    cases}.
\item Sub-optimal sound and complete algorithms can be faster for simple,
  average, and real instances of the problem, but less efficient for worst
  cases, than optimal algorithms.
\item Sub-optimal sound and complete algorithms can be compliant to software
  engineering requirements, i.e., they can be modular and expandable.
\item Sub-optimal sound and complete algorithms may be optimal when
  considering sub-languages belonging to a lower complexity class.
\end{itemize}

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Summary of Part I of the course}

\begin{itemize}
\item Main lesson: Logic can be a useful tool.  It allows us to
  represent information about a domain in a very straight-forward way
  then deduce additional facts using one general domain-independent
  "algorithm": deduction.  Consequently, logic lends itself to
  large-scale, distributed-design problems.
  
\item Each logic is made up of a syntax, a semantics, a definition of
  the reasoning problems and the computational properties, and
  inference procedures for the reasoning problems (possibly sound and
  complete).  The syntax describes how to write correct sentences in
  the language, the semantics tells us what sentences mean in the
  "real world."  The inference procedure derives results logically
  implied by a set of premises.

\end{itemize}
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{}

\begin{itemize}
\item Logics differ in terms of their representation power and
  computational complexity of inference.  The more restricted the
  representational power, the faster the inference in general.

\item Propositional logic: we can only talk about facts and whether or
  not they are true.  In the worst case, we can use the brute force
  truth-table method to do inference.  Proof methods such as tableaux
  are generally more efficient, easier to implement, and easier to
  understand.
  
\item First-order logic: we can now talk about objects and relations
  between them, and we can quantify over objects.  Good for
  representing most interesting domains, but inference is not only
  expensive, but may not terminate.

\end{itemize}
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{Methodology: \\ a guide to axiomatising domains in 
FOL.\\1.}

\begin{itemize}
\item Define a model or microworld, as specifically and precisely as the
   nature of the domain allows. (Obviously, a much more concrete model
   can be given in the domain of spatial relations than in the domain
   of human emotions.)  You can then check for the soundness and
   consistency of your axioms by establishing that they are all true
   in the model.

\item    Do not cheat on your model. That is, if you find that you want to
   include in your axioms some new feature that is not in your model,
   do not just write down a new axiom.  Rather, you should rethink the
   model to include the new feature, and check that all of your axioms
   still make sense relative to the revised model.
   \end{itemize}
   
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{2.}

Make two tables enumerating all the sorts and all the non-logical
   primitives you use in your logic, with their definitions in terms
   of the model. If it is not possible to give necessary and
   sufficient conditions for the primitive, write down in English as
   precise a definition as you can manage, and try at least to bound
   the concept by giving some necessary conditions and some sufficient
   conditions.
   
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{3.}

Some of the tenets of good programming style hold for
   axiomatisations as well:
   
   \begin{enumerate}
   \item Non-logical primitives, like programming language identifiers,
      should be long enough that the reader can immediately know what
      they mean, but not so long that your axioms must be split up
      over many lines.
   \item Modularise. If you find the same subformula coming up again and
      again, define a new primitive to capture it.
   \item Use indentation and brackets to make the structure of the axiom
      apparent.
      \end{enumerate}
      
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{4.}

Cast a cold eye on every material implication.  Keep in mind that
   "$p \implies q$" means exactly "$\neg p \lor q$", and nothing more.
   
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{5.}

If you have written "$\forall x. p(x) \land q(x)$" it is likely that you
   have made a mistake.  Rewrite it as the two axioms
   "$\forall x. p(x)$" and "$\forall x. q(x)$" and see if it still makes sense.
   
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{6.}

\begin{itemize}
\item If you have written "$\exists x.  (p(x) \implies q(x))$" then it
is 100 to 1 that you have made a mistake.  Rewrite it in the logically
equivalent form "$(\exists x.  \neg p(x)) \lor (\exists x.  q(x))$"
and you will probably realize where you have gone wrong.
   
\item The only exception to this I have ever seen is where the
variable $x$ does not actually appear in the left hand side of the
implication; for instance, in a form like "$\forall y. \exists x. p(y)
\implies q(x,y)$".  Rewrite this for clarity as "$\forall y. p(y) 
\implies \exists x. q(x,y)$."

\end{itemize}
   
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{7.}

\begin{itemize}
    \item
If you have the implication "$p \implies q$", see if you can turn it
into a biconditional "$p \leftrightarrow q$."  You may have to
strengthen the right hand side to "$p\leftrightarrow (q \land r)$". 
This can be an easy way to get a more powerful theory.
    \item

   This does, however, require some care in choosing a grouping.
   Forms that are logically equivalent as implications may cease to be
   so when the implication is turned into a biconditional, and you
   have to choose the correct form. For instance, the two formulas
         $$\forall x. (\exists y. x = y+y) \implies \mbox{\tt even}(x)$$
   and 
         $$\forall x,y. x = y+y \implies \mbox{\tt even}(x)$$
   are equivalent. However, though the first can be turned into the
   correct biconditional
         $$\forall x. (\exists y. x = y+y) \leftrightarrow \mbox{\tt even}(x)$$
   the second cannot.

   \end{itemize}
       
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{7 bis.}

\begin{itemize}
    \item
   Another example: The assertion {\it "If a triangle is equilateral then
   it is equiangular"} can be represented
       $$\tt\forall X. (triangle(x) \land equilateral(x)) \implies 
       equiangular(x)$$
   To turn this into a biconditional, however, requires separating out
   the condition "$\tt triangle(x)$" as a condition on the entire
   biconditional.
       $$\tt\forall x. triangle(x) \implies (equilateral(x)) \leftrightarrow
       equiangular(x))$$
   \end{itemize}
       
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{8.}

Equality and function symbols are powerful representational tools;
   by all means, use them.  However, there are a number of common
   errors to be avoided.

   \begin{itemize}
   
   \item The formula "$x=y$" means that $x$ and $y$ are identical
   things; it is not a translation of "{\tt x is y}".  Beware: "{\tt
   Block1 = Red; Block2 = Blue; Block3 = Red.}" This would imply that
   {\tt Block1=Block3}.
   
      \item Keep in mind that functions in FOL are necessarily total. 
      Therefore formulas like "$\exists y.  y = {\sf f}(x)$" are
      always true and therefore vacuous.
   \end{itemize}
       
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{8 bis.}

   \begin{itemize}
   
      \item If you write down an FOL sentence containing the form
      "$x=t$" for some variable $x$ and term $t$, then you should
      think whether it is possible to simplify the sentence.  In
      particular, the sentence "$\forall x.  x=t \implies p(x)$" is
      equivalent to "$\forall x.  p(t)$".  If $t$ does not contain $x$,
      then this is equivalent to $p(t)$.  Similarly, "$\exists x.  x=t
      \land p(x)$" is equivalent to "$\exists x.  p(t)$".  If $t$ does
      not contain $x$, this is equivalent to $p(t)$.

     \item For example, if you are translating the sentence, {\it
     "Your father is older than you are,"} (in the sense of "you"
     meaning "everyone"), it is natural to gloss this as {\it "If X is
     the father of Y then X is older than Y"} and then to write it as
     "$\tt\forall y,y.  x=father(y) \implies older(y,y)$".  This can
     be expressed more elegantly as "$\tt\forall y. older(father(y),y).$"
  
      \item On the other hand, the original form with the explicit
      implication may lend itself to conversion to a biconditional, as
      discussed in (7) above.  For instance, the fact, {\it "2 is an
      even prime,"} if expressed in the form "$\tt \forall(x) x=2
      \implies (even(x) \land prime(x))$", can be easily converted to
      the biconditional {\it "2 is the only even prime,"} "$\tt
      \forall x.  x=2 \leftrightarrow (even(x) \land prime(x)).$"
   \end{itemize}
       
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{9.}

Keep in mind that FOL does not have negation as failure.  This is
   not Prolog.  This is particularly important in recursive
   definitions.  If you try to define "above" as the transitive
   closure of "on":
        $$\tt\forall x,y. on(z,y) \implies above(x,x)$$
        $$\tt\forall x,y,z.  (on(x,y) \land above(y,z)) \implies
        above(x,z)$$
   you will be able to prove that some things are above others, but
   you will never be able to prove that something is not above
   something else, because this definition is consistent with
   everything in the world being above everything.
   
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{10.}

Don't do programming.  FOL theories describe what's true, not how
    to compute things.  If you find yourself yearning for loops,
    reassignable variables, data structures, or gotos, then either
    you're on the wrong track or you should stop working in FOL and
    switch to a programming language.

\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{slide}{10 bis.}

\begin{itemize}
\item Check to see whether there exists a simpler or more general model
    for your axiomatisation than the microworld you have in mind.  For
    example, if you think a microworld involves gravity, then imagine
    a gravity-less version, and ask whether your axioms are still true
    in that.  Another example: some theories of spatial regions in the
    AI literature are in fact true of arbitrary sets.

\item    Finding such an alternative model can have its pros and cons.
    Clearly, it means that you have not captured all aspects of your
    microworld.  On the other hand, in a given application, you may
    not need these aspects. Identifying the axiomatisation as a
    description of a simpler model may lead you to effective
    algorithms, decidability results, and so on. But, one way or
    another, it is definitely a fact worth knowing about an axiomatic
    system.
    \end{itemize}
    
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}
