\chapter{Derived Inference Rules}
\label{derived-rules}

The notion of {\it proof\/} is defined abstractly in the manual
\LOGIC: a proof of a sequent $(\Gamma,t)$ from a set of sequents
$\Delta$ (with respect to a deductive system ${\cal D}$) was defined
to be a chain of sequents culminating in $(\Gamma,t)$, such that every
element of the chain either belongs to $\Delta$ or else follows from
$\Delta$ and earlier elements of the chain by deduction.  The notion
of a {\it theorem\/} was also defined in \LOGIC: a theorem of a
deductive system is a sequent that follows from the empty set of
sequents by deduction; \ie, it is the last element of a proof from the
empty set of sequents, in the deductive system.  In this section,
proofs and theorems are made concrete in \HOL.

The deductive system of \HOL\
was sketched in Section~\ref{rules}, where
the eight families of primitive inferences making up the
deductive system were specified by diagrams. It was explained that
these families of inferences are represented in \HOL\ via
\ML\ functions, and that theorems
are represented by an \ML\ abstract type called \ml{thm}.\index{thm@\ml{thm}}
The eight \ML\ functions corresponding to the inferences
are operations of the type \ml{thm}, and each of the eight
returns a value of type \ml{thm}. It was explained that the
type \ml{thm} has primitive destructors, but no primitive
constructor; and that in that way, the logic is protected against
the computation of theorems except by functions representing
primitive inferences, or compositions of these.

Finally, the primitive \HOL\ logic was supplemented by three primitive
constants and four axioms, to form the basic logic.  The primitive
inferences, together with the primitive constants, the five axioms,
and a collection of definitions, give a starting point for
constructing proofs, and hence computing theorems. However, proving
even the simplest theorems from this minimal basis costs considerable
effort. The basis does not immediately provide the transitivity of
equality, for example, or a means of universal quantification; both of
these themselves have to be derived.

\section{Simple Derivations}

As an illustration of a proof in \HOL{}, the following chain of
theorems forms a proof (from the empty set, in the \HOL{} deductive
system), for the particular terms \ml{``}$t_1$\ml{``}%''
and \ml{``}$t_2$\ml{``},%''
both of \HOL\ type \ml{``:bool``}:%''

\begin{enumerate}
\item $t_1$\ml{ ==> }$t_2$\ml{ |- }$t_1$\ml{ ==> }$t_2$

\item $t_1$\ml{ |- }$t_1$

\item $t_1$\ml{ ==> }$t_2$\ml{, }$t_1$\ml{ |- }$t_2$
\end{enumerate}

\noindent That is, the third theorem follows from the first and second.

In the session below, the proof is performed in the \HOL\ system,
using the \ML\ functions \ml{ASSUME}\index{ASSUME@\ml{ASSUME}} and
\ml{MP}.

\setcounter{sessioncount}{1}
\begin{session}
\begin{verbatim}
- show_assums := true;
> val it = () : unit

- val th1 = ASSUME ``t1 ==> t2``;
> val th1 = [t1 ==> t2] |- t1 ==> t2 : thm

- val th2 = ASSUME ``t1:bool``
> val th2 = [t1] |- t1 : thm

- MP th1 th2;
> val it = [t1 ==> t2, t1] |- t2 : thm
\end{verbatim}
\end{session}

\noindent More briefly, one could evaluate the following, and `count'\index{counting inferences, in HOL proofs@counting inferences, in \HOL{} proofs} the
invocations of functions representing primitive inferences.

\begin{session}
\begin{verbatim}
#set_flag(`timing`, true);;
false : bool
Run time: 0.0s

#MP(ASSUME "t1 ==> t2")(ASSUME "t1:bool");;
t1 ==> t2, t1 |- t2
Run time: 0.0s
Intermediate theorems generated: 3
\end{verbatim}
\end{session}

\noindent Each of the three inference steps of the abstract proof
corresponds to the application%
%
\index{inferences, in HOL logic@inferences, in \HOL{} logic!as ML function applications@as \ML\ function applications}%
\index{proof steps, as ML function applications@proof steps, as \ML\ function applications}%
\index{proof!the notion of, in HOL system@the notion
  of, in \HOL\ system}%
%
of an \ML\ function in the performance of the proof in \HOL; and each
of the \ML\ functions corresponds to a primitive inference of the
deductive system.

It is worth emphasising that, in either case, every
primitive inference in the proof chain is made, in the sense
that for each inference, the corresponding \ML\ function is evaluated.  That is,
\HOL\ permits no short-cut around the necessity of performing
complete proofs.  The short-cut provided by derived
\index{inferences, in HOL logic@inferences, in \HOL{} logic!in derived rules}
inference rules (as implemented in \ML) is around the necessity of
\emph{specifying} every step; something that would be impossible for
a proof of any length. It can be seen from this that the derived
rule,%
%
\index{proofs, in HOL logic@proofs, in \HOL{} logic!as ML function applications@as \ML\ function applications}
\index{proofs, in HOL logic@proofs, in \HOL{} logic!as generated by derived rules}
\index{derived rules, in HOL logic@derived rules, in \HOL{} logic!importance of}
%
and its representation as an \ML{} function, is essential to the
\HOL{} methodology; theorem proving would be otherwise impossible.

There are, of course, an infinite number of proofs, of the `form'
shown in the example, that can be conducted in \HOL: one for every
pair of \ml{``:bool``}-typed terms. %''
Moreover, every time a theorem of the form

$$t_1 \ \imp \ t_2, \ t_1 \ \vdash \ t_2$$

\noindent is required, its proof must be constructed anew. To capture the
general pattern of inference, an \ML\ function can be written to
implement an inference rule as a derivation from the primitive inferences.
Abstractly, a \emph{derived inference rule}
\index{derived rules, in HOL logic@derived rules, in \HOL{} logic!justification of}
%
is a rule that can be justified on the basis of the primitive
inference rules (and/or the axioms).  In the present case, the rule
required `undischarges' assumptions.  It is specified for \HOL{} by

\bigskip

\begin{center}
\begin{tabular}{c}
$\Gamma${\small\verb% |- %}$t_1${\small\verb% ==> %}$t_2$\\ \hline
$\Gamma\cup\{t_1\}${\small\verb% |- %}$t_2$
\end{tabular}
\end{center}

\bigskip

\noindent This general rule is valid because from a \HOL\ theorem of the
form $\Gamma${\small\verb% |- %}$t_1${\small\verb%==>%}$t_2$, the theorem
$\Gamma\cup\{t_1\}${\small\verb% |- %}$t_2$ can be derived
as for the specific instance above.
The rule can be implemented in \ML\ as a function (\ml{UNDISCH},
say)\index{UNDISCH@\ml{UNDISCH}} that calls the
appropriate sequence of primitive
inferences. The \ML\ definition of \ml{UNDISCH} is simply

\begin{session}
\begin{verbatim}
- val UNDISCH th = MP th (ASSUME(fst(dest_imp(concl th))));;
> val UNDISCH = fn : thm -> thm
\end{verbatim}
\end{session}

\noindent This provides a function that maps a theorem to a theorem;
that is, performs proofs in \HOL.
The following session illustrates the use of the derived rule, on
a consequence of the axiom \ml{IMP\_ANTISYM\_AX}. (The inferences are
counted.%
\index{counting inferences, in HOL proofs@counting inferences, in \HOL{} proofs}%
%
) Assume that the printing of theorems has been adjusted as above and
\ml{th} is bound as shown below:

\setcounter{sessioncount}{1}
\begin{session}
\begin{verbatim}
#th;;
|- (t1 ==> t2) ==> (t2 ==> t1) ==> (t1 = t2)
Run time: 0.0s

#set_flag(`timing`,true);;
true : bool
Run time: 0.0s

#UNDISCH th;;
t1 ==> t2 |- (t2 ==> t1) ==> (t1 = t2)
Run time: 0.1s
Intermediate theorems generated: 2

#UNDISCH it;;
t1 ==> t2, t2 ==> t1 |- t1 = t2
Run time: 0.0s
Intermediate theorems generated: 2
\end{verbatim}
\end{session}

\noindent Each successful application of {\small\verb%UNDISCH%}
to a theorem invokes an application
of {\small\verb%ASSUME%}, followed by an application of {\small\verb%MP%};
\ml{UNDISCH} constructs the
2-step proof for any given theorem (of appropriate form).
As can be
seen, it relies on the class of \ML\ functions that access \HOL\ syntax:
in particular, \ml{concl} to produce the conclusion
of the theorem, \ml{dest\_imp} to separate the implication, and the
selector \ml{fst} to choose the antecedent.

This particular example is very simple, but a derived inference rule
can perform proofs of arbitrary length.  It can also make use of
previously defined rules.  In this way, the normal inference patterns
can be developed much more quickly and easily; transitivity,
generalization, and so on, support the familiar patterns of inference.

A number of derived inference rules are pre-defined when the \HOL\
system is entered (of which \ml{UNDISCH} is one of the first).  In
Section~\ref{avra_standard}, the abstract derivations are given for
the pre-defined rules that reflect the more usual inference patterns
of the predicate (and lambda) calculi.  Like those shown, some of the
pre-defined derived rules in \HOL\ generate relatively short proofs.
Others invoke thousands of primitive inferences, and clearly save a
great deal of effort. Furthermore, rules can be defined by the user to
make still larger steps, or to implement more specialized patterns.

All of the pre-defined derived rules in \HOL\ are described
in \REFERENCE.

\section{Rewriting}
\label{avra_rewrite}

\index{rewriting!rules for|(}
\index{REWRITE_RULE@\ml{REWRITE\_RULE}|(}
Included in the set of derived inferences that are pre-defined in
\HOL\ is a group of rules with complex definitions that do a limited
amount of `automatic' theorem-proving in the form of rewriting.  The
ideas and implementation were originally developed by
Milner\index{Milner, R.}  and Wadsworth\index{Wadsworth, C.} for
Edinburgh \LCF,\index{LCF@\LCF!Edinburgh} and were later implemented
more flexibly and efficiently by Paulson\index{Paulson, L.} and
Huet\index{Huet, G.} for Cambridge \LCF.\index{LCF@\LCF!Cambridge}
They appear in \HOL{} in the Cambridge form. The basic rewriting rule
is \ml{REWRITE\_RULE}.  All of the rewriting rules are described in
detail in \REFERENCE.

\ml{REWRITE\_RULE} uses a list of equational theorems
\index{equational theorems, in HOL logic@equational theorems, in \HOL{} logic!use of in rewriting}
\index{theorems, in HOL logic@theorems, in \HOL{} logic!equational}
(theorems whose conclusions can be regarded as having the form
$t_1${\small\verb% = %}$t_2$) to replace
any subterms of an object theorem that `match' $t_1$ by the
corresponding instance of $t_2$. The rule matches recursively and to any depth,
until no more replacements can be made,
using internally defined search, matching and
instantiation\index{type instantiation, in HOL logic@type instantiation, in \HOL{} logic!in rewriting rule} algorithms.  The validity
 of \ml{REWRITE\_RULE} rests
ultimately on the primitive rules \ml{SUBST} (for making the substitutions);
\ml{INST\_TYPE}\index{INST_TYPE@\ml{INST\_TYPE}} (for instantiating types); and the derived rules for
generalization and specialization (see Sections~\ref{avra_gen}
and \ref{avra_spec}) for instantiating terms.  The definition
of \ml{REWRITE\_RULE} in \ML\
also relies on a large number of general and \HOL-oriented
\ML\ functions.
%The implementation is partly described in Chapter~\ref{avra_conv}.

In practice, the derived rule \ml{REWRITE\_RULE} plays a central role
in proofs, because it takes over a very large number of inferences
which may happen in a complex and unpredictable order. It is unlike
any other primitive or pre-defined rule, first because of the number
of inferences it generates\footnote{The number of inferences performed
  by this rule is generally `inflated'; \ie\ is generally greater than
  the length of the proof itself, if the proof could be `seen'.  This
  is because, in the current implementation, some inference is done
  during the search phase that is not necessarily in support of
  successful replacements.}; and second because its outcome is often
unexpected. Its power is increased by the fact that any existing
equational theorem can be supplied as a `rewrite rule', including a
standard \HOL\ set of pre-proved tautologies; and these rewrite rules
can interact with each other in the rewriting process to transform the
original theorem.

The application of \ml{REWRITE\_RULE}, in the session below,
illustrates that replacements are made at all levels of the
structure of a term.
The example is numerical;
the infixes {\small\verb%"$>"%} and {\small\verb%"$<"%} are
the usual `greater than'  and `less than' relations, respectively,
and \ml{"SUC"}, the
usual successor function.
Use is made of the pre-existing definition of {\small\verb%"$>"%}:
\ml{GREATER} (see \REFERENCE).
The timing\index{counting inferences, in HOL proofs@counting inferences, in \HOL{} proofs} facility is used again, for interest, and the printing
of theorems is adjusted as above.

\setcounter{sessioncount}{1}
\begin{session}
\begin{verbatim}
#top_print print_all_thm;;
- : (thm -> void)

#set_flag(`timing`,true);;
false : bool
Run time: 0.0s

#REWRITE_RULE
 [GREATER]
 (ASSUME "SUC 4 > 0 = (SUC 3 > 0 = (SUC 2 > 0 = (SUC 1 > 0 = SUC 0 > 0)))");;
##Definition GREATER autoloaded from theory `arithmetic`.
GREATER = |- !m n. m > n = n < m
Run time: 1.5s
Intermediate theorems generated: 1

(SUC 4) > 0 =
((SUC 3) > 0 = ((SUC 2) > 0 = ((SUC 1) > 0 = (SUC 0) > 0)))
|- 0 < (SUC 4) =
   (0 < (SUC 3) = (0 < (SUC 2) = (0 < (SUC 1) = 0 < (SUC 0))))
Run time: 0.3s
Intermediate theorems generated: 23
\end{verbatim}
\end{session}

\noindent Notice that rewriting
equations can be extracted from
universally quantified theorems.
To construct the
proof step-wise, with all of the instantiations,
substitutions, and uses of transitivity, \etc,
would be a lengthy process. The rewriting rules make it easy,
and do so whilst still generating the entire chain of inferences.
\index{REWRITE_RULE@\ml{REWRITE\_RULE}|)}
\index{rewriting!rules for|)}

\section{Derivation of the Standard Rules}
\label{avra_standard}

\index{derived rules, in HOL logic@derived rules, in \HOL{} logic!pre-defined|(}
%
The \HOL{} system provides all the standard introduction and
elimination rules of the predicate calculus pre-defined as derived
inferences.  It is these derived rules, rather than the primitive
rules, that one normally uses in practice.  In this section, the
derivations of some of the standard rules are given, in sequence.
These derivations only use the axioms and definitions in the theory
\theoryimp{bool} (see Section~\ref{boolfull}), the eight primitive
inferences of the \HOL\ logic, and inferences defined earlier in the
sequence.

Theorems,%
%
\index{theorems, in HOL logic@theorems, in \HOL{} logic!as inference rules}%
%
in accordance with the definition given at the beginning of this
chapter, are treated as rules without hypotheses; thus the derivation
of a theorem resembles the derivation of a rule except in not having
hypotheses. (The derivation of \ml{TRUTH}, Section~\ref{avra_T}, is
the only example given of this, but there are several others in \HOL.)
There are also some rules that are intrinsically more general than
theorems.  For example, for any two terms $t_1$ and $t_2$, the theorem
$\vdash(\lquant{x}t_1)t_2 = t_1[t_2/x]$ follows by the primitive rule
\rul{BETA\_CONV}. The rule \ml{BETA\_CONV} returns a theorem for each
pair of terms $t_1$ and $t_2$, and is therefore equivalent to an
infinite family%
%
\index{families of inferences, in HOL logic@families of inferences, in \HOL{} logic}%
%
of theorems. No single theorem can be expressed in the \HOL{} logic
that is equivalent to \rul{BETA\_CONV}.%
\index{theorems, in HOL logic@theorems, in \HOL{} logic!rules inexpressible as}
\index{beta-conversion, in HOL logic@beta-conversion, in \HOL{} logic!not expressible as a theorem}%
%
%(See Chapter~\ref{avra_conv} for further discussion of this point.)
(\ml{UNDISCH} is not a rule of this sort, as it can, in fact, be
expressed as a theorem.)

For each derivation given below, there is an \ML\ function definition
in the \HOL\ system that implements the derived rule as a procedure in
\ML. The actual implementation in the \HOL\ system differs in some
cases from the derivations given here, since the system code has been
optimised for improved performance.

In addition, for reasons that are mostly historical, not all the
inferences that are derived in terms of the abstract logic are
actually derived in the current version of the \HOL\ system.  That is,
there are currently about forty rules that are installed in the system
on an `axiomatic' basis, all of which should be derived by explicit
inference.  Although the current status of these rules is not
satisfactory, and it is planned, as a high priority, to derive them
properly in a future version, their current status does not actually
compromise the consistency of the logic.  In effect, the existing
\HOL\ system has a deductive system more comprehensive than the one
presented abstractly, but the model outlined in \LOGIC{} would easily
extend to cover it.%
%
\index{derived rules, in HOL logic@derived rules, in \HOL{} logic!pre-defined|)}

For reference, in \HOL\ Version 2.0 the following rules that should be
derived
%
\index{inference rules, of HOL logic@inference rules, of \HOL{} logic!some not properly derived|(}
\index{rules in HOL logic, some not properly derived@rules in \HOL{} logic, some not properly derived|(}
%
are not derived, but (for efficiency) are implemented as
primitives. The list includes some conversions and conversion-valued
functions. % (conversions are discussed in Chapter~\ref{avra_conv}).
\vfill \newpage

\begin{hol}
\index{derived rules, in HOL logic@derived rules, in \HOL{} logic!list of axiomatic}
\index{AP_TERM@\ml{AP\_TERM}}
\index{AP_THM@\ml{AP\_THM}}
\index{CCONTR@\ml{CCONTR}}
\index{CHOOSE@\ml{CHOOSE}}
\index{CONJ@\ml{CONJ}}
\index{CONJUNCT1@\ml{CONJUNCT1}}
\index{CONJUNCT2@\ml{CONJUNCT2}}
\index{DISJ_CASES@\ml{DISJ\_CASES}}
\index{DISJ1@\ml{DISJ1}}
\index{DISJ2@\ml{DISJ2}}
\index{EQ_IMP_RULE@\ml{EQ\_IMP\_RULE}}
\index{EQ_MP@\ml{EQ\_MP}}
\index{EQT_INTRO@\ml{EQT\_INTRO}}
\index{ETA_CONV@\ml{ETA\_CONV}}
\index{EXISTS@\ml{EXISTS}}
\index{EXT@\ml{EXT}}
\index{GEN@\ml{GEN}}
\index{MK_ABS@\ml{MK\_ABS}}
\index{MK_COMB@\ml{MK\_COMB}}
\index{num_CONV@\ml{num\_CONV}}
\index{SPEC@\ml{SPEC}}
\index{SUBS@\ml{SUBS}}
\index{SUBS_OCCS@\ml{SUBS\_OCCS}}
\index{SUBST_CONV@\ml{SUBST\_CONV}}
\index{SYM@\ml{SYM}}
\index{TRANS@\ml{TRANS}}
\begin{verbatim}
   ADD_ASSUM              CONTR                  IMP_ANTISYM_RULE
   ALPHA                  DEF_EXISTS_RULE        IMP_TRANS
   AP_TERM                DISJ_CASES             INST
   AP_THM                 DISJ1                  MK_ABS
   SUBS                   DISJ2                  MK_COMB
   SUBS_OCCS              EQ_IMP_RULE            MK_EXISTS
   CCONTR                 EQ_MP                  NOT_ELIM
   CHOOSE                 EQT_INTRO              NOT_INTRO
   CONJ                   ETA_CONV               num_CONV
   EXISTS                 SPEC                   TRANS
   EXT                    SUBST_CONV             CONJUNCT1
   GEN                    SYM                    CONJUNCT2
\end{verbatim}\end{hol}
\index{inference rules, of HOL logic@inference rules, of \HOL{} logic!some not properly derived|)}
\index{rules in HOL logic, some not properly derived@rules in \HOL{} logic, some not properly derived|)}

\index{inference rules, of HOL logic@inference rules, of \HOL{} logic!derived|(}
The derivations that follow consist of sequences of numbered steps each of
which
\begin{enumerate}
\item is an axiom, or
\item is a hypothesis of the rule being derived, or
\item follows from preceding steps by a rule of inference (either primitive
or previously derived).
\end{enumerate}

\noindent Note that the abbreviation \ml{conv} (standing for
`conversion') is used for the \ML\ type \ml{term ->
  thm}.%
% \footnote{This stands for `conversion', as explained in
% Chapter~\ref{avra_conv}.}

\subsection{Adding an assumption}
\index{derived rules, in HOL logic@derived rules, in \HOL{} logic!list and derivations of some|(}

\begin{holboxed}
\index{ADD_ASSUM@\ml{ADD\_ASSUM}|pin}
\begin{verbatim}
   ADD_ASSUM : term -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t\over \Gamma,\ t'\turn t$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $t'\turn t'$ \hfill [\rul{ASSUME}]
\item $\Gamma\turn t$ \hfill [Hypothesis]
\item $\Gamma\turn t'\imp t$ \hfill [\rul{DISCH} 2]
\item $\Gamma,\ t'\turn t$ \hfill [\rul{MP} 3,1]
\end{proof}

%\subsection{Undischarging [\rul{UNDISCH}]}
\subsection{Undischarging}

\begin{holboxed}
\index{implication, in HOL logic@implication, in \HOL{} logic!inference rules for}
\index{UNDISCH@\ml{UNDISCH}|pin}
\begin{verbatim}
   UNDISCH : thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1\imp t_2 \over\Gamma,\ t_1\turn t_2$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $t_1\turn t_1$ \hfill [\rul{ASSUME}]
\item $\Gamma\turn t_1\imp t_2$ \hfill [Hypothesis]
\item $\Gamma,\ t_1\turn t_2$ \hfill [\rul{MP} 2,1]
\end{proof}

\subsection{Symmetry of equality}

\begin{holboxed}
\index{SYM@\ml{SYM}|pin}
\index{symmetry of equality rule, in HOL logic@symmetry of equality rule, in \HOL{} logic}
\index{equality, in HOL logic@equality, in \HOL{} logic!symmetry rule for}
\begin{verbatim}
   SYM : thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1 = t_2\over \Gamma\turn t_2 = t_1$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma\turn t_1=t_2$\hfill [Hypothesis]
\item $\turn t_1=t_1$ \hfill [\rul{REFL}]
\item $\Gamma\turn t_2=t_1$\hfill [\rul{SUBST} 1,2]
\end{proof}

\subsection{Transitivity of equality}

\begin{holboxed}
\index{transitivity of equality rule, in HOL logic@transitivity of equality rule, in \HOL{} logic}
\index{equality, in HOL logic@equality, in \HOL{} logic!transitivity rule for}
\index{TRANS@\ml{TRANS}|pin}
\begin{verbatim}
   TRANS : thm -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma_1\turn t_1=t_2\qquad\qquad\qquad \Gamma_2\turn t_2=t_3 \over
\Gamma_1\cup\Gamma_2\turn t_1=t_3$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma_2\turn t_2=t_3$\hfill [Hypothesis]
\item $\Gamma_1\turn t_1=t_2$\hfill [Hypothesis]
\item $\Gamma_1\cup\Gamma_2\turn t_1=t_3$\hfill [\rul{SUBST} 1,2]
\end{proof}

\subsection{Application of a term to a theorem}%
\index{function application, in HOL logic@function application, in \HOL{} logic!inference rules for}

\begin{holboxed}
\index{AP_TERM@\ml{AP\_TERM}|pin}
\begin{verbatim}
   AP_TERM : term -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1=t_2\over\Gamma\turn t\ t_1 = t\ t_2$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma\turn t_1=t_2$\hfill [Hypothesis]
\item $\turn t\ t_1 = t\ t_1$ \hfill [\rul{REFL}]
\item $\Gamma\turn t\ t_1 = t\ t_2$ \hfill [\rul{SUBST} 1,2]
\end{proof}

\subsection{Application of a theorem to a term}

\begin{holboxed}
\index{AP_THM@\ml{AP\_THM}|pin}
\begin{verbatim}
   AP_THM : thm -> conv
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1=t_2\over \Gamma\turn t_1\ t = t_2\ t$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma\turn t_1=t_2$\hfill [Hypothesis]
\item$\turn t_1\ t = t_1\ t$\hfill [\rul{REFL}]
\item $\Gamma\turn t_1\ t = t_2\ t$\hfill [\rul{SUBST} 1,2]
\end{proof}

\subsection{Modus Ponens for equality}
\label{avra_eq_mp}

\begin{holboxed}
\index{EQ_MP@\ml{EQ\_MP}|pin}
\index{equality, in HOL logic@equality, in \HOL{} logic!MP rule for@\ml{MP} rule for}
\begin{verbatim}
   EQ_MP : thm -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma_1\turn t_1=t_2\qquad\qquad\qquad \Gamma_2\turn t_1\over
\Gamma_1\cup\Gamma_2\turn t_2$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma_1\turn t_1=t_2$ \hfill [Hypothesis]
\item $\Gamma_2\turn t_1$ \hfill [Hypothesis]
\item $\Gamma_1\cup\Gamma_2\turn t_2$ \hfill [\rul{SUBST} 1,2]
\end{proof}

\subsection{Implication from equality}
\index{equality, in HOL logic@equality, in \HOL{} logic!other rules for|(}
\index{implication, in HOL logic@implication, in \HOL{} logic!inference rules for}
\begin{holboxed}
\index{EQ_IMP_RULE@\ml{EQ\_IMP\_RULE}|pin}
\begin{verbatim}
   EQ_IMP_RULE : thm -> (thm # thm)
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1=t_2\over
\Gamma\turn t_1\imp t_2 \qquad\qquad\qquad \Gamma\turn t_2\imp t_1$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma\turn t_1=t_2$ \hfill [Hypothesis]
\item $t_1\turn t_1$ \hfill [\rul{ASSUME}]
\item $\Gamma,\ t_1\turn t_2$ \hfill [\rul{EQ\_MP} 1,2]
\item $\Gamma\turn t_1\imp t_2$ \hfill [\rul{DISCH} 3]
\item $\Gamma\turn t_2=t_1$ \hfill [\rul{SYM} 1]
\item $t_2\turn t_2$ \hfill [\rul{ASSUME}]
\item $\Gamma,\ t_2\turn t_1$ \hfill [\rul{EQ\_MP} 5,6]
\item $\Gamma\turn t_2\imp t_1$ \hfill [\rul{DISCH} 7]
\item $\Gamma\turn t_1\imp t_2$ and $\Gamma\turn t_2\imp t_1$\hfill [4,8]
\end{proof}

\subsection{\T-Introduction}
\label{avra_T}

\index{T@\holtxt{T}!rules of inference for|(}
\begin{hol}
\begin{verbatim}
   TRUTH
\end{verbatim}
\end{hol}

\vspace{12pt plus2pt minus1pt}

$$\turn\T$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn \T = ((\lquant{x}x)=(\lquant{x}x))$\hfill [Definition of \T]
\item $\turn ((\lquant{x}x)=(\lquant{x}x)) = \T$\hfill [\rul{SYM} 1]
\item $\turn (\lquant{x}x)=(\lquant{x}x)$\hfill [\rul{REFL}]
\item $\turn\T$ \hfill [\rul{EQ\_MP} 2,3]
\end{proof}

\subsection{Equality-with-\T\ elimination}

\begin{holboxed}
\index{EQT_ELIM@\ml{EQT\_ELIM}|pin}
\begin{verbatim}
   EQT_ELIM : thm -> thm
\end{verbatim}
\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t = \T\over \Gamma\turn t$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma\turn t = \T$\hfill [Hypothesis]
\item $\Gamma\turn \T = t$\hfill [\rul{SYM} 1]
\item $\turn \T$\hfill [\rul{TRUTH}]
\item $\Gamma\turn t$\hfill [\rul{EQ\_MP} 2,3]
\end{proof}

\subsection{\texorpdfstring{Specialization ($\forall$-elimination)}{Specialization (forall-elimination)}}

\begin{holboxed}
\index{SPEC@\ml{SPEC}|pin}
\index{specialization rule, in HOL logic@specialization rule, in \HOL{} logic}
\begin{verbatim}
   SPEC : term -> thm -> thm
\end{verbatim}
\end{holboxed}

\label{avra_spec}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn \uquant{x}t\over \Gamma\turn t[t'/x]$$
\begin{itemize}
\item $t[t'/x]$ denotes the result of substituting $t'$ for free\index{free variables, in HOL logic@free variables, in \HOL{} logic}
occurrences of $x$ in $t$, with the restriction that no free variables in $t'$
become bound after substitution.
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn \forall = (\lquant{P}P = (\lquant{x}\T))$ \hfill
[\rul{INST\_TYPE} applied to the definition of $\forall$]
\item $\Gamma\turn \forall(\lquant{x}t)$\hfill [Hypothesis]
\item $\Gamma\turn (\lquant{P}P=(\lquant{x}\T))(\lquant{x}t)$\hfill
[\rul{SUBST} 1,2]
\item $\turn  (\lquant{P}P=(\lquant{x}\T))(\lquant{x}t) =
((\lquant{x}t)=(\lquant{x}\T))$\hfill [\rul{BETA\_CONV}]
\item $\Gamma\turn (\lquant{x}t)=(\lquant{x}\T)$\hfill [\rul{EQ\_MP} 4,3]
\item $\Gamma\turn (\lquant{x}t)\ t' = (\lquant{x}\T)\ t'$ \hfill
[\rul{AP\_THM} 5]
\item $\turn (\lquant{x}t)\ t' = t[t'/x]$ \hfill [\rul{BETA\_CONV}]
\item $\Gamma\turn t[t'/x] = (\lquant{x}t)\ t'$ \hfill [\rul{SYM} 7]
\item $\Gamma\turn t[t'/x] = (\lquant{x}\T)\ t'$ \hfill [\rul{TRANS} 8,6]
\item $\turn (\lquant{x}\T)\ t' = \T$ \hfill [\rul{BETA\_CONV}]
\item $\Gamma\turn t[t'/x] = \T$ \hfill [\rul{TRANS} 9,10]
\item $\Gamma\turn t[t'/x]$ \hfill [\rul{EQT\_ELIM} 11]
\end{proof}

\subsection{Equality-with-\T\ introduction}

\begin{holboxed}
\index{EQT_INTRO@\ml{EQT\_INTRO}|pin}
\begin{verbatim}
   EQT_INTRO : thm -> thm
\end{verbatim}
\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t\over\Gamma\turn t=\T$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn\uquant{b_1\ b_2}(b_1\imp b_2)\imp(b_2\imp b_1)\imp(b_1=b_2)$
\hfill [Axiom]
\item $\turn\uquant{b_2}(t\imp b_2)\imp(b_2\imp t)\imp(t=b_2)$
\hfill [\rul{SPEC} 1]
\item $\turn(t\imp\T)\imp(\T\imp t)\imp(t=\T)$\hfill [\rul{SPEC} 2]
\item $\turn\T$\hfill [\rul{TRUTH}]
\item $\turn t\imp\T$\hfill [\rul{DISCH} 4]
\item $\turn(\T\imp t)\imp(t=\T)$\hfill [\rul{MP} 3,5]
\item $\Gamma \turn t$\hfill [Hypothesis]
\item $\Gamma\turn\T\imp t$\hfill [\rul{DISCH} 7]
\item $\Gamma\turn t=\T$\hfill [\rul{MP} 6,8]
\end{proof}
\index{equality, in HOL logic@equality, in \HOL{} logic!other rules for|)}
\index{T@\holtxt{T}!rules of inference for|)}

\subsection{\texorpdfstring{Generalization ($\forall$-introduction)}{Generalization (forall-introduction)}}%
\index{universal quantifier, in HOL logic@universal quantifier, in \HOL{} logic!inference rules for}

\begin{holboxed}
\index{GEN@\ml{GEN}|pin}
\index{generalization rule, in HOL logic@generalization rule, in \HOL{} logic}
\begin{verbatim}
   GEN : term -> thm -> thm
\end{verbatim}
\end{holboxed}

\label{avra_gen}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t\over\Gamma\turn\uquant{x} t$$
\begin{itemize}
\item Where $x$ is not free in $\Gamma$.
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma\turn t$\hfill [Hypothesis]
\item $\Gamma\turn t = \T$\hfill [\rul{EQT\_INTRO} 1]
\item $\Gamma\turn(\lquant{x}t)=(\lquant{x}\T)$\hfill [\rul{ABS} 2]
\item $\turn \forall(\lquant{x}t) = \forall(\lquant{x}t)$\hfill [\rul{REFL}]
\item $\turn \forall = (\lquant{P} P =(\lquant{x}\T))$\hfill
[\rul{INST\_TYPE} applied to the definition of $\forall$]
\item $\turn\forall(\lquant{x}t)=(\lquant{P} P=(\lquant{x}\T))(\lquant{x}t)$
\hfill [\rul{SUBST} 5,4]
\item $\turn(\lquant{P} P=(\lquant{x}\T))(\lquant{x}t)=((\lquant{x}t)
=(\lquant{x}\T))$\hfill [\rul{BETA\_CONV}]
\item $\turn\forall(\lquant{x}t) = ((\lquant{x}t)=(\lquant{x}\T))$
\hfill [\rul{TRANS} 6,7]
\item $\turn((\lquant{x}t)=(\lquant{x}\T)) = \forall(\lquant{x}\T)$
\hfill [\rul{SYM} 8]
\item $\Gamma\turn\forall(\lquant{x}t)$\hfill [\rul{EQ\_MP} 9,3]
\end{proof}

\subsection{\texorpdfstring{Simple $\alpha$-conversion}{Simple alpha-conversion}}

\begin{holboxed}
\begin{verbatim}
   SIMPLE_ALPHA
\end{verbatim}
\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\turn(\lquant{x_1}t\ x_1) = (\lquant{x_2}t\ x_2)$$
\begin{itemize}
\item Where neither $x_1$ nor $x_2$ occurs free in $t$.\footnote{\ml{SIMPLE\_ALPHA} is
included here because it is
used in a subsequent derivation, but it is not actually in the
\HOL\ system, as it is subsumed by other functions.}
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item$\turn(\lquant{x_1}t\ x_1)\ x = t\ x$\hfill [\rul{BETA\_CONV}]
\item$\turn(\lquant{x_2}t\ x_2)\ x = t\ x$\hfill [\rul{BETA\_CONV}]
\item $\turn t\ x = (\lquant{x_2}t\ x_2)\ x$\hfill [\rul{SYM} 2]
\item $\turn (\lquant{x_1}t\ x_1)\ x = (\lquant{x_2}t\ x_2)\ x$
\hfill [\rul{TRANS} 1,3]
\item $\turn(\lquant{x}(\lquant{x_1}t\ x_1)\ x) =
(\lquant{x}(\lquant{x_2}t\ x_2)\ x)$\hfill [\rul{ABS} 4]
\item $\turn\uquant{f}(\lquant{x}f\ x) = f$\hfill
[Appropriately type-instantiated axiom]
\item $\turn(\lquant{x}(\lquant{x_1}t\ x_1)x) = \lquant{x_1}t\ x_1$
\hfill [\rul{SPEC} 6]
\item $\turn(\lquant{x}(\lquant{x_2}t\ x_2)x) = \lquant{x_2}t\ x_2$
\hfill [\rul{SPEC} 6]
\item $\turn (\lquant{x_1}t\ x_1) = (\lquant{x}(\lquant{x_1}t\ x_1)x)$
\hfill [\rul{SYM} 7]
\item $\turn (\lquant{x_1}t\ x_1) = (\lquant{x}(\lquant{x_2}t\ x_2)x)$
\hfill [\rul{TRANS} 9,5]
\item $\turn(\lquant{x_1}t\ x_1)=(\lquant{x_2}t\ x_2)$\hfill
[\rul{TRANS} 10,8]
\end{proof}

\subsection{\texorpdfstring{$\eta$-conversion}{Eta-conversion}}

\begin{holboxed}
\index{ETA_CONV@\ml{ETA\_CONV}|pin}
\begin{verbatim}
   ETA_CONV : conv
\end{verbatim}
\end{holboxed}
\vspace{12pt plus2pt minus1pt}

$$\turn(\lquant{x'}t\ x') = t$$
\begin{itemize}
\item Where $x'$ does not occur free\index{free variables, in HOL logic@free variables, in \HOL{} logic} in $t$ (we use $x'$ rather than just $x$
to motivate the use of \rul{SIMPLE\_ALPHA} in the derivation below).
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn\uquant{f}(\lquant{x}f\ x) = f$\hfill
[Appropriately type-instantiated axiom]
\item  $\turn(\lquant{x}t\ x) = t$\hfill [\rul{SPEC} 1]
\item $\turn(\lquant{x'}t\ x')=(\lquant{x}t\ x)$\hfill [\rul{SIMPLE\_ALPHA}]
\item $\turn(\lquant{x'}t\ x')=t$\hfill [\rul{TRANS} 3,2]
\end{proof}

\subsection{Extensionality}
\index{universal quantifier, in HOL logic@universal quantifier, in \HOL{} logic!inference rules for}

\begin{holboxed}
\index{EXT@\ml{EXT}|pin}
\index{extensionality rule, in HOL logic@extensionality rule, in \HOL{} logic}
\begin{verbatim}
   EXT : thm -> thm
\end{verbatim}
\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn\uquant{x} t_1\ x = t_2\ x\over\Gamma\turn t_1=t_2$$
\begin{itemize}
\item Where $x$ is not free\index{free variables, in HOL logic@free variables, in \HOL{} logic} in $t_1$ or $t_2$.
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma\turn\uquant{x}t_1\ x=t_2\ x$\hfill [Hypothesis]
\item $\Gamma\turn t_1\ x'=t_2\ x'$\hfill [\rul{SPEC} 1 ($x'$ is a fresh)]
\item $\Gamma\turn(\lquant{x'}t_1\ x') = (\lquant{x'}t_2\ x')$\hfill
        [\rul{ABS} 2]
\item $\turn(\lquant{x'}t_1\ x') = t_1$\hfill [\rul{ETA\_CONV}]
\item $\turn t_1 = (\lquant{x'}t_1\ x')$\hfill [\rul{SYM} 4]
\item $\Gamma\turn t_1 = (\lquant{x'}t_2\ x')$\hfill [\rul{TRANS} 5,3]
\item $\turn(\lquant{x'}t_2\ x') = t_2$\hfill [\rul{ETA\_CONV}]
\item $\Gamma\turn t_1=t_2$\hfill [\rul{TRANS} 6,7]
\end{proof}

\subsection{\texorpdfstring{$\hilbert$-introduction}{Hilbert-introduction}}

\begin{holboxed}
\index{choice operator, in HOL logic@choice operator, in \HOL{} logic!inference rules for}
\index{SELECT_INTRO@\ml{SELECT\_INTRO}|pin}
\begin{verbatim}
   SELECT_INTRO : thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1\ t_2\over\Gamma\turn t_1(\hilbert\ t_1)$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn\uquant{P\ x}P\ x\imp P(\hilbert\ P)$\hfill [Suitably
type-instantiated axiom]
\item $\turn t_1\ t_2 \imp t_1(\hilbert\ t_1)$\hfill [\rul{SPEC} 1 (twice)]
\item $\Gamma\turn t_1\ t_2$\hfill [Hypothesis]
\item $\Gamma\turn t_1(\hilbert\ t_1)$\hfill [\rul{MP} 2,3]
\end{proof}

\subsection{\texorpdfstring{$\hilbert$-elimination}{Hilbert-elimination}}

\begin{holboxed}
\index{choice operator, in HOL logic@choice operator, in \HOL{} logic!inference rules for}
\index{SELECT_ELIM@\ml{SELECT\_ELIM}|pin}
\begin{verbatim}
   SELECT_ELIM : thm -> (term # thm) -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma_1\turn t_1(\hilbert\ t_1)\qquad\qquad\qquad\Gamma_2,\ t_1\ v\turn t
\over \Gamma_1\cup\Gamma_2\turn t$$
\begin{itemize}
\item Where $v$ occurs nowhere except in the assumption $t_1\ v$ of the second
hypothesis.
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma_2,\ t_1\ v\turn t$ \hfill [Hypothesis]
\item $\Gamma_2\turn t_1\ v\imp t$\hfill [\rul{DISCH} 1]
\item $\Gamma_2\turn\uquant{v}t_1\ v\imp t$\hfill [\rul{GEN} 2]
\item $\Gamma_2\turn t_1(\hilbert\ t_1)\imp t$\hfill [\rul{SPEC} 3]
\item $\Gamma_1\turn t_1(\hilbert\ t_1)$\hfill [Hypothesis]
\item $\Gamma_1\cup\Gamma_2\turn t$\hfill [\rul{MP} 4,5]
\end{proof}

\subsection{\texorpdfstring{$\exists$-introduction}{Exists-introduction}}
\index{existential quantifier, in HOL logic@existential quantifier, in \HOL{} logic!inference rules for|(}

\begin{holboxed}
\index{EXISTS@\ml{EXISTS}|pin}
\begin{verbatim}
   EXISTS : (term # term) -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1[t_2]\over \Gamma\turn \equant{x}t_1[x]$$
\begin{itemize}
\item Where $t_1[t_2]$ denotes a term $t_1$ with some free\index{free variables, in HOL logic@free variables, in \HOL{} logic}
occurrences of $t_2$
singled out, and $t_1[x]$ denotes the result of replacing these
occurrences of $t_1$ by $x$, subject to the restriction that $x$
doesn't become bound after substitution.
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn(\lquant{x}t_1[x])t_2= t_1[t_2]$\hfill [\rul{BETA\_CONV}]
\item $\turn t_1[t_2] = (\lquant{x}t_1[x])t_2$\hfill [\rul{SYM} 1]
\item $\Gamma\turn t_1[t_2]$\hfill [Hypothesis]
\item $\Gamma\turn(\lquant{x}t_1[x])t_2$\hfill [\rul{EQ\_MP} 2,3]
\item $\Gamma\turn(\lquant{x}t_1[x])(\hilbert(\lquant{x}t_1[x]))$\hfill
[\rul{SELECT\_INTRO} 4]
\item $\turn \exists = \lquant{P} P(\hilbert\ P)$\hfill
[\rul{INST\_TYPE} applied to the definition of $\exists$]
\item $\turn\exists(\lquant{x}t_1[x]) =
(\lquant{P}P(\hilbert\ P))(\lquant{x}t_1[x])$\hfill [\rul{AP\_THM} 6]
\item $\turn(\lquant{P}P(\hilbert\ P))(\lquant{x}t_1[x]) =
(\lquant{x}t_1[x])(\hilbert(\lquant{x}t_1[x]))$\hfill [\rul{BETA\_CONV}]
\item $\turn\exists(\lquant{x}t_1[x]) =
(\lquant{x}t_1[x])(\hilbert(\lquant{x}t_1[x]))$\hfill [\rul{TRANS} 7,8]
\item $\turn(\lquant{x}t_1[x])(\hilbert(\lquant{x}t_1[x])) =
\exists(\lquant{x}t_1[x])$\hfill [\rul{SYM} 9]
\item $\Gamma\turn\exists(\lquant{x}t_1[x])$\hfill [\rul{EQ\_MP} 10,5]
\end{proof}

\subsection{\texorpdfstring{$\exists$-elimination}{Exists-elimination}}

\begin{holboxed}
\index{CHOOSE@\ml{CHOOSE}|pin}
\begin{verbatim}
   CHOOSE : (term # thm) -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma_1\turn\equant{x}t[x]\qquad\qquad\qquad \Gamma_2,\ t[v]\turn t'
\over \Gamma_1\cup\Gamma_2\turn t'$$
\begin{itemize}
\item Where $t[v]$ denotes a term $t$ with some free\index{free variables, in HOL logic@free variables, in \HOL{} logic}
occurrences of the variable $v$
singled out, and $t[x]$ denotes the result of replacing these
occurrences of $v$ by $x$, subject to the restriction that $x$ doesn't become
bound after substitution.
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn \exists = \lquant{P} P(\hilbert\ P)$\hfill
[\rul{INST\_TYPE} applied to the definition of $\exists$]
\item $\turn\exists(\lquant{x}t[x]) =
(\lquant{P}P(\hilbert\ P))(\lquant{x}t[x])$\hfill [\rul{AP\_THM} 1]
\item $\Gamma_1\turn\exists(\lquant{x}t[x])$\hfill [Hypothesis]
\item $\Gamma_1\turn (\lquant{P}P(\hilbert\ P))(\lquant{x}t[x])$
\hfill [\rul{EQ\_MP} 2,3]
\item $\turn(\lquant{P}P(\hilbert\ P))(\lquant{x}t[x]) =
(\lquant{x}t[x])(\hilbert(\lquant{x}t[x]))$\hfill [\rul{BETA\_CONV}]
\item $\Gamma_1\turn(\lquant{x}t[x])(\hilbert(\lquant{x}t[x])$\hfill
[\rul{EQ\_MP} 5,4]
\item $\turn(\lquant{x}t[x])v = t[v]$\hfill [\rul{BETA\_CONV}]
\item $\turn t[v] =(\lquant{x}t[x])v$\hfill [\rul{SYM} 7]
\item $\Gamma_2,\ t[v]\turn t'$\hfill [Hypothesis]
\item $\Gamma_2\turn t[v]\imp t'$\hfill [\rul{DISCH} 9]
\item $\Gamma_2\turn(\lquant{x}t[x])v\imp t'$\hfill [\rul{SUBST} 8,10]
\item $\Gamma_2,\ (\lquant{x}t[x])v\turn t'$\hfill [\rul{UNDISCH} 11]
\item $\Gamma_1\cup\Gamma_2\turn t'$\hfill [\rul{SELECT\_ELIM} 6,12]
\end{proof}
\index{existential quantifier, in HOL logic@existential quantifier, in \HOL{} logic!inference rules for|)}

\subsection{Use of a definition}

\begin{holboxed}
\index{RIGHT_BETA@\ml{RIGHT\_BETA}|pin}
\begin{verbatim}
   RIGHT_BETA : thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t = \lquant{x}t'[x]
\over \Gamma\turn t\ t = t'[t]$$
\begin{itemize}
\item Where  $t$ does not contain $x$.
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma\turn t = \lquant{x} t'[x]$\hfill
[Suitably type-instantiated hypothesis]
\item $\Gamma\turn t\ t =
(\lquant{x}t'[x])\ t$\hfill
[\rul{AP\_THM} 1 ]
\item $\turn(\lquant{x}t'[x])\ t =
t'[t]$\hfill [\rul{BETA\_CONV}]
\item $\Gamma\turn t\ t = t'[t]$\hfill
[\rul{TRANS} 2,3]
\end{proof}

\subsection{Use of a definition}

\begin{holboxed}
\index{RIGHT_LIST_BETA@\ml{RIGHT\_LIST\_BETA}|pin}
\begin{verbatim}
   RIGHT_LIST_BETA : thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t = \lquant{x_1\cdots x_n}t'[x_1,\ldots,x_n]
\over \Gamma\turn t\ t_1\cdots t_n = t'[t_1,\ldots,t_n]$$
\begin{itemize}
\item Where none of the $t_i$ contain any of the $x_i$.
\end{itemize}

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\Gamma\turn t = \lquant{x_1\cdots x_n} t'[x_1,\ldots,x_n]$\hfill
[Suitably type-instantiated hypothesis]
\item $\Gamma\turn t\ t_1\cdots t_n =
(\lquant{x_1\cdots x_n}t'[x_1,\ldots,x_n])\ t_1\cdots t_n$\hfill
[\rul{AP\_THM} 1 (n times)]
\item $\turn(\lquant{x_1\cdots x_n}t'[x_1,\ldots,x_n])\ t_1\cdots t_n =
t'[t_1,\ldots,t_n]$\hfill [\rul{BETA\_CONV} (n times)]
\item $\Gamma\turn t\ t_1\cdots t_n = t'[t_1,\ldots,t_n]$\hfill
[\rul{TRANS} 2,3]
\end{proof}

\subsection{\texorpdfstring{$\wedge$-introduction}{Conjunction-introduction}}
\label{avra_conj}

\begin{holboxed}
\index{CONJ@\ml{CONJ}|pin}
\index{conjunction, in HOL logic@conjunction, in \HOL{} logic!inference rule for}
\begin{verbatim}
   CONJ : thm -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma_1\turn t_1\qquad\qquad\qquad\Gamma_2\turn t_2\over
\Gamma_1\cup\Gamma_2 \turn t_1\conj t_2$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn \conj = \lquant{b_1\ b_2}\uquant{b}(b_1\imp(b_2\imp b))\imp b$
\hfill [Definition of $\conj$]
\item $\turn t_1\conj t_2 = \uquant{b}(t_1\imp(t_2\imp b))\imp b$\hfill
[\rul{RIGHT\_LIST\_BETA} 1]
\item $t_1\imp(t_2\imp b)\turn t_1\imp(t_2\imp b)$\hfill [\rul{ASSUME}]
\item $\Gamma_1\turn t_1$\hfill [Hypothesis]
\item $\Gamma_1,\ t_1\imp(t_2\imp b)\turn t_2\imp b$\hfill [\rul{MP} 3,4]
\item $\Gamma_2\turn t_2$\hfill [Hypothesis]
\item $\Gamma_1\cup\Gamma_2,\ t_1\imp(t_2\imp b)\turn b$\hfill [\rul{MP} 5,6]
\item $\Gamma_1\cup \Gamma_2\turn(t_1\imp(t_2\imp b))\imp b$\hfill
[\rul{DISCH} 7]
\item $\Gamma_1\cup \Gamma_2\turn \uquant{b}(t_1\imp(t_2\imp b))\imp b$\hfill
[\rul{GEN} 8]
\item $\Gamma_1\cup \Gamma_2\turn t_1\conj t_2$\hfill
[\rul{EQ\_MP} (\rul{SYM} 2),9]
\end{proof}

\subsection{\texorpdfstring{$\wedge$-elimination}{Conjunction-elimination}}

\begin{holboxed}
\index{CONJUNCT1@\ml{CONJUNCT1}|pin}
\index{CONJUNCT2@\ml{CONJUNCT2}|pin}
\begin{verbatim}
   CONJUNCT1 : thm -> thm, CONJUNCT2 : thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1\conj t_2\over
\Gamma\turn t_1\qquad\qquad\qquad \Gamma\turn t_2$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn \conj = \lquant{b_1\ b_2}\uquant{b}(b_1\imp(b_2\imp b))\imp b$
\hfill [Definition of $\conj$]
\item $\turn t_1\conj t_2 = \uquant{b}(t_1\imp(t_2\imp b))\imp b$\hfill
[\rul{RIGHT\_LIST\_BETA} 1]
\item $\Gamma\turn t_1\conj t_2$\hfill [Hypothesis]
\item $\Gamma\turn \uquant{b}(t_1\imp(t_2\imp b))\imp b$\hfill
[\rul{EQ\_MP} 2,3]
\item $\Gamma\turn (t_1\imp(t_2\imp t_1))\imp t_1$\hfill [\rul{SPEC} 4]
\item $t_1\turn t_1$\hfill [\rul{ASSUME}]
\item $t_1 \turn t_2\imp t_1$\hfill [\rul{DISCH} 6]
\item $\turn t_1\imp(t_2\imp t_1)$\hfill [\rul{DISCH} 7]
\item $\Gamma\turn t_1$\hfill [\rul{MP} 5,8]
\item $\Gamma\turn (t_1\imp(t_2\imp t_2))\imp t_2$\hfill [\rul{SPEC} 4]
\item $t_2\turn t_2$\hfill [\rul{ASSUME}]
\item $\turn t_2\imp t_2$\hfill [\rul{DISCH} 11]
\item $\turn t_1\imp(t_2\imp t_2)$\hfill [\rul{DISCH} 12]
\item $\Gamma\turn t_2$\hfill [\rul{MP} 10,13]
\item $\Gamma\turn t_1$ and $\Gamma\turn t_2$\hfill [9,14]
\end{proof}

\subsection{\texorpdfstring{Right $\vee$-introduction}{Right disjunction-introduction}}\index{disjunction, in HOL logic@disjunction, in \HOL{} logic!inference rule for|(}

\begin{holboxed}
\index{DISJ1@\ml{DISJ1}|pin}
\begin{verbatim}
   DISJ1 : thm -> conv
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1\over \Gamma\turn t_1\disj t_2$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn \disj =
\lquant{b_1\ b_2}\uquant{b}(b_1\imp b)\imp(b_2\imp b)\imp b$
\hfill [Definition of $\disj$]
\item $\turn t_1\disj t_2 = \uquant{b}(t_1\imp b)\imp(t_2\imp b)\imp b$
\hfill [\rul{RIGHT\_LIST\_BETA} 1]
\item $\Gamma\turn t_1$\hfill [Hypothesis]
\item $t_1\imp b\turn t_1\imp b$\hfill [\rul{ASSUME}]
\item $\Gamma,\ t_1\imp b\turn b$\hfill [\rul{MP} 4,3]
\item $\Gamma,\ t_1\imp b\turn(t_2\imp b)\imp b$\hfill [\rul{DISCH} 5]
\item $\Gamma\turn (t_1\imp b)\imp(t_2\imp b)\imp b$\hfill [\rul{DISCH} 6]
\item $\Gamma\turn \uquant{b}(t_1\imp b)
\imp(t_2\imp b)\imp b$\hfill [\rul{GEN} 7]
\item $\Gamma\turn t_1\disj t_2$\hfill [\rul{EQ\_MP} (\rul{SYM} 2),8]
\end{proof}

\subsection{\texorpdfstring{Left $\vee$-introduction}{Left disjunction-introduction}}

\begin{holboxed}
\index{DISJ2@\ml{DISJ2}|pin}
\begin{verbatim}
   DISJ2 : term -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_2\over \Gamma\turn t_1\disj t_2$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn \disj =
\lquant{b_1\ b_2}\uquant{b}(b_1\imp b)\imp(b_2\imp b)\imp b$
\hfill [Definition of $\disj$]
\item $\turn t_1\disj t_2 = \uquant{b}(t_1\imp b)\imp(t_2\imp b)\imp b$
\hfill [\rul{RIGHT\_LIST\_BETA} 1]
\item $\Gamma\turn t_2$\hfill [Hypothesis]
\item $t_2\imp b\turn t_2\imp b$\hfill [\rul{ASSUME}]
\item $\Gamma,\ t_2\imp b\turn b$\hfill [\rul{MP} 4,3]
\item $\Gamma\turn(t_2\imp b)\imp b$\hfill [\rul{DISCH} 5]
\item $\Gamma\turn (t_1\imp b)\imp(t_2\imp b)\imp b$\hfill [\rul{DISCH} 6]
\item $\Gamma\turn \uquant{b}(t_1\imp b)
\imp(t_2\imp b)\imp b$\hfill [\rul{GEN} 7]
\item $\Gamma\turn t_1\disj t_2$\hfill [\rul{EQ\_MP} (\rul{SYM} 2),8]
\end{proof}

\subsection{\texorpdfstring{$\vee$-elimination}{Disjunction-elimination}}

\begin{holboxed}
\index{DISJ_CASES@\ml{DISJ\_CASES}|pin}
\begin{verbatim}
   DISJ_CASES : thm -> thm -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma\turn t_1\disj t_2\qquad\qquad\qquad\Gamma_1,\ t_1\turn t
\qquad\qquad\qquad \Gamma_2,\ t_2\turn t\over
\Gamma\cup\Gamma_1\cup\Gamma_2\turn t$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn \disj =
\lquant{b_1\ b_2}\uquant{b}(b_1\imp b)\imp(b_2\imp b)\imp b$
\hfill [Definition of $\disj$]
\item $\turn t_1\disj t_2 = \uquant{b}(t_1\imp b)\imp(t_2\imp b)\imp b$
\hfill [\rul{RIGHT\_LIST\_BETA} 1]
\item $\Gamma\turn t_1\disj t_2$\hfill [Hypothesis]
\item $\Gamma\turn\uquant{b}(t_1\imp b)\imp(t_2\imp b)\imp b$\hfill
[\rul{EQ\_MP} 2,3]
\item $\Gamma\turn(t_1\imp t)\imp(t_2\imp t)\imp t$\hfill [\rul{SPEC} 4]
\item $\Gamma_1,\ t_1\turn t$\hfill [Hypothesis]
\item $\Gamma_1\turn t_1\imp t$\hfill [\rul{DISCH} 6]
\item $\Gamma\cup \Gamma_1\turn (t_2\imp t)\imp t$\hfill [\rul{MP} 5,7]
\item $\Gamma_2,\ t_2\turn t$\hfill [Hypothesis]
\item $\Gamma_2\turn t_2\imp t$\hfill [\rul{DISCH} 9]
\item $\Gamma\cup \Gamma_1\cup \Gamma_2\turn t$\hfill [\rul{MP} 8,10]
\end{proof}
\index{disjunction, in HOL logic@disjunction, in \HOL{} logic!inference rule for|)}

\subsection{Classical contradiction rule}
\index{F (falsity), the HOL constant@\holtxt{F} (falsity), the \HOL{} constant!rules of inference for}

\begin{holboxed}
\index{CCONTR@\ml{CCONTR}|pin}
\index{contradiction rule, in HOL logic@contradiction rule, in \HOL{} logic}
\begin{verbatim}
   CCONTR : term -> thm -> thm
\end{verbatim}\end{holboxed}

\vspace{12pt plus2pt minus1pt}

$$\Gamma,\ \neg t\turn \F\over \Gamma\turn t$$

\vspace{12pt plus2pt minus1pt}

\begin{proof}
\item $\turn \neg = \lquant{b}b\imp\F$\hfill [Definition of $\neg$]
\item $\turn \neg t = t\imp\F$\hfill [\rul{RIGHT\_LIST\_BETA} 1]
\item $\Gamma,\ \neg t\turn\F$\hfill [Hypothesis]
\item $\Gamma\turn \neg t\imp\F$\hfill  [\rul{DISCH} 3]
\item $\Gamma\turn (t\imp\F)\imp\F$\hfill [\rul{SUBST} 2,4]
\item $t = \F\turn t = \F$\hfill [\rul{ASSUME}]
\item $\Gamma,\ t=\F\turn (\F\imp\F)\imp\F$\hfill [\rul{SUBST} 6,5]
\item $\F\turn\F$\hfill [\rul{ASSUME}]
\item $\turn \F\imp\F$\hfill [\rul{DISCH} 8]
\item $\Gamma,\ t=\F\turn\F$\hfill [\rul{MP} 7,9]
\item $\turn \F = \uquant{b}b$\hfill [Definition of $\F$]
\item $\Gamma,\ t=\F\turn \uquant{b}b$\hfill [\rul{SUBST} 11,10]
\item $\Gamma,\ t=\F\turn t$\hfill [\rul{SPEC} 12]
\item $\turn \uquant{b} (b = \T)\disj(b = \F)$\hfill [Axiom]
\item $\turn (t = \T)\disj(t = \F)$\hfill [\rul{SPEC} 14]
\item $t=\T\turn t=\T$\hfill [\rul{ASSUME}]
\item $t=\T\turn t$\hfill [\rul{EQT\_ELIM} 16]
\item $\Gamma\turn t$\hfill [\rul{DISJ\_CASES} 15,17,13]
\end{proof}
\index{derived rules, in HOL logic@derived rules, in \HOL{} logic!list and derivations of some|)}
\index{inference rules, of HOL logic@inference rules, of \HOL{} logic!derived|)}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "description"
%%% End:


%!TEX root = forallx-ubc.tex
\chapter{Entailment and Models for SL}
\label{ch.SLmodels}

This chapter offers a formal semantics for SL, allowing us to be more precise about the notion of truth in SL. We'll also highlight some important features of \emph{entailment}, a key concept in formal logic.

A formal, logical language is built from two kinds of elements: logical symbols and non-logical symbols. Connectives like `\eand' and `\eif' are logical symbols, because their meaning is specified within the formal language. When writing a symbolization key, you are not allowed to change the meaning of the logical symbols. You cannot say, for instance, that the `\enot' symbol will mean `not' in one argument and `perhaps' in another. The `\enot' symbol always means logical negation. It is used to translate the English language word `not', but it is a symbol of a formal language and is defined by its truth conditions.

The sentence letters in SL are non-logical symbols, because their meaning is not defined by the logical structure of SL. When we translate an argument from English to SL, for example, the sentence letter $M$ does not have its meaning fixed in advance; instead, we provide a symbolization key that says how $M$ should be interpreted in that argument.

In translating from English to a formal language, we provided symbolization keys which were interpretations of all the non-logical symbols we used in the translation. An \define{interpretation} gives a meaning to all the non-logical elements of the language. We'll also use the term `\define{model}' as another word for an interpretation. In our simple formal language SL, meaning is simply a matter of truth and falsity, relative to a given interpretation. These notions too need to be characterized in a formal way.

%
%
%When we gave definitions for a sentence of SL and for a sentence of QL, we distinguished between the \define{object language} and the \define{metalanguage}. The object language is the language that we are \emph{talking about}: either SL or QL. The metalanguage is the language that we use to talk about the object language: English, supplemented with some mathematical jargon. It will be important to keep this distinction in mind.

%\nix{box about Tarski? The logician Alfred Tarksi introduced this distinction ca.~1940. Tarski argued that the truth conditions for a language could never be expressed in the language itself --- the metalanguage needed to be more powerful than the object language. So it's simply not possible to give a definition of truth for SL that is itself a sentence of SL --- describing the semantics of SL requires a more powerful language.}

\section{Semantics for SL}
\label{sec.semanticsSL}

This section provides a rigorous, formal characterization of \emph{truth in SL} which builds on what we already know from doing truth tables. We were able to use truth tables to reliably test whether a sentence was a tautology in SL, whether two sentences were equivalent, whether an argument was valid, and so on. For instance: \metaA{} is a tautology in SL if and only if it is assigned `1' on every line of a complete truth table.

This worked because each line of a truth table corresponds to a way the world might be. We considered all the possible combinations of 1s and 0s for the sentence letters that made a difference to the sentences we cared about. The truth table allowed us to determine what would happen given these different combinations. An \emph{interpretation} in SL provides a truth value to each atomic sentence in use; and every combination of truth values is represented by an interpretation.

(Technical side note: one might be tempted to \emph{identify} interpretations with assignments of truth values to atomic sentences. (In past versions of this book, that's actually what I did.) For a variety of reasons, this is not (any longer) my preference. One reason is that there can be different ways to assign truth values to atomic sentences, corresponding to one and the same row of the truth table, if one includes values for atoms that are not mentioned in the truth table. In a truth table for a sentence that doesn't include an $R$, for instance, these two assignments of truth values to atoms are effectively equivalent, and correspond to the same row of the truth table: \{$P=1$, $Q=1$, $R=1$\}, \{$P=1$, $Q=1$, $R=0$\}. So there could be different interpretations corresponding to the same row of the truth table, but an interpretation \emph{determines} a row of a truth table.

A more complex motivation for my terminological choice here has to do with the relationship between SL and QL, a more complex language we'll learn later in the textbook. I'll return to this connection in \S\ref{sec.0PlaceModels}.)

Once we construct a truth table, the symbols `1' and `0' are divorced from their metalinguistic meaning of `true' and `false'. We interpret `1' as meaning `true', but the formal properties of 1 are defined by the characteristic truth tables for the various connectives.  The symbols in a truth table have a formal meaning that we can specify entirely in terms of how the connectives operate. For example, if $A$ is value 1, then $\enot A$ is value 0.

To formally define truth in SL, then, we want a function that assigns, for each interpretation, a 1 or 0 to each of the sentences of SL. We can interpret this function as a definition of truth for SL if it assigns 1 to all of the true sentences of SL and 0 to all of the false sentences of SL. Call this function `$v$' (for `valuation'). We want $v$ to be a function such that for any sentence \metaA{}, $v(\metaA{})=1$ if \metaA{} is true and $v(\metaA{})=0$ if \metaA{} is false.

Recall that the recursive definition of a wff for SL had two stages: The first step said that atomic sentences (solitary sentence letters) are wffs. The second stage allowed for wffs to be constructed out of more basic wffs. There were clauses of the definition for all of the sentential connectives. For example, if \metaA{} is a wff, then \enot\metaA{} is a wff.

Our strategy for defining the truth function, $v$, will also be in two steps. The first step will handle truth for atomic sentences; the second step will handle truth for compound sentences.

\section{Defining truth in SL}
How can we define truth for an atomic sentence of SL? Consider, for example, the sentence $M$. Without an interpretation, we cannot say whether $M$ is true or false. It might mean anything. If we use $M$ to symbolize `The moon orbits the Earth', then $M$ is true. If we use $M$ to symbolize `The moon is a giant turnip', then $M$ is false.

When we give a symbolization key for SL, we provide a translation into English of the sentence letters that we use. In this way, the interpretation specifies what each of the sentence letters \emph{means}. However, this is not enough to determine whether or not that sentence is true. The sentences about the moon, for instance, require that you know some rudimentary astronomy. Imagine a small child who became convinced that the moon is a giant turnip. She could understand what the sentence `The moon is a giant turnip' means, but mistakenly think that it was true.

So a symbolization key alone does not determine whether a sentence is true or false. Truth or falsity depends also on what the world is like. If $M$ meant `The moon is a giant turnip' and the real moon were a giant turnip, then $M$ would be true. To get a truth value via the symbolization key, one has to first translate the sentence into English, and then rely on one's knowledge of what the world is like.

We want a logical system that can proceed without astronomical investigation. Moreover, we want to abstract away from the specific commitments of a given symbolization key. So our logical definition of truth will proceed in a different way. We ignore any proffered symbolization key, and take, from a given interpretation, a \emph{truth value assignment}. Formally, this is just a function that tells us the truth value of all the atomic sentences. Call this function `$a$' (for `assignment'). We define $a$ for all sentence letters \script{P}, such that
\begin{displaymath}
a(\script{P}) =
\left\{
	\begin{array}{ll}
	1 & \mbox{if \script{P} is true},\\
	0 & \mbox{otherwise.}
	\end{array}
\right.
\end{displaymath}
This means that $a$ takes any atomic sentence of SL and assigns it either a one or a zero; one if the sentence is true, zero if the sentence is false.

You can think of $a$ as being like a row of a truth table. Whereas a truth table row assigns a truth value to a few atomic sentences, the truth value assignment assigns a value to every atomic sentence of SL. There are infinitely many sentence letters, and the truth value assignment gives a value to each of them. When constructing a truth table, we only care about sentence letters that affect the truth value of sentences that interest us. As such, we ignore the rest.

It is important to note that the truth value assignment, $a$, is not part of the language SL. Rather, it is part of the mathematical machinery that we are using to describe SL. It encodes which atomic sentences are true and which are false.

We now define the truth function, $v$, using the same recursive structure that we used to define a wff of SL.

\begin{enumerate}
\item If \metaA{} is a sentence letter, then $v(\metaA{})=a(\metaA{})$.
%\setcounter{Example}{\arabic{enumi}}\end{enumerate}
%...
% Break out of the {enumerate} environment to say something about what is
% going on. Using \setcounter in this way preserves the numbering, so
% that the list can resume after the comments.

%This is a mathematical equals sign, not the identity predicate we defined for QL.

% Resume the {enumerate} environment and restore the counter.
%...
%\begin{enumerate}\setcounter{enumi}{\arabic{Example}}
\item If \metaA{} is ${\enot}\metaB{}$ for some sentence \metaB{}, then
\begin{displaymath}v(\metaA{}) =
	\left\{\begin{array}{ll}
	1 & \mbox{if $v(\metaB{}) = 0$},\\
	0 & \mbox{otherwise.}
	\end{array}\right.
\end{displaymath}

\item If \metaA{} is $(\metaB{}\eand\metaC{})$ for some sentences \metaB{}, \metaC{}, then
\begin{displaymath}v(\metaA{}) =
	\left\{\begin{array}{ll}
	1 & \mbox{if $v(\metaB{}) = 1$ and $v(\metaC{}) = 1$,}\\
	0 & \mbox{otherwise.}
	\end{array}\right.
\end{displaymath}
\setcounter{Example}{\arabic{enumi}}\end{enumerate}
%...
\label{truthdefinition}
You may be tempted to worry that this definition is circular, because it uses the word `and' in trying to define `and.' But remember, we are not attempting to give a definition of the English word `and'; we are giving a definition of truth for sentences of SL containing the logical symbol `\eand.' We define truth for object language sentences containing the symbol `\eand' using the metalanguage word `and.' There is nothing circular about that.

%...
\begin{enumerate}\setcounter{enumi}{\arabic{Example}}
\item If \metaA{} is $(\metaB{}\eor\metaC{})$ for some sentences \metaB{}, \metaC{}, then
\begin{displaymath}v(\metaA{}) =
	\left\{\begin{array}{ll}
	0 & \mbox{if $v(\metaB{}) = 0$ and $v(\metaC{}) = 0$,}\\
	1 & \mbox{otherwise.}
	\end{array}\right.
\end{displaymath}
%\setcounter{Example}{\arabic{enumi}}\end{enumerate}
%...
%Notice that this defines truth for sentences containing the symbol `\eor' using the word `and.'
%...
%\begin{enumerate}\setcounter{enumi}{\arabic{Example}}
\item If \metaA{} is $(\metaB{}\eif\metaC{})$ for some sentences \metaB{}, \metaC{}, then
\begin{displaymath}v(\metaA{}) =
	\left\{\begin{array}{ll}
	0 & \mbox{if $v(\metaB{}) = 1$ and $v(\metaC{}) = 0$,}\\
	1 & \mbox{otherwise.}
	\end{array}\right.
\end{displaymath}

\item If \metaA{} is $(\metaB{}\eiff\metaC{})$ for some sentences \metaB{}, \metaC{}, then
\begin{displaymath}v(\metaA{}) =
	\left\{\begin{array}{ll}
	1 & \mbox{if $v(\metaB{}) = v(\metaC{})$},\\
	0 & \mbox{otherwise.}
	\end{array}\right.
\end{displaymath}
\end{enumerate}

Since the definition of $v$ has the same structure as the definition of a wff, we know that $v$ assigns a value to \emph{every} wff of SL. Since the sentences of SL and the wffs of SL are the same, this means that $v$ returns the truth value of every sentence of SL.

Truth in SL is always truth \emph{relative to} some interpretation, because the definition of truth for SL does not say whether a given sentence is true or false. Rather, it says how the truth of that sentence relates to a truth value assignment.

\section{Semantic entailment}

We are now in a position to give more precise definitions of terms like `tautology', `contradiction', and so on. Truth tables provided a way to \emph{check} whether a sentence was a tautology in SL, but they did not \emph{define} what it means to be a tautology in SL. We will give definitions of these concepts for SL in terms of \define{entailment}.

The relation of semantic entailment is about satisfiability --- that is, whether there is any possible interpretation that meets a certain set of conditions. `\metaA{} entails \metaB{}', means that there is no interpretation for which \metaA{} is true and \metaB{} is false. An interpretation provides a valuation function that gives truth values to atomic sentences; so \metaA{} entails \metaB{} if and only if every assignment of truth values to atomic sentences that makes \metaA{} true also makes \metaB{} true. (We could just as well say that  `\metaA{} entails \metaB{}', means that there is no \emph{valuation function} that makes \metaA{} true and \metaB{} false. Interpretations specify valuation functions.)

We abbreviate entailment with a symbol called the \emph{double turnstile}:
$\metaA{}\models\metaB{}$ means `\metaA{} semantically entails \metaB{}.'

The double turnstile, like `\metaA{}', etc., is part of the \emph{metalanguage} we use to discuss SL; it is not part of SL itself.

\section{Entailment, validity, and informally good arguments}

Entailment is a formal notion. It is connected in important ways to the informal notion of a good argument, but when considering entailment in SL, it is important to remember to apply the definitions rigorously and precisely, rather than relying on your sense of whether the argument is a good one. The notions can come apart in some surprising ways.

Let's start with a straightforward example. Consider whether this entailment claim is true: $$(P\eand Q) \models (P\eor Q)$$ This is true if and only if every interpretation that satisfies $(P\eand Q)$, also satisfies  $(P\eor Q)$. Hopefully it is obvious to you that this is true. Only an interpretation that assigns 1 to both $P$ and $Q$ will satisfy the left, and any such interpretation will certainly satisfy the right as well. (You could draw the truth table to verify this if you want the practice.) So, as one might naturally expect, $(P\eand Q) \models (P\eor Q)$.

Here is a less intuitive example. What should we make of this claim?

\begin{quote}
$(P\eand Q) \models (A\eiff\enot\enot A)$
\end{quote}

Notice that the sentence letters on the left-hand-side here are completely different letters from those on the right-hand-side. So there is a straightforward sense in which the two sides of the turnstile have \emph{nothing to do with one another}. Nevertheless, this \emph{is} a true entailment claim. This is because it satisfies the definition: every interpretation that satisfies the left (i.e., every interpretation with a valuation function assigns `1' to both $P$ and $Q$), also satisfies $(A\eiff\enot\enot A)$. This for the simple reason that every valuation \emph{whatsoever} satisfies $(A\eiff\enot\enot A)$; it is a tautology.

From this example we can see that a tautology will be entailed by anything whatsoever. If the right-hand-side of the entailment claim is a tautology, it doesn't matter what's on the left --- you know it's going to be true.

So these are all true:

\begin{earg}
\item[] $P \models (P \eor \enot P)$
\item[] $Q \models (P \eor \enot P)$
\item[] $(P \eand \enot P) \models (P \eor \enot P)$
\end{earg}

\section{Tautologies are entailed by the empty set}

In the examples so far, we've been talking about one sentence entailing another. But we can also describe a set of several sentences as jointly entailing an SL sentence: $$\metaA{}_1,\metaA{}_2,\metaA{}_3,\cdots\models\metaB{}$$ means that there is no truth value assignment for which all of the sentences in the set $\{\metaA{}_1,\metaA{}_2,\metaA{}_3,\cdots\}$ are true and \metaB{} is false. It will sometimes be convenient to use a variable that can stand in for any set of sentences; just as `\metaA{}' can stand for any sentence of SL, we can let `\metaSetX{}' stand in for any set of sentences in SL. (In the case of `$\metaA{}\models\metaB{}$' above, `\metaSetX{}' is the singleton set containing just \metaA{}.)

In general, we may say that $$\metaSetX{}\models\metaB{}$$ means that there's no interpretation satisfying every member of set \metaSetX{} without also satisfying sentence \metaB{}.

We saw in the previous section that a tautology ---  an SL sentence that is true in every interpretation --- is entailed by any sentence. The reasoning applies more generally: a tautology will be entailed by any set of sentences. This includes the \emph{empty set}, which can be written `$\emptyset$'. In general `$\metaSetX{} \models \metaA{}$' says that every interpretation that satisfies everything in \metaSetX{}, satisfies \metaA{}; in the special case where \metaSetX{} is $\emptyset$, every interpretation trivially satisfies everything in \metaSetX{}. So `$\emptyset \models \metaA{}$' says that absolutely every interpretation satisfies \metaA{}. That is, it says that \metaA{} is a tautology.

By convention, we can leave the left side of an entailment claim blank, instead of writing in $\emptyset$. In other words, $$\models \metaA{} $$ is shorthand for $$ \emptyset \models \metaA{}.$$

So these entailment claims are true, because in each case the sentence on the right is a tautology:

\begin{earg}
\item[] $\models (P \eor \enot P)$
\item[] $\models (P \eiff P)$
\item[] $\models ((P \eand\enot P)\eif (A \eor B))$
\end{earg}

And these entailment claims are not true, because each sentence on the right is not a tautology:

\begin{earg}
\item[] $\models P$
\item[] $\models (P \eand \enot P)$
\item[] $\models \enot(P \eif \enot P)$
\end{earg}

(If you need help seeing why a given sentence is or is not a tautology, draw out the truth table and check to see whether it has a 1 on every row. See \S\ref{sec.usingtruthtables}.)

\section{Inconsistent sentences entail absurdities}

Consider this entailment claim: $$(P \eand \enot P) \models Q$$This statement is true. It says that every interpretation satisfying $(P \eand \enot P)$ also satisfies $Q$. But $(P \eand \enot P)$ is a contradiction --- no interpretations satisfy it. So trivially, `every' interpretation that satisfies it satisfies $Q$.

This explanation had nothing to do with the specifics of the sentence $Q$. Exactly the same considerations would demonstrate that, for any sentence \metaB{}, $(P \eand \enot P) \models \metaB{}$. And the same goes for any other contradictory sentence, or any set of sentences that are mutually inconsistent. These are all true:

\begin{earg}
\item[] $(P \eand \enot P) \models (\enot Q \eif R)$
\item[] $P, (\enot Q \eand \enot P) \models (Q \eiff P)$
\item[] $(P \eand\enot P) \models ((A_1 \eor A_2) \eif \enot (A_3 \eiff (A_4 \eand \enot A_2)))$
\end{earg}

You can think of evaluating an entailment claim as like checking to see whether a rule is being violated or not. If there's a rule that says every student with a dog has to have a permit, you check each student with a dog, and make sure they have a permit. If you find someone without a dog, it doesn't matter whether they have a permit or not. (If you don't have a dog, you're not breaking the rule.) Or if you find someone with a permit, it doesn't matter whether they have a dog. (Nobody with a permit can be breaking the rule.) An entailment claim is like a rule that says every interpretation that satisfies the left-hand-side must also satisfy the right-hand-side. To verify it, you can ignore any interpretation that falsifies the left, or that satisfies the right.

In each of the cases above, you don't even need to examine the sentence at the right to confirm that the entailment claim is true, since you already know that no interpretations satisfy the sentences on the left. (This is analogous to knowing that no students have a dog --- in this case you don't have to check to see whether anyone has a permit to confirm that the rule is being respected.) Any entailment claim with an unsatisfiable set of sentences on the left is true. Unsatisfiable sets of sentences entail \emph{every} sentence.

We have a special notation for describing this situation. We write: $$\metaSetX{} \models \bot$$ to indicate that the set \metaSetX{} entails an \emph{absurdity}; think of `$\bot$' as standing in for an arbitrary unsatisfiable SL wff. So you can think of `$\metaSetX{} \models \bot$' as saying that every interpretation that satisfies $\metaSetX{}$ satisfies the unsatisfiable. That's just another way of saying that \emph{no} interpretation satisfies $\metaSetX{}$. (Compare: `the only Klingons who hate honour are the Klingons who aren't Klingons at all.')

%By convention, we treat $$\metaSetX{} \models$$ as shorthand for $$\metaSetX{} \models \bot.$$ So if you see an entailment claim with nothing on the right, read it as saying that the left is unsatisfiable.
%\label{sec.botshorthand}

So these entailment claims are true, because the set of sentences on the left is not satisfiable:

\begin{earg}
\item[] $(P \eand \enot P) \models \bot$
\item[] $P, (\enot Q \eand \enot P) \models\bot$
\item[] $(P \eiff\enot P) \models\bot$
\end{earg}

And these entailment claims are not true, because the sentences on the left \emph{can} be satisfied:

\begin{earg}
\item[] $(P \eor \enot P) \models\bot$
\item[] $P, \enot Q, (R \eor Q) \models\bot$
\item[] $\enot P, \enot Q, (P \eif \enot\enot Q) \models\bot$
\end{earg}

(If you need help seeing why a given set of sentences can be satisfied, draw out the truth table and check to see if any row assigns a 1 to each sentence. See \S\ref{sec.usingtruthtables}.)

\section{Defining concepts in terms of entailment}

The double turnstile symbol allows us to give concise definitions for various concepts in SL:
\begin{quote}
A \define{tautology in SL} is a sentence \metaA{}  such that $\emptyset\models\metaA{}$.

A \define{contradiction in SL} is a sentence \metaA{} such that $\metaA{}\models\bot$.

A sentence is \define{contingent in SL} if and only if it is neither a tautology nor a contradiction.

An argument with premises \metaSetX{} and conclusion \metaA{} is \define{valid in SL} if and only if $\metaSetX{}\models\metaA{}$.

Two sentences \metaA{} and \metaB{} are \define{logically equivalent in SL} if and only if both $\metaA{}\models\metaB{}$ and $\metaB{}\models\metaA{}$.

A set of sentences $\metaSetX{}$ is \define{inconsistent in SL} if and only if $\metaSetX{}\models \bot$. Otherwise $\metaSetX{}$ is \define{consistent in SL}.\label{def.consistencySL}

 \end{quote}

\practiceproblems

\problempart
\label{HW3.C}
Each of the following claims can be evaluated with truth tables. For each, what would you look for in a completed truth table to evaluate it? The Greek letters can stand for any arbitrary sentence of SL. The first claim has the answer filled out for you.

\begin{earg}
		\item[0.] $\Phi$ is a tautology.
		To evaluate this claim, check to see whether the main connective of $\Phi$ has a 1 under it in every row. If so, it is true.
		\item $\Phi \models \Psi$.
		To evaluate this claim, check to see whether...

		\item $\Phi$ is contingent.
\item $\Phi \models \bot$
		\item $\emptyset \models \Phi$
	\end{earg}

\problempart
Determine whether each entailment claim is true. You may construct a truth table to test it if you like, but these examples are simple enough so that you may be able to just think it through and get the right answer.
\begin{earg}
\item $Q \models (P \eor Q)$
\item $P, Q \models (P \eor P)$
\item $P \eiff Q, P \models Q$ %  \textcolor{red}{True.}
\item $S \models (Q \eif Q)$   %\textcolor{red}{True.}
\item $P \eand \enot P \models (Q \eor \enot Q)$%   \textcolor{red}{True.}
\item $(P \eand \enot P) \models (Q \eand \enot Q)$
\item $(P \eor \enot P) \models \bot$
\item $P \eor \enot P \models Q$%   \textcolor{red}{False: $\{P=1, Q=0\}$.}
\item $\models (P \eor \enot P)$
\item $\models (P \eand \enot P)$
\item $(A \eor B) \eif \enot P \models (P \eor \enot P)$
\item $(P \eiff Q) \models ((P \eand Q) \eor \enot (P \eor Q))$
\end{earg}


%
% body.tex
%
% Copyright © 2020 Libao Jin <jinlibao@outlook.com>
% Distributed under terms of the MIT license.
%
Please note that the deadline will be enforced as per the previous homework. Remember that you are allowed to work in teams of two on this assignment. You are encouraged to prepare your work in \LaTeX{}; a template will be provided to help you put it all together. If you choose  to submit a hard copy, you may submit only one copy for a team, indicating the names of both contributors. Online submission is encouraged, however, in that case both members of a team should submit the PDF file containing  their work and showing both their names. \\[20pt]
\textbf{Instruction}
\begin{enumerate}[label={\arabic*.}]
  \item Go to \url{https://www.overleaf.com} and sign in (required).
  \item Open \href{https://www.overleaf.com/read/qczrkwtzpxft}{template}, click \emph{Menu} (up left corner), then \emph{Copy Project}.
  \item Go to \verb|LaTeX/meta.tex| (the file \verb|meta.tex| under the folder \verb|LaTeX|) to change the section and your name, e.g.,
    \begin{itemize}
      \item change title to \verb|\title{MATH 3340-01 Scientific Computing Homework 3}|
      \item change author to \verb|\author{Albert Einstein \& Carl F. Gauss}|
    \end{itemize}
  \item For Problem 1, 2, 3, you need to write function/script files, store results to output files, and save graphs to figure files. Here are suggested names for function files, script files, output files, and figure files:
    \begin{table}[!hbtp]
      \centering
      % \caption{caption}
      % \label{tab:label}
      \begin{tabular}{cllll}
        \toprule
        Problem & Function File        & Script File     & Output File       & Figure File       \\
        \midrule
        1       & \verb|jacobi.m|      & \verb|hw3_p1.m| & \verb|hw3_p1.txt| & \verb|hw3_p1.pdf| \\
        2       & \verb|gaussSeidel.m| & \verb|hw3_p2.m| & \verb|hw3_p2.txt| & \verb|hw3_p2.pdf| \\
        3       &                      & \verb|hw3_p3.m| & \verb|hw3_p3.txt| & \verb|hw3_p3.pdf| \\
        \bottomrule
      \end{tabular}
    \end{table}

    Once finished, you need to upload these files to the folder \verb|src| on Overleaf. If you have different filenames, please update the filenames in \verb|\lstinputlisting{../src/your_script_name.m}| accordingly. You can code in the provided files in \href{https://libaoj.in/courses/2021s/MATH3340/Homework/3/hw3.zip}{hw3.zip}, and use the MATLAB script \verb|save_results.m| to generate the output files and store the graphs to \verb|.pdf| files automatically (the script filenames should be exactly same as listed above).
  \item Recompile, download, and submit the generated PDF.
  \item You may find \href{https://libaoj.in/files/LaTeX.Mathematical.Symbols.pdf}{\LaTeX{}.Mathematical.Symbols.pdf} and the second part of \href{https://libaoj.in/courses/2021s/MATH3341/slides/Math.3341.Lab.01.Slides.pdf}{Lab 01 Slides} and \href{https://libaoj.in/courses/2021s/MATH3341/slides/Math.3341.Lab.02.Slides.pdf}{Lab 02 Slides} helpful.
\end{enumerate}

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Problem 1}%
\label{sec:problem_1}
Solve, using a MATLAB code, the following system:
\begin{equation*}
  \begin{cases}
    5x - y + z + w   = 9 \\
    x + 7y + 2z + 2w = 3 \\
    2x + y + 5z + w  = 7 \\
    x - y + z + 4w   = 6
  \end{cases}
\end{equation*}
Use the Jacobi method with with a tolerance of $10^{-5}$ for the norm of the residual. Arrange your results in a table of the form
\begin{table}[!hbtp]
  \centering
  \caption{caption}
  \label{tab:label}
  \begin{tabular}{ccccc}
    \toprule
    iteration & $x$      & $y$      & $z$      & $w$      \\
    \midrule
    $0$       & $0$      & $0$      & $0$      & $0$      \\
    $1$       & $1$      & $2$      & $3$      & $4$      \\
    $\vdots$  & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
    \bottomrule
  \end{tabular}
\end{table}
so that you can see how $x$, $y$, $z$ and $w$ change with each iteration. You can create such a table using \verb|disp| in a loop; you may also use variants of \verb|printf| (in C Language), i.e., \verb|fprintf| or \verb|sprintf| if you are familiar with these functions, but do not use the MATLAB \verb|table| command as it does not do quite what is expected here. Also, as obvious from the table above, start with the zero guess. Moreover, plot the norm of the residual versus the iteration number; use a logarithmic scale on the vertical axis (the residual axis). Turn in your code and the output as described. The code can be organized as:
\begin{enumerate}
  \item a function file that implements Jacobi's method; and
  \item a script that calls the function with with the appropriate inputs and processes the results.\end{enumerate}
Your plot should have a plot title, axes labels and a legend. Use the \verb|help plot| command and the class notes  to investigate the various options  available when plotting.
\begin{solution}
  \quad
  \begin{itemize}
    \item
      Function file \verb|jacobi.m|
      \lstinputlisting[style=MATLAB]{../src/jacobi.m}
    \item
      Script file \verb|hw3_p1.m|
      \lstinputlisting[style=MATLAB]{../src/hw3_p1.m}
    \item
      Output file \verb|hw3_p1.txt|
      \lstinputlisting[style=Plain]{../src/hw3_p1.txt}
      \begin{figure}[!hbtp]
        \centering
        \includegraphics[width=0.8\linewidth]{../src/hw3_p1.pdf}
        \caption{}%
        \label{fig:}
      \end{figure}
  \end{itemize}
\end{solution}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Problem 2}%
\label{sec:problem_2}
Solve again the system above, in MATLAB, using the Gauss-Seidel method. Produce the same results as for the previous problem.
\begin{solution}
  \quad
  \begin{itemize}
    \item
      Function file \verb|gaussSeidel.m|
      \lstinputlisting[style=MATLAB]{../src/gaussSeidel.m}
    \item
      Script file \verb|hw3_p2.m|
      \lstinputlisting[style=MATLAB]{../src/hw3_p2.m}
    \item
      Output file \verb|hw3_p2.txt|
      \lstinputlisting[style=Plain]{../src/hw3_p2.txt}
      \begin{figure}[!hbtp]
        \centering
        \includegraphics[width=0.8\linewidth]{../src/hw3_p2.pdf}
        \caption{}%
        \label{fig:}
      \end{figure}
  \end{itemize}
\end{solution}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Problem 3}%
\label{sec:problem_3}
Solve the twenty-one systems of equations:
\begin{equation*}
  \begin{cases}
    7x + y + 2z = 0.01 m^{2} - 2m \\
    x - 5y + 2z = 2 - m \\
    2x + y + 5z = 9
  \end{cases}
\end{equation*}
obtained by setting, in turn, the value of the quantity $m$ on the right-hand side to all integers in between, and including, $m = 0$ and $m = 20$. This time use the LU-decomposition of the system matrix that is implemented in MATLAB by the \verb|lu| function. Perform the decomposition only once, then use the lower- and upper-triangular factors repeatedly to find each successive solution. Turn in the code and a plot of the first and second components of the solution (that is, the values of $x$ and $y$) as a function of thee right-hand side parameter $m$.
\begin{solution}
  \quad
  \begin{itemize}
    \item
      Script file \verb|hw3_p3.m|
      \lstinputlisting[style=MATLAB]{../src/hw3_p3.m}
    \item
      Output file \verb|hw3_p3.txt|
      \lstinputlisting[style=Plain]{../src/hw3_p3.txt}
      \begin{figure}[!hbtp]
        \centering
        \includegraphics[width=0.8\linewidth]{../src/hw3_p3.pdf}
        \caption{}%
        \label{fig:}
      \end{figure}
  \end{itemize}
\end{solution}


\documentclass{article}
\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{January 24, 2014}
\maketitle
\section*{page 26 number 2}

notice that pde is stated for the interior of the region
model can break down on the edges
u stays at zero for time zero which is consistent with initial condition
notice that the slope at $x=1$ for initial condition is $-\pi$ but is 1 for boundary condition

heat is flowing in (proportional to negative slope).

second boundary condition says that heat flow into the rod at x=1 (temperature gradient at $x=1$ is positive) which means low temperature inside, high temperature outside

notice boundary conditions are $0<t<\infty$ so initial condition doesn't intersect boundary condition, because solution is discontinuous at $t=0$

\section*{last time}
lessons 2 and 3 where PDE is $u_t=\alpha^2 u_{xx}$ IC is $u(x,0)$ for different types of pde's and different types of bc's

\section*{lesson 4}
derivation of pde
page 28
letter A is area of cross section
\subsection*{condition 1}
rod consists of homogeneous conducting material.  temperature varies in rod, but substrate doesn't. homogeneous medium.
\subsection*{condition 2}
laterally insulated-no heat flow across lateral surface
\subsection*{condtion 3}
thin rod, temperature is uniform across cross section.
\begin{align*}
  u_t&=\alpha^2u_{xx} \text{on} 0<x<L, 0<t<\infty\\
  u(x,t)=\text{temperature in degrees}& u(x,t)& \text{is degrees}\\
  \text{total heat energy in} [x_1,x_2]=\int_{x_1}^{x_2}{cupA,\mathrm{d}x} & c&=\text{specific heat}=\frac{\text{calories}}{\text{degree of mass}}\\
  &&p&=\text{density}\\
  \text{rate of change of energy}&=\frac{\mathrm{d}}{\mathrm{d}t}\int_{x_1}^{x_2}{cupA,\mathrm{d}x}=\int_{x_1}^{x_2}{cpu_t A,\mathrm{d}x}\\
  \intertext{law of conservation of energy}
  &=\text{flow rate of energy at end points}+\text{generation rate of energy(internal)}\\
  \text{generation rate}&=\int_{x_1}^{x_2}{f(s,t)A,\mathrm{d}s} & f&=\frac{\text{cal}}{\text{sec cm}^3}\\
  \text{flow rate}&=-DA(c\rho u)_x \frac{\text{cal}}{\text{cm}^2}\\
  \intertext{D is thermal diffusivity}
  &=-DA(c\rho u)_x-(-DA(c\rho u)_x)+\int_{x_1}^{x_2}{f(s,t)A,\mathrm{d}s}
\end{align*}

we are thinking of stuff flowing into and out of the region $[x_1,x_2]$
\subsection*{condition 1}
tube of solution of stuff. homogeneous medium (liquid)
\subsection*{condition 2}
tube (glass or whatever) allows no flow of stuff through it. similar to insulation above.
\subsection*{condition 3}
concentration of stuff is uniform by symmetry
\begin{align*}
  \omega_t=D\omega_{xx} \text{on} 0<x<L, 0<t<+\infty\\
  \omega(x,t)=\text{density of stuff}\\
  \text{total stuff in} [x_1,x_2]=\int_{x_1}^{x_2}{\omega(x,t)A,\mathrm{d}x}
  \text{rate of change of stuff}&=\frac{\mathrm{d}}{\mathrm{d}t}\int_{x_1}^{x_2}{\omega A,\mathrm{d}x}=\int_{x_1}^{x_2}{\omega_t A,\mathrm{d}x}\\
  \intertext{law of conservation of stuff (mass or whatever)}
  &=\text{flow rate of stuff at endpoints}+\text{generation rate of stuff}
  \text{generation rate}&=\frac{\text{stuff}}{\text{sec}}=\int_{x_1}^{x_2}{f(s,t)A,\mathrm{d}s} & f&=\frac{\text{stuff}}{\text{sec cm}^3}\\
  \text{flow rate of stuff at x}&=-DA\omega_x\\
  \intertext{D is diffusion coefficient cm squared per second, this is Fick's law}
  &=-DA\omega_x(x_1,t)-(-DA\omega_x(x_2,t))+\int_{x_1}^{x_2}{f(s,t)A,\mathrm{d}s}
\end{align*}
\end{document}


\chapter{Legendre expansions of energy-angle probability densities
in the laboratory frame}
\label{Sec:Legendre-lab}
Another representation of joint energy-angle probability densities
$\pi(E', \mu \mid E)$ in \xendl\ is as a table of the Legendre
coefficients $\pi_\ell(E' \mid E)$ in the expansion
\begin{equation}
  \pi( E', \mu \mid E) = \sum_\ell
  \left(
    \ell + \frac{1}{2}
  \right)
  \pi_\ell( E' \mid E) P_\ell( \mu ).
 \label{piLegendre}
\end{equation}
Here, $E$ denotes the energy of the incident particle in the
laboratory frame.  For the outgoing particle, the energy $E'$ and
direction cosine $\mu$ may be given in either center-of-mass or laboratory
coordinates.  The treatment of laboratory-frame data is discussed in this section,
center-of-mass data in the next.  Data given in the laboratory frame are
much easier to deal with because no boost is involved.

This type of data is ordered according to
\begin{equation}
\{ E, \{ E', \{ \pi_\ell(E' \mid E) \} \} \}.
 \label{ENDF-I4}
\end{equation}
All of the data for the lowest incident energy $E$
is given first, ordered according to outgoing energy~$E'$.  For
given values of $E$ and $E'$, the data consist of Legendre coefficients
$\pi_\ell(E', \mid E)$.  Note that for this data format, the number
of Legendre coefficients may vary, depending on the energies $E$ and~$E'$.

The {\gettransfer} code also handles data for Legendre expansions of
energy-angle probability densities in the {\ENDL} format~\cite{Omega},
\begin{equation}
\{ \ell, \{ E, \{ E', \pi_\ell(E', \mid E) \} \} \}.
 \label{ENDL-I4}
\end{equation}
That is, the $\ell = 0$ data are given first, ordered according to
incident energy~$E$.  The data then consist of pairs
$\{ E', \pi_\ell(E', \mid E) \}$ for given $\ell$ and $E$.
%This data format is deprecated, however.

\section{Computation of the transfer matrices for data in the laboratory frame}
The calculation of the transfer
matrices for laboratory-frame data proceeds as follows.
In terms of $\pi_\ell(\Elab'   \mid E)$,
the integral Eq.~(\ref{Inum}) for the number-preserving transfer matrix
takes the form
\begin{equation}
   \Inum_{g,h,\ell} =
     \int_{\calE_g} dE \, \sigma ( E ) M(E) w(E) \widetilde \phi_\ell(E)
   \int_{\calE_h' } d\Elab'   \, \pi_\ell(\Elab'   \mid E),
 \label{InumI4}
\end{equation}
and Eq.~(\ref{Ien}) for the energy-preserving transfer matrix becomes
\begin{equation}
   \Ien_{g,h,\ell} =
     \int_{\calE_g} dE \, \sigma ( E ) M(E) w(E) \widetilde \phi_\ell(E)
     \int_{\calE_h' } d\Elab'   \, \pi_\ell(\Elab'   \mid E) \Elab'  .
 \label{IenI4}
\end{equation}

Computation of the integrals Eqs.~(\ref{InumI4}) and~(\ref{IenI4})
depends on the type of interpolation used with respect to the
energy $E$ of the incident particle, and the procedures are
exactly the same as for integration in Eqs.~(\ref{InumI4-0})
and~(\ref{IenI4-0}) of the isotropic energy probability densities
$\pi_0(\Elab'   \mid E)$.  Thus, if unit-base interpolation is to
be used for $\pi_\ell(\Elab'   \mid E)$, then the map Eq.~(\ref{unitbaseMap})
converts
the integrals Eqs.~(\ref{InumI4}) and~(\ref{IenI4}) to the form
\begin{equation}
   \Inum_{g,h,\ell} =
     \int_{\calE_g} dE \, \sigma ( E ) M(E) w(E) \widetilde \phi_\ell(E)
   \int_{\widehat\calE_h' } d\widehat \Elab'   \,
     \widehat\pi_\ell(\widehat \Elab'   \mid E)
 \label{InumhatI4}
\end{equation}
and
\begin{equation}
   \Ien_{g,h,\ell} =
     \int_{\calE_g} dE \, \sigma ( E ) M(E) w(E) \widetilde \phi_\ell(E)
   \int_{\widehat\calE_h' } d\widehat \Elab'   \,
     \widehat\pi_\ell(\widehat \Elab'   \mid E) \Elab'  .
 \label{IenhatI4}
\end{equation}
In these intergrals $\widehat\calE_h'$ denotes result of mapping the
outgoing energy bin $\calE_h'$ with the transformation Eq.~(\ref{unitbaseMap}).
Furthermore, $\Elab'  $ in Eq.~(\ref{IenhatI4}) is to be obtained from $\widehat \Elab'  $
using the inverse unit-base mapping Eq.~(\ref{unitbaseInvert}).

The geometrical considerations involved in integrating
Eqs.~(\ref{InumhatI4}) and~(\ref{IenhatI4}) over the incident energy bin~$\calE_g$
and the mapped outgoing energy bin~$\widehat\calE_h'$ are illustrated
in Figure~\ref{Fig:unit-base-region}.

\section{Form of the input file for Legendre coefficient data in the laboratory frame}
These data may be input in either of two forms, the format
in Eq.~(\ref{ENDF-I4}) from \ENDF\ with all Legendre
coefficients given together at each incident energy $E$ and outgoing energy~$E'$
or that  in Eq.~(\ref{ENDL-I4}) with
one Legendre order at a time.
For both formats, all energies must be in the same units as the energy groups.

\subsection{Input of all Legendre coefficients together}\label{Sec:ENDF-I4-data}
For energy-angle tables in the standard format of Eq.~(\ref{ENDF-I4}),
the Section~\ref{data-model} line in the input
file to identify the data is\\
      \Input{Process: Legendre energy-angle data}{}\\
and the model-dependent data in Section~\ref{model-info} consists of the
Legendre coefficients $\pi_\ell(E' \mid E)$ in Eq.~(\ref{ENDF-I4}) at incident energies~$E$
and outgoing energies~$E'$.

The format for the Legendre coefficient data in
Section~\ref{model-info} given at $K$ values of $E$ is\\
  \Input{Product Frame: lab}{}\\
  \Input{Legendre data by incident energy:}{$n = K$}\\
  \Input{Incident energy interpolation:}{probability interpolation flag}\\
  \Input{Outgoing energy interpolation:}{list interpolation flag}\\
where the interpolation flag for incident energy is one for probability density
tables as in Section~\ref{interp-flags-probability}, and that for outgoing energy
is for a simple list.
These lines are followed by $K$ sections of the form\\
  \Input{ Ein: $E$:}{\texttt{n = $J_k$}}\\
for $J_k$ outgoing energies $E$.  For each value of $E$ there is
data\\
  \Input{  Eout: $E'$:}{\texttt{n = $L$}}\\
with Legendre coefficients $\pi_\ell(E' \mid E)$ for $\ell = 0$, 1, \ldots\ , $L - 1$.

An example of these data with energies in MeV is\\
  \Input{Legendre data by incident energy:  n = 26}{}\\
   \Input{Incident energy interpolation: lin-lin cumulativepoints}{}\\
  \Input{Outgoing energy interpolation: flat}{}\\
   \Input{Ein: 1.140200e+01:  n = 2}{}\\
  \Input{  Eout: 0.000000e+00:  n = 5}{}\\
 \Input{ \indent  1.000000e+11}{}\\
 \Input{ \indent  0.000000e+00}{}\\
 \Input{ \indent  0.000000e+00}{}\\
   \Input{ \indent  0.000000e+00}{}\\
   \Input{ \indent  0.000000e+00}{}\\
    \Input{ Eout: 1.000000e-11:  n = 5}{}\\
   \Input{ \indent  0.000000e+00}{}\\
   \Input{ \indent  0.000000e+00}{}\\
   \Input{ \indent  0.000000e+00}{}\\
   \Input{ \indent  0.000000e+00}{}\\
   \Input{ \indent  0.000000e+00}{}\\
\Input{}{$\cdots$}\\
   \Input{Ein: 2.000000e+01:  n = 27}{}\\
    \Input{ Eout: 0.000000e+00:  n = 5}{}\\
   \Input{ \indent  4.179200e-02}{}\\
   \Input{ \indent  0.000000e+00}{}\\
   \Input{ \indent  4.179200e-06}{}\\
   \Input{ \indent  0.000000e+00}{}\\
   \Input{ \indent  3.395500e-07}{}\\
 \Input{ \indent}{ etc.}

 \subsection{Input of one Legendre coefficient at a time}\label{sec:ENDL-I4}
For data given one Legendre coefficient at a time as in Eq.~(\ref{ENDL-I4}),
the line in Section~\ref{data-model} of the input
file identifying the data is\\
      \Input{Process: Legendre EEpP data transfer matrix}{}\\
The first lines in the data for Section~\ref{model-info} are\\
  \Input{Product Frame: lab}{}\\
 \Input{LEEpPData:}{$n = L$}\\
where $L$ is the number of Legendre coefficients, one greater than the
order of the Legendre expansion.  The interpolation flags as
in Section~\ref{interp-flags-probability} are\\
   \Input{Incident energy interpolation:}{probability interpolation flag}\\
  \Input{Outgoing energy interpolation:}{list interpolation flag}\\
The interpolation flag for incident energy is one for probability density
tables as in Section~\ref{interp-flags-probability}, and that for outgoing energy
is for a simple list.

The data are then given in $L$ sections, each of the form\\
   \Input{ order: l = $\ell$:}{\texttt{n = $K$}}\\
where $K$ is the number of incident energies.
For each incident energy $E'$ there is a block of data\\
    \Input{ Ein:}{$E$: \quad \texttt{n = $J_k$}}\\
for $J_k$ pairs of values of outgoing energy $E'$ and
Legendre coefficient $\pi_\ell(E' \mid E)$.  For energies measured in MeV,
these data may look like\\
  \Input{LEEpPData: n = 4}{}\\
  \Input{Incident energy interpolation: lin-lin unitbase}{}\\
  \Input{Outgoing energy interpolation: lin-lin}{}\\
  \Input{order: l = 0: n = 10}{}\\
   \Input{Ein:  3.350000000000e+00 : n = 3}{}\\
  \Input{ \indent   3.716500000000e-01   0.000000000000e+00}{}\\
  \Input{ \indent   3.716800000000e-01   2.857140000000e+04}{}\\
  \Input{ \indent   3.717200000000e-01   0.000000000000e+00}{}\\
  \Input{Ein:  4.460200000000e+00 : n = 2}{}\\
  \Input{ \indent   1.238900000000e-01   1.008970000000e+00}{}\\
   \Input{ \indent  1.115000000000e+00   1.008970000000e+00}{}\\
 \Input{$\cdots$}{}\\
  \Input{Ein:  2.000000000000e+01 : n = 2}{}\\
     \Input{ \indent  1.699600000000e-02  1.232820000000e-01}{}\\
     \Input{ \indent  8.128500000000e+00  1.232820000000e-01}{}\\
   \Input{order: l = 1: n = 10}{}\\
    \Input{Ein:  3.350000000000e+00 : n = 3}{}\\
     \Input{ \indent  3.716500000000e-01  0.000000000000e+00}{}\\
     \Input{ \indent  3.716800000000e-01  2.690500000000e+04}{}\\
     \Input{ \indent  3.717200000000e-01  0.000000000000e+00}{}\\
\Input{$\cdots$}{}\\
    \Input{order:l = 3: n = 10}{}\\
    \Input{Ein:  3.350000000000e+00 : n = 3}{}\\
     \Input{ \indent  3.716500000000e-01  0.000000000000e+00}{}\\
     \Input{ \indent  3.716800000000e-01  2.690500000000e+04}{}\\
     \Input{ \indent  3.717200000000e-01  0.000000000000e+00}{}\\
\Input{$\cdots$}{}\\
  \Input{Ein:  2.000000000000e+01 : n = 28}{}\\
     \Input{ \indent  1.699600000000e-02  1.172400000000e-01}{}\\
     \Input{ \indent  3.283800000000e-02 -8.646000000000e-03}{}\\
     \Input{ \indent  4.868100000000e-02 -3.589400000000e-02}{}\\
     \Input{ \indent  6.452400000000e-02 -4.528500000000e-02}{}\\
     \Input{ \indent  8.036700000000e-02 -4.921500000000e-02}{}\\
     \Input{ \indent  1.120500000000e-01 -5.186400000000e-02}{}\\
    \Input{ \indent }{$\cdots$}\\
    \Input{ \indent  7.082900000000e+00  7.783200000000e-02}{}\\
     \Input{ \indent  8.128500000000e+00  1.172400000000e-01}{}


\documentclass[../research.tex]{subfile}

\subsection{Lebesgue Integration}
\label{sec:4.1}

\subsection{The Banach-Tarski Paradox}
\label{sec:4.3}

\subsection{Order Theory}
\label{sec:4.4}

    \begin{definition}[Partial order]
        Given a set $P$, a \textit{partial order}, $\leq$, is a binary relation on $P$ satisying the
        following:
        \begin{enumerate}
            \item Reflexivity: $p\leq p \quad\forall p\in P$
            \item Antisymmetry: $p\leq q\wedge q\leq p\Rightarrow$ $p=q\quad\forall p,q\in P$
            \item Transitivity: $p\leq q$, $q\leq r$ $\Rightarrow$ $p\leq r\quad\forall p,q,r\in P$
        \end{enumerate}
        We call a set with a partial order a \textit{poset}, $(P,\leq)$.
    \end{definition}

    \begin{definition}[Lattice]
    \end{definition}

\subsection{Diffeology}
\label{sec:4.5}

\subsection{Tensors}
\label{sec:4.6}

    \subsubsection{Dual space of a vector space}
    \label{sec:4.6.1}

        \begin{definition}[Linear functional]
        \end{definition}

    \subsubsection{Cotangent vectors}
    \label{sec:4.6.2}

    \subsubsection{Differential Forms}
    \label{sec:4.6.3}