%! TEX root = LC.tex
% vim: tw=50
% 25/10/2024 11AM

We have new typing rules:
\begin{itemize}
  \item $\frac{\Gamma \trel M : \psi \times
    \varphi}{\Gamma \trel \pi_1(M) : \psi}$
  \item $\frac{\Gamma \trel M : \psi \times
    \varphi}{\Gamma \trel \pi_2(M) : \varphi}$
  \item $\frac{\Gamma \trel M : \psi}{\Gamma \trel
    \iota_1(M) : \psi + \varphi}$
  \item $\frac{\Gamma \trel N : \varphi}{\Gamma
    \trel \iota_2(N) : \psi + \varphi}$
  \item $\frac{\Gamma \trel M : \psi ~~ \Gamma
    \trel N : \varphi}{\Gamma \trel \langle M, N
    \rangle : \varphi \times \psi}$
  \item $\frac{\Gamma \trel L : \psi + \varphi ~~
    \Gamma, x : \psi \trel M : \rho ~~ \Gamma, y :
    \varphi \trel N : \rho}{\Gamma \trel \case(L;
    x^\psi . M; x^\varphi . N)}$
  \item $\frac{}{\Gamma \trel * : 1}$
  \item $\frac{\Gamma \trel M : 0}{\Gamma \trel
    !_\varphi M : \varphi}$ for each $\varphi \in
    \stypes$
\end{itemize}

They come with new reduction rules:
\begin{itemize}
  \item \textbf{Projections:} $\pi_1 \langle M, N
    \rangle \tob M$ and $\pi_2 \langle M, N
    \rangle \tob N$
  \item \textbf{Pairs:} $\langle \pi_1 M, \pi_2 M
    \rangle \toe M$
  \item \textbf{Definition by cases:}
    $\case(\iota_1(M); x  K; y . L) \tob K[x
    \defeq M]$ and $\case(\iota_2(M); x . K; y .
    L) \tob L[y \defeq M]$
  \item \textbf{Unit:} If $\Gamma \trel M : 1$,
    then $M \toe *$
\end{itemize}

When setting up Curry-Howard with these new types,
we let:
\begin{itemize}
  \item $0 \leftrightsquigarrow \false$
  \item $\times \leftrightsquigarrow \pand$
  \item $+ \leftrightsquigarrow \por$
  \item $\to \leftrightsquigarrow \to$
\end{itemize}

\begin{example}
  % Example 1.3.4
  Consider the following proof of $(\varphi \pand
  \chi) \to (\psi \to \varphi)$:
  \begin{logicproof}
    \frac{\ass{\varphi \pand \chi}}{\varphi}
    \qquad
    \ass{\psi}
    \\()
    \psi \to \varphi
    \\()
    (\varphi \pand \chi) \to (\psi \to \varphi)
  \end{logicproof}
  We decorate this proof by turning the
  assumptions into variables and following the
  Curry-Howard correspondence:
  \begin{logicproof}
    \frac{\ass{\varphi \pand \chi} : p}{\varphi :
    \pi_1(p)} \qquad \ass{\psi} : b
    \\()
    \psi \to \varphi : \lambda b : \psi . \pi_1(p)
    \\()
    (\varphi \pand \chi) \to (\psi \to \varphi)
  \end{logicproof}
\end{example}

\begin{center}
  \begin{tabular}{c|c}
    ST$\lambda$C
    & IPC \\
    \hline
    (primitive) types
    & (primitive) propositions \\
    variable
    & hypothesis \\
    ST$\lambda$-term
    & proof \\
    type constructor
    & logical connective \\
    term inhabitation
    & provability \\
    term reduction
    & proof normalisation
  \end{tabular}
\end{center}

\subsection{Semantics for IPC}

\begin{fcdefn}[Lattice]
  \glsnoundefn{latt}{lattice}{lattices}%
  \glsadjdefn{dist}{distributive}{\gls{latt}}%
  \glsadjdefn{bdd}{bounded}{\gls{latt}}%
  \glsadjdefn{comp}{complemented}{\gls{latt}}%
  \glsnoundefn{ba}{Boolean algebra}{Boolean
  algebras}%
  % Definition 1.4.1
  A \emph{lattice} is a set $L$ equipped with
  binary commutative and associative operations
  $\wedge$ and $\vee$ that satisfy the absorption
  laws:
  \[
    a \vee (a \wedge b) = a; \qquad a \wedge (a
    \vee b) = a
  ,\]
  for all $a, b \in L$.

  A lattice is:
  \begin{citems}
    \item \uncloze{\emph{Distributive}} if $a \wedge (b \vee
      c) = (a \wedge b) \vee (a \wedge c)$ for all
      $a, b, c \in L$.
    \item \uncloze{\emph{Bounded}} if there are elements
      $\bot, \top \in L$ such that $a \vee
      \bot = a$ and $a \wedge \top = a$.
    \item \uncloze{\emph{Complemented}} if it is bounded and
      for every $a \in L$ there is $a^* \in L$
      such that $a \wedge a^* = \bot$ and $a \vee
      a^* = \top$.
  \end{citems}
  A \emph{Boolean algebra} is a complemented
  distributive lattice.
\end{fcdefn}

Note that $\wedge$ and $\vee$ are idempotent in
any \gls{latt}. Moreover, we can define an
ordering on $L$ by setting $a \le b$ if $a \wedge
b = a$.

\begin{example}
  % Example 1.4.2
  \phantom{}
  \begin{enumerate}[(1)]
    \item For every set $I$, the power set
      $\mathcal{P}(I)$ with $\wedge \defeq \cap$
      and $\vee \defeq \cup$ is the prototypical
      \gls{ba}. More generally, the clopen subsets
      of a topological space form a \gls{ba}.
      Interestingly: every \gls{ba} corresponds to a
      \gls{ba} constructed in this way.
    \item The set of finite and cofinite subsets
      of $\Zbb$ is a \gls{ba}.
    \item The set of Zariski-closed subsets of the
      affine variety $\Cbb^n$ is a \gls{dist}
      \gls{latt} but not a \gls{ba}.
  \end{enumerate}
\end{example}
