%! TEX root = LST.tex
% vim: tw=50
% 13/02/2024 09AM

\begin{notation*}
  \glssymboldefn{pexists}{$\exists$}{$\exists$}
  We also introduce the symbols $\pand$, $\por$,
  $\pnot$ and $\true$ as in \cref{sec1}, and we
  also introduce the new symbol $(\pexists x) p$
  for $\pnot (\pforall x) \pnot p$.
\end{notation*}

\begin{flashcard}[free-variable-defn]
\begin{definition*}[Free occurence]
  \glsadjdefn{free}{free}{occurence}
  \glsadjdefn{bound}{bound}{occurence}
  \cloze{An occurence of a \gls{var} $x$ in a
    \gls{form} $p$
  is always \emph{free} except if $p = (\pforall
  x) q$, in which case the $\pforall x$ quantifier
  \emph{binds} every free occurence of $x$, and
  then such occurences of $x$ are called
  \emph{bound} occurences (the formal definition
  is by induction in $L$). Note that since the
  symbol $\pexists$ implicitly uses a $\pforall$,
  this symbol can also bind free occurences of a
\gls{var}.}
\end{definition*}
\end{flashcard}

\begin{example*}
  In the language of groups:
  \[ (\pexists x)(mxx = y) \pimpl (\pforall z)
  \pnot (mmzzz = y) \]
  Here the occurences of $x$ and $z$ are
  \gls{bound}, while the occurences of $y$ are
  \gls{free}.
  \[ (\pforall x)(\pforall y)(\pforall z) (mmxyz =
  mxmyz) \]
  has no free \glspl{var}.
  \[ (\pexists x)(mxx = y) \pimpl (\pforall
  y)(\pforall x)(myz = mzy) \]
  Technically the above is a correct \gls{form},
  where $y$ occurs both as a \gls{free} \gls{var}
  and a \gls{bound} \gls{var}, but
  in practise we avoid this.

  In the language of \glspl{poset}:
  \[ (\pforall x)(\pforall y)(((x \le y) \pand (y
  \le x)) \pimpl(x = y)) \]
  has no \gls{free} \glspl{var}.
\end{example*}

\begin{flashcard}[sentence-defn]
\begin{definition*}[Sentence]
  \glsnoundefn{sent}{sentence}{sentences}
  \cloze{A \emph{sentence} is a \gls{form} with no free
  \glspl{var}.}
\end{definition*}
\end{flashcard}

\begin{flashcard}[free-variable]
\begin{definition*}[Free variables]
  \glssymboldefn{FV}{FV}{FV}
  \glsadjdefn{freev}{free}{variable}
  \cloze{A \gls{var} $x$ in a \gls{form} is \emph{free} if
  it has a \gls{free} occurence in $p$. Let
  $\FV(p)$ denote the set of free \glspl{var} in
  $p$.}
\end{definition*}
\end{flashcard}

\begin{flashcard}[L-structure-defn]
\begin{definition*}[$L$-structure]
  \glsnoundefn{Lstruc}{$L$-structure}{$L$-structures}
  \glsnoundefn{struc}{structure}{structures}
  \cloze{Let $L = L(\pOmega, \pPi, \arity)$ be a
  \glsref[folang]{first-order folang}. A
  \emph{structure} in $L$ (or
  \emph{$L$-structure}) is a non-empty set $A$
  together with a function $\omega_A : A^n \to A$
  for every $\omega \in \pOmega$ where $n =
  \arity(\omega)$ and subsets $\varphi_A \subset
  A^n$ for every $\varphi \in \pPi$ where $n =
  \arity(\varphi)$ (or equivalently $\varphi_A :
  A^n \to \{0, 1\}$ by identifying a set with its
  indicator function).}
\end{definition*}
\end{flashcard}

\begin{example*}
  In language of groups: a \gls{struc} is a
  non-empty set $A$ with functions $m_A : A^2 \to
  A$, $i_A : A \to A$, $e_A \in A$ ($A^0$ is the
  singleton set). (An operation symbol with
  \gls{arity} $0$ is called a \emph{constant}).
  This is not a group yet!

  In the language of \glspl{poset}: a structure is
  a non-empty set $A$ with $\le_A \subset A^2$,
  i.e. a relation on $A$. This is not yet a
  \gls{poset}.
\end{example*}

\vspace{-1em}
\textbf{Next step:} to define for a formula $p$
what it means that ``$p$ is satisfied in $A$''.

\begin{example*}
  $p = (\pforall x)(mxix = e)$ in language of
  \glspl{poset}. $p$ satisfied in a structure $A$
  should mean that for all $a \in A$ we have
  $m_A(a, i_A(a)) = e_A$.
\end{example*}

\vspace{-1em}
Here is the formal definitoion in a \gls{folang}
$L = L(\pOmega, \pPi, \arity)$:

\begin{flashcard}[interpretation-defn]
\begin{definition*}[Interpretation of a term]
  \glsnoundefn{interp}{interpretation}{interpretations}
  \cloze{Let $A$ be an \gls{Lstruc}. A \gls{term} $t$ in
  $L$ with $\FV(t) \subset \{x_1, \ldots, x_n\}$ has
  \emph{interpretation} $t_A : A^n \to A$ defined
  as follows:
  \begin{itemize}
    \item If $t = x_i$, $1 \le i \le n$, then
      $t_A(a_1, \ldots, a_n) = a_i$.
    \item If $t = \omega t_1 \cdots t_m$ ($\omega
      \in \pOmega$, $m = \arity(\omega)$, $t_1,
      \ldots, t_m$ \glspl{term}), then
      \[ t_A(a_1, \ldots, a_n) = \omega_A((t_1)_A
      (a_1, \ldots, a_n), \ldots, (t_m)_A(a_1,
      \ldots, a_n)) \]
  \end{itemize}}
\end{definition*}
\end{flashcard}

\begin{example*}
  In groups,
  \[ t = m \ub{x_1}\ub{mx_2 x_3} \]
  has interpretation
  \[ t_A(a_1, a_2, a_3) = m_A(a_1, m_A(a_2, a_3))
  .\]
\end{example*}

\begin{flashcard}[interpretation-of-formula-defn]
\begin{definition*}[Interpretation of a formula]
  \glsnoundefn{interpf}{interpretation}{formula}
  \cloze{We interpret a \gls{form} $p$ with $\FV(p)
  \subset \{x_1, \ldots, x_n\}$ as a subset $p_A
  \subset A^n$ (or equivalently as a function $p_A
  : A^n \to \{0 1\}$).
  \begin{itemize}
    \item If $p = (s = t)$, then
      \[ p_A(a_1, \ldots, a_n) = 1 \iff s_A(a_1,
      \ldots, a_n) = t_A(a_1, \ldots, a_n) \]
    \item If $p = \varphi t_1 \cdots t_m$
      ($\varphi \in \pPi$, $m = \arity(\varphi)$,
      $t_1, \ldots, t_m$ \glspl{term}), then
      \[ p_A(a_1, \ldots, a_n) = 1 \iff
      \varphi_A((t_1)_A (a_1, \ldots, a_n),
      \ldots, (t_m)_A (a_1, \ldots, a_n)) = 1 \]
    \item $\pperp_A$ is the constant $0$ function.
    \item $p = (q \implies r)$:
      \[ p_A(a_1, \ldots, a_n) = 0 \iff q_A(a_1,
      \ldots, a_n) = 1 \quad \text{and} \quad r_A(x_1, \ldots,
      a_n) = 0 \]
    \item $p = (\pforall x_{n + 1}) q$ where
      $\FV(q) \subset \{x_1, \ldots, x_{n + 1}\}$:
      \[ p_A = \{(a_1, \ldots, a_n) \in A^n \st
      (a_1, \ldots, a_n, a_{n + 1}) \in q_A \text{
      for all $a_{n + 1} \in A$}\} \]
  \end{itemize}
  }
\end{definition*}
\end{flashcard}

\begin{example*}
  In groups, if $p = (mmxyz = mxmyz)$ has
  \gls{interpf}
  \[ p_A = \{(a, b, c) \in A^3 \st m_A(m_A(a, b),
  c) = m_A(a, m_A(b, c))\} .\]
  The formula $q = (\pforall x)(\pforall
  y)(\pforall z) p$ has \gls{interpf} $q_A = 1$
  if and only if $p_A = A^3$.
\end{example*}

\begin{flashcard}[satisfied-formula-defn]
\begin{definition*}[Satisfied formula]
  \glsadjdefn{satisfied}{satisfied}{\gls{form}}
  \glsnoundefn{fmodel}{model}{models}
  \cloze{A \gls{form} $p$ in a \gls{folang} $L$ is
  \emph{satisfied} in an \gls{Lstruc} $A$ if $p_A
  = A^n$ ($n$ is the number of \gls{freev}
  variables in $p$), or equivalently $p_A$ is the
  constant $1$ function. We also say \emph{$p$
  holds in $A$} or \emph{$p$ is true in $A$} or
  \emph{$A$ is a model for $p$}.}
\end{definition*}
\end{flashcard}

\begin{flashcard}[theory-defn]
\begin{definition*}[Theory]
  \glsnoundefn{theory}{theory}{theories}
  \cloze{A \emph{theory} in a \gls{folang} $L$ is a set
  of \glspl{sent} in $L$.}
\end{definition*}
\end{flashcard}

\begin{flashcard}[model-for-theory-defn]
\begin{definition*}[Model-defn]
  \glsnoundefn{model}{model}{models}
  \cloze{A \emph{model} for a \gls{theory} $T$ is an
  \gls{Lstruc} $A$ that is a \gls{fmodel} for all
  $p \in T$.}
\end{definition*}
\end{flashcard}

\subsubsection*{Examples}

\begin{enumerate}[(1)]
  \item Theory of groups: the \gls{folang} is
    specified by $\pOmega = \{m, i, e\}$ (with
    arities $2, 1, 0$ respectively) and $\pPi =
    \emptyset$. The \gls{theory} is
    \begin{align*}
      T = \{
      &(\pforall x)(\pforall y)(\pforall
      z)(mmxyz = mxmyz), \\
      &(\pforall x)((mxe = x) \pand (mex = x)), \\
      &(\pforall x)((mxix = e) \pand (mixx =
      e))\}
    \end{align*}
    Then \glspl{model} for $T$ are precisely
    groups. So we can axiomatise groups as a
    first-order \gls{theory}.
  \item \glsref[poset]{Partially ordered sets}
    $\pOmega = \emptyset$, $\pPi = \{\le\}$
    (with arity $2$).
    \begin{align*}
      T = \{
      &(\pforall x)(x \le x), \\
      &(\pforall x)(\pforall y)(((x \le y)
      \pand (y \le x)) \pimpl (x = y), \\
      &(\pforall x)(\pforall y)(\pforall z)(((x
      \le y) \pand (y \le z)) \pimpl (x \le
      z))\}
    \end{align*}
    Then \glspl{model} are precisely
    \glspl{poset}.
