\documentclass[letterpaper, 10pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb,scrextend}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{silence}
\WarningFilter{latex}{You have requested package}
\input{ltx/pkg/preamble}

\begin{document}

\lhead{MAT224 Linear Algebra II}
\chead{Kernel, Image \& Dimension Theorem}
\rhead{Week 05}

\title{Linear Algebra II \\ \Large{MAT224}}
\author{Lennart Döppenschmitt}
% \maketitle
% \tableofcontents

\lb
\textbf{Announcements for the test}
\begin{enumerate}
    \item Don't quote numbers of Theorems, but their content and why they apply in this case.
    \item Famous theorems have names, for example \emph{Extend-,} \emph{Reduce-} and \emph{Fundamental} Theorem.

    \item The test covers everything we did from sections 1.1 - 1.6 and section 2.1,
        homework problems 1 to 4 and Assignments 1 \& 2

    \item Please read the \emph{Term-Test-1 information document} about logistics
        well in advance!
    \item \emph{Don't} leave the upload to the last minute!
        Plan for some technical difficulties, they always occur! :(

    \item
        Read question statements carefully and slowly! Make sure you distinguish \emph{if} vs.
        \emph{if and only if} in statements. Give a proof or explanation when the question
        requires one.
    \item
        While we write $\vec v$ for vectors, the book and other sources may write
        $\textbf{x} ∈ V$.
    \item
        By abuse of notation, the image of a vector under a transformation $T(\vec v)$ can
        sometimes be abbreviated as $T \textbf{x} $.

\end{enumerate}

\vspace{100pt}
\section*{Kernel and Image}%
\textbf{Textbook:} Section 2.3

\lb
\textbf{Definition (2.3.1 \& 2.3.10)}
\lb
For a linear transformation $ \map{V}[T]{W}$, we define
\begin{enumerate}
    \item
        the \emph{preimage} $T^{-1}(S)$ of $S \subseteq W$ under $T$ as all $\vec v ∈ V$ that map into $S$.
    \item
        the \emph{kernel} $\ker(T)$ of $T$  as all $\vec v ∈ V$ that map to $\vec 0$ under $T$,
    \item
        the \emph{image} $\tx{im}(T)$ of $T$ as all $\vec w ∈ W$ such that $\vec w = T(\vec v)$ for some $\vec v ∈ V$,
\end{enumerate}

\vspace{100pt}
\lb
\textbf{Example}
\begin{itemize}
    \item
    The kernel of $\map{\pol{n}{\R}}[\frac{d}{dx}]{\pol{n}{\R}}$ are all constant polynomials,
    while the image consists of polynomials of degree $n-1$.

    \item
    The kernel of the evaluation map $\map{\pol{n}{\R}}[\tx{ev}_2]{\R}$ are all
    polynomials that have a root at $x = 2$. What is the image?

    \item
    What is the image of the linear transformation defined in example 2.2.2 $\map{\R^2}[T]{\R^2}$?
    \[ T(\vec e_1) = \vec e_1 + \vec e_2 \]
    \[ T(\vec e_2) = \vec 2 e_1 - 2 \vec e_2 \]
\end{itemize}

\newpage
\lb
\textbf{Proposition 2.3.2 \& 2.3.11}
\lb
For every linear transformation $\map{V}[T]{W}$
\begin{enumerate}
    \item $\ker(T)$ is a subspace in $V$
    \item $\tx{im}(T)$ is a subspace in $W$.
\end{enumerate}
\begin{proof}
\end{proof}

\vspace{300pt}
\lb
\textbf{Proposition 2.3.7}
\lb
Let $\map{V}[T]{W}$ be a linear transformation between vector spaces $V$ and $W$ with
bases $α$ and $β$ respectively.
\lb
\ble{
    The subspace $\ker(T)$ is isomorphic to the solution space to
    the homogeneous system of $[T]_α^β$.
}
\lb
\q{
    That is,
    \begin{itemize}
        \item
            for every $\vec v ∈ \ker(T)$ the coordinate tuple $[\vec v]_α$
            solves $[T]_α^β \vec x = \vec 0$.
        \item
            for every solution $ \vec s = \begin{pmatrix} s_1 \\ \vdots \\ s_n \end{pmatrix}$
            of the system $[T]_α^β \vec x = \vec 0$, the \emph{realization} in the basis $α$, namely
            \[ \iv{(γ^α)} \left(\begin{pmatrix} s_1 \\ \vdots \\ s_n \end{pmatrix} \right) \]
            is a vector in $\ker(T)$.
    \end{itemize}
}
\begin{proof}
\end{proof}

\newpage
\lb
\textbf{Example}
\lb
Find the kernel of the evaluation map $ \map{\pol{n}{\R}}[\tx{ev}_2]{\R}$.

\newpage
\lb
\textbf{Observation (analogous to 2.3.7)}
\lb
Let $\map{V}[T]{W}$ be a linear transformation between vector spaces $V$ and $W$ with
bases $α$ and $β$ respectively.
\lb
\ble{
    The subspace $\tx{im}(T)$ is isomorphic to the space of all $\vec b ∈ \R^m$ such that
    the system of linear equations $[T]_α^β \vec x = \vec b$ has a solution
}
\lb
\q{
    That is,
    \begin{itemize}
        \item
            for every $\vec w ∈ \tx{im}(T)$ the system
            $[T]_α^β \vec x = [\vec w]_β$ has a solution.
        \item
            for every constant vector $ \vec b = \begin{pmatrix} b_1 \\ \vdots \\ b_n \end{pmatrix}$
            such that the system $[T]_α^β \vec x = \vec b$ has a solution, the \emph{realization} in the basis $β$, namely
            \[ \iv{(γ^β)} \left(\begin{pmatrix} b_1 \\ \vdots \\ b_n \end{pmatrix} \right) \]
            is a vector in $\tx{im}(T)$.
    \end{itemize}
}
\begin{proof}
\end{proof}

\vspace{200pt}

\lb
\textbf{Discussion}
\lb
Based on this observation, which $\vec v ∈ V$ will be in the preimage $T^{-1}(\vec w)$?

\newpage
\lb
\textbf{Definition}
\lb
For a matrix $A = [ a_1, a_2, \ldots, a_m] ∈ \mat{n, m}{\R}$ we denote
the span of the columns of $A$ by
\[ \tx{col}(A) = \spn{a_1, \ldots, a_m} \]

\vspace{100pt}
\lb
\textbf{Lemma}
\lb
For a matrix $A = [ a_1, a_2, \ldots, a_m] ∈ \mat{n, m}{\R}$ the system
\[ A\vec x = \vec b \]
has a solution if and only if
$\vec b ∈ \tx{col}(A)$
\begin{proof}
\end{proof}

\vspace{100pt}
\lb
\textbf{Proposition}
\lb
Let $\map{V}[T]{W}$ be a linear transformation between vector spaces $V$ and $W$ with
bases $α$ and $β$ respectively.
\lb
The image of $T$ is isomorphic to $\tx{col}([T]_α^β)$ under the coordinate map
$ \map{W}[γ^β]{\R^m}$.
\begin{proof}
\end{proof}

\vspace{100pt}
\lb
\textbf{Example}
\lb
Find the image of the linear transformation
\begin{align*}
    \R^2 &\ra \R^3 \\
    \ttpl{x}{y} &\mapsto \tttpl{x+y}{x}{y}
\end{align*}

\newpage
\lb
Notice that the columns might not be independent,
in which case the columns are a spanning set of the image, but not a basis.

\lb
\textbf{Theorem (Nicholson - Linear algebra with Applications)}
\lb
Given a linear transformation $\map{V}[T]{W}$ with matrix $[T]_α^β$ for some bases $α$ and $β$.
Let $R = \tx{RREF}([T]_α^β)$ be the reduced row echolon form of $[T]_α^β$.
\lb
Then if the leading 1s in are $R$ lie in columns
$j_1, j_2,\ldots, j_r$, the columns $j_1, j_2,\ldots, j_r$ of $[T]_α^β$ are a basis for
$ \tx{col}([T]_α^β)$
\begin{proof}
\end{proof}

\vspace{200pt}
\lb
\textbf{Discussion}
\lb
Suppose a linear transformation $\map{V}[T]{W}$ is given in a some bases $α$ and $β$ by
\[ [T]_α^β = \begin{pmatrix} 1 & 2 & 0 & 1 \\ 1 & 2 & 1 & 0 \end{pmatrix} \]
Find a basis for $\tx{im}(T)$ and $\ker(T)$.

% \lb
% \textbf{Proposition 2.3.12}
% \lb
% If $ \cb{\vec v_1, \ldots, \vec v_k}$ spans $V$, then $ \cb{T(\vec v_1), \ldots, T(\vec v_k)}$
% spans $\tx{im}(T)$.
% \begin{proof}
% \end{proof}

\newpage
\lb
A similar question is discussed in Example 2.3.9 in the book.

\lb
\textbf{Discussion}
\lb
Find the kernel, the image and bases of them for
the following transformations in bases of your choice.

\begin{enumerate}
    \item tbd
\end{enumerate}

\newpage
\section*{Dimension Theorem}%

\textbf{Textbook:} Section 2.3 \& 2.4
\lb
\textbf{Theorem 2.3.17 (Rank-Nullity)}
\lb
For any linear transformation $\map{V}[T]{W}$
\[ \dim(V) = \dim(\ker(T)) + \dim( \tx{im}(T)) \]

\lb
\textbf{Remark}
\begin{itemize}
    \item
        $\dim( \tx{im}(T))$ is the same as the rank of $[T]_α^β$ and by abuse of
        notation also referred to as $\tx{rank}(T)$.
    \item
        Some books refer to $\dim(\ker(T))$ as the \emph{nullity} of $T$.
\end{itemize}

\begin{proof}
\end{proof}

\vspace{300pt}
\lb
\textbf{Theorem}
\lb
A linear transformation $T$ is injective if and only if $\ker(T) = \cb{\vec 0}$
\begin{proof}
\end{proof}

\newpage
\lb
\textbf{True or False}
Let $\map{V}[T]{W}$ be a linear transformation
\begin{enumerate}
    \item[$\square$]
        If $T$ is an isomorphism, then $\dim(V) = \dim(W)$.
    \item[$\square$]
        If $\dim(V) > \dim(W)$, $T$ has to be injective.
    \item[$\square$]
\end{enumerate}

\newpage
\section*{Composition}%
\textbf{Textbook:} Section 2.5

\lb
\textbf{Discussion}
\lb
Without doing a lot of work, can you argue what the matrix
representing the composition $F \circ T$ is assuming you know $[F]$ and $[T]$?

\newpage
\section*{Review session}%
\begin{itemize}
    \item Vector spaces
    \item subspaces
    \item Sum, intersection, direct sum
    \item Linear independence
    \item Spanning set
    \item Basis
    \item Dimension
    \item Linear Transformation
\end{itemize}

\end{document}


%&latexf
\documentclass[a4paper]{article}
\usepackage{color}
\setlength{\hoffset}{-0.5in}\hoffset-0.5in
\setlength{\textwidth}{15cm}
\usepackage{hyperref}
\usepackage{amsmath, amsfonts, amsthm, amssymb}
\usepackage{verbatim}
\usepackage{stmaryrd}
\usepackage{fancyhdr}
\usepackage{color}
\usepackage[dvips]{graphicx}
\usepackage{subfigure}
\linespread{1.5}
%\font\twelvemsb=msbm10 at 12pt
\newfam\msbfam
%\textfont\msbfam=\twelvemsb
\def\Bbb#1{\fam\msbfam\relax#1}

\topmargin = 20pt
\voffset = -20pt
\addtolength{\textheight}{2cm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{exa}{Example}[section]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{notation}[theorem]{Notation}
\newtheorem{assumption}[theorem]{Assumption}
\newtheorem{conjecture}[theorem]{Conjecture}

\newcommand{\ind}{1\hspace{-2.1mm}{1}} %Indicator Function
\newcommand{\I}{\mathtt{i}}
\newcommand{\D}{\mathrm{d}}
\newcommand{\E}{\mathrm{e}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\sgn}{\mathrm{sgn}}
\newcommand{\atanh}{\mathrm{arctanh}}
\def\equalDistrib{\,{\buildrel \Delta \over =}\,}
\numberwithin{equation}{section}
\def\blue#1{\textcolor{blue}{#1}}
\def\red#1{\textcolor{red}{#1}}

\begin{document}

\include{ThesisFrontPage}
\include{ThesisAcknowledgements}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\text{}\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setcounter{tocdepth}{4}
\tableofcontents
\newpage
%\newpage
%\include{ThesisNotations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\fancyhead{}
\fancyfoot{}
\pagestyle{fancy}
%\fancyhead{\sffamily\small \thepage}
%\fancyhead{\sffamily\small \nouppercase{\rightmark}}
\fancyhead[RO,LE]{\sffamily\small \thepage}
\fancyhead[LO,RE]{\sffamily\small \nouppercase{\rightmark}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\include{Thesis_Part1_Introduction}
%\include{Thesis_Part2_Tools}
%\include{Thesis_Part3_Large}
%\include{Thesis_Part4_Small}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}
General introduction.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Option pricing}
\subsection{The fundamental theorem of asset pricing}

\subsection{The Black-Scholes model}
Consider a given probability space $(\Omega, (\mathcal{F})_t,\mathbb{P})$
supporting a Brownian motion~$(W_t)_{t\geq 0}$.
In the Black-Scholes model, the stock price process~$(S_t)_{t\geq 0}$ is the unique strong solution to
the following stochastic differential equation:
\begin{equation}\label{eq:BS}
\frac{\D S_t}{S_t} = r \D t + \sigma \D W_t,
\qquad S_0>0,
\end{equation}
where $r\geq 0$ denotes the instantaneous risk-free interest rate and $\sigma>0$ the instantaneous volatility.

\subsubsection{No interest rates}
\subsubsection{Including interest rates}
A European call price $C_t(S_0,K,\sigma)$ with maturity $t>0$ and strike $K>0$
pays at maturity $(S_t-K)_+=\max(S_t-K,0)$.
When the stock price follows the Black-Scholes SDE~\eqref{eq:BS},
Black and Scholes~\cite{BS73} proved that its price at inception is worth
$$
C_t(S_0,K,\sigma) = S_0\mathcal{N}(d_+) - K\E^{-rt}\mathcal{N}(d_-),
$$
where
$$
d_{\pm} := \frac{\log\left(S_0 \E^{rt}/K\right)}{\sigma\sqrt{t}} \pm \frac{\sigma\sqrt{t}}{2},
$$
and where~$\mathcal{N}$ denotes the cumulative distribution function of the Gaussian random variable.

Here is an example of how to insert a picture:

\begin{figure}[!ht]
\centering
\subfigure{\includegraphics[scale=0.2]{Picture.eps}}
\caption{This is the caption for the figure.}
\label{fig:Pict}
\end{figure}

or two side-by-side pictures:

\begin{figure}[!ht]
\centering
\subfigure{\includegraphics[scale=0.3]{Picture.eps}}
\hspace{15pt}
\subfigure{\includegraphics[scale=0.3]{Picture.eps}}
\caption{Blablabla}
\label{fig:Pict2}
\end{figure}

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Model calibration}
\subsection{What is calibration?}
Here is an example of a matrix in $A\in\mathcal{M}_n(\RR)$:
$$
A =
\begin{pmatrix}
a_{11} & a_{12} & \ldots & a_{1n}\\
a_{21} & \ddots & \ddots  & \vdots\\
\vdots &  \ddots & \ddots  & \vdots\\
a_{n1} &  \ldots &  \ldots & a_{1n}.
\end{pmatrix}
$$

\subsection{Numerical methods for calibration}
...

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\appendix

\section{Review of stochastic calculus}
\subsection{Riemann integration}
\subsection{The It\^o integral}

\section{Some technical proofs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\include{ThesisConclusion}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{thebibliography}{9}
\bibitem{BS73}F.~ Black and M.~Scholes.
The Pricing of Options and Corporate Liabilities.
\textit{Journal of Political Economy}, {\tt 81} (3): 637-659, 1973.

\bibitem{KS97}I.~ Karatzas and S.E.~Shreve.
Brownian Motion and Stochastic Calculus.
Springer-Verlag, 1997.

\bibitem{KT81}S.~Karlin and H.~Taylor.
A Second Course in Stochastic Processes.
Academic Press, 1981.

\bibitem{Tank} P.~Tankov.
Pricing and hedging in exponential L\'evy models: review of recent results.
\textit{Paris-Princeton Lecture Notes in Mathematical Finance}, Springer, 2010.

\bibitem{W03}D.~Williams.
Probability With Martingales.
CUP, 1991.

\end{thebibliography}

\end{document}


\section{Entropy}
Entropy is central to the second and third laws of thermodynamics, as well as understanding the spontaneity of processes. It's a concept you'll see appear not only in physics, but in chemistry and biology as well.

\subsection{Types of Systems}
Just before we define our notion of this mysterious "entropy", it will help to define what different kinds of systems mean. An \textbf{Open system} is one in which both matter and energy can be exchanged with its environment. A \textbf{Closed system} is a system where energy can be exchanged with the environment, but no matter. Finally, an \textbf{isolated} system is where neither matter nor energy can be exchanged with the environment. \\
As a quick example, suppose my system is a half cup of water. If I leave the top of the cup open, it's an open system as the water molecules can evaporate and leave the cup. If I close the top of the cup, then it's a closed system as I can still give energy to the cup (say, by heating it in a microwave) even if the water molecules can't escape from it. If the cup is perfectly insulated and closed off, then its an isolated system as neither matter nor energy can enter or exit the cup. With this in mind, let's proceed with the most mindbending concept of this unit!
\input{Entropy/classicaldefinition}
\input{Entropy/statisticaldefinition}
\input{Entropy/questions}


\documentclass[11pt]{article}
\usepackage[
top    = 2.50cm,% presumably you don't want it to be 0pt as well?
bottom = 2.50cm,
left   = 2cm,
right  = 2cm,
marginparsep = 0pt,
marginparwidth=0pt,
]{geometry}

\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage[most]{tcolorbox}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{multicol}
\pagestyle{fancy}
\fancyhead[l]{Heat - Abridged edition}
\fancyhead[r]{Giorgio Grigolo {\textcopyright}}
\tikzset{
	mypath/.style={
		postaction=decorate,
		decoration={markings,
			mark=at position #1 with {\coordinate (x);\arrow{>}}},
		thick},
	>=stealth
}
\begin{document}
\section{First Law of Thermodynamics}
	\begin{center}
		\textit{The net change in the internal energy of a system is the sum of the net heat transfer from or to the system and the work done by or on the system.}
\end{center}
\begin{equation}
	\Delta U = \Delta Q + \Delta W\tag{\si\joule}
\end{equation}
\begin{center}
	Where $\Delta U$ is the net change in internal energy, $\Delta Q$ is the net amuont of heat transferred and $\Delta W$ is the net amount of work done.
\end{center}
\section{Specific Heat Capacity: }

\begin{equation}
	\Delta Q = mc\Delta\theta\tag{\si{\joule}}
\end{equation}

\section{Work done during volume changes: }
\begin{equation}
	\Delta W = p \Delta V\tag{\si{\joule}}
\end{equation}
\begin{center}
	Where $p$ is the \textbf{pressure} (\si{\pascal}) exerted and $\Delta V$ is the change in \textbf{volume} (\si{\meter\cubed}).
\end{center}
\subsection{Graph: }
\begin{center}
	\begin{tikzpicture}[scale=1.8]
	\draw[<->] (4.5,0) node[below] {$V$} -| (0,3.5) node[left] {$p$};
	\path (1,1) coordinate (2) {} (2.5,.8) coordinate (1) {}
	(1,2) coordinate (3) {} (2.5,1.5) coordinate (4) {};
	\path[font=\footnotesize] (1) node[below right] {1}
	(2) node[left] {2}
	(3) node[above right] {3}
	(4) node[above right] {4};
	\draw[mypath=.4,shorten <=-.15cm] (1) to[bend left=5] (2);
	\path (x) node[below] {$\mathrm{d}Q=0$};
	\draw[mypath=.4,shorten <=-.2cm,shorten >=-.2cm] (3) to[bend right=15] (4);
	\path (x) node[above right] {$\mathrm{d}Q=0$};
	\draw[mypath=.5] (2) -- (3);
	\draw[->] (x)++(-.5,0) -- + (.3,0) node[midway,above] {$\Delta Q_h$};
	\draw[mypath=.5] (4) -- (1);
	\draw[<-] (x)++(.5,0) -- + (-.3,0) node[midway,above] {$\Delta Q_c$};
	\draw[dashed] (2) -- (1,0) node[below] {$V_2$}
	(1) -- (2.5,0) node[below] {$V_1$};
	\foreach \i in {1,...,4} \filldraw[fill=white] (\i) circle (1pt);
\end{tikzpicture}
\end{center}

\section{Latent heat: }
\begin{center}
	\textit{The heat required to convert a solid into a liquid or vapour, or a liquid into a vapour, without change of temperature.}
\end{center}

\begin{equation}
\Delta Q =ml\tag{\si{\joule\per\kg}}
\end{equation}

\begin{center}

\end{center}
\end{document}


\graphicspath{{figures--tt/}}

%%%%%%%%%%%%%%%%% CHAPTER 11

\chapter{Truth tables and validity}\label{c:tt-validity}

\section{Validity}\label{s:tt-validity}

Having examined the logical relations between two sentences in \S\ref{equivalence--tt} and \S\ref{consistency--tt}, we can now go a step further and consider the relationship between the premises and the conclusion of an argument.
%This begins with \define{entailment}.
%\begin{factboxy}{Entailment}
%The sentences $\meta{A}_1, \meta{A}_2, \ldots, \meta{A}_n$ \define{entail} the sentence $\meta{C}$ if there is no valuation of the atomic sentences that makes all of $\meta{A}_1, \meta{A}_2, \ldots, \meta{A}_n$ true and $\meta{C}$ false.
%\end{factboxy}
Recall the definition of \define{valid}.
\begin{factboxy}{valid}
An argument is \define{valid} when (and only when) it is the case that if the premises are true, then the conclusion has to be true.
\end{factboxy}

% Next is this important observation: if $\meta{A}_1, \meta{A}_2, \ldots, \meta{A}_n$ entail $\meta{C}$, then $\meta{A}_1, \meta{A}_2, \ldots, \meta{A}_n \proves \meta{C}$ is valid.
% Here's why entailment equals validity. If $\meta{A}_1, \meta{A}_2, \ldots, \meta{A}_n$ entail $\meta{C}$, then there is no valuation that makes all of $\meta{A}_1, \meta{A}_2, \ldots, \meta{A}_n$ true while making $\meta{C}$ false. This means that it is \emph{impossible} for each of $\meta{A}_1, \meta{A}_2, \ldots, \meta{A}_n$ to be true and $\meta{C}$ to be false. And that is just what it takes for an argument with premises $\meta{A}_1, \meta{A}_2, \ldots, \meta{A}_n$ and conclusion $\meta{C}$ to be valid!
% In short, we have a way to test whether an argument in English is valid. First, we symbolize the premises and conclusion in TFL. Then we test for entailment using truth tables.

When using a truth table to determine if an argument is valid, we list the premise or premises first, then, the turnstile symbol (`\proves'), and, finally, the conclusion. We will use `$\enot L \eif (M \eor L), \enot L \proves M$' as our example.

\begin{notebox}
The symbol `$\proves$' is used to separate the premises from the conclusion in arguments in TFL. It can be read as \textit{therefore}.
\end{notebox}

\begin{center}
\begin{tabular}{d d | f e e e e h | f h | g | f}
$M$ & $L$ & \enot&$L$&\eif&$(M$&\eor&$L)$& \enot&$L$& \proves & $M$\\
\hline
 T & T & F & T & \TTbf{T} & T & T & T & \TTbf{F} & T && \TTbf{T}\Tstrut\\
 T & F & T & F & \TTbf{T} & T & T & F & \TTbf{T} & F && \TTbf{T}\\
 F & T & F & T & \TTbf{T} & F & T & T & \TTbf{F} & T && \TTbf{F}\\
 F & F & T & F & \TTbf{F} & F & F & F & \TTbf{T} & F && \TTbf{F}
\end{tabular}
\end{center}

Once the truth table is completed for `$\enot L \eif (M \eor L), \enot L \proves M$', we investigate whether this argument satisfies (or violates) the definition of \textit{valid}. Ask yourself, ``When both premises are true, is the conclusion true?'' And ``Is there any line (that is, any valuation) where both premises are true and the conclusion is false?'' If the answer to the first question is always ``yes,'' then the argument is valid. If the answer to the second question is ever ``no,'' then the argument is invalid.

As you can see, there is only one row where both `$\enot L \eif (M \eor L)$' and `$\enot L$' are true, and so that is the row that mainly concerns us. On that row, the conclusion is also true. Hence, `$\enot L \eif (M \eor L), \enot L \proves M$' is valid.
\begin{center}
\begin{tabular}{d d | f e e e e h | f h | g | f}
$M$ & $L$ & \enot&$L$&\eif&$(M$&\eor&$L)$& \enot&$L$& \proves & $M$\\
\hline
 T & T & F & T & \TTbf{T} & T & T & T & \TTbf{F} & T && \TTbf{T}\Tstrut\\
 T & F & T & F & \circled{\TTbf{T}} & T & T & F & \circled{\TTbf{T}} & F &\cm& \TTbf{T}\\
 F & T & F & T & \TTbf{T} & F & T & T & \TTbf{F} & T && \TTbf{F}\\
 F & F & T & F & \TTbf{F} & F & F & F & \TTbf{T} & F && \TTbf{F}
\end{tabular}
\end{center}

When using truth tables to determine if an argument is valid, we will put `\cm' and `\xm' in the column under the turnstile. As just shown, when all of the premises are true and the conclusion is true, we put a `\cm' on that line beneath the turnstile. If, on a line, all of the premise are true and the conclusion is false, then we put a `\xm' beneath the turnstile.
Also (and \textbf{importantly!}), when there is a line where one or more of the premises are false, we put a `\cm' beneath the turnstile (whether the conclusion is true or false).

An argument is valid when it is the case that \textit{if the premises are true}, then the conclusion has to be true. In the argument above, the premises are true when `$M$' is true and `$L$' is false---which is line 2. That there are other valuations where both premises are not true doesn't matter. Such lines don't violate our definition of \textit{valid}, and so they get a `\cm'.

\begin{notebox}
To see that an argument containing a premise that is false can still be valid, consider this argument (which can't be translated into TFL, so don't try).
\begin{earg}
\item[P1.] City A is larger than city B.
\item[P2.] City B is larger than city C.
\item[C.] Therefore, city A is larger than city C.
\end{earg}
Even though it can't be represented in TFL, this argument is clearly valid: if the premises are true, then the conclusion has to be true. And that doesn't change if, out there in the world (or in some parallel universe), city B is larger than city A.
\end{notebox}

Completing our truth table we have this:
\begin{center}
\begin{tabular}{d d | f e e e e h | f h | g | f}
$M$ & $L$ & \enot&$L$&\eif&$(M$&\eor&$L)$& \enot&$L$& \proves & $M$\\
\hline
 T & T & F & T & \TTbf{T} & T & T & T & \TTbf{F} & T &\cm& \TTbf{T}\Tstrut\\
 T & F & T & F & \circled{\TTbf{T}} & T & T & F & \circled{\TTbf{T}} & F &\cm& \TTbf{T}\\
 F & T & F & T & \TTbf{T} & F & T & T & \TTbf{F} & T &\cm& \TTbf{F}\\
 F & F & T & F & \TTbf{F} & F & F & F & \TTbf{T} & F &\cm& \TTbf{F}
\end{tabular}
\end{center}

%% The `good and bad lines' box could go here.

Now, let's make one small (but significant) change to the argument: $\enot L \eif (M \eor L)$, $\enot L \proves \enot M$. The premises are the same, but now the conclusion is $\enot M$ instead of $M$.
%Here is the truth table:
%\begin{center}
%\begin{tabular}{c c|d e e e e f|d f| c | c}
%$M$&$L$&\enot&$L$&\eif&$(M$&\eor&$L)$&\enot&$L$		&\proves		& $\enot M$\\
%\hline
% T & T & F & T & \TTbf{T} & T & T & T 	& \TTbf{F} 	& T 		&	& \TTbf{F}\Tstrut\\
% T & F & T & F & \TTbf{T} & T & T & F 	& \TTbf{T} 	& F		&	& 	\TTbf{F}\\
% F & T & F & T & \TTbf{T} & F & T & T 	& \TTbf{F} 	& T 		&	& \TTbf{T}\\
% F & F & T & F & \TTbf{F} & F & F & F 	& \TTbf{T} 	& F 		&	& \TTbf{T}
%\end{tabular}
%\end{center}

The truth values for the premises are the same, and the truth values for the conclusion have, on each line, flipped from T to F or vice versa. Now, when we evaluate each line, what do we find? As before, on lines 1, 3, and 4, one of the premises is false, and so they get a `\cm'. On line 2, the premises are true and the conclusion is false. That line gets a `\xm'! Because there is a line where the premises are true and the conclusion is false, `$\enot L \eif (M \eor L)$, $\enot L \proves \enot M$' is not valid.
\begin{center}
\begin{tabular}{d d | f e e e e h | f h | g | f}
$M$&$L$&\enot&$L$&\eif&$(M$&\eor&$L)$&\enot&$L$	&\proves				& $\enot M$\\
\hline
 T & T & F & T & \TTbf{T} & T & T & T & \TTbf{F} & T 		&	\cm					& \TTbf{F}\Tstrut\\
 T & F & T & F & \circled{\TTbf{T}} & T & T & F & \circled{\TTbf{T}} & F 	& \xm	& \circled{\TTbf{F}}\\
 F & T & F & T & \TTbf{T} & F & T & T & \TTbf{F} & T 		&	\cm					& \TTbf{T}\\
 F & F & T & F & \TTbf{F} & F & F & F & \TTbf{T} & F 		&	\cm					& \TTbf{T}
\end{tabular}
\end{center}

\begin{factboxy}{good and bad lines}\label{s:tt-good-lines}
Let's call lines that violate the definition of \define{valid} \textit{bad lines} and the lines that do not \textit{good lines}.
	\begin{enumerate}
		\item[(1)] Any line where all of the premises are true and the conclusion is false \textbf{is a bad line}. Put an `\xm' on that line.
		\item[(2)] Any line where all of the premises are true and the conclusion is true \textbf{is a good line}. Put a `\cm' on that line.
		\item[(3)] Any line where the conclusion is true cannot be a bad line. (So, whatever the case may be with the premises, \textbf{it's a good line}.) Put a `\cm' on that line.
		\item[(4)] Any line where at least one premise is false cannot be a bad line. (So, whatever the case may be with the rest of the argument, \textbf{it's a good line}.) Put a `\cm' on that line.
	\end{enumerate}
\end{factboxy}

\section{Some examples}

Here are some examples using truth tables to determine whether an argument is valid. As a reminder, the definition of valid is given in \S\ref{s:tt-validity}, and we can also use 1 - 4 on p.~\pageref{s:tt-good-lines} (which are consequences of the definition). We will begin with arguments that have only one premise and then do some with multiple premises.

\begin{earg}
\item[\ex{1P-1}] First we will determine if `$P \eand Q \proves Q$' is valid. The premise, `$P \eand Q$', is only true on line 1. Since it is false on lines 2 - 4, we know that those are good lines. (See guideline 4.) On line 1, `$P \eand Q$' is true and the conclusion, `$Q$', is true, and so that is also a good line. (See guideline 2.) Since every line is a good line, this argument is valid.
\begin{center}
\begin{tabular}{d d | f e h | g | f}
$P$& $Q$& 	$P$& $\eand$& $Q$& $\proves$& $Q$\\
\hline
 T & T 	&   T& \TTbf{T} & T & \cm & \TTbf{T}\Tstrut\\
 T & F 	&   T& \TTbf{F} & F & \cm & \TTbf{F}\\
 F & T 	&   F& \TTbf{F} & T & \cm & \TTbf{T}\\
 F & F 	&   F& \TTbf{F} & F & \cm & \TTbf{F}
\end{tabular}
\end{center}

\item[\ex{1P-2}]
In `$\enot (P\eor Q) \proves \enot P \eand Q$', the premise is false on lines 1 -- 3, and so we know that those are good lines. On line 4, the premise is true and the conclusion is false, which means that line 4 is a bad line. (See guideline 1.) Since it has at least one bad line, this argument is not valid.
\begin{center}
\begin{tabular}{d d | f e e h | g | f e e e}
$P$& $Q$& 	$\enot$& $(P$& $\eor$& $Q)$& $\proves$& $\enot$& $P$& $\eand$& $Q$\\
\hline
 T & T 	&   \TTbf{F} & T & T& T& 	\cm & F& T& \TTbf{F}& T\Tstrut\\
 T & F 	&   \TTbf{F} & T & T& F&	\cm & F& T& \TTbf{F}& F\\
 F & T 	&   \TTbf{F} & F & T& T&	\cm & T& F& \TTbf{T}& T\\
 F & F 	&   \TTbf{T} & F & F& F&	\xm & T& F& \TTbf{F}& F
\end{tabular}
\end{center}

\item[\ex{2P-1}]Now an argument with two premises: `$P \eif Q, \enot Q \proves \enot P$'. Since both premise are not true on lines 1, 2, and 3, those are all good lines. On line 4, both premises are true and the conclusion is true, and so that is a good line. Since every line is a good line, this argument is valid.
\begin{center}
\begin{tabular}{d d | f e h | f h | g | f e}
$P$ & $Q$ & $P$ & $\eif$ & $Q$ & $\enot$ & $Q$ & \proves & $\enot$ &$P$\\
\hline
T & T &   T &   \TTbf{T} &T   & \TTbf{F} &T & \cm &\TTbf{ F } &T\Tstrut\\
T & F &   T &   \TTbf{F} &F   & \TTbf{T} &F & \cm & \TTbf{F } &T\\
F & T &   F &   \TTbf{T} &T   & \TTbf{F} &T & \cm & \TTbf{T } &F\\
F & F &   F &   \TTbf{T} &F   & \TTbf{T} &F & \cm & \TTbf{T } &F\\
\end{tabular}
\end{center}

\item[\ex{2P-2}]
Next, consider `$P\eif Q, P \eif \enot Q \proves P$'. Since the second premise is false on line 1 and the first premise is false on line 2, those are good lines. On line 3, both of the premises are true and the conclusion is false. That's a bad line. And then the same is also the case on line 4, and so that is a bad line also. Since two of the lines in this truth table are bad lines, the argument is invalid.
\begin{center}
\begin{tabular}{d d | f e e 	j e e e 	   j	  j }
$P$ &$Q$ 	&$P$ & $\eif$ &$Q$,  	& $P$ & $\eif$ & $\enot$ &$Q$ & \proves	& $P$\\
\hline
T &T   &T &\TTbf{T} &T   &T &\TTbf{F} &F  &T & \cm &\TTbf{T}\Tstrut\\
T &F   &T &\TTbf{F} &F    &T &\TTbf{T} &T &F  & \cm &\TTbf{T}\\
F &T   &F &\TTbf{T} &T    &F &\TTbf{T} &F &T  & \xm &\TTbf{F}\\
F &F   &F &\TTbf{T} &F    &F &\TTbf{T} &T &F  & \xm &\TTbf{F}\\
\end{tabular}
\end{center}

\item[\ex{3P-1}] In the last argument, we have three premises. One of the premises is false on each of lines 1, 2, 4, 5, 7, and 8, and so those are all good lines. On line 3, all of the premises are true and the conclusion is true, and so that is a good line. On line 6, all of the premises are true but the conclusion is false, and so that is a bad line. Since one of the lines is a bad line, this argument is invalid.
\begin{center}
\begin{tabular}{d d d | f e e     j e e		 j e e e 	   j 	  j }
$P$& $Q$& $R$&  $P$& 	$\eor$& 	$Q$,&   $P$		&$\eif$	&$R$,		&$Q$		&$\eif$	&$\enot$	&$R$	&$\proves$& $R$\\
\hline
T& T& T &   T &\TTbf{T}& T   &   T &\TTbf{T}& T   &   T& \TTbf{F}& F& T&\cm   & \TTbf{T}\Tstrut\\
T& T& F &   T &\TTbf{T}& T   &   T &\TTbf{F}& F   &   T& \TTbf{T}& T& F&\cm   & \TTbf{F}\\
T& F& T &   T &\TTbf{T}& F   &   T &\TTbf{T}& T   &   F& \TTbf{T}& F& T&\cm   & \TTbf{T}\\
T& F& F &   T &\TTbf{T}& F   &   T &\TTbf{F}& F   &   F& \TTbf{T}& T& F &\cm  & \TTbf{F}\\\arrayrulecolor{light-gray}\hline
F& T& T &   F &\TTbf{T}& T   &   F &\TTbf{T}& T   &   T& \TTbf{F}& F& T&\cm   & \TTbf{T}\Tstrut\\
F& T& F &   F &\TTbf{T}& T   &   F &\TTbf{T}& F   &   T& \TTbf{T}& T& F &\xm & \TTbf{F}\\
F& F& T &   F &\TTbf{F}& F   &   F &\TTbf{T}& T   &   F& \TTbf{T}& F& T &\cm  & \TTbf{T}\\
F& F& F &   F &\TTbf{F}& F   &   F &\TTbf{T}& F   &   F& \TTbf{T}& T& F &\cm  & \TTbf{F}\\
\end{tabular}
\end{center}

\end{earg}

\section{`$\proves$' versus `$\eif$'}

When using truth tables to determine whether an argument is valid, it may help you to notice a similarity between `$\proves$' and `$\eif$'. As you know, a conditional is true under every circumstance except when the antecedent is true and the consequent if false. (So, when we have a `T' under the antecedent and an `F' under the consequent, we put an `F' under the `$\eif$'.) Meanwhile, in an argument, when all of  the premises are true and the conclusion is false, the argument is invalid. (So, for a specific line, when we have a `T' under every premise and an `F' under the conclusion, we put a `\xm' under the `$\proves$'.)

The reasoning here is similar. In both cases, we are violating the principle---of either the conditional or of a valid argument---when we have a false sentence that follows from a sentence or a set of sentences that are all true. Thus, if $\meta{A} \eif \meta{C}$ is false, then $\meta{A} \proves \meta{C}$ is invalid (and if $\meta{A} \proves \meta{C}$ is invalid, then $\meta{A} \eif \meta{C}$ is false). Conversely, whenever $\meta{A} \eif \meta{C}$ is true, then $\meta{A} \proves \meta{C}$ is valid (and vice versa).

\section{The limits of this type of analysis}\label{s:ParadoxesOfMaterialConditional}

We have seen in chapters \ref{s:SemanticConcepts} and \ref{c:tt-validity} that truth tables are a useful tool for analyzing sentences---whether those are individual sentences, pairs of sentences, or arguments. There are limitations to this type of analysis, however, and it worth understanding some of those limitations.

First, consider this argument:
	\begin{earg}
		\item Daisy has four legs.\\
		Therefore, Daisy has more than two legs.
	\end{earg}
To symbolize this argument in TFL, we would have to use two different atomic sentences---perhaps `$F$' for the premise  and `$T$' for the conclusion. The English version of this argument is clearly valid, but `$F \proves T$' is just as clearly invalid.
\begin{center}
\begin{tabular}{d d | f e e}
$F$& $T$&  $T$& $\proves$& $F$\\
\hline
T& T& T&\cm&  T\Tstrut\\
T& F& F&\cm&  T\\
F& T& T&\xm&  F\\
F& F& F&\cm&  F\\
\end{tabular}
\end{center}
Hence, we should keep in mind that while some English sentences can be effectively translated into TFL, not all can be.

Next, consider this sentence:
\begin{earg}
\setcounter{eargnum}{1}
\item\label{n:JohnBald} John is neither bald nor not-bald.
\end{earg}
This is symbolized in TFL as `$\enot(B \eor \enot B)$', and, as you can see  from the truth table, it is a contradiction.
\begin{center}
\begin{tabular}{d | f e e e e}
$B$&  $\enot$& ($B$& $\eor$& $\enot$& $B$)\\
\hline
T&  \TTbf{F}&   T& T& F& T\Tstrut\\
F&  \TTbf{F}&   F& T& T& F\\
\end{tabular}
\end{center}
But sentence \ref{n:JohnBald} does not seem like a contradiction. After all, someone could very well add ``John is on the borderline of baldness,'' which would (it seems) mean that sentence \ref{n:JohnBald} is true. But since TFL cannot represent a place between `$B$' and `$\enot B$', it cannot treat \textit{John is neither bald nor not-bald} as true.

Third, let's think about this statement:
\begin{earg}
\setcounter{eargnum}{2}
\item\label{n:GodParadox}	It's not the case that, if God exists, he answers evil prayers.
\end{earg}
Symbolizing this in TFL, we have `$\enot (G \eif E)$'. As we can see from the truth table, `$\enot (G \eif E)$' \proves `$G$' is valid.
\begin{center}
\begin{tabular}{d d | f e e e j j}
$E$& $G$&  $\enot$& ($G$& $\eif$& $E$)& $\proves$& $G$\\
\hline
T& T&  \TTbf{F}&   T& T& T&\cm&    \TTbf{T}\Tstrut\\
T& F&  \TTbf{F}&   F& T& T&\cm&    \TTbf{F}\\
F& T&  \TTbf{T}&   T& F& F&\cm&    \TTbf{T}\\
F& F&  \TTbf{F}&   F& T& F&\cm&   \TTbf{F}\\
\end{tabular}
\end{center}
So sentence \ref{n:GodParadox} seems to entail that God exists. But that's not what we expect. An atheist could believe that `It's not the case that, if God exists, he answers evil prayers' without accepting that God does, in fact, exist.

It might be that sentence \ref{n:GodParadox}, despite appearances, does not express what we mean. We can try rephrasing it this way:
\begin{earg}
\setcounter{eargnum}{3}
\item\label{n:GodParadox2} If God exists, he does not answer evil prayers.
\end{earg}
This we symbolize as `$G \eif \enot E$'. Now, as shown in the truth table on the left, `$G$' does not follow from this premise. (That is, the argument `$G \eif \enot E \proves G$' is invalid.) But, at the same time, from the premise `$\enot G$' (i.e., `God does not exist'), it follows that `if God exists, he answers evil prayers'.

\bigskip
\noindent\begin{minipage}{.50\linewidth}
\begin{center}
\begin{tabular}{d d | f e e e j j}
$E$& $G$&  ($G$& $\eif$& $\enot$& $E$)& \proves& $G$\\
\hline
T& T&    T& \TTbf{F}& F& T&\cm&    \TTbf{T}\Tstrut\\
T& F&    F& \TTbf{T}& F& T&\xm&    \TTbf{F}\\
F& T&    T& \TTbf{T}& T& F&\cm&    \TTbf{T}\\
F& F&    F& \TTbf{T}& T& F&\xm&    \TTbf{F}\\
\end{tabular}
\end{center}
%\medskip
\end{minipage}
\begin{minipage}{.50\linewidth}
\begin{center}
\begin{tabular}{d d | f e j j e e}
$E$& $G$&  $\enot$& $G$& $\proves$& ($G$& $\eif$& $E$)\\
\hline
T& T&  \TTbf{F}& T&\cm&    T& \TTbf{T}& T\Tstrut\\
T& F&  \TTbf{T}& F&\cm&    F& \TTbf{T}& T\\
F& T&  \TTbf{F}& T&\cm&    T& \TTbf{F}& F\\
F& F&  \TTbf{T}& F&\cm&    F& \TTbf{T}& F\\
\end{tabular}
\end{center}
\end{minipage}
\bigskip

(We can also put these final two points as follows. When `$G$' is false, `$G \eif \enot E$' is true, and so we don't have to be committed to the existence of God to accept that `If God exists, he does not answer evil prayers'. But if `$G$' is false, then `$G \eif E$'---i.e., `If God exists, he answers evil prayers'---is true.)

In different ways, these three examples illustrate some of the limitations of using a language like TFL that can only handle truth-functional connectives. These limitations give rise to some interesting questions in philosophical logic, however. The case of John's baldness (or non-baldness) raises the general question of what logic we should use when dealing with \emph{vague} discourse. The case of God answering evil prayers illustrates some of the \emph{paradoxes of material implication}.

Part of the purpose of studying truth-functional propositional logic is to equip ourselves with the tools to explore these questions of philosophical logic. But we have to walk before we can run; and  so we have to become proficient using TFL before we can adequately discuss its limits and consider alternatives.

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

%  exercises for `truth tables and validity'

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

%\practiceproblems
\section{Practice exercises}
\setcounter{ProbPart}{0}

\problempart
\label{pr.TT.valid}
Create a truth table for each argument and then determine if the argument is valid or invalid.
\begin{earg}
\item $A\eif A \proves A$\vspace{.5ex} %invalid
\item $A\eif(A\eand\enot A) \proves \enot A$\vspace{.5ex} %valid
\item $A\eor(B\eif A) \proves \enot A \eif \enot B$\vspace{.5ex} %valid
\item $A\eor B, B\eor C, \enot A \proves B \eand C$\vspace{.5ex} %invalid
\item $(B\eand A)\eif C, (C\eand A)\eif B \proves (C\eand B)\eif A$\vspace{.5ex} %invalid

\item $A\eif B$, $B \proves  A$\vspace{.5ex} %invalid
\item $A\eiff B$, $B\eiff C \proves A\eiff C$\vspace{.5ex} %valid
\item $A \eif B$, $A \eif C\proves B \eif C$\vspace{.5ex} %invalid.
\item $A \eif B$, $B \eif A\proves A \eiff B$\vspace{.5ex} %valid.

\item $A\eor\bigl[A\eif(A\eiff A)\bigr] \proves  A $\vspace{.5ex}%invalid
\item $A\eor B$, $B\eor C$, $\enot B \proves A \eand C$\vspace{.5ex} %valid
\item $A \eif B$, $\enot A\proves \enot B$ \vspace{.5ex}%invalid
\item $A$, $B\proves \enot(A\eif \enot B)$ \vspace{.5ex}%valid
\item $\enot(A \eand B)$, $A \eor B$, $A \eiff B\proves C$ \vspace{.5ex}%valid
\end{earg}

\problempart
\begin{earg}
\item Suppose that $(\meta{A}\eand\meta{B})\eif\meta{C}$ is neither a tautology nor a contradiction. Is it possible to determine if $\meta{A}, \meta{B} \proves \meta{C}$ is valid or not? Explain.
\item Suppose that \meta{A} is a contradiction. Is $\meta{A}, \meta{B} \proves \meta{C}$ valid or invalid? Explain.
\item Suppose that \meta{C} is a tautology. Is $\meta{A}, \meta{B}\proves \meta{C}$ valid or invalid? Explain.
\end{earg}

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

%  answers for `truth tables and validity'

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

\section{Answers}
\setcounter{ProbPart}{0}

\problempart
\label{pr.TT.valid}
Use truth tables to determine whether each argument is valid or invalid.
\begin{earg}
\item $A\eif A \proves A$\\
This argument is invalid.
\myanswer{\begin{center}
\begin{tabular}{d | f e e   j  j}
$A$ &$A$&$\eif$&$A$& \proves   &$A$\\
\hline
 T & T & \TTbf{T} & T& \cm  & T\Tstrut\\
 F & F & \TTbf{T} & F& \xm  & F
 \end{tabular}
\end{center}}

\item $A\eif(A\eand\enot A) \proves \enot A$\\
This argument is valid.
\myanswer{\begin{center}
\begin{tabular}{d | f e e e e e   j  j e}
$A$&$A$&$\eif$&$(A$&$\eand$&$\enot$&$A)$& \proves &$\enot$&$A$\\
\hline
 T & T & \TTbf{F} & T & F& F&T&\cm  &\TTbf{F}&T\Tstrut\\
 F & F & \TTbf{T} & F & F&T&F&\cm  &\TTbf{T}&F
\end{tabular}
\end{center}}

\item $A\eor(B\eif A) \proves \enot A \eif \enot B$\\
This argument is valid.
\myanswer{\begin{center}
\begin{tabular}{d d | f e e e e    j   j e e e e}
$A$ & $B$ & $A$&$\eor$&$(B$&$\eif$&$A)$& \proves &$\enot$&$A$&$\eif$&$\enot$&$B$\\
\hline
T & T & T & \TTbf{T} & T & T & T &\cm& F & T & \TTbf{T} & F & T\Tstrut\\
T & F & T & \TTbf{T} & F & T & T &\cm& F & T & \TTbf{T} & T & F \\
F & T & F & \TTbf{F} & T & F & F &\cm& T & F & \TTbf{F} & F & T \\
F & F & F & \TTbf{T} & F & T & F &\cm& T & F & \TTbf{T} & T & F
\end{tabular}
\end{center}}

\item $A\eor B, B\eor C, \enot A \proves B \eand C$\\
This argument is invalid.
\myanswer{\begin{center}
\begin{tabular}{d d d | f e e   j e e   j e   j  j e e}
$A$ & $B$ & $C$ & $A$&$\eor$&$B$,&$B$&$\eor$&$C$,&$\enot$&$A$& \proves &$B$&$\eand$&$C$\\
\hline
T & T & T & T & \TTbf{T} & T & T & \TTbf{T} & T & \TTbf{F} & T &\cm& T & \TTbf{T} & T\Tstrut\\
T & T & F & T & \TTbf{T} & T & T & \TTbf{T} & F & \TTbf{F} & T &\cm& T &\TTbf{F} & F \\
T & F & T & T & \TTbf{T} & F & F & \TTbf{T} & T & \TTbf{F} & T &\cm& F & \TTbf{F} & T \\
T & F & F & T & \TTbf{T} & F & F & \TTbf{F} & F & \TTbf{F} & T &\cm& F & \TTbf{F} & F\\\arrayrulecolor{light-gray}\hline
T & T & T & F & \TTbf{T} & T & T & \TTbf{T} & T & \TTbf{T} & F &\cm& T & \TTbf{T} & T\Tstrut\\
T & T & F & F & \TTbf{T} & T & T & \TTbf{T} & F & \TTbf{T} & F &\xm& T &\TTbf{F} & F \\
T & F & T & F & \TTbf{F} & F & F & \TTbf{T} & T & \TTbf{T} & F &\cm& F & \TTbf{F} & T \\
T & F & F & F & \TTbf{F} & F & F & \TTbf{F} & F & \TTbf{T} & F &\cm& F & \TTbf{F} & F
\end{tabular}
\end{center}}

\item $(B\eand A)\eif C, (C\eand A)\eif B \proves (C\eand B)\eif A$\\
This argument is invalid.
%\myanswer{\begin{center}
%\begin{tabular}{d d d | f e e e e   j e e e e   j   j e e e e}
%$A$ & $B$ & $C$ & $(B$&$\eand$&$A)$&$\eif$&$C$,&$(C$&$\eand$&$A)$&$\eif$&$B$& \proves &$(C$&$\eand$&$ B)$&$\eif$&$A$\\
%\hline
%T & T & T & T & T & T & \TTbf{T} & T & T & T & T & \TTbf{T} & T &\cm& T & T & T & \TTbf{T} & T\Tstrut\\
%T & T & F & T & T & T & \TTbf{F} & F & F & F & T & \TTbf{T} & T &\cm& F & F & T & \TTbf{T} & T\\
%T & F & T & F & F & T & \TTbf{T} & T & T & T & T & \TTbf{F} & F &\cm& T & F & F & \TTbf{T} & T\\
%T & F & F & F & F & T & \TTbf{T} & F & F & F & T & \TTbf{T} & F &\cm& F & F & F & \TTbf{T} & T\\\arrayrulecolor{light-gray}\hline
%F & T & T & T & F & F & \TTbf{T} & T & T & F & F & \TTbf{T} & T &\xm& T & T & T & \TTbf{F} & F\Tstrut\\
%F & T & F & T & F & F & \TTbf{T} & F & F & F & F & \TTbf{T} & T &\cm& F & F & T & \TTbf{T} & F\\
%F & F & T & F & F & F & \TTbf{T} & T & T & F & F & \TTbf{T} & F &\cm& T & F & F & \TTbf{T} & F\\
%F & F & F & F & F & F & \TTbf{T} & F & F & F & F & \TTbf{T} & F &\cm& F & F & F & \TTbf{T} & F
%\end{tabular}
%\end{center}}

%% This one leaves out the left side of the truth table to save space:

\myanswer{\begin{center}
\begin{tabular}{| f e e e e   j e e e e   j   j e e e e}
$(B$&$\eand$&$A)$&$\eif$&$C$,&$(C$&$\eand$&$A)$&$\eif$&$B$& \proves &$(C$&$\eand$&$ B)$&$\eif$&$A$\\
\hline
T & T & T & \TTbf{T} & T & T & T & T & \TTbf{T} & T &\cm& T & T & T & \TTbf{T} & T\Tstrut\\
T & T & T & \TTbf{F} & F & F & F & T & \TTbf{T} & T &\cm& F & F & T & \TTbf{T} & T\\
F & F & T & \TTbf{T} & T & T & T & T & \TTbf{F} & F &\cm& T & F & F & \TTbf{T} & T\\
F & F & T & \TTbf{T} & F & F & F & T & \TTbf{T} & F &\cm& F & F & F & \TTbf{T} & T\\\arrayrulecolor{light-gray}\hline
T & F & F & \TTbf{T} & T & T & F & F & \TTbf{T} & T &\xm& T & T & T & \TTbf{F} & F\Tstrut\\
T & F & F & \TTbf{T} & F & F & F & F & \TTbf{T} & T &\cm& F & F & T & \TTbf{T} & F\\
F & F & F & \TTbf{T} & T & T & F & F & \TTbf{T} & F &\cm& T & F & F & \TTbf{T} & F\\
F & F & F & \TTbf{T} & F & F & F & F & \TTbf{T} & F &\cm& F & F & F & \TTbf{T} & F
\end{tabular}
\end{center}}

\item $A\eif B$, $B \proves  A$ \hfill \myanswer{Invalid}
\item $A\eiff B$, $B\eiff C \proves A\eiff C$ \hfill \myanswer{Valid}
\item $A \eif B$, $A \eif C\proves B \eif C$ \hfill \myanswer{Invalid}
\item $A \eif B$, $B \eif A\proves A \eiff B$ \hfill \myanswer{Valid}

\item $A\eor\bigl[A\eif(A\eiff A)\bigr] \proves  A $\vspace{.5ex} \hfill \myanswer{Invalid}
\item $A\eor B$, $B\eor C$, $\enot B \proves A \eand C$\vspace{.5ex} \hfill \myanswer{Valid}
\item $A \eif B$, $\enot A\proves \enot B$ \vspace{.5ex} \hfill \myanswer{Invalid}
\item $A$, $B\proves \enot(A\eif \enot B)$ \vspace{.5ex} \hfill \myanswer{Valid}
\item $\enot(A \eand B)$, $A \eor B$, $A \eiff B\proves C$ \vspace{.5ex} \hfill \myanswer{Valid}
\end{earg}

\problempart
\begin{earg}
\item Suppose that $(\meta{A}\eand\meta{B})\eif\meta{C}$ is neither a tautology nor a contradiction. Is it possible to determine if $\meta{A}, \meta{B} \proves \meta{C}$ is valid or not?
\begin{ebullet}
\item[] \myanswer{Since the sentence $(\meta{A}\eand\meta{B})\eif\meta{C}$ is not a tautology, there is some line on which it is false. Since it is a conditional, on that line, \meta{A} and \meta{B} are true and \meta{C} is false. Hence, the argument, `$\meta{A}, \meta{B} \proves\meta{C}$', is invalid.}
\end{ebullet}

\item Suppose that \meta{A} is a contradiction. Is $\meta{A}, \meta{B} \proves \meta{C}$ valid or invalid?
\begin{ebullet}
\item[] \myanswer{Since \meta{A} is false on every line of a truth table, there is no line on which \meta{A} and \meta{B} are true and \meta{C} is false. Hence, the argument is  valid. (Although that would be kind of an odd argument since we know that one of the premises is a contradiction.)}
\end{ebullet}

\item Suppose that \meta{C} is a tautology. Is $\meta{A}, \meta{B} \proves \meta{C}$ valid or invalid?
\begin{ebullet}
\item[] \myanswer{Since \meta{C} is true on every line of a complete truth table, there is no line on which \meta{A} and \meta{B} are true and \meta{C} is false. Hence, the argument is valid.}
\end{ebullet}
\end{earg}

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

% Chapter 12

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

\chapter{Truth table shortcuts}
With practice, you will become adept at quickly filling out truth tables. There are, however, some shortcuts that will (1) save you some time and (2) reinforce the meaning the concepts that can be tested using truth tables.

\section{Testing for validity}\label{test-valid}

As we said in \S\ref{s:tt-validity}, when we use truth tables to test for validity, we are checking for \emph{bad} lines: lines where the premises are all true and the conclusion is false. Consequently,
	\begin{earg}
		\item[\textbullet] Any line where the conclusion is true is not a bad line.
		\item[\textbullet] Any line where some premise is false is not a bad line.
	\end{earg}
Since \emph{all} we are doing is looking for bad lines, if we find a line where the conclusion is true, we do not need to evaluate anything else on that line. That line definitely isn't bad. Likewise, if we find a line where some premise is false, we do not need to evaluate anything else on that line.

With this in mind, consider how we might investigate wither this argument is valid:
	$$\enot L \eif (J \eor L), \enot L \proves J$$
The first step is evaluating the conclusion. If we find that the conclusion is true on some line, then that is not a bad line, and so we can simply ignore the rest of the line.  \begin{center}
\begin{tabular}{d d | f e e e e e  j e   j j}
$J$&$L$&\enot&$L$&\eif&$(J$&\eor&$L)$, &\enot&$L$&\proves&$J$\\
\hline
 T & T & &&&&&&&&\cm& {T}\Tstrut\\
 T & F & &&&&&&&&\cm& {T}\\
 F & T & &&?&&&&?&&?& {F}\\
 F & F & &&?&&&&?&&?& {F}
\end{tabular}
\end{center}
The blank spaces under $\enot L \eif (J \eor L)$ and $\enot L$  indicate that we are not going to bother doing any more investigation since the line is not bad. The question-marks indicate that we need to keep investigating. On those lines, it is possible that the premises are true and the conclusion is false.

The easiest premise to evaluate is the second ($\enot L$), and so we do that next.
\begin{center}
\begin{tabular}{d d| f e e e e e   j e  j j}
$J$&$L$&\enot&$L$&\eif&$(J$&\eor&$L)$,&\enot&$L$&\proves&$J$\\
\hline
 T & T & &&&&&&&&\cm& {T}\Tstrut\\
 T & F & &&&&&&&&\cm& {T}\\
 F & T & &&&&&&{F}&&\cm& {F}\\
 F & F & &&?&&&&{T}&&?& {F}
\end{tabular}
\end{center}
Now we see that we no longer need to consider the third line. It will not be a bad line, because at least one of the premises is false on that line, namely, $\enot L$. Finally, we complete the fourth line:
\begin{center}
\begin{tabular}{d d | f e e e e e   j e  j  j}
$J$&$L$&\enot&$L$&\eif&$(J$&\eor&$L)$,&\enot&$L$&\proves&$J$\\
\hline
 T & T & &&&&&&&&\cm& {T}\Tstrut\\
 T & F & &&&&&&&&\cm& {T}\\
 F & T & &&&&&&{F}& &\cm& {F}\\
 F & F & T &  & \TTbf{F} &  & F & & {T} & &\cm& {F}
\end{tabular}
\end{center}
Since the fourth line tells us that the first premise is false, the truth table has no bad lines. Hence, the argument is valid: any valuation for which all the premises are true is a valuation for which the conclusion is true.

Let us check whether the following argument is valid using the same method.
$$A\eor B, \enot (A\eand C), \enot (B \eand \enot D) \proves (\enot C\eor D)$$
Again, we first determine the truth value of the conclusion. Since this is a disjunction, it is true whenever either disjunct is true. We can speed things along by noting that the conclusion will be true whenever `$D$' is true. Then we only have to determine the truth value for `$\enot C$' on the lines where $D$ is false.

Once we have the truth values for the conclusion, we can, as we did in the last example, ignore every line apart from the lines where the conclusion is false.
\begin{center}
\begin{tabular}[t]{d d d d | f   e   e  j  j e e e }
$A$ & $B$ & $C$ & $D$ & $A\eor B$, & $\enot (A\eand C)$, & $\enot (B\eand \enot D)$&\proves & $(\enot$ &$C$& $\eor$ & $D)$\\
\hline
T & T & T & T & & &			&\cm		&  &&  \TTbf{T} & \Tstrut\\
T & T & T & F & ? & ? & ? 	&?		& F & &  \circled{\TTbf{F}} & \\
T & T & F & T &  & &			&\cm  & & &  \TTbf{T} & \\
T & T & F & F &  &  &   		&\cm	& T & &  \TTbf{T} &\\\arrayrulecolor{light-gray}\hline
T & F & T & T &  &  &  		&\cm	& & &  \TTbf{T} &\Tstrut\\
T & F & T & F & ? & ? & ?  	&?	& F &  &  \circled{\TTbf{F}} &\\
T & F & F & T & & & 			&\cm	& & & \TTbf{T} &\\
T & F & F & F & & & 			&\cm	& T &  & \TTbf{T} & \\\arrayrulecolor{light-gray}\hline
F & T & T & T & & & 			&\cm	& & & \TTbf{T} & \Tstrut\\
F & T & T & F & ? & ? & ? 	&?	& F &  & \circled{\TTbf{F}} &\\
F & T & F & T & & &  			&\cm	& & & \TTbf{T} & \\
F & T & F & F & & & 			&\cm	&T & & \TTbf{T} & \\\arrayrulecolor{light-gray}\hline
F & F & T & T & & & 			&\cm	& & & \TTbf{T} & \Tstrut\\
F & F & T & F & ? & ? & ? 	&?	& F & & \circled{\TTbf{F}} & \\
F & F & F & T & & & 			&\cm	& & & \TTbf{T} & \\
F & F & F & F & & & 			&\cm	& T& & \TTbf{T} & \\
\end{tabular}
\end{center}
We must now evaluate the premises. The first premise is the simplest, and so we start there. Of the four lines where the conclusion is false, there are three where $A \eor B$ is true. So the truth values for the next premise have to be determined for those three lines. (The second premise is simpler to evaluate than the third, so it's next.)

On those three lines, there is only one where the first two premise are true. With a little bit more work, we find that the third premise is false on that line. There is no line where the premises are true and the conclusion is false! The argument is valid.
\begin{center}
\begin{tabular}[t]{d d d d | f e e    e e e e    e e e e e   e    e e e e }
$A$ & $B$ & $C$ & $D$ & $A$ & $\eor$ & $B$, & $\enot$ & $(A$ &$\eand$ &$ C)$, & $\enot$ & $(B$ & $\eand$ & $\enot$ & $D)$&\proves & $(\enot$ &$C$& $\eor$ & $D)$\\
\hline
T & T & T & T & & && & && & && & & 								&\cm	& &  &  \TTbf{T} & \Tstrut\\
T & T & T & F & &\TTbf{T}& & \TTbf{F}& &T& & & & & & 		&\cm	& F & &  \circled{\TTbf{F}} & \\
T & T & F & T & & && & && & &&  & &   							&\cm	& & &  \TTbf{T} & \\
T & T & F & F & & && & && & &&  &  &   							&\cm	& T & &  \TTbf{T} & \\\arrayrulecolor{light-gray}\hline
T & F & T & T & & && & && & &&  &  &  							&\cm	& & &  \TTbf{T} & \Tstrut\\
T & F & T & F & &\TTbf{T}& &\TTbf{F}& &T& &  && & & 		&\cm	& F & & \circled{\TTbf{F}} & \\
T & F & F & T & & && & && & && & & 								&\cm	& & & \TTbf{T} & \\
T & F & F & F & & && & && & && & & 								&\cm	& T &  & \TTbf{T} & \\\arrayrulecolor{light-gray}\hline
F & T & T & T& & && & && & & & & & 								&\cm	& & & \TTbf{T} & \Tstrut\\
F & T & T & F & &\TTbf{T}& & \TTbf{T}& & F& & \TTbf{F}& & T& T&  			&\cm	& F &  & \circled{\TTbf{F}} & \\
F & T & F & T & & && & && & && & &  								&\cm	& & & \TTbf{T} & \\
F & T & F & F& & && & && & && & & 								&\cm	&T & & \TTbf{T} & \\\arrayrulecolor{light-gray}\hline
F & F & T & T & & && & && & && & & 								&\cm	& & & \TTbf{T} & \Tstrut\\
F & F & T & F & & \TTbf{F} & & & & & & &&  &  &  				&\cm	& F & & \circled{\TTbf{F}} & \\
F & F & F & T & & && & && & && & & 								&\cm	& & & \TTbf{T} & \\
F & F & F & F & & && & && & && & & 								&\cm	& T& & \TTbf{T} & \\
\end{tabular}
\end{center}
If we had used no shortcuts, we would have had to write 256 `T's or `F's on this table. Using shortcuts, we only had to write 37. We have saved ourselves a \emph{lot} of work.

\section{Partial truth tables }\label{s:PartialTruthTable}

In the previous section, we saw how an incomplete truth table---although one that still had all of the lines---could be enough to determine if an argument is valid or invalid. That's one method where we use less than the full truth table. Another is where we create a one line truth table. This is called a \define{partial truth table}.

We can also use partial truth tables to determine if a sentence is not a tautology or is not a contradiction, and to determine if a set of sentences are not consistent or are consistent.

\paragraph{Tautology}
To show that a sentence is a tautology, we need to show that it is true on every valuation. That is to say, we need to know that it is true on every line of the truth table. To do that, we need a complete truth table.

To show that a sentence is \emph{not} a tautology, however, we only need one line: a line on which the sentence is false. Therefore, in order to show that some sentence is not a tautology, it is enough to provide a single valuation---a single line of the truth table---that makes the sentence false.

Suppose that we want to show that the sentence `$(U \eand T) \eif (S \eand W)$' is \emph{not} a tautology. We set up a \define{partial truth table}. We have only left space for one line, rather than 16, since we are only looking for one line on which the sentence is false. Let us suppose that the sentence is false
\begin{center}
\begin{tabular}{d d d d | f e e e e e e}
$S$&$T$&$U$&$W$&$(U$&\eand&$T)$&\eif    &$(S$&\eand&$W)$\\
\hline
   &   &   &   &    &   &    &\TTbf{F}&    &   &\Tstrut\\
\end{tabular}
\end{center}
The main logical operator of the sentence is a conditional. In order for the conditional to be false, the antecedent must be true and the consequent must be false. So we put those in the table.
\begin{center}
\begin{tabular}{d d d d | f e e e e e e}
$S$&$T$&$U$&$W$&$(U$&\eand&$T)$&\eif    &$(S$&\eand&$W)$\\
\hline
   &   &   &   &    &  T  &    &\TTbf{F}&    &   F &\Tstrut\\
\end{tabular}
\end{center}
For the `$(U\eand T)$' to be true, both `$U$' and `$T$' must be true. Knowing that, we can set the truth values for these atomic sentences on the left side of the truth table.
\begin{center}
\begin{tabular}{d d d d| f e e e e e e}
$S$&$T$&$U$&$W$&$(U$&\eand&$T)$&\eif    &$(S$&\eand&$W)$\\
\hline
   & T & T &   &  T &  T  & T  &\TTbf{F}&    &   F &\Tstrut\\
\end{tabular}
\end{center}
Now we just need to see if we can make `$(S\eand W)$' false, which requires at least one of `$S$' and `$W$' to be false. Since the truth values for `$S$' and `$W$' have not been set yet, we can make both `$S$' and `$W$' false if we want. With that, we finish the table in this way:
\begin{center}
\begin{tabular}{d d d d | f e e e e e e}
$S$&$T$&$U$&$W$&$(U$&\eand&$T)$&\eif    &$(S$&\eand&$W)$\\
\hline
 F & T & T & F &  T &  T  & T  &\TTbf{F}&  F &   F & F\Tstrut\\
\end{tabular}
\end{center}
We now have a partial truth table that shows that `$(U \eand T) \eif (S \eand W)$' is not a tautology. Put otherwise, we have shown that there is a valuation that makes `$(U \eand T) \eif (S \eand W)$' false, namely, the valuation where `$S$' is false, `$T$' is true, `$U$' is true and `$W$' is false (which would be line 10 in a full truth table).

To be clear, we use this method in an \textit{attempt} to show that a sentence is not a tautology. If a sentence is a tautology, then we won't be able to find an assignment of `true' and `false' for every sentence letter that makes the full sentence false.

\paragraph{Contradiction}
Showing that a sentence is a contradiction requires a complete truth table: we need to show that the sentence is false on every line of the truth table.

On the other hand, to show that a sentence is \emph{not} a contradiction, all we need to do is find a valuation that makes the sentence true, and so a single line of a truth table will suffice. We can illustrate this with the same example.
\begin{center}
\begin{tabular}{d d d d | f e e e e e e}
$S$&$T$&$U$&$W$&$(U$&\eand&$T)$&\eif    &$(S$&\eand&$W)$\\
\hline
  &  &  &  &   &   &   &\TTbf{T}&  &  &\Tstrut\\
\end{tabular}
\end{center}
One way for this sentence to be true is for the antecedent to be false. Since the antecedent is a conjunction, we can just make one of the conjuncts false. Let's make `$U$' false. Then, we can assign whatever truth value we like to the other atomic sentences. With $S =$ \textit{false}, $T =$ \textit{true}, $U =$ \textit{false}, and $W =$ \textit{false}, we have shown that `$(U \eand T) \eif (S \eand W)$' is not contradiction.
\begin{center}
\begin{tabular}{d d d d | f e e e e e e}
$S$&$T$&$U$&$W$&$(U$&\eand&$T)$&\eif    &$(S$&\eand&$W)$\\
\hline
 F & T & F & F &  F &  F  & T  &\TTbf{T}&  F &   F & F\Tstrut\\
\end{tabular}
\end{center}

\paragraph{Equivalent}
To show that two sentences are logically equivalent, we must show that the sentences have the same truth value on every valuation. So this requires a  complete truth table.

To show that two sentences are \emph{not} logically equivalent, we only need to show that there is a valuation on which they have different truth values. So this requires only a one-line partial truth table. We make the table so that one sentence is true and the other false.

\paragraph{Consistent}
To show that some sentences are jointly consistent, we must show that there is a valuation that makes all of the sentences true. This requires only a partial truth table with a single line.

To show that some sentences are jointly inconsistent, we must show that there is no valuation which makes all of the sentence true. So this requires a complete truth table: You must show that on every row of the table at least one of the sentences is false.

\begin{table*}\centering\sffamily\footnotesize
\ra{1.25}
\begin{tabular}{@{}l l l@{}}\toprule
\textth{To check} & \textth{that it is} & \textth{that it is not}\\\midrule
tautology & complete & one-line partial \\
contradiction &  complete & one-line partial \\
equivalent & complete  & one-line partial \\
consistent & one-line partial & complete \\
valid & complete & one-line partial \\
\bottomrule
\end{tabular}
\caption{The kind of truth table required to check each of these logical notions.}\label{table.CompleteVsPartial}
\end{table*}

\paragraph{Valid}
To show that an argument is valid, we must show that there is no valuation that makes all of the premises true and the conclusion false. This requires a truth table with all of the requisite lines, although we can take the shortcuts that were described in the first section of this chapter.

To show that argument is invalid, we must show that there is a valuation that makes all of the premises true and the conclusion false. So this requires only a one-line partial truth table where all of the premises are true and the conclusion is false.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Exercises for Partial truth tables chapter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Practice exercises}
\setcounter{ProbPart}{0}

\problempart
\label{pr.TT.equiv3}
If it is possible, use a partial truth table to show that the pair of sentences are \textbf{not equivalent}. If it can't be shown that they are not equivalent, then create a full truth table showing that they are equivalent.
\begin{earg}
\item $A$, $\enot A$ %No
\item $A$, $A \eor A$ %Yes
\item $A\eif A$, $A \eiff A$ %Yes
\item $A \eor \enot B$, $A\eif B$ %No
\item $A \eand \enot A$, $\enot B \eiff B$ %Yes
\item $\enot(A \eand B)$, $\enot A \eor \enot B$ %Yes
\item $\enot(A \eif B)$, $\enot A \eif \enot B$ %No
\item $(A \eif B)$, $(\enot B \eif \enot A)$ %Yes
\item $ ((U \eif (X \eor X)) \eor U)$ and $\enot (X \eand (X \eand U))$
\item $ ((C \eand (N \eiff C)) \eiff C)$ and $(\enot \enot \enot N \eif C)$
\item $[(A \eor B) \eand C]$ and $[A \eor (B \eand C)]$
\item $((L \eand C) \eand I)$ and $L \eor C$
\end{earg}

\problempart
\label{pr.TT.consistent4}
If it is possible, use a partial truth table to show that the set of sentences are \textbf{consistent}. If it can't be shown that they are consistent, then create a full truth table showing that they are not consistent.
\begin{earg}
\item $A \eand B$, $C\eif \enot B$, $C$ %inconsistent
\item $A\eif B$, $B\eif C$, $A$, $\enot C$ %inconsistent
\item $A \eor B$, $B\eor C$, $C\eif \enot A$ %consistent
\item $A$, $B$, $C$, $\enot D$, $\enot E$, $F$ %consistent
\item $A \eand (B \eor C)$, $\enot(A \eand C)$, $\enot(B \eand C)$ %consistent
\item $A \eif B$, $B \eif C$, $\enot(A \eif C)$ %inconsistent
\item $A\eif A$, $\enot A \eif \enot A$, $A\eand A$, $A\eor A$ %consistent
\item $A \eif \enot A$, $\enot A \eif A$%inconsistent.
\item $A\eor B$, $A\eif C$, $B\eif C$ %consistent
\item $A \eor B$, $A \eif C$, $B \eif C$, $\enot C$ %	Inconsistent
\item $B\eand(C\eor A)$, $A\eif B$, $\enot(B\eor C)$  %inconsistent
\item $(A \eiff B) \eif B$,  $B \eif \enot (A \eiff B)$, $A \eor B$  %	Consistent
\item $A\eiff(B\eor C)$, $C\eif \enot A$, $A\eif \enot B$ %consistent
\item  $A \eiff B$,  $\enot B \eor \enot A$,  $A \eif  B$ % Consistent
\item $A \eiff B$, $A \eif C$, $B \eif D$, $\enot(C \eor D)$ %consitent
\item $\enot (A \eand \enot B)$,  $B \eif \enot A$, $\enot B$   %Consistent
\end{earg}

\problempart
\label{pr.TT.valid4}
If it is possible, use a partial truth table to show that the argument is \textbf{invalid}. If it can't be shown that the argument is invalid, then, using the shortcuts explained in \S \ref{test-valid}, create a full truth table showing that it is valid.
\begin{earg}
\item $A\eor\bigl[A\eif(A\eiff A)\bigr] \proves A$ %invalid
\item $A\eiff\enot(B\eiff A) \proves A$ %invalid
\item $A\eif B, B \proves A$ %invalid
\item $A\eor B, B\eor C, \enot B \proves A \eand C$ %valid
\item $A\eiff B, B\eiff C \proves A\eiff C$ %valid
\item $A\eif(A\eand\enot A)\proves \enot A$% valid
\item $A \eor B$, $A \eif B$, $B \eif A \proves  A \eiff B$  % Valid
\item $A\eor(B\eif A)\proves \enot A \eif \enot B$ %valid
\item $A \eor B$, $A \eif B$, $ B \eif A \proves  A \eand B$ %valid
\item $(B\eand A)\eif C$, $(C\eand A)\eif B\proves (C\eand B)\eif A$ % invalid
\item $\enot (\enot A \eor \enot B)$, $A \eif \enot C \proves  A \eif (B \eif C)$ % invalid.
\item $A \eand (B \eif C)$, $\enot C \eand (\enot B \eif \enot A)\proves C \eand \enot C$ % valid
\item $A \eand B$, $\enot A \eif \enot C$, $B \eif \enot D \proves  A \eor B$ % Invalid
\item $A \eif B\proves (A \eand B) \eor (\enot A \eand \enot B)$ % invalid
\item $\enot A \eif B$,$ \enot B \eif C $,$ \enot C \eif A \proves  \enot A \eif (\enot B \eor \enot C) $% Invalid
\item $A\eiff\enot(B\eiff A)\proves A$ % invalid
\item $A\eor B$, $B\eor C$, $\enot A\proves B \eand C$ % invalid
\item $A \eif C$, $E \eif (D \eor B)$, $B \eif \enot D\proves (A \eor C) \eor (B \eif (E \eand D))$ % invalid
\item $A \eor B$, $C \eif A$, $C \eif B\proves A \eif (B \eif C)$ % invalid
\item $A \eif B$, $\enot B \eor A\proves A \eiff B$ % valid
\end{earg}

\problempart
\label{pr.TT.TTorC3}
If it is possible, use a partial truth table to show that the sentence is \textbf{not a tautology} or \textbf{not a contradiction}. If it can't be shown that it is not a tautology or not a contradiction, then give a full truth table showing that the sentence is a tautology, contradiction, or contingent. (Note that if the sentence is not a tautology \textit{and} not a contradiction, then it is contingent.)

% truth tables in LaTeX generated by http://www.curtisbright.com/logic/. Be sure to give him a shout out.

\begin{earg}
\item  $A \eif \enot A$ \vspace{.5ex}

%{\color{red}
%$
%\begin{array}{c|cccc}
%A&A&\eif&\enot&A\\\hline
%T&T&\mathbf{F}&F&T\\
%F&F&\mathbf{T}&T&F
%\end{array}
%$
%
%Contingent	 \vspace{6pt}
%}
%	T letter, 2 connectives
\item $A \eif (A \eand (A \eor B))$ \vspace{.5ex}

%{\color{red}
%$
%\begin{array}{cc|ccc@{}ccc@{}ccc@{}c@{}c}
%A&B&A&\eif&(&A&\eand&(&A&\eor&B&)&)\\\hline
%T&T&T&\mathbf{T}&&T&T&&T&T&T&&\\
%T&F&T&\mathbf{T}&&T&T&&T&T&F&&\\
%F&T&F&\mathbf{T}&&F&F&&F&T&T&&\\
%F&F&F&\mathbf{T}&&F&F&&F&F&F&&
%\end{array}
%$
%
%Tautology \vspace{6pt}
%}
%			2 letters, 3 connectives

\item $(A \eif B) \eiff (B \eif A)$ 	\vspace{.5ex}				%
%
%{\color{red}
%$
%\begin{array}{cc|c@{}ccc@{}ccc@{}ccc@{}c}
%a&b&(&a&\rightarrow&b&)&\leftrightarrow&(&b&\rightarrow&a&)\\\hline
%T&T&&T&T&T&&\mathbf{T}&&T&T&T&\\
%T&F&&T&F&F&&\mathbf{F}&&F&T&T&\\
%F&T&&F&T&T&&\mathbf{F}&&T&F&F&\\
%F&F&&F&T&F&&\mathbf{T}&&F&T&F&
%\end{array}
%$
%
%Contingent \vspace{6pt}
%
%}
%		2 letters, 3 connectives

\item $A \eif \enot(A \eand (A \eor B)) $	\vspace{.5ex}

%{\color{red}
%$
%\begin{array}{cc|cccc@{}ccc@{}ccc@{}c@{}c}
%a&b&a&\rightarrow&\enot&(&a&\eand&(&a&\eor&b&)&)\\\hline
%T&T&T&\mathbf{F}&F&&T&T&&T&T&T&&\\
%T&F&T&\mathbf{F}&F&&T&T&&T&T&F&&\\
%F&T&F&\mathbf{T}&T&&F&F&&F&T&T&&\\
%F&F&F&\mathbf{T}&T&&F&F&&F&F&F&&
%\end{array}
%$
%
%Contingent	\vspace{6pt}
%
%}
%
% 2 letters, 4 connectives

\item $\enot B \eif [(\enot A \eand A) \eor B]$\vspace{.5ex}

%{\color{red}
%$
%\begin{array}{cc|cccc@{}c@{}cccc@{}ccc@{}c}
%a&b&\enot&b&\rightarrow&(&(&\enot&a&\eand&a&)&\eor&b&)\\\hline
%T&T&F&T&\mathbf{T}&&&F&T&F&T&&T&T&\\
%T&F&T&F&\mathbf{F}&&&F&T&F&T&&F&F&\\
%F&T&F&T&\mathbf{T}&&&T&F&F&F&&T&T&\\
%F&F&T&F&\mathbf{F}&&&T&F&F&F&&F&F&
%\end{array}
%$
%Contingent	 \vspace{6pt}
%
%}
%	2 letters, 5 connectives

\item $\enot(A \eor B) \eiff (\enot A \eand \enot B)$ \vspace{.5ex}

%{\color{red}
%$
%\begin{array}{cc|cc@{}ccc@{}ccc@{}ccccc@{}c}
%a&b&\enot&(&a&\eor&b&)&\leftrightarrow&(&\enot&a&\eand&\enot&b&)\\\hline
%T&T&F&&T&T&T&&\mathbf{T}&&F&T&F&F&T&\\
%T&F&F&&T&T&F&&\mathbf{T}&&F&T&F&T&F&\\
%F&T&F&&F&T&T&&\mathbf{T}&&T&F&F&F&T&\\
%F&F&T&&F&F&F&&\mathbf{T}&&T&F&T&T&F&
%\end{array}
%$
%
%Tautology \vspace{6pt}
%}
%2 letters, 6 connectives

\item $[(A \eand B) \eand C] \eif B$\vspace{.5ex}
%
%{\color{red}
%$
%\begin{array}{ccc|c@{}c@{}ccc@{}ccc@{}ccc}
%a&b&c&(&(&a&\eand&b&)&\eand&c&)&\rightarrow&b\\\hline
%T&T&T&&&T&T&T&&T&T&&\mathbf{T}&T\\
%T&T&F&&&T&T&T&&F&F&&\mathbf{T}&T\\
%T&F&T&&&T&F&F&&F&T&&\mathbf{T}&F\\
%T&F&F&&&T&F&F&&F&F&&\mathbf{T}&F\\
%F&T&T&&&F&F&T&&F&T&&\mathbf{T}&T\\
%F&T&F&&&F&F&T&&F&F&&\mathbf{T}&T\\
%F&F&T&&&F&F&F&&F&T&&\mathbf{T}&F\\
%F&F&F&&&F&F&F&&F&F&&\mathbf{T}&F
%\end{array}
%$
%
%Tautology \vspace{6pt}
%}
%
%3 letters, 3 connectives

\item $\enot\bigl[(C\eor A) \eor B\bigr]$\vspace{.5ex}
%
%{\color{red}
%$
%\begin{array}{ccc|cc@{}c@{}ccc@{}ccc@{}c}
%a&b&c&\enot&(&(&c&\eor&a&)&\eor&b&)\\\hline
%T&T&T&\mathbf{F}&&&T&T&T&&T&T&\\
%T&T&F&\mathbf{F}&&&F&T&T&&T&T&\\
%T&F&T&\mathbf{F}&&&T&T&T&&T&F&\\
%T&F&F&\mathbf{F}&&&F&T&T&&T&F&\\
%F&T&T&\mathbf{F}&&&T&T&F&&T&T&\\
%F&T&F&\mathbf{F}&&&F&F&F&&T&T&\\
%F&F&T&\mathbf{F}&&&T&T&F&&T&F&\\
%F&F&F&\mathbf{T}&&&F&F&F&&F&F&
%\end{array}
%$
%
%Contingent \vspace{6pt}
%
%}
%	 	3 letters, 3 connectives

\item $\bigl[(A\eand B) \eand\enot(A\eand B)\bigr] \eand C$ \vspace{.5ex}
%
%{\color{red}
%$
%\begin{array}{ccc|c@{}c@{}ccc@{}cccc@{}ccc@{}c@{}ccc}
%a&b&c&(&(&a&\eand&b&)&\eand&\enot&(&a&\eand&b&)&)&\eand&c\\\hline
%T&T&T&&&T&T&T&&F&F&&T&T&T&&&\mathbf{F}&T\\
%T&T&F&&&T&T&T&&F&F&&T&T&T&&&\mathbf{F}&F\\
%T&F&T&&&T&F&F&&F&T&&T&F&F&&&\mathbf{F}&T\\
%T&F&F&&&T&F&F&&F&T&&T&F&F&&&\mathbf{F}&F\\
%F&T&T&&&F&F&T&&F&T&&F&F&T&&&\mathbf{F}&T\\
%F&T&F&&&F&F&T&&F&T&&F&F&T&&&\mathbf{F}&F\\
%F&F&T&&&F&F&F&&F&T&&F&F&F&&&\mathbf{F}&T\\
%F&F&F&&&F&F&F&&F&T&&F&F&F&&&\mathbf{F}&F
%\end{array}
%$
%
%Contradiction \vspace{6pt}
%
%}
%
%% 	3 letters, 5 connectives
%
\item $(A \eand B) ]\eif[(A \eand C) \eor (B \eand D)]$ \vspace{.5ex}
%
%{\color{red}
%$
%\begin{array}{cccc|c@{}c@{}ccc@{}c@{}ccc@{}c@{}ccc@{}ccc@{}ccc@{}c@{}c}
%a&b&c&d&(&(&a&\eand&b&)&)&\eif&(&(&a&\eand&c&)&\eor&(&b&\eand&d&)&)\\\hline
%T&T&T&T&&&T&T&T&&&\mathbf{T}&&&T&T&T&&T&&T&T&T&&\\
%T&T&F&F&&&T&T&T&&&\mathbf{F}&&&T&F&F&&F&&T&F&F&&\\
%\end{array}
%$
%
%Contingent \vspace{6pt}
%}
%
%	4 letters, 5 connectives

\item  $\enot (A \eor A)$\vspace{.5ex}							%	Contradiction		1 letter, 2 connectives
\item $(A \eif B) \eor (B \eif A)$\vspace{.5ex}					%	Tautology			2 letters, 2 connectives
\item $[(A \eif B) \eif A] \eif A$\vspace{.5ex}					%	Tautology			2 letters, 3 connectives
\item $\enot[( A \eif B) \eor (B \eif A)]$\vspace{.5ex}			%	Contradiction		2 letters, 4 connectives
\item $(A \eand B) \eor (A \eor B)$\vspace{.5ex} 				%	Contingent		2 letters, 5 connectives
\item $\enot(A\eand B) \eiff A$\vspace{.5ex} 					%contingent			2 letters, 3 connectives
\item $A\eif(B\eor C)$\vspace{.5ex} 							%contingent			3 letters, 2 connectives
\item $(A \eand\enot A) \eif (B \eor C)$\vspace{.5ex} 			%tautology			3 letters, 4 connectives
\item $(B\eand D) \eiff [A \eiff(A \eor C)]$\vspace{.5ex}			%contingent			4 letters, 4 connectives
\item $\enot[(A \eif B) \eor (C \eif D)]$\vspace{.5ex} 			% Contingent. 		4 letters, 4 connectives
\end{earg}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% UMB-CS114-2015F: Introduction to Programming in Java
% Copyright 2015 Pejman Ghorbanzade <pejman@ghorbanzade.com>
% Creative Commons Attribution-ShareAlike 4.0 International License
% More info: https://github.com/ghorbanzade/UMB-CS114-2015F
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \topDirectory {../..}
\def \texDirectory {\topDirectory/src/main/tex}

\documentclass[10pt, compress]{beamer}

\usepackage{\texDirectory/template/style/directives}
\input{\texDirectory/template/config}
\usepackage{\texDirectory/template/style/beamerthemeUmassLecture}
\doc{number}{4}
%\setbeamertemplate{footline}[text line]{}

\begin{document}
\prepareCover

\section{Course Administration}

\begin{slide}
	\begin{itemize}
		\item[] 31/40 user accounts at \href{http://www.ghorbanzade.com}{Course Website} created so far.
		\item[] Assignment 1 released. Due on Oct 05 at 17:30 PM.
	\end{itemize}
\end{slide}

\begin{slide}
	\begin{block}{Overview}
		\begin{itemize}
			\item[] Data Types
			\item[] Operators
		\end{itemize}
	\end{block}
\end{slide}

\section{Data Types}

\begin{slide}
	\begin{block}{Variables}
		A variable is a name for a location in memory used to hold a data value. All variables in java should be declared. Once.
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			int a = 123;
			int b = 99;
			int c = a + b;
			a = 25;
		\end{minted}
	\end{block}
	\begin{block}{Constants}
		A constant is a special variable that holds a data whose value does not change throughout the program.
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			final int d = 2015;
		\end{minted}
	\end{block}
\end{slide}

\begin{slide}
	\begin{block}{Identifiers}
		An identifier is a sequence of letters, digits, underscore signs and dollar signs; the first of which is not a digit.
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			int HeLlO = 123;
			int $_Q2d$o = 99;
			int _ASc = HeLlO + $_Q2d$o;
			$_Q2d$o = 25;
		\end{minted}
	\end{block}
	\begin{itemize}
		\item[] Identifiers are case sensitive.
		\item[] You cannot use Java \textbf{reserved} words for identifiers
		\item[] Using dollar and underscore signs are discouraged.
	\end{itemize}
\end{slide}

\begin{slide}
	Java is statically-typed: all \textbf{variables} must first be declared.
	\begin{block}{Primitive Data Types}
		\begin{columns}
		\begin{column}{0.5\textwidth}
			\begin{itemize}
				\item[] boolean
				\item[] byte
				\item[] short
				\item[] int
			\end{itemize}
		\end{column}
		\begin{column}{0.5\textwidth}
			\begin{itemize}
				\item[] long
				\item[] float
				\item[] double
				\item[] char
			\end{itemize}
		\end{column}
		\end{columns}
	\end{block}
	\begin{block}{Built-in Data Types}
		\begin{itemize}
			\item[] Primitive Data Types
			\item[] String
		\end{itemize}
	\end{block}
\end{slide}

\begin{slide}
	\begin{block}{Declaration}
		A declaration associates a variable with a type at compile time.

		Declaration should be made before first use of variable.
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			int a, b;
			a = 13;
			b = 25;
			int c = 10;
			int d = b - c;
			d = d - c;
		\end{minted}
	\end{block}
\end{slide}

\begin{slide}
	\begin{block}{Declaration}
		Declared data type should be consistent with the value assigned.
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			boolean snowDay = false;
			byte numStudentClass = 64;
			short numStudentTotal = 15741;
			int populationWorld = 318881992;
			long gangnamYoutube = 2238643747;
			float snowHeight = 19.75;
			double avogadro = 6.022e23;
			char letter = 'Q';
			String word = "Beacons";
		\end{minted}
	\end{block}
\end{slide}

\begin{slide}
	\begin{block}{Assignment}
		An assignment associates a data type value with a variable.
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			double discriminant = b*b - 4*a*c;
		\end{minted}
		The meaning of = is decidedly \textbf{not} the same as in mathematical equations.
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			int a, b, c;
			a = 23;
			b = 25;
			c = a;
			a = b;
			b = c;
		\end{minted}
	\end{block}
\end{slide}

\section{Operators}

\begin{slide}
	An operation is an action performed on one or more values either to modify the value or to produce a new one.
	\begin{block}{Classification}
		\begin{columns}
			\begin{column}{0.5\textwidth}
				\begin{itemize}
					\item[] Arithmetic Operators
					\item[] Relational Operators
					\item[] Bitwise Operators
				\end{itemize}
			\end{column}
			\begin{column}{0.5\textwidth}
				\begin{itemize}
					\item[] Logical Operators
					\item[] Assignment Operators
					\item[] Ternary Operators
				\end{itemize}
			\end{column}
		\end{columns}
	\end{block}
\end{slide}

\begin{slide}
	\begin{block}{Arithmetic Operators}
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			int A = 10;
			int B = 25;
		\end{minted}
		\begin{table}
			\begin{tabular}{lcc}
				\toprule
				Operator & Example & Output\\
				\midrule
				Addition & A + B & 35 \\
				Subtraction & A - B & -15\\
				Multiplication & A * B & 250\\
				Division & B / A & 2\\
				Modulus & B \% A & 5\\
				Increment & A++ & 11\\
				Decrement & B-{}- & 24\\
				\bottomrule
			\end{tabular}
			\caption{Arithmetic Operators}
		\end{table}
	\end{block}
\end{slide}

\begin{slide}
	\begin{block}{Relational Operators}
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			int A = 10;
			int B = 25;
		\end{minted}
		\begin{table}
			\begin{tabular}{lcc}
				\toprule
				Operator & Example & Output\\
				\midrule
				Equality & A == B & false\\
				Inequality & A != B & true\\
				Greater than & A > B & false\\
				Less than & A < B & true\\
				Greater than or equal to & A >= B & false\\
				Less than or equal to & A <= B & true\\
				\bottomrule
			\end{tabular}
			\caption{Relational Operators}
		\end{table}
	\end{block}
\end{slide}

\begin{slide}
	\begin{block}{Bitwise Operators}
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			int A = 0b11111111;
			int B = 0b00001010;
		\end{minted}
		\begin{table}
			\begin{tabular}{lcc}
				\toprule
				Operator & Example & Output\\
				\midrule
				Binary AND & A \& B & 0b00001010\\
				Binary OR & A | B & 0b11111111\\
				Binary XOR & A \textasciicircum B & 0b11110101\\
				Binary Ones Complement & \textasciitilde B & 0b11110101\\
				Binary Left Shift & B <{}< 2 & 0b00101000\\
				Binary Right Shift & B >{}> 2 & 0b10000010\\
				Shift Right Zero Fill & A >{}>{}> 2 & 0b00000010 \\
				\bottomrule
			\end{tabular}
			\caption{Bitwise Operators}
		\end{table}
	\end{block}
\end{slide}

\begin{slide}
	\begin{block}{Logical Operators}
		\begin{minted}[fontsize=\small,tabsize=8]{java}
			boolean A = true;
			boolean B = false;
		\end{minted}
		\begin{table}
			\begin{tabular}{lcc}
				\toprule
				Operator & Example & Output\\
				\midrule
				Logical AND & A \&\& B & false\\
				Logical OR & A || B & true\\
				Logical NOT & !B & true\\
				\bottomrule
			\end{tabular}
			\caption{Logical Operators}
		\end{table}
	\end{block}
\end{slide}

\plain{}{Keep Calm\\and\\Start Writing Code}

\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% UMB-CS240-2016S: Programming in C
% Copyright 2016 Pejman Ghorbanzade <pejman@ghorbanzade.com>
% Creative Commons Attribution-ShareAlike 4.0 International License
% More info: https://github.com/ghorbanzade/UMB-CS240-2016S
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section*{Question 5}

The following structure is defined to implement a resizable array of integers.

\lstset{language=c,tabsize=4}
\lstinputlisting[firstline=20,lastline=24]{\resDirectory/array-list.h}

\begin{enumerate}
\item Write a function with the following signature that returns value of element $e_{i}$ of the array $A$ where $i$ is the element index.

\lstinputlisting[firstline=28,lastline=28,numbers=none]{\resDirectory/array-list.h}

\item Write a function with the following signature that updates value of element $e_{i}$ of the array $A$ with a given value $v$, where $i$ is the index..
The function is expected to return previous value of $e_{i}$.

\lstinputlisting[firstline=29,lastline=29,numbers=none]{\resDirectory/array-list.h}
\end{enumerate}


%%%%%%%%%%%
%% Home work template for Graduate School
%% Author : Thamme Gowda N.
%% Originally from  https://github.com/thammegowda/hw-tex-templ
%%%%%%%%%%%%%%

\documentclass[a4paper,doc,notimes]{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
%%\documentclass[tikz]{standalone}
\usepackage{tikz}
%Required by APA6 package
\usepackage[normalem]{ulem}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{adjustbox}

%Oft-used, oft-abused
\usepackage{afterpage}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{censor}
\usepackage{color}
\usepackage{csquotes}
\usepackage{enumitem}
\usepackage{float}
\usepackage{hyperref}
\usepackage{lmodern}
%\usepackage{media9}
\usepackage{multirow}
\usepackage{outlines}
\usepackage{pdfpages}
\usepackage{placeins}
\usepackage{soul}
\usepackage{tabularx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{xcolor}
\usepackage{mathtools}
\graphicspath{ {images/}}

\usepackage{sectsty}
\sectionfont{\fontsize{14}{12}\selectfont}

\setenumerate[1]{label=\Roman*.}
\setenumerate[2]{label=\Alph*.}
\setenumerate[3]{label=\roman*.}
\setenumerate[4]{label=\alph*.}

% break page where ever is required
\allowdisplaybreaks
\renewcommand{\thesubsection}{\thesection.\alph{subsection}}
\usepackage{titling}
\setlength{\droptitle}{-9em}
\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}
\usepackage{listings}

\title{\noindent  \textbf{ USC CSCI 567 HOMEWORK 5 SOLUTIONS} }
\author{\textbf{ThammeGowda Narayanaswamy} \\
EMail: tnarayan@usc.edu  USCID: 2074-6694-39}

\date{} %% NO date

\begin{document}
\maketitle

\section{Clustering}
\subsection{}
Given that
\begin{equation}\label{e:sse}
	D = \sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} \parallel x_n - \mu_k \parallel^2_2 = \sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} (x_n - \mu_k)^2
\end{equation}
By using the fact: the $argmin_{\mu_k}$ for \ref{e:sse} is when its first order partial derivative is zero.

\begin{align*}
  \frac{\partial}{\partial \mu_k} \sum_{n=1}^{N} \sum_{k'=1}^{K} r_{nk'} (x_n - \mu_{k'})^2 =& 0 & \\
   \sum_{n=1}^{N} r_{nk} x_n - \mu_k \sum_{n=1}^{N} r_{nk}  =& 0 & \\
   \implies \mu_k^* =& \frac{1}{\sum_{n=1}^{N} r_{nk}} \sum_{n=1}^{N} r_{nk} x_n \numberthis \label{e:mean}
\end{align*}
The equation \ref{e:mean} implies that the $\mu_k^*$ is the mean of the data points in the cluster $k$.

\subsection{}
Given that
\begin{equation}\label{e:l1norm}
	D = \sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} | x_n - \mu_k |_1 = \sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} sign(x_n - \mu_k) (x_n - \mu_k)
\end{equation}
By using the fact: the $argmin_{\mu_k}$ for \ref{e:l1norm} is when its first order partial derivative is zero.
\begin{align*}
 \frac{\partial}{\partial \mu_k}\sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} sign(x_n - \mu_k) (x_n - \mu_k) =& 0 & \\
 \sum_{n=1}^{N} \sum_{k=1}^{K} - r_{nk} sign(x_n - \mu_k) =& 0 & \numberthis \label{e:median}
\end{align*}
Now if we interpret the meaning of \ref{e:median}, we get the following:
\begin{itemize}

	\item $sign(x_n - \mu_k)$ is $+1$ when $x_n > \mu_k$ and $-1$ when $x_n < \mu_k$
	\item Equation \ref{e:median} is lower when there are equal number of $x_n > \mu_k$ and $x_n < \mu_k$
	\item $\implies$ that $\mu_k$ is the median of $x$ . This argument holds for both the cases of even and odd number of points in the dataset.
\end{itemize}

\subsection{}

Given
\begin{equation}
	\tilde{D} = \sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} \parallel\phi(x_n) - \tilde{\mu_k} \parallel_2^2 \\
\end{equation}
\subsubsection{}
\begin{align*}
\implies \tilde{D} = & \sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} [\phi(x_n) - \tilde{\mu_k}]^T [\phi(x_n) - \tilde{\mu_k}] \\
 =& \sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} [\phi(x_n)^T\phi(x_n) + \tilde{\mu_k}^2 - 2 \phi(x_n) \tilde{\mu_k} ] \\
  & \text{By subsituting } k(x_1, x_2) = \phi(x_1)^T\phi(x_2) \\
 =& \sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} [k(x_n, x_n) + \tilde{\mu_k}^2 - 2 \phi(x_n) \tilde{\mu_k} ] \numberthis \label{e:D1} \\
\end{align*}
Using \ref{e:mean} to simplify the middle term of \ref{e:D1}, we have
\begin{align*}
	\tilde{\mu_k} =& \frac{1}{\sum_{i=1}^{N} r_{ik}} \sum_{i=1}^{N} r_{ik} \phi(x_i)
				 = \frac{1}{N_k} \sum_{i=1}^{N} r_{ik} \phi(x_i) \numberthis \label{e:mean2}& \space  \because N_k = \sum_{i=1}^{N} r_{ik} \\
 =& \frac{1}{N_k^2} \sum_{i=1}^{N} r_{ik} \sum_{j=1}^{N} r_{jk} \phi(x_i)^T\phi(x_j) \\
 & \text{By subsituting } k(x_1, x_2) = \phi(x_1)^T\phi(x_2) \\
 \tilde{\mu_k}^2 =& \frac{1}{N_k^2} \sum_{i=1}^{N} r_{ik} \sum_{j=1}^{N} r_{jk} k(x_i, x_j) \numberthis \label{e:D2}
\end{align*}
Simplifying the last term of \ref{e:D1},
\begin{align*}
 \phi(x_n) \tilde{\mu_k} & = \phi(x_n) \frac{1}{N_k} \sum_{i=1}^{N} r_{ik} \phi(x_i) = \frac{1}{N_k} \sum_{i=1}^{N} r_{ik} \phi(x_n)^T \phi(x_i) \\
 & \text{By subsituting } k(x_1, x_2) = \phi(x_1)^T\phi(x_2) \\
\phi(x_n) \tilde{\mu_k} &= \frac{1}{N_k} \sum_{i=1}^{N} r_{ik} \times k(x_n, x_i) \numberthis \label{e:D3}
\end{align*}
Substituting \ref{e:D2} and \ref{e:D3} in \ref{e:D1}, we have:
\begin{align*}
\tilde{D} =& \sum_{n=1}^{N} \sum_{k=1}^{K} r_{nk} \bigg[k(x_n, x_n) +  \frac{1}{N_k^2} \sum_{i=1}^{N} r_{ik} \sum_{j=1}^{N} r_{jk} \times k(x_i, x_j) - 2 \frac{1}{N_k} \sum_{i=1}^{N} r_{ik} \times k(x_n, x_i) \bigg] \numberthis \label{e:D4} \\
& \text{where } N_k = \sum_{i=1}^{N} r_{ik}
\end{align*}
We note that, the $L_2$ norm difference between mean of cluster to $x_n$ is given by (used later)
\begin{equation} \label{e:D5}
 \parallel\phi(x_n) - \tilde{\mu_k} \parallel_2^2 = k(x_n, x_n) +  \frac{1}{N_k^2} \sum_{i=1}^{N} r_{ik} \sum_{j=1}^{N} r_{jk} \times k(x_i, x_j) - 2 \frac{1}{N_k} \sum_{i=1}^{N} r_{ik} \times k(x_n, x_i)
\end{equation}

%%%%%%%%%%%%%%%%
\subsubsection{}
To assign a data point $x_n$ to a cluster, we first compute the value of \ref{e:D5} for all the clusters $k \in 1, 2, K$. Then assign it to a the cluster with minimum distance. i.e
\begin{equation}\label{e:asgn}
	A(x_n) = argmin_k \parallel x_n - \mu_k \parallel^2_2
\end{equation}
where $A(x_n)$ stores the cluster assignment of $x_n$

\subsubsection{Pseudo code}
\begin{lstlisting}[mathescape=true]
function kernel_k_means(k, X, K):
  Parameters:
    k : Number of clusters
    X : Array of data points
    K : Kernel Function
  Returns:
    $A(x_n)$: cluster assignments for all the points in X

  Step 1: Initialize centroids of k clusters to
         some random points in the dataset
      for i in range(k):
        $\mu_k \leftarrow random$

  Step 2: Compute the assignment of points
      for n in range(N):
        $A(x_n) \leftarrow argmin_k \parallel x_n - \mu_k \parallel^2_2 $ # Use equation $\ref{e:D5}$ to compute

  Step 3: Recompute the mean/centroid of cluster
      for i in range(k):
        $\mu_k \leftarrow$ Use equation $\ref{e:mean2}$ to compute the mean

  Step 4: Check for termination
      if the values of $\mu_k$ does not change:
        return $A(x_n)$ for all $x_n$
      else:
        go to Step 2
\end{lstlisting}
\section{Gaussian Mixture Model}
\subsection{}

\begin{align*}
L = & P(x_1|\alpha) = \alpha f(x_1|\theta_1) + (1 - \alpha) f(x_1|\theta_2) = \alpha N(0, 1) + (1 - \alpha) N(0, 0.5)  & \\
L = & \frac{\alpha}{\sqrt{2 \pi}} e^{-\frac{x_1^2}{2}} + \frac{1 - \alpha}{\sqrt{\pi}} e^{-x_1^2} & \\
= & \big[\frac{1}{\sqrt{2 \pi}} e^{-\frac{x_1^2}{2}} - \frac{1}{\sqrt{\pi}} e^{-x_1^2} \big] \times \alpha + \frac{1}{\sqrt{\pi}} e^{-x_1^2} \numberthis \label{e:2a1} &  \\
\end{align*}

Note that the above equation is of form $m \alpha + c$ which is a linear in $\alpha$ \\ where $m = \frac{1}{\sqrt{2 \pi}} e^{-\frac{x_1^2}{2}} - \frac{1}{\sqrt{\pi}} e^{-x_1^2}$ and $c = \frac{1}{\sqrt{\pi}} e^{-x_1^2}$ \\
The maximum likelihood estimation of $\alpha$ as follows.
\begin{enumerate}
	\item When $m$ is positive, that is when $\frac{1}{\sqrt{2 \pi}} e^{-\frac{x_1^2}{2}} > \frac{1}{\sqrt{\pi}} e^{-x_1^2}$, we chose maximum value i.e. $\alpha=1$
	\item When $m$ is negative, that is when $\frac{1}{\sqrt{2 \pi}} e^{-\frac{x_1^2}{2}} < \frac{1}{\sqrt{\pi}} e^{-x_1^2}$, we chose minimum value i.e $\alpha=0$
\end{enumerate}

Alternatively we can also use an iterative algorithm such as Expectation Maximization algorithm to compute the above.

\section{EM algorithm}

Given Zero-inflated Poisson Distribution:

\begin{equation}\label{e:observed}
p(x_i) = \begin{cases}
\pi + (1-\pi) e^{-\lambda} & \text{if } x_i = 0\\
(1-\pi) \frac{\lambda^{x_i} e^{-\lambda}}{x_i!} &  \text{if } x_i > 0
\end{cases}
\end{equation}
\subsection{}

For every observation $x_i=0$, let us introduce an hidden indicator variable $z_i$ to indicate whether or not the observation from Zero inflation or Poisson process. i.e.

\begin{equation}\label{e:hidden}
z_i = \begin{cases}
1,& \text{if } x_i \text{from zero inflation}\\
0,&  \text{if } x_i \text{from poisson process}
\end{cases}
\end{equation}
Using \ref{e:observed} and \ref{e:hidden}, we can rewrite PDF $\forall x_i \ge 0 $ as the following:

\begin{equation}\label{e:combines}
p(x_i) = \begin{cases}
\pi^{z_i} \times ((1-\pi) e^{-\lambda})^{1-z_i} & \text{if } x_i = 0, z_i \in{0,1}\\
(1-\pi) \frac{\lambda^{x_i} e^{-\lambda}}{x_i!} &  \text{if } x_i > 0
\end{cases}
\end{equation}

The likelihood of parameters $\lambda$ and $\pi$ in \ref{e:combined} based on $N$ observations in dataset $D$ is given by
\begin{align*}
L = & \prod_{i=1}^{N} p(x_i) = \prod_{i:x_i=0}^{N} p(x_i) \times \prod_{i:x_i \ge 0}^{N} p(x_i) \\
L = &  \prod_{i:x_i=0}^{N} \pi^{z_i} \times ((1-\pi) e^{-\lambda})^{1-z_i} \times \prod_{i:x_i \ge 0}^{N} (1-\pi) \frac{\lambda^{x_i} e^{-\lambda}}{x_i!} \numberthis \\
& \text{The log likelihood is} \\
log L = & log \bigg[ \prod_{i:x_i=0}^{N} \pi^{z_i} \times ((1-\pi) e^{-\lambda})^{1-z_i} \times \prod_{i:x_i \ge 0}^{N} (1-\pi) \frac{\lambda^{x_i} e^{-\lambda}}{x_i!} \bigg] \\
= & \sum_{i:x_i=0}^{N} \big[z_i \log \pi +  (1 - z_i)[\log (1- \pi) -\lambda]\big]
  + \sum_{i:x_i \ge 0}^{N} \big[\log(1- \pi) + x_i \log \lambda -\lambda - \log x_i! \big] \numberthis \label{e:loglike}
\end{align*}
\subsection{}
For the E-step, we need to find probability of hidden variables. This is done by following
\begin{align*}
	P(z_i=1|x_i, \lambda, \pi) & = \frac{P(x_i=0|z_i=1, \lambda, \pi) \times P(z_i=1)}{P(x_i=0)} = \frac{\pi}{\pi + (1-\pi)e^{-\lambda}} = \gamma_{i1} \\
	P(z_i=0|x_i=0, \lambda, \pi) & = \frac{P(x_i=0|z_i=0, \lambda, \pi) \times P(z_i=0)}{P(x_i=0)} = \frac{(1-\lambda)e^{-\lambda}}{\pi + (1-\pi)e^{-\lambda}} = \gamma_{i0}
\end{align*}

For the M-step we need to find the better estimate of parameters $\pi$ and $\lambda$.

We define a function $Q(\theta^t, \theta^{t-1})$
\begin{align*}
Q(\theta^t, \theta^{t-1}) &= E_{P(Z|X, \lambda^{t-1}, \pi^{t-1})}[log(P(X,Z|\lambda,\pi))] \\
  &= \sum_{i:x_i=0}^{N} \big[E[z_i] \log \pi +  E[1 - z_i][\log (1- \pi) -\lambda]\big]
  + \sum_{i:x_i \ge 0}^{N} \big[\log(1- \pi) + x_i \log \lambda -\lambda - \log x_i! \big] \\
  &= \sum_{i:x_i=0}^{N} \big[\gamma_{i1} \log \pi +  \gamma_{i0}[\log (1- \pi) -\lambda]\big]
  + \sum_{i:x_i \ge 0}^{N} \big[\log(1- \pi) + x_i \log \lambda -\lambda - \log x_i! \big] \numberthis \label{e:Q}
\end{align*}
The update rule can be obtained by finding the derivative of \ref{e:Q} w.r.t $\lambda$ and $\pi$.
\begin{align*}
	\frac{\partial Q}{\partial \lambda} & = \sum_{i:x_i=0}^{N} \gamma_{i0} + \sum_{i:x_i \ge 0}^{N} [\frac{x_i}{\lambda} -1 ] \numberthis \\
	\frac{\partial Q}{\partial \pi} &= \sum_{i:x_i=0}^{N} (\frac{\gamma_{i1}}{\pi} - \frac{\gamma_{i0}}{(1-\pi)}) + \sum_{i:x_i \ge 0}^{N} \frac{-1}{1-\pi}	 \\
	\implies & \lambda^{t+1} = \frac{\sum_{i=1}^{N}}{\sum_{i:x_i>0}^{N} 1 + \sum_{i:x_i=0}^{N} \gamma_{i0} }  \text { and }  \pi^{t+1} = \sum_{i:x_i=0}^{N} \frac{\gamma_{i1}}{N}  \\
\end{align*}
\section{Programming}
\stepcounter{subsection}
\subsection{K means}
\subsubsection \\
\includegraphics*[scale=0.5]{k_means.png}

\subsubsection{}
\begin{enumerate}
	\item The circles dataset is not linearly separable. K means doesn't have right objective function to optimize.
\end{enumerate}

\subsection{Kernel K means}
\subsubsection{Kernel}

\begin{align*}
    & k(x_1, x_2) \leftarrow 1.0 - \frac{min(r1, r2)}{ max(r1, r2)} \\
    \text{where  } &  r_1 \leftarrow || x_1 - 0 ||_2  \\
    \text{ and } & r_2 \leftarrow || x_2 - 0 ||_2 \\
    & \text{ and $0$ is the center of the cicles, in this data set it is origin of coordinate system}
\end{align*}

\subsubsection{}
\includegraphics[scale=0.75]{images/kernel_kmeans.png}

\subsection{EM Algorithm}

\subsubsection{Log likelihood of EM}
\includegraphics[scale=0.55]{loglikelihood.png}
\subsubsection{Best Cluster Assignment}

\textbf{Plot} \\
 \includegraphics[scale=0.7]{em_clusters.png} \\

\textbf{Best Parameters}
\begin{verbatim}
Mean:
# 1
	[-0.3258436 ,  0.97128906]

# 2
	 [-0.63945162,  1.47450927]

# 3
	 [ 0.75896021,  0.67976991]

Covariance:
#1
		 [ 0.03603698,  0.01465574],
		 [ 0.01465574,  0.01628796]

#2
		  [ 0.03595904,  0.01548498],
		  [ 0.01548498,  0.01937919]

# 3
		 [ 0.02717059, -0.00840047],
		 [-0.00840047,  0.04044201]

\end{verbatim}

\end{document}