%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% fphw Assignment
% LaTeX Template
% Version 1.0 (27/04/2019)
%
% This template originates from:
% https://www.LaTeXTemplates.com
%
% Authors:
% Class by Felipe Portales-Oliva (f.portales.oliva@gmail.com) with template
% content and modifications by Vel (vel@LaTeXTemplates.com)
%
% Template (this file) License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%    PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[
    12pt, % Default font size, values between 10pt-12pt are allowed
    %letterpaper, % Uncomment for US letter paper size
    %spanish, % Uncomment for Spanish
]{fphw}

% Template-specific packages
\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters
\usepackage{fontspec,unicode-math} % Required for using utf8 characters in math mode
\usepackage{parskip}  % To add extra space between paragraphs
% \usepackage{mathpazo} % Use the Palatino font
\usepackage{graphicx} % Required for including images
\usepackage{booktabs} % Better horizontal rules in tables
\usepackage{hyperref} % For links (both internal and external)
% \usepackage{listings} % Required for insertion of code
\usepackage{enumerate}% To modify the enumerate environment
\usepackage{cleveref} % Better \ref command -> \cref
\usepackage{import}   % This 4 packages and the command allow importing pdf
\usepackage{xifthen}  % figures generated with inkscape
\usepackage{pdfpages} % Source: https://castel.dev/post/lecture-notes-2/
\usepackage{mathtools}
\usepackage{wrapfig}
\usepackage{cancel}
\usepackage{transparent}
\newcommand{\incfig}[1]{%
    \def\svgwidth{0.95\columnwidth}
    \small
        \import{./images/}{#1.pdf_tex}
}

\setlength{\parindent}{15pt}
\setlength{\headheight}{22.66pt}

%----------------------------------------------------------------------------------------
%    ASSIGNMENT INFORMATION
%----------------------------------------------------------------------------------------

\title{Task 5 \\ Stereographic Projection} % Assignment title

\author{Emilio Domínguez Sánchez} % Student name

\date{November 4th, 2020} % Due date

\institute{University of Murcia \\ Faculty of Mathematics} % Institute or school name

\class{Geometría de Superficies} % Course or class name

\professor{Dr. Pascual Lucas Saorin} % Professor or teacher in charge of the assignment

%----------------------------------------------------------------------------------------
%    Definitions
%----------------------------------------------------------------------------------------

\usepackage{physics}
\newcommand{\R}{\mathbb{R}}
\newcommand{\sphere}{{\mathbb{S}^2}}
\newcommand{\inner}[2]{\left\langle #1, \; #2 \right\rangle}

\begin{document}

\maketitle % Output the assignment title, created automatically using the information in the custom commands above

%----------------------------------------------------------------------------------------
%    ASSIGNMENT CONTENT
%----------------------------------------------------------------------------------------

\section*{Problem}

\begin{problem}

The stereographic projection is a function that projects the sphere given by the equation

\begin{equation*}
    \sphere = \qty{\mqty(x & y & z) : x^2 + y^2 + (z-1)^2 = 1}
\end{equation*}

onto the plane $z = 0$, which we identify with $\R^2$.
The projection; $π$; maps the point $p = \mqty(x & y & z) \in \sphere - \qty{N}$,
where $N = \mqty(0 & 0 & 2)$,
to the insersection of the plane $z = 0$ with the line that connects $N$ and $p$.

\begin{enumerate}
    \item Prove that $X = π^{-1} : \R^2 \to \sphere - \qty{N}$
    is a parametrization of the sphere.

    \item Find the coefficients of the first fundamental form of $X$.
\end{enumerate}
\end{problem}

%----------------------------------------------------------------------------------------

\subsection*{Answer}

    The statement talks about $π$ and gives a valid definition for it because
the intersection of a line and a plane is at most one point and
the lines that join $N$ and a different point are never parallel to the plane $z=0$.
However, all the questions are related to $X ≔ π^{-1}$.
Out approach finds the expression for $X$ without computing the expression of $π$.
Nevertheless, we can use the fact that we know that $π$ is well defined
to define $X$ in a way that it is $π^{-1}$ (by construction)
and is therefore biyective (hence inyective),
which comes in handy to prove that it is a parametrization
without proving that the inverse is also continuos.
That is, without finding an expression for $π$.

    Take a point $\mqty(u & v)$ of $\R^2$.
$X(u, v)$ is the image of a point $\mqty(x & y & z)$ if and only if
$\mqty(u & v & 0)$ is the intersection of the plane $z = 0$ and
the line $l ≔ \qty{N + λ(\mqty(x & y & z)-N)}_{λ \in \R}$.
Hence, $l$ is also the line that passes through $N$ and $\mqty(u & v & 0)$,
and $π^{-1}(\qty{\mqty(u & v)})$ is, by definition, $l \cap (\sphere - N)$.

\begin{equation*}
    l =
    \qty{\mqty(u & v & 0) + λ\qty(N-\mqty(u & v & 0))}_{λ \in \R} =
    \qty{\mqty(u(1-λ) & v(1-λ) & 2λ)}_{λ \in \R}. \\
\end{equation*}
\begin{equation*}
    l \cap \sphere = \\
    \qty{\mqty(u(1-λ) & v(1-λ) & 2λ)}_{λ \in \R} \cap \qty{x^2 + y^2 + (z-1)^2 = 1},
\end{equation*}

\pagebreak

    Substituting the parametric equations of $l$ into the implicit equation of $\sphere$
leaves us with the equation\footnote{
Note that we know $l(1) = N \in \sphere$,
which means that $λ = 1$ is a solution of the equation.}

\begin{gather*}
    \begin{aligned}
        u^2(1-λ)^2 + v^2(1-λ)^2 + (2λ-1)^2 &= 1 \\
        (1-λ)\qty[(u^2+v^2)(1-λ) - 4λ] &= 0,
    \end{aligned} \\
\end{gather*}

\noindent
of solutions $λ = 1$ and $λ = \frac{u^2+v^2}{u^2+v^2+4} = 1 - \frac{4}{u^2+v^2+4}$.
That gives

\begin{align*}
    l \cap \sphere &=
    \qty{
        \mqty(\frac{4u}{u^2+v^2+4} & \frac{4v}{u^2+v^2+4} & 2-\frac{8}{u^2+v^2+4}),
        N
    } \qq{and} \\
    l \cap (\sphere - N) &=
    \qty{
        \mqty(\frac{4u}{u^2+v^2+4} & \frac{4v}{u^2+v^2+4} & 2-\frac{8}{u^2+v^2+4})
    }.
\end{align*}

    The fact that the intersection is defined for all $\mqty(u & v)$ and is unique
proves that $π$ is a biyection between $\sphere - N$ and $\R^2$.
And the expression for $π^{-1}$ would be

\begin{equation*}
    X(u, v) =
    \mqty(\dfrac{4u}{u^2+v^2+4} & \dfrac{4v}{u^2+v^2+4} & 2-\dfrac{8}{u^2+v^2+4}).
\end{equation*}

    Now we foucs on the properties of $X$. Its differential is

\begin{equation*}
    %TODO \mqty was not handled as I expected in a subindex
    \dd{X}_{(u \; v)} =
    \pmqty{
    -4u^2 + 4v^2 + 16 & -8uv \\
    -8uv & 4u^2 - 4v^2 + 16 \\
    16u & 16v \\
    } \times \frac{1}{(u^2+v^2+4)^2}
\end{equation*}

\noindent
which is of maximum range because

\begin{multline*}
    \mqty|
    -4u^2 + 4v^2 + 16 & -8uv \\
    -8uv & 4u^2 - 4v^2 + 16
    | = \\
    16^2 - (4u^2-4v^2)^2 - (8uv)^2 =
    16^2 - 16(u^4+v^4) + 32u^2v^2 - 64u^2v^2 = \\
    16^2 - (4(u^2+v^2))^2,
\end{multline*}
\begin{multline*}
    \mqty|
    -4u^2 + 4v^2 + 16 & -8uv \\
    16u & 16v \\
    | = \\
    -64u^2v + 64v^3 + 256v + 128u^2v =
    v(64(u^2 + v^2) + 256)
\end{multline*}
\noindent
and
\begin{multline*}
    \mqty|
    -8uv & 4u^2 - 4v^2 + 16 \\
    16u & 16v \\
    | = \\
    -128uv^2 - 64u^3 + 64uv^2 - 256u =
    u(-64(u^2 + v^2) - 256)
\end{multline*}

\noindent
are $0$ when $u^2+v^2 = 4$, $v = 0$ and $u = 0$, respectively,
which cannot happen at the same time.
All the work up until now,
plus the fact that $X$ in inyective because it is the inverse of $π$,
is enough to apply the technical result that proves that
$X^{-1}$ exists and is continuous.
In other words, to show that $X$ is a parametrization of $\sphere$.

\subsubsection*{Coefficients}

\newcommand{\dX}[1]{{\pdv{X_{(u \; v)}}{#1}}}

Writing

\begin{align*}
    \dX{u} &= \frac{\mqty(-4u^2 + 4v^2 + 16 & -8uv & 16u)}{(u^2+v^2+4)^2}, \\
    \dX{v} &= \frac{\mqty(-8uv & 4u^2 - 4v^2 + 16 & 16v)}{(u^2+v^2+4)^2};
\end{align*}

\noindent
we get that the coefficients are

\begin{multline*}
    {E = \inner{\dX{u}}{\dX{u}} = } \\
    \frac{1}{(u^2+v^2+4)^4}
        \qty(16u^4+16v^4+256-32u^2v^2-128u^2+128v^2 + 64u^2v^2 + 256u^2) = \\
    \frac{1}{(u^2+v^2+4)^4}
        \qty(16u^4+16v^4 +32u^2v^2 + 128u^2 + 128v^2 + 256) = \\
    \frac{16}{(u^2+v^2+4)^4}
        \qty(u^4+v^4 +2u^2v^2 + 8u^2 + 8v^2 + 16) =
    \frac{16}{(u^2+v^2+4)^2},
\end{multline*}
\begin{multline*}
    {G = \inner{\dX{v}}{\dX{v}} = }
    \hfill \text{(by symmetry)} \hfill =
    \frac{16}{(u^2+v^2+4)^2}
\end{multline*}
and
\begin{multline*}
    {F = \inner{\dX{u}}{\dX{v}} = }
    \hfill \frac{1}{(u^2+v^2+4)^4} \qty(-128uv - 128uv + 256uv) \hfill =
    0.
\end{multline*}

(Note that $X$ is an orthogonal parametrization because $F = 0$.)

%----------------------------------------------------------------------------------------

\end{document}


% !TeX program = lualatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex

\documentclass[international_finance_p1.tex]{subfiles}

\begin{document}
\setbeamercovered{transparent}
\section{Forward-looking Market Instruments}

\subsection{The currency forwards}
\begin{frame}{The currency forwards}
\begin{block}{The currency forward }
   is a contract in the foreign exchange market that locks in the exchange rate for the purchase or sale of a currency on a future date.
\end{block}
\begin{itemize}[<+->]
\item
A currency forward represents \emph{a binding obligation}, which means that the contract buyer or seller cannot walk away if the ``locked in'' rate eventually proves to be adverse.
\item
To compensate for the risk of non-delivery, financial institutions may require a \emph{deposit }from retail investors or smaller firms with whom they do not have a business relationship.
\end{itemize}
\end{frame}
\begin{frame}{Determining a currency forward rate}
\begin{align}
F=\frac{\text{Bid}+\text{Ask}}{2}\cdot \frac{1+i_1 \cdot \frac{n}{365}}{1+i_2 \cdot \frac{n}{365}}
\end{align}

where

$F$ – forward rate;

Bid, Ask – spot bid and ask rate respectively;

$i_1$ – annual interest rate for quoted currency;

$i_2$ – annual interest rate for base currency;

$n$ – forward contract period in days
\end{frame}
\setbeamercovered{invisible}
\begin{frame}
\begin{exampleblock}{Forward rate calculation}
assume a current spot rate for the Russian ruble of US\$1 = RUR76.45 or USD/RUR=76.45, a one-year interest rate for Russian rubles of 8\% (key rate held by the Central Bank of Russian Federation), and one-year interest rate for US dollars of 0.25\%. Assume that USD/RUR bid and ask are 75.00 and 76.0 respectively. So, 3-months (3M) forward interest rate would be
\begin{align*}
F_{3M;USDRUB}&=\onslide<2->{ \frac{75+76}{2} \cdot \frac{1+0.08 \cdot \frac{90}{365}}{1+0.0025 \cdot \frac{90}{365}}\\}
\onslide<3->{F_{3M;USDRUB}&=76,9419}
\end{align*}
\end{exampleblock}
\end{frame}
\setbeamercovered{transparent}
\subsection{The foreign exchange swaps}
\begin{frame}
\begin{block}{A foreign exchange swap }
\quad is an arrangement where there is a simultaneous exchange of two currencies on a specific date at a rate agreed at the time of the contract, and a reverse exchange of the same two currencies at a date further in the future at a rate agreed at the time of the contract.
\end{block}
A foreign exchange swap consists of two legs:

1) a spot foreign exchange transaction, and;

2) a forward foreign exchange transaction.
\end{frame}
\begin{frame}{The forward points or swap points }
are quoted as the difference between forward and spot: $F - S$.
\begin{align}
F-S&=S \left(\frac{1+i_1 \cdot \frac{n}{base}}{1+i_2 \cdot \frac{n}{base}}-1\right)\nonumber\\
&=\frac{S(i_1-i_2)T}{1+i_2T}\nonumber\\
&\approx S(i_1-i_2)T
\end{align}
where
$n$ - forward contract term;

$T=\frac{n}{base}$;

$base=\text{365 or 366}$.
If $i_2T$ is small. Thus, the value of the swap points is roughly proportional to the interest rate differential.

The most common use of foreign exchange swaps is for institutions to fund their foreign exchange balances
\end{frame}
\setbeamercovered{invisible}
\begin{frame}
\begin{exampleblock}{Swap points calculation}
% Table generated by Excel2LaTeX from sheet 'Лист2'
\begin{table}[htbp]
  \centering
  \caption{Assume that we have such\\RUB and USD interest rates}
    \begin{tabular}{lr}
    \toprule
    \%RUB & 8\% \\
    \midrule
    \%USD & 0,25\% \\
    n     & 90 \\
    base  & 365 \\
    $SW_{USDRUB}$ & \onslide<2->{0,01911} \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%
\end{exampleblock}
\end{frame}
\setbeamercovered{transparent}
\subsection{The currency swaps}
\begin{frame}{}
\begin{itemize}[<+->]
\item
A currency swap is a contract in which two counterparties exchange streams of interest payments in different currencies for an agreed period of time and then exchange principal amounts in the respective currencies at an agreed exchange rate at maturity.
\item
Currency swaps allow firms to obtain long-term foreign currency financing at lower cost than they can by borrowing directly
\end{itemize}
\end{frame}
\begin{frame}{}
% Table generated by Excel2LaTeX from sheet 'Лист3'
\begin{table}[htbp]
  \centering
  \caption{Loan rates for two firms in different currencies}
    \begin{tabular}{lrr}
    \toprule
          & USD interest rate, \% & EUR interest rate, \% \\
    \midrule
    Firm A & 10    & 7 \\
    Firm B & 9     & 8 \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%
Suppose, US firm has free access to loans from US banks, but can not have such favorable opportunities on Germany capital market.

Similarly, the German firm can have good loan conditions in the homeland, but far less favorable ones in the USA.

By currency swap agreement both firms can use comparative advantages of each other to reduce the cost of loan.

\end{frame}

\begin{frame}[shrink=10]{Cash flows of the two borrowers}{in currency swap agreement}
\begin{figure}
	\centering
	\begin{overprint}
		\forloop{slideno}{1}{\value{slideno} < 2}{%
			\only<\value{slideno}>{
				\includegraphics[page=\value{slideno},
				scale=.7
				% trim={<left> <lower> <right> <upper>}
				,trim={0cm 1cm 1.5cm 0cm},clip]
				{tikz/currency_swap}}}
	\end{overprint}
	\vspace*{-1.5em}
	\caption{\captionf{Currency swap}}
\end{figure}
\end{frame}

\begin{frame}
Thus, both firms obtain the loans in necessary foreign currency at a lower rate, than it would be in case of the request for the credit directly in foreign bank. As a whole the Firm A saves on interest payments 0,8 ml – 0,7 ml = 0,1 ml EUR, and the Firm B saves on interest payments 1,25 ml – 1,125 ml = 0,125 ml USD.
\end{frame}

\subsection{The foreign exchange futures}
\begin{frame}
Futures are similar to forward contracts. Each future contract has a fixed amount and pre-determined dates. The difference of futures from forwards consists in the following:

1. Futures trading is carried out on the open exchange market, and forwards – on interbank. Therefore dates of future contracts expiration are attached to certain dates. Futures contracts are standardized on expiration periods, volumes and terms of delivery. In case of forward contracts expiration periods and volumes of the transaction are determined by the mutual arrangement of the parties.

2. Futures are traded only on most liquid currency pairs. Forward contracts are traded almost on all currency pairs.
\end{frame}
\begin{frame}
3. The futures market is available not only to big investors, but also small. The forward market is limited by that the minimum sum for the transaction amounts 500 thousand US dollars.

4. For about 95\% futures trading volume come to an end with the conclusion of the opposite transaction, thus there is no real delivery of the currency. The parties receive only a difference between the initial price of the contract and the price existing in the day of the closing transaction. On the contrary, for about 95\% forwards transactions come to an end with currency delivery.

5. Futures transactions cost are cheaper because of standardization.

\end{frame}
\subsection{The foreign exchange options}
\begin{frame}
\begin{block}{Foreign currency options }
\quad are contracts that give a buyer the right to buy (call option) or sell (put option) currencies at a specified price within a specific period of time. The strike price is the price at which the owner of the contract has the right but not the obligation to transact.
\end{block}
\end{frame}
\begin{frame}{Comparison of currency call and put options I}
\begin{columns}
\begin{column}{0.5\textwidth}
\textbf{Currency call option}

1. In case the currency call option is executed, expenses of the currency buyer will make:
$$R_{oe}=R_o+P,$$

where $R_o$ – an exchange rate at which the currency will be acquired;

$P$ – premium for the option (buyer`s expenses).

\end{column}
\begin{column}{0.5\textwidth}  %%<--- here
\textbf{Currency put option}

1. In case the currency put option is executed, revenue of the currency seller will make:
$$R_{oe}=R_o-P,$$

where $R_o$ – an exchange rate at which the currency will be acquired;

$P$ – premium for the option (seller`s expenses anyway).
\end{column}
\end{columns}
\end{frame}

\begin{frame}{Comparison of currency call and put options II}
\begin{columns}
\begin{column}{0.5\textwidth}
\textbf{Currency call option}

2. In case the currency call option isn't executed, expenses of the currency buyer will make:
$$R_{te}=R_t+P,$$

where $R_t$ – the current market currency rate of exchange.
\end{column}
\begin{column}{0.5\textwidth}  %%<--- here
\textbf{Currency put option}

2. In case the currency put option isn't executed, revenue of the currency seller will make:
$$R_{te}=R_t-P,$$

where $R_t$ – the current market currency rate of exchange.
\end{column}
\end{columns}
\end{frame}

\begin{frame}{Comparison of currency call and put options III}
\begin{columns}
\begin{column}{0.5\textwidth}
\textbf{Currency call option}

3. As the buyer is interested in minimization of the expenses, a condition under which execution of this option will be favorable to him, will be:
\begin{align*}
 R_{oe} &< R_{te}\\
 &or \\
 R_o &< R_t.
\end{align*}
\end{column}
\begin{column}{0.5\textwidth}  %%<--- here
\textbf{Currency put option}

3. As the seller is interested in maximization of the revenue, a condition under which execution of this option will be favorable to him, will be:
\begin{align*}
 R_{oe} &> R_{te}\\
 &or \\
 R_o &> R_t.
\end{align*}
\end{column}
\end{columns}
\end{frame}

\begin{frame}{Comparison of currency call and put options IV}
\begin{columns}
\begin{column}{0.5\textwidth}
\textbf{Currency call option}

4. The buyer of the call option will make profit, if rate of exchange will rise so that it can cover option premium, i.e.
$$R_{oe} + P < R_{te}$$

If both sides of inequality are equal, the trade will be break-even.
\end{column}
\begin{column}{0.5\textwidth}  %%<--- here
\textbf{Currency put option}

4. The buyer of the put option will make profit, if rate of exchange will fall so that it can cover option premium, i.e.
$$R_{oe}-P>R_{te}$$

If both sides of inequality are equal, the trade will be break-even.
\end{column}
\end{columns}
\end{frame}

\begin{frame}[shrink=10]{}
\begin{exampleblock}{Example}
Consider the firm in Russia that needs \$1 million US dollars in 3 months. The firm decided to buy 3-months call option contract for USD/RUR
% Table generated by Excel2LaTeX from sheet 'optionprem'
\begin{table}[htbp]
  \centering
  \caption{Currency market conditions}
    \begin{tabular}{lrr}
    \toprule
          & Bid   & Ask \\
    \midrule
    USD/RUR spot rate & 32.5  & 33.2 \\
    USD/RUR 3-months forward premium & 0.6   & 0.8 \\
    USD/RUR 3-month option premium & 0.2   & 0.2 \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%
Should the firm execute the option if the Bid/Ask rate of exchange for USD/RUR makes, respectively, 32.80 and 33.40 in three months?
\end{exampleblock}
\end{frame}
\setbeamercovered{invisible}
\begin{frame}{}
\begin{exampleblock}{Solution}
If the firm execute the call option, its costs of dollar`s purchase will make

\onslide<2->
33,20 + 0,80 + 0,20 = 34,20.

\onslide<3->
If the firm doesn't execute the option, its expenses will make:

\onslide<4->
33,40 + 0,20 = 33,60.

\onslide<5->
Thus, option execution will be unprofitable to firm since increases its costs of dollar`s purchase per 0,60 rubles for one dollar.
\end{exampleblock}
\end{frame}
\setbeamercovered{transparent}
\subsection{Pricing forex options}

\end{document}


\documentclass{article}

\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{marvosym}
\usepackage{dingbat}
\usepackage{tikz}

\title{Longest branch of a tree}
\date{}

\usetikzlibrary{arrows}

\tikzset{
  treenode/.style = {align=center, inner sep=0pt, text centered, font=\sffamily},
  wn/.style = {treenode, circle, black, font=\ttfamily, draw=white, fill=white, text width=1.5em},
  txt/.style = {black, anchor=west, font=\ttfamily, draw=white, fill=white},
  edge from parent/.style={thick,draw=black, latex-}
}

\begin{document}
\maketitle

\section{Longest tree branch}

This exercise is about parallelizing a Depth First Search (DFS) traversal of
a random tree. We assume that each node has a weight which corresponds
to the time it takes to process it. Our DFS traversal finds the
longest branch in the tree, i.e., the branch such that the sum of the
weigths of its nodes is maximum.

The tree is nodes of type \texttt{node\_t} which contain the following members

\begin{itemize}
\item \texttt{weight}: the weight of the node;
\item \texttt{branch\_weight}: the weight of the branch that connects
  the node to the root of the tree; this is set to zero at the
  beginning and is updated during the DFS traversal;
\item \texttt{id}: the node number;
\item \texttt{nc}: the number of children of the node.
\item \texttt{*children}: an array of pointers to the children of the node.
\end{itemize}

The traversal is done recursively using the following code

\begin{verbatim}
void longest_branch_seq_rec(node_t *root, unsigned int *weight, unsigned int *leaf){
  int i;
  process(root);
  root->branch_weight += root->weight;

  if(root->nc>0) {
    for(i=0; i<root->nc; i++){
      root->children[i].branch_weight = root->branch_weight;
      longest_branch_seq_rec(root->children+i, weight, leaf);
    }
  } else {
    if(root->branch_weight > *weight){
      *weight = root->branch_weight;
      *leaf   = root->id;
    }
  }
}
\end{verbatim}

The \texttt{weight} and \texttt{leaf} arguments of this function are
meant to return the weight of the longest branch and the corresponding
leaf.  When we visit a node, first we process it using the
\texttt{process} routine and we update the weight of the branch that
connects it to the root (i.e., we add its weight to the branch weight
of its father).  Then, if it has children, we recursively call this
code on each one of them, if not then it means that we have reached a
leaf of the tree; in this case if the weight of the current branch is
grater than the current maximum contained in the \texttt{weight}
variable, we update \texttt{weight} and \texttt{leaf}.

For example, on the tree below, this method would return the leaf
number $3$ and the associated weight of $137$.

\begin{center}
  \includegraphics[width=0.4\textwidth]{tree.pdf}
\end{center}

\section{Package content}
In the \texttt{tree\_branch} directory you will find the
following files:
\begin{itemize}
\item \texttt{main.c}: this file contains the main program which first
  initializes the tree for a provided number of maximum levels. The main
  program then calls a sequential routine \texttt{longest\_branch\_seq}
  containing the above code, then calls the
  \texttt{longest\_branch\_par} routine which is supposed to contain a
  parallel version of the traversal code.
\item \texttt{longest\_branch\_seq.c}: contains a routine implementing a
  sequential traversal with the code presented above.
\item \texttt{longest\_branch\_par.c} contains a routine implementing a
  parallel tree traversal. \textbf{Only this file has to be modified
    for this exercise}.
\item \texttt{aux.c, aux.h}: these two files contain auxiliary
  routines and \textbf{must not be modified}.
\end{itemize}

The code can be compiled with the \texttt{make} command: just type
\texttt{make} inside the \texttt{tree\_branch} directory; this
will generate a \texttt{main} program that can be run like this:

\begin{verbatim}
$ ./main l s
\end{verbatim}

where \texttt{l} is the number of levels in the tree. The argument $s$
is the seed for the random number generation (which is used to build
the tree), and can be used to create trees of different shapes for a
fixed number of levels.

\section{Assignment}
\begin{itemize}
\item {\huge \Keyboard} At the beginning, the
  \texttt{longest\_branch\_par} routine contains an exact copy of the
  \texttt{longest\_branch\_seq} one. Modify these routine in order to
  parallelize it.  Make sure that the result computed by the three
  routines (sequential and parallel ones) is consistently (that is, at
  every execution of the parallel code) the same; a message printed at
  the end of the execution will tell you whether this is the
  case. Note that there may be multiple branches of the same length;
  in this case any of them will be considered a correct result. Also,
  modify the code in order to count the number of nodes updated by
  each of the working threads.
\item \smallpencil Report the execution times for the implemented
  parallel version with 1, 2 and 4 threads and for different tree
  sizes. Analyze and comment on your results: is the achieved speedup
  reasonable or not? Report your answer in the \texttt{responses.txt}
  file.
\end{itemize}

\paragraph{Advice}
\begin{itemize}
\item As usual, when developing and debugging choose trees of small
  size. When evaluating performance it's better to choose a larges
  tree size.
\end{itemize}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{multicol}
\usepackage{algpseudocode}
\usepackage{algorithm}

% Geometry
\usepackage{geometry}
\geometry{letterpaper, left=15mm, top=20mm, right=15mm, bottom=20mm}

% Fancy Header
\usepackage{fancyhdr}
\renewcommand{\footrulewidth}{0.4pt}
\pagestyle{fancy}
\fancyhf{}
\chead{CSC 360 - Analysis of Algorithms}
\lfoot{CALU Fall 2021}
\rfoot{RDK}

% Add vertical spacing to tables
\renewcommand{\arraystretch}{1.4}

% Macros
\newcommand{\definition}[1]{\underline{\textbf{#1}}}

\newenvironment{rcases}
  {\left.\begin{aligned}}
  {\end{aligned}\right\rbrace}

% Begin Document
\begin{document}

\begin{itemize}

    \item Read Chapters 7 and 8 for Week 3. Quiz in Week 3.

    \item What governs how fast an algorithm can run?
    \begin{itemize}
        \item The complexity of the problem; a problem has a theoretical best solution
        \item The efficiency of the algorithm; an algorithm can give a close enough solution in a fraction of the time
    \end{itemize}

    \item Sometimes writing a program that always guesses the correct solution is not always good enough.
    \begin{itemize}
        \item Time complexity; a program taking too long for its answer; keep in mind timescales
    \end{itemize}

\end{itemize}

\section*{Properites of Exponents}

\begin{itemize}

    \item $x^a * x^b = x^{a+b}$
    \item $(x^a)^b = x^{ab}$
    \item $x^a / x^b = x^{a-b}$

\end{itemize}

\section*{Properties of Logarithms}
\begin{itemize}

    \item $x^a = b$ iff $log_x b = a$

    \item $log_a b = log_c b / log_c a$ if $a, b, c > 0, a \neq 0$
    \begin{itemize}
        \item Let $x = log_c b$, $y = log_c a$, $z = log_a b$
        \item $b = c^x, b=a^z \rightarrow b = c^x = a^z$
        \item $a = c^y$
        \item $b = c^x = c^{yz}$
        \item $x = yz \rightarrow z = x/y$
    \end{itemize}

    \item $logab = loga + logb$
    \begin{itemize}
        \item Let $x = log_2 a, y = log_2 b, z = log_2 ab$ if $a, b > 0$
        \item $2^x = a, 2^y = b, 2^z = ab$
        \item $2^x * 2^y = 2^z$
        \item $2^{x+y} = 2^z$
        \item $x + y = z$
    \end{itemize}

    \item $log_2 (a/b) = log_2 a - log_2 b$ if $a, b > 0$
    \begin{itemize}
        \item Let $x = log_2 a, y = log_2 b, z = log_2 (a/b)$
        \item $2^x = a, 2^y = b, 2^z = a / b$
        \item $2^x / 2^y = 2^z$
        \item $x-y = z$
    \end{itemize}

\end{itemize}

\pagebreak

\section*{Disproof}
\begin{itemize}
    \item Only need to find one counter example
    \item Example: $n! < n^2 + n^5$ \\
    \begin{tabular}{l l l}
        Pick $n=9$ & & \\
        $9! = 362880$ & $9^2 = 81$ & $9^5 = 59130$ \\
        $362880 < 81 + 59130$ & FALSE! &
    \end{tabular}
\end{itemize}

\section*{Proof by Induction}
\begin{itemize}
    \item Use proof by Induction for discrete types only.
    \item Happens in 3 steps:
    \begin{enumerate}
        \item Start with a (very small) base case.
        \item Inductive Hypothesis: ``Since we showed a base case in Step 1, let's assume it holds true for values through $k$''
        \item Show that if the Hypothesis works for value $k$, the Hypothesis holds for $k+1$
    \end{enumerate}
\end{itemize}

\subsection*{Example of Induction}

\[ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} \]

\begin{enumerate}
    \item Let $n=1 \rightarrow 1 = 1$
    \item Assume the property is true for $1, 2, \ldots, k$
    \item Show if true for $k$, then true for $k+1$
    \\
    \begin{tabular}{l l l}
        $\sum_{i=1}^{k+1} i$ & $=$ & $\sum_{i=1}^{k} + k + 1$ \\
        & $=$ & $\frac{k(k+1)}{2} + k + 1$ \\
        & $=$ & $\frac{k(k+1)}{2} + \frac{2(k+1)}{2}$ \\
        & $=$ & $\frac{k(k+1) + 2(k+1)}{2}$ \\
        & $=$ & $\frac{(k+1)(k+2)}{2}$ \\
        & $=$ & $\frac{(k+1)(k+1+1)}{2}$ \\
    \end{tabular}

\end{enumerate}

\pagebreak

\subsection*{Example 2 of Induction}

\[ \sum_{i=1}^{n} i(i+1) = \frac{n(n+1)(n+2)}{3} \]

\begin{enumerate}
    \item Let $n=1 \rightarrow 2 = 2$
    \item Assume the property is true for $1, 2, \ldots, k$
    \item Show if true for $k$, then true for $k+1$
    \\
    \begin{tabular}{l l l}
        $\sum_{i=1}^{k+1} i(i+1)$ & $=$ & $\sum_{i=1}^{k} i(i+1) + (k+1)(k+2)$ \\
        & $=$ & $\frac{k(k+1)(k+2)}{3} + (k+1)(k+2)$ \\
        & $=$ & $\frac{k(k+1)(k+2)}{3} + \frac{3(k+1)(k+2)}{3}$ \\
        & $=$ & $\frac{k(k+1)(k+2) + 3(k+1)(k+2)}{3}$ \\
        & $=$ & $\frac{(k+1)(k+2)(k+3)}{3}$ \\
        & $=$ & $\frac{(k+1)(k+1+1)(k+1+2)}{3}$ \\
    \end{tabular}

\end{enumerate}

\subsection*{Example 3 of Induction}

Fibonnaci Numbers $\rightarrow F_0 = 1, F_1 = 1, \ldots, (F_i = F_{i-1} + F_{i-2})$

Prove that $F_i < ({\frac{5}{3}})^i$, for $i \geq 1$

\begin{enumerate}

    \item $F_1 = 1 < (\frac{5}{3})^1$
    \item Assume this is true for $1, \ldots, k$
    \item Show if true for $k$, then true for $k+1$
    \\
    \begin{tabular}{l l l l l}
        $F_{k+1}$ & $=$ & $F_k + F_{k-1}$ && \\
        $F_{k+1}$ & $<$ & $(\frac{5}{3})^k + (\frac{5}{3})^{k-1}$ && \\
        $F_{k+1}$ & $<$ & $(\frac{3}{5})(\frac{5}{3})^{k+1} + (\frac{3}{5})^2(\frac{5}{3})^{k+1}$ && \\
        $F_{k+1}$ & $<$ & $(\frac{5}{3})^{k+1} * ((\frac{3}{5})^2+(\frac{3}{5}))$ && \\
        $F_{k+1}$ & $<$ & $(\frac{5}{3})^{k+1} * (\frac{15}{25} + \frac{9}{25})$ && \\
        $F_{k+1}$ & $<$ & $(\frac{5}{3})^{k+1} * \frac{24}{25}$ & $<$ & $({\frac{5}{3}})^{k+1}$ \\
    \end{tabular}

\end{enumerate}

\end{document}


%!TEX root = ../main.tex
\section{Introduction}
\label{sec:introduction}
%Copatterns. This is an preparatory study for our master's thesis.
%How do we fit copatterns into Idris?
In the world of functional programming, the use of inductive data types has long been a standard practice. Inductive data types enable users to define fundamental data structures such as lists, trees, and graphs, and to analyze data by pattern matching. A fundamental property of inductively defined data is that it is inherently finite. Since it is defined in terms of constructors, infinite structures cannot be defined inductively in systems with finite memory unless certain evaluation strategies are abandoned. In particular, programming languages such as Haskell have successfully been able to blur the lines between finite and infinite structures through the power of lazy evaluation. An alternative approach is to define infinite data explicitly by the use of \emph{co}inductive data types. These were first implemented by Hagino for his SymML language\,\citep{Hagino89}, allowing users to define coinductive data in terms of its \emph{destructors}. This means that it does not make sense to think of coinductive data as something that is constructed. Rather, coinductive data can be thought of as something that can be taken apart and observed, and therefore the terms ``observation'' and ``destructor'' are used interchangably. Explicit coinductive data types have since been added to several other programming systems, examples of which are the Coq proof system\,\citep{Coq:manual}, Agda\,\citep{Norell:thesis}, Beluga\,\citep{Pientka10}, and Idris\,\citep{BradyIdrisImpl13}.

While most (if not all) systems with inductive data types have a pattern matching construct for analyzing data, many systems with coinductive data types do not have dedicated constructs for manipulating destructors. Instead, coinductive data is also subjected to pattern matching. In SymML, Hagino describes a \texttt{merge} construct for describing how a coinductive definition can be destructed, an example of which is shown in Figure~\ref{fig:merge_SymML}.

\begin{figure}
\begin{alltt}
codatatype 'a inflist = head is 'a & tail is 'a inflist;

fun iseq1() = merge head <= 1
              & tail <= iseq1();
\end{alltt}
\caption{An example of the \texttt{merge} construct in SymML. Here, \texttt{inflist} is a definition of an infinite list, and \texttt{iseq1} is an infinite list of ones.}
\label{fig:merge_SymML}
\end{figure}

In Coq, no such construct exists, and the same is the case for Idris. In the wake of work done by Abel and Pientka\,\citep{Abel13Wellfounded} and Abel, Pientka, Thibodeau, and Setzer\,\citep{Abel13Copatterns}, a construct similar to Hagino's \texttt{merge} has recently been implemented in Agda. This construct is called a \emph{copattern}. By allowing projections on the left-hand side of function definitions, copatterns enable users to define corecursive functions in terms of observations. In effect, coinductive data no longer has to be analyzed with pattern matching, but can more naturally be expressed by the observations that can be made on it.

\subsection{Goals and Contributions}
This project serves as a preparation for our master's thesis, where we plan to implement copatterns and coinductive data defined by observations in Idris. The goals of this project are:

\begin{itemize}
\item To understand the ideas behind copatterns.
\item To understand how copatterns are used in practice, for example by studying Agda.
\item To understand how copatterns can be implemented.
\item To implement a simple functional programming language with copatterns.
\item To understand how the current termination checker in Idris works by implementing a similar termination checker employing the size-change principle\,\citep{LeeJones01SizeChange} for said language.
\end{itemize}

As a result of pursuing these goals, our contributions are:

\begin{itemize}
\item An investigation into whether the intended changes can be implemented in Idris without changing its core type theory.
\item A survey of the literature describing different implementations of the size-change principle. This is done in order to find out whether it is feasible to extend the size-change termination checker in Idris to work as a productivity checker for corecursive function definitions with copatterns. Additionally, existing approaches to productivity checking will be explored, for example the guardedness principle.
\item A proposal for a productivity checking algorithm for corecursive function definitions with copatterns.
\end{itemize}

\subsection{Outline}
In Section~\ref{sec:background}, we describe the core concepts behind coinductive data, copatterns, and productivity. Section~\ref{sec:related_work} provides a survey of the relevant literature, in particular with respect to termination and productivity checking. The implementation of a small functional language with copatterns is described in Section~\ref{sec:implementing-copatterns}. In Section~\ref{sec:productivity}, we present our proposal for a productivity algorithm for corecursive functions with copatterns, while also discussing the virtues of other approaches to productivity checking. Section~\ref{sec:copatterns_in_idris} explains the necessary changes in order for us to add definitions with copatterns to Idris, and finally, Section~\ref{sec:conclusion} provides a conclusion for the entire report.


%!TEX root = forallxsol.tex
%\part{Natural deduction for TFL}
%\label{ch.NDTFL}
%\addtocontents{toc}{\protect\mbox{}\protect\hrulefill\par}

\renewenvironment{proof} %TB: make proofs smaller, since space is a premium here
	{\noindent\par\noindent\small$\begin{nd}}
	{\end{nd}$\noindent\normalsize\ignorespacesafterend}

\setcounter{chapter}{14}
\chapter{Basic rules for TFL}\setcounter{ProbPart}{0}
\problempart
The following two `proofs' are \emph{incorrect}. Explain the mistakes they make.
\begin{multicols}{2}
\begin{proof}
\hypo{abc}{(\enot L \land A) \eor L}
\open
\hypo{nla}{\enot L \eand A}
\have{nl}{\enot L}\ae{nl}
        \have{a}{A}\ae{abc}
\close
\open
        \hypo{l}{L}
        \have{red}{\ered}\ri{l, nl}
        \have{a2}{A}\re{red}
\close
\have{con}{A}\oe{abc, nla-a, l-a2}
\end{proof}
\vfill
\noindent\myanswer{$\eand$E on line 5 can't be applied to line~1, since it is not of the form $\meta{A} \eand \meta{B}$.  `$A$' could be obtained by $\eand$E, but from line~2.}

\myanswer{$\ered$I on line 5 illicitly refers to a line from a closed subproof (line~3).}
\hfill
\columnbreak
\begin{proof}
\hypo{abc}{A \eand (B \eand C)}
\hypo{bcd}{(B \eor C) \eif D}
\have{b}{B}\ae{abc}
\have{bc}{B \eor C}\oi{b}
\have{d}{D}\ce{bc, bcd}
\end{proof}
\vfill
\noindent\myanswer{$\eand$E on line 3 should yield `$B \eand C$'.  `$B$' could then be obtained by $\eand$E again.}

\myanswer{The citation for line 5 is the wrong way round: it should be `$\eif$E 2, 4'.}
\end{multicols}

\problempart
The following three proofs are missing their citations (rule and line numbers). Add them, to turn them into \textit{bona fide} proofs. Additionally, write down the argument that corresponds to each proof.
\newpage
\begin{multicols}{2}
\begin{proof}
\hypo{ps}{P \eand S}
\hypo{nsor}{S \eif R}
\have{p}{P}\ae{ps}
\have{s}{S}\ae{ps}
\have{r}{R}\ce{nsor, s}
\have{re}{R \eor E}\oi{r}
\end{proof}
\\\myanswer{Corresponding argument: \\$P \eand S, S \eif R \therefore R \eor E$}

\bigskip

\begin{proof}
\hypo{ad}{A \eif D}
\open
	\hypo{ab}{A \eand B}
	\have{a}{A}\ae{ab}
	\have{d}{D}\ce{ad, a}
	\have{de}{D \eor E}\oi{d}
\close
\have{conc}{(A \eand B) \eif (D \eor E)}\ci{ab-de}
\end{proof}
\\\myanswer{Corresponding argument: \\$A \eif D \therefore (A \eand B) \eif (D \eor E)$}

\columnbreak

\begin{proof}
\hypo{nlcjol}{\enot L \eif (J \eor L)}
\hypo{nl}{\enot L}
\have{jol}{J \eor L}\ce{nlcjol, nl}
\open
	\hypo{j}{J}
	\have{jj}{J \eand J}\ai{j, j}
	\have{j2}{J}\ae{jj}
\close
\open
	\hypo{l}{L}
	\have{red}{\ered}\ri{l, nl}
	\have{j3}{J}\re{red}
\close
\have{conc}{J}\oe{jol, j-j2, l-j3}
\end{proof}
\\\myanswer{Corresponding argument:\\
$\enot L \eif (J \eor L), \enot L \therefore J$}
\end{multicols}

\solutions
\problempart
\label{pr.solvedTFLproofs}
Give a proof for each of the following arguments:
\begin{earg}
\item $J\eif\enot J \therefore \enot J$
\myanswer{\begin{proof}
\hypo{jnj}{J \eif \enot J}
\open
	\hypo{j}{J}
	\have{nj}{\enot J}\ce{jnj, j}
	\have{red}{\ered}\ri{j, nj}
\close
\have{con}{\enot J}\ni{j-red}
\end{proof}}

\item $Q\eif(Q\eand\enot Q) \therefore \enot Q$
\myanswer{\begin{proof}
\hypo{qq}{Q \eif  (Q \eand \enot Q)}
\open
	\hypo{q}{Q}
	\have{con}{Q \eand \enot Q}\ce{qq, q}
	\have{nq}{\enot Q}\ae{con}
	\have{red}{\ered}\ri{q, nq}
\close
\have{con}{\enot Q}\ni{q-red}
\end{proof}}

\item $A\eif (B\eif C) \therefore (A\eand B)\eif C$
\myanswer{\begin{proof}
\hypo{abc}{A \eif (B \eif C)}
\open
	\hypo{ab}{A \eand B}
	\have{a}{A}\ae{ab}
	\have{bc}{B \eif C}\ce{abc, a}
	\have{b}{B}\ae{ab}
	\have{c}{C}\ce{bc, b}
\close
\have{con}{(A \eand B) \eif C}\ci{ab-c}
\end{proof}}

\item $K\eand L \therefore K\eiff L$
\myanswer{\begin{proof}
\hypo{kl}{K \eand L}
\open
	\hypo{k1}{K}
	\have{l1}{L}\ae{kl}
\close
\open
	\hypo{l2}{L}
	\have{k2}{K}\ae{kl}
\close
\have{con}{K \eiff L}\bi{k1-l1, l2-k2}
\end{proof}}

\item $(C\eand D)\eor E \therefore E\eor D$
\myanswer{\begin{proof}
\hypo{cde}{(C \eand D) \eor E}
\open
	\hypo{cd}{C \eand D}
	\have{d}{D}\ae{cd}
	\have{ed}{E \eor D}\oi{d}
\close
\open
	\hypo{e}{E}
	\have{ed1}{E \eor D}\oi{e}
\close
\have{con}{E \eor D}\oe{cde, cd-ed, e-ed1}
\end{proof}}

\item $A\eiff B, B\eiff C \therefore A\eiff C$
\myanswer{\begin{proof}
\hypo{ab}{A \eiff B}
\hypo{bc}{B \eiff C}
\open
	\hypo{a}{A}
	\have{b}{B}\be{ab, a}
	\have{c}{C}\be{bc, b}
\close
\open
	\hypo{c1}{C}
	\have{b1}{B}\be{bc,c1}
	\have{a1}{A}\be{ab, b1}
\close
\have{con}{A \eiff C}\bi{a-c, c1-a1}
\end{proof}}

\item $\enot F\eif G, F\eif H \therefore G\eor H$
\myanswer{\begin{proof}
\hypo{nfg}{\enot F \eif G}
\hypo{fh}{F \eif H}
\open
        \hypo{ncon}{\enot (G \eor H)}
        \open
                \hypo{f}{F}
                \have{h}{H}\ce{fh, f}
                \have{gh1}{G \eor H}\oi{h}
                \have{bot1}{\ered}\ri{ncon, gh1}
        \close
        \have{nf}{\enot F}\ni{f-bot1}
        \have{g}{G}\ce{nfg,nf}
        \have{gh2}{G \eor H}\oi{g}
        \have{bot2}{\ered}\ri{ncon, gh2}
\close
\have{con}{G \eor H}\ip{ncon-bot2}
\end{proof}}

\item $(Z\eand K) \eor (K\eand M), K \eif D \therefore D$
\myanswer{\begin{proof}
\hypo{zkkm}{(Z \eand K) \eor (K \eand M)}
\hypo{kd}{K \eif D}
\open
	\hypo{zk}{Z \eand K}
	\have{k}{K}\ae{zk}
\close
\open
	\hypo{km}{K \eand M}
	\have{k1}{K}\ae{km}
\close
\have{k2}{K}\oe{zkkm, zk-k, km-k1}
\have{d}{D}\ce{kd, k2}
\end{proof}}

\item $P \eand (Q\eor R), P\eif \enot R \therefore Q\eor E$
\myanswer{\begin{proof}
\hypo{pqr}{P \eand (Q \eor R)}
\hypo{pnr}{P \eif \enot R}
\have{p}{P}\ae{pqr}
\have{nr}{\enot R}\ce{pnr, p}
\have{qr}{Q \eor R}\ae{pqr}
\open
	\hypo{q}{Q}
	\have{qe}{Q \eor E}\oi{q}
\close
\open
	\hypo{r}{R}
	\have{red}{\ered}\ri{r, nr}
	\have{qe1}{Q \eor E}\re{red}
\close
\have{con}{Q \eor E}\oe{qr, q-qe, r-qe1}
\end{proof}}

\newpage
\item $S\eiff T \therefore S\eiff (T\eor S)$
\myanswer{\begin{proof}
\hypo{st}{S \eiff T}
\open
	\hypo{s}{S}
	\have{t}{T}\be{st, s}
	\have{ts}{T \eor S}\oi{t}
\close
\open
	\hypo{ts1}{T \eor S}
	\open
		\hypo{t1}{T}
		\have{s3}{S}\be{st, t1}
	\close
	\open
		\hypo{s1}{S}
		\have{ss}{S \eand S}\ai{s1, s1}
		\have{s2}{S}\ae{ss}
	\close
	\have{s4}{S}\oe{ts1, t1-s3, s1-s2}
\close
\have{con}{S \eiff (T \eor S)}\bi{s-ts, ts1-s4}
\end{proof}}

\item $\enot (P \eif Q) \therefore \enot Q$
\myanswer{\begin{proof}
\hypo{npq}{\enot (P \eif Q)}
\open
	\hypo{q}{Q}
	\open
		\hypo{p}{P}
		\have{qq}{Q \eand Q}\ai{q, q}
		\have{q2}{Q}\ae{qq}
	\close
	\have{pq}{P \eif Q}\ci{p-q2}
	\have{red}{\ered}\ri{pq, npq}
\close
\have{con}{\enot Q}\ni{q-red}
\end{proof}}

\item $\enot (P \eif Q) \therefore P$
\myanswer{\begin{proof}
\hypo{npq}{\enot (P \eif Q)}
\open
	\hypo{np}{\enot P}
	\open
		\hypo{p2}{P}
		\have{red}{\ered}\ri{p2, np}
		\have{q}{Q}\re{red}
	\close
	\have{pq}{P \eif Q}\ci{p2-q}
	\have{red1}{\ered}\ri{pq, npq}
\close
\have{con}{P}\ip{np-red1}
\end{proof}}
\end{earg}

\chapter{Additional rules for TFL}
\label{s:Further}
\setcounter{ProbPart}{0}
\problempart
\label{pr.justifyTFLproof}
The following proofs are missing their citations (rule and line numbers). Add them wherever they are required:
\begin{multicols}{2}
\begin{proof}
\hypo{1}{W \eif \enot B}
\hypo{2}{A \eand W}
\hypo{2b}{B \eor (J \eand K)}
\have{3}{W}\ae{2}
\have{4}{\enot B}\ce{1, 3}
\have{5}{J \eand K}\ds{2b, 4}
\have{6}{K}\ae{5}
\end{proof}
\vfill
\begin{proof}
\hypo{1}{L \eiff \enot O}
\hypo{2}{L \eor \enot O}
\open
	\hypo{a1}{\enot L}
	\have{a2}{\enot O}\ds{2, a1}
	\have{a3}{L}\be{1, a2}
	\have{a4}{\ered}\ri{a3, a1}
\close
\have{3b}{\enot\enot L}\ni{a1-a4}
\have{3}{L}\dne{3b}
\end{proof}
\columnbreak
\begin{proof}
\hypo{1}{Z \eif (C \eand \enot N)}
\hypo{2}{\enot Z \eif (N \eand \enot C)}
\open
	\hypo{a1}{\enot(N \eor  C)}
	\have{a2}{\enot N \eand \enot C}\dem{a1}
	\have{a6}{\enot N}\ae{a2}
	\have{b4}{\enot C}\ae{a2}
		\open
		\hypo{b1}{Z}
		\have{b2}{C \eand \enot N}\ce{1, b1}
		\have{b3}{C}\ae{b2}
		\have{red}{\ered}\ri{b3, b4}
	\close
	\have{a3}{\enot Z}\ni{b1-red}
	\have{a4}{N \eand \enot C}\ce{2,a3}
	\have{a5}{N}\ae{a4}
	\have{a7}{\ered}\ri{a5, a6}
\close
\have{3b}{\enot\enot(N \eor C)}\ni{a1-a7}
\have{3}{N \eor C}\dne{3b}
\end{proof}
\end{multicols}

\problempart
Give a proof for each of these arguments:
\begin{earg}
\item $E\eor F$, $F\eor G$, $\enot F \therefore E \eand G$
\myanswer{\begin{proof}
\hypo{ef}{E \eor F}
\hypo{fg}{F \eor G}
\hypo{nf}{\enot F}
\have{e}{E}\ds{ef, nf}
\have{g}{G}\ds{fg, nf}
\have{eg}{E \eand G}\ai{e, g}
\end{proof}}

\item $M\eor(N\eif M) \therefore \enot M \eif \enot N$
\myanswer{\begin{proof}
\hypo{mnm}{M \eor (N \eif M)}
\open
	\hypo{nm}{\enot M}
	\have{nim}{N \eif M}\ds{mnm, nm}
	\have{nn}{\enot N}\mt{nim, nm}
\close
\have{nminn}{\enot M \eif \enot N}\ci{nm-nn}
\end{proof}}

\item $(M \eor N) \eand (O \eor P)$, $N \eif P$, $\enot P \therefore M\eand O$
\myanswer{\begin{proof}
\hypo{mnop}{(M \eor N) \eand (O \eor P)}
\hypo{nip}{N \eif P}
\hypo{np}{\enot P}
\have{nn}{\enot N}\mt{nip, np}
\have{mn}{M \eor N}\ae{mnop}
\have{m}{M}\ds{mn, nn}
\have{op}{O \eor P}\ae{mnop}
\have{o}{O}\ds{op, np}
\have{mo}{M \eand O}\ai{m, o}
\end{proof}}

\item $(X\eand Y)\eor(X\eand Z)$, $\enot(X\eand D)$, $D\eor M$ \therefore $M$
\myanswer{\begin{proof}
\hypo{xyxz}{(X\eand Y)\eor(X\eand Z)}
\hypo{nxd}{\enot (X \eand D)}
\hypo{dm}{D \eor M}
\open
	\hypo{xy}{X \eand Y}
	\have{x}{X}\ae{xy}
\close
\open
	\hypo{xz}{X \eand Z}
	\have{x2}{X}\ae{xz}
\close
\have{x3}{X}\oe{xyxz, xy-x, xz-x2}
\open
	\hypo{d}{D}
	\have{xd}{X \eand D}\ai{x3, d}
	\have{red}{\ered}\ri{xd, nxd}
\close
\have{nd}{\enot D}\ni{d-red}
\have{m}{M}\ds{dm, nd}
\end{proof}}

\end{earg}

\chapter{Proof-theoretic concepts}
\label{s:ProofTheoreticConcepts}

\setcounter{ProbPart}{0}
\problempart
Show that each of the following sentences is a theorem:
\begin{earg}
\item $O \eif O$
\myanswer{\begin{proof}
\open
	\hypo{o}{O}
	\have{o2}{O}\by{R}{o}
\close
\have{con}{O \eif O}\ci{o-o2}
\end{proof}}
\item $N \eor \enot N$
\myanswer{\begin{proof}
\open
        \hypo{ncon}{\enot (N \eor \enot N)}
        \open
                \hypo{n}{N}
                \have{nnn1}{N \eor \enot N}\oi{n}
                \have{bot1}{\ered}\ri{ncon, nnn1}
        \close
        \have{nn}{\enot N}\ni{n-bot1}
        \have{nnn2}{N \eor \enot N}\oi{nn}
        \have{bot2}{\ered}\ri{ncon, nnn2}
\close
\have{con}{N \eor \enot N}\ip{ncon-bot2}
\end{proof}}

\newpage
\item $J \eiff [J\eor (L\eand\enot L)]$
\myanswer{\begin{proof}
\open
	\hypo{j1}{J}
	\have{jlnl1}{J \eor (L \eand \enot L)}\oi{j1}
\close
\open
	\hypo{jlnl2}{J \eor (L \eand \enot L)}
%	\open
%		\hypo{j2}{J}
%		\have{j3}{J}\by{R}{j2}
%	\close
	\open
		\hypo{lnl}{L \eand \enot L}
		\have{l}{L}\ae{lnl}
		\have{nl}{\enot L}\ae{lnl}
		\have{red}{\ered}\ri{l,nl}
%		\have{j4}{J}\re{red}
	\close
	\have{nlnl}{\enot (L \eand \enot L)}\ni{lnl-red}
	\have{j5}{J}\ds{jlnl2, nlnl}
\close
\have{con}{J \eiff [J\eor (L\eand\enot L)]}\bi{j1-jlnl1, jlnl2-j5}
\end{proof}}
\item $((A \eif B) \eif A) \eif A$
\myanswer{\begin{proof}
\open
	\hypo{aba}{(A \eif B) \eif A}
	\open
		\hypo{na}{\enot A}
		\have{nab}{\enot (A \eif B)}\mt{aba, na}
		\open
			\hypo{a}{A}
			\have{red}{\ered}\ri{a, na}
			\have{b}{B}\re{red}
		\close
		\have{ab}{A \eif B}\ci{a-b}
		\have{red1}{\ered}\ri{ab, nab}
	\close
	\have{a2}{A}\ip{aba-red1}
\close
\have{con}{((A \eif B) \eif A) \eif A}\ci{aba-a2}
\end{proof}}
\end{earg}

\problempart
Provide proofs to show each of the following:
\begin{earg}
\item $C\eif(E\eand G), \enot C \eif G \proves G$
\myanswer{\begin{proof}
\hypo{ceg}{C \eif (E \eand G)}
\hypo{ncg}{\enot C \eif G}
\open
        \hypo{ng}{\enot G}
        \open
                \hypo{c}{C}
                \have{eg}{E \eand G}\ce{ceg, c}
                \have{g1}{G}\ae{eg}
                \have{bot1}{\ered}\ri{ng, g1}
        \close
        \have{nc}{\enot C}\ni{c-bot1}
        \have{g2}{G}\ce{ncg, nc}
        \have{bot2}{\ered}\ri{ng, g2}
\close
\have{con}{G}\ip{ng-bot2}
\end{proof}}

\item $M \eand (\enot N \eif \enot M) \proves (N \eand M) \eor \enot M$
\myanswer{\begin{proof}
\hypo{MnNnM}{M \eand (\enot N \eif \enot M)}
\have{M}{M}\ae{MnNnM}
\have{nNnM}{\enot N \eif \enot M}\ae{MnNnM}
\open
	\hypo{nN}{\enot N}
	\have{nM}{\enot M}\ce{nNnM, nN}
	\have{red}{\ered}\ri{M, nM}
\close
\have{N}{N}\ip{nN-red}
\have{NM}{N \eand M}\ai{N, M}
\have{con}{(N \eand M) \eor \enot M}\oi{NM}
\end{proof}}

\item $(Z\eand K)\eiff(Y\eand M), D\eand(D\eif M) \proves Y\eif Z$
\myanswer{\begin{proof}
\hypo{zkym}{(Z \eand K) \eiff (Y \eand M)}
\hypo{ddm}{D \eand (D \eif M)}
\have{d}{D}\ae{ddm}
\have{dm}{D \eif M}\ae{ddm}
\have{m}{M}\ce{dm, d}
\open
	\hypo{y}{Y}
	\have{ym}{Y \eand M}\ai{y, m}
	\have{zk}{Z \eand K}\be{zkym, ym}
	\have{z}{Z}\ae{zk}
\close
\have{yz}{Y \eif Z}\ci{y-z}
\end{proof}}

\item $(W \eor X) \eor (Y \eor Z), X\eif Y, \enot Z \proves W\eor Y$
\myanswer{\begin{proof}
\hypo{wxyz}{(W \eor X) \eor (Y \eor Z)}
\hypo{xy}{X \eif Y}
\hypo{nz}{\enot Z}
\open
	\hypo{wx}{W \eor X}
	\open
		\hypo{w}{W}
		\have{wy1}{W \eor Y}\oi{w}
	\close
	\open
		\hypo{x}{X}
		\have{y1}{Y}\ce{xy, x}
		\have{wy2}{W \eor Y}\oi{y1}
	\close
	\have{wy3}{W \eor Y}\oe{wx, w-wy1, x-wy2}
\close
\open
	\hypo{yz}{Y \eor Z}
	\have{y}{Y}\ds{yz, nz}
	\have{wy}{W \eor Y}\oi{y}
\close
\have{wy4}{W \eor Y}\oe{wxyz, wx-wy3, yz-wy}
\end{proof}}
\end{earg}

\problempart
Show that each of the following pairs of sentences are provably equivalent: %TB: a bit of a hack here, to try to get the multicols thing working nicer.

\

1. $R \eiff E$, $E \eiff R$
\myanswer{\ignorespaces\begin{multicols}{2}
\begin{proof}
\hypo{re}{R \eiff E}
\open
	\hypo{e}{E}
	\have{r}{R}\be{re, e}
\close
\open
	\hypo{r1}{R}
	\have{e1}{E}\be{re, r1}
\close
\have{con}{E \eiff R}\bi{e-r, r1-e1}
\end{proof}\begin{proof}
\hypo{re}{E \eiff R}
\open
	\hypo{e}{E}
	\have{r}{R}\be{re, e}
\close
\open
	\hypo{r1}{R}
	\have{e1}{E}\be{re, r1}
\close
\have{con}{R \eiff E}\bi{r1-e1, e-r}
\end{proof}
\end{multicols}}
2. $G$, $\enot\enot\enot\enot G$
\myanswer{\begin{multicols}{2}
\begin{proof}
\hypo{g}{G}
\open
	\hypo{nnng}{\enot \enot \enot G}
	\have{ng}{\enot G}\dne{nnng}
	\have{red}{\ered}\ri{g,ng}
\close
\have{nnnng}{\enot\enot\enot\enot G}\ni{nnng-red}
\end{proof}\begin{proof}
\hypo{nnnng}{\enot\enot\enot\enot G}
\have{nng}{\enot \enot G}\dne{nnnng}
\have{g}{G}\dne{nng}
\end{proof}
\end{multicols}}
3. $T\eif S$, $\enot S \eif \enot T$
\myanswer{\begin{multicols}{2}
\begin{proof}
\hypo{ts}{T \eif S}
\open
	\hypo{ns}{\enot S}
	\have{nt}{\enot T}\mt{ts, ns}
\close
\have{nsnt}{\enot S \eif \enot T}\ci{ns-nt}
\end{proof}\begin{proof}
\hypo{nsnt}{\enot S \eif \enot T}
\open
	\hypo{t}{T}
	\open
		\hypo{ns}{\enot S}
		\have{nt}{\enot T}\ce{nsnt, ns}
		\have{red}{\ered}\ri{t, nt}
	\close
	\have{nns}{\enot \enot S}\ni{ns-red}
	\have{s}{S}\dne{nns}
\close
\have{ts}{T \eif S}\ci{t-s}
\end{proof}\end{multicols}}
4. $U \eif I$, $\enot(U \eand \enot I)$
\myanswer{
\begin{multicols}{2}
\begin{proof}
\hypo{ui}{U \eif I}
\open
	\hypo{uni}{U \eand \enot I}
	\have{u}{U}\ae{uni}
	\have{ni}{\enot I}\ae{uni}
	\have{i}{I}\ce{ui, u}
	\have{red}{\ered}\ri{i, ni}
\close
\have{con}{\enot (U \eand \enot I)}\ni{uni-red}
\end{proof}
\begin{proof}
\hypo{con}{\enot (U \eand \enot I)}
\open
	\hypo{u}{U}
	\open
		\hypo{ni}{\enot I}
		\have{uni}{U \eand \enot I}\ai{u, ni}
		\have{red}{\ered}\ri{uni, con}
	\close
	\have{nni}{\enot\enot I}\ni{ni-red}
	\have{i}{I}\dne{nni}
\close
\have{ui}{U \eif I}\ci{u-i}
\end{proof}
\end{multicols}}
\newpage 5. $\enot (C \eif D), C \eand \enot D$
\myanswer{\begin{multicols}{2}
\begin{proof}
\hypo{cnd}{C \eand \enot D}
\have{c}{C}\ae{cnd}
\have{nd}{\enot D}\ae{cnd}
\open
	\hypo{cd}{C \eif D}
	\have{d}{D}\ce{cd, c}
	\have{red}{\ered}\ri{d, nd}
\close
\have{ncd}{\enot (C \eif D)}\ni{cd-red}
\end{proof}
\begin{proof}
\hypo{ncd}{\enot (C \eif D)}
\open
	\hypo{d}{D}
	\open
		\hypo{c}{C}
		\have{d1}{D}\by{R}{d}
	\close
	\have{cd}{C \eif D}\ci{c-d1}
	\have{red}{\ered}\ri{cd, ncd}
\close
\have{nd}{\enot D}\ni{d-red}
\open
	\hypo{nc}{\enot C}
	\open
		\hypo{c1}{C}
		\have{red1}{\ered}\ri{c1, nc}
		\have{d2}{D}\re{red1}
	\close
	\have{cd1}{C \eif D}\ci{c1-d2}
	\have{red2}{\ered}\ri{cd1, ncd}
\close
\have{nnc}{\enot \enot C}\ni{nc-red2}
\have{c2}{C}\dne{nnc}
\have{cnd}{C \eand \enot D}\ai{c2, nd}
\end{proof}
\end{multicols}}
6. $\enot G \eiff H$, $\enot(G \eiff H)$
\myanswer{\begin{multicols}{2}
\begin{proof}
\hypo{ngh}{\enot G \eiff H}
\open
	\hypo{gh}{G \eiff H}
	\open
		\hypo{g}{G}
		\have{h}{H}\be{gh, g}
		\have{ng}{\enot G}\be{ngh, h}
		\have{red}{\ered}\ri{g, ng}
	\close
	\open
		\hypo{ng1}{\enot G}
		\have{h1}{H}\be{ngh, ng1}
		\have{g1}{G}\be{gh, h1}
		\have{red1}{\ered}\ri{g1, ng1}
	\close
	\have{red2}{\ered}\tnd{g-red, ng1-red1}
\close
\have{con}{\enot (G \eiff H)}\ni{gh-red2}
\end{proof}
\begin{proof}
\hypo{ngh}{\enot (G \eiff H)}
\open
	\hypo{ng}{\enot G}
	\open
		\hypo{nh}{\enot H}
		\open
			\hypo{g}{G}
			\have{red}{\ered}\ri{g, ng}
			\have{h}{H}\re{red}
		\close
		\open
			\hypo{h1}{H}
			\have{red1}{\ered}\ri{h1, nh}
			\have{g1}{G}\re{red1}
		\close
		\have{gh}{G \eiff H}\bi{g-h, h1-g1}
		\have{red2}{\ered}\ri{gh, ngh}
	\close
	\have{h2}{H}\ip{nh-red2}
\close
\open
	\hypo{h3}{H}
	\open
		\hypo{g2}{G}
		\open
			\hypo{g4}{G}
			\have{h5}{H}\by{R}{h3}
		\close
		\open
			\hypo{h4}{H}
			\have{g3}{G}\by{R}{g2}
		\close
		\have{gh1}{G \eiff H}\bi{g4-h5, h4-g3}
		\have{red3}{\ered}\ri{gh1, ngh}
	\close
	\have{ng1}{\enot G}\ni{g2-red3}
\close
\have{con}{\enot G \eiff H}\bi{ng-h2, h3-ng1}
\end{proof}
\end{multicols}}

\problempart
If you know that $\meta{A}\proves\meta{B}$, what can you say about $(\meta{A}\eand\meta{C})\proves\meta{B}$? What about $(\meta{A}\eor\meta{C})\proves\meta{B}$? Explain your answers.
\\\myanswer{If $\meta{A} \proves \meta{B}$, then $(\meta{A} \eand \meta{C})\proves \meta{B}$. After all, if $\meta{A} \proves \meta{B}$, then there is some proof with assumption $\meta{A}$ that ends with $\meta{B}$, and no undischarged assumptions other than $\meta{A}$. Now, if we start a proof with assumption $(\meta{A} \eand \meta{C})$, we can obtain $\meta{A}$ by $\eand$E. We can now copy and paste the original proof of $\meta{B}$ from $\meta{A}$, adding 1 to every line number and line number citation. The result will be a proof of $\meta{B}$ from assumption $\meta{A}$.}

\myanswer{However, we cannot prove much from $(\meta{A} \eor \meta{C})$. After all, it might be impossible to prove $\meta{B}$ from $\meta{C}$.}

\

\problempart In this chapter, we claimed that it is just as hard to show that two sentences are not provably equivalent, as it is to show that a sentence is not a theorem. Why did we claim this? (\emph{Hint}: think of a sentence that would be a theorem iff \meta{A} and \meta{B} were provably equivalent.)
\\\myanswer{Consider the sentence $\meta{A} \eiff \meta{B}$. Suppose we can show that this is a theorem. So we can prove it, with no assumptions, in $m$ lines, say. Then if we assume $\meta{A}$ and copy and paste the proof of $\meta{A} \eiff \meta{B}$ (changing the line numbering), we will have a deduction of this shape:
\begin{proof}
\hypo{a}{\meta{A}}
\have[m][1]{m}{\meta{A} \eiff \meta{B}}
\have{b}{\meta{B}}\be{m, a}
\end{proof}
\\This will show that $\meta{A} \proves \meta{B}$. In exactly the same way, we can show that $\meta{B} \proves \meta{A}$. So if we can show that $\meta{A} \eiff \meta{B}$ is a theorem, we can show that $\meta{A}$ and $\meta{B}$ are provably equivalent.}

\myanswer{Conversely, suppose we can show that $\meta{A}$ and $\meta{B}$ are provably equivalent. Then we can prove $\meta{B}$ from the assumption of $\meta{A}$ in $m$ lines, say, and prove $\meta{A}$ from the assumption of $\meta{B}$ in $n$ lines, say. Copying and pasting these proofs together (changing the line numbering where appropriate), we obtain:
\begin{proof}
\open
	\hypo{a}{\meta{A}}
	\have[m]{b1}{\meta{B}}
\close
\open
	\hypo{b}{\meta{B}}
	\have[m+n]{a1}{\meta{A}}
\close
\have{ab}{\meta{A} \eiff \meta{B}}\bi{a-b1, b-a1}
\end{proof}
\\Thus showing that $\meta{A} \eiff \meta{B}$ is a theorem.}

\myanswer{There was nothing special about $\meta{A}$ and $\meta{B}$ in this. So what this shows is that the problem of showing that two sentences are provably equivalent is, essentially, the same problem as showing that a certain kind of sentence (a biconditional) is a theorem.}

\setcounter{chapter}{18}
\chapter{Derived rules}\setcounter{ProbPart}{0}
\problempart
Provide proof schemes that justify the addition of the third and fourth De Morgan rules as derived rules.

\
\\\myanswer{Third rule:
\begin{proof}
		\have[m]{nab}{\enot \meta{A} \eand \enot \meta{B}}
		\have[k]{na}{\enot \meta{A}}\ae{nab}
		\have{nb}{\enot \meta{B}}\ae{nab}
		\open
			\hypo{aob}{\meta{A} \eor \meta{B}}
			\open
				\hypo{a}{\meta{A}}
				\have{con1}{\ered}\ri{a, na}
			\close
			\open
				\hypo{b}{\meta{B}}
				\have{con2}{\ered}\ri{b, nb}
			\close
			\have{con3}{\ered}\oe{aob, a-con1, b-con2}
		\close
		\have{con}{\enot (\meta{A} \eor \meta{B})}\ni{aob-con3}
	\end{proof}}

\
\\\myanswer{Fourth rule:
	\begin{proof}
		\have[m]{nab}{\enot (\meta{A} \eor \meta{B})}
		\open
			\hypo[k]{a}{\meta{A}}
			\have{aob}{\meta{A} \eor \meta{B}}\oi{a}
			\have{nab1}{\ered}\ri{aob, nab}
		\close
		\have{na}{\enot \meta{A}}\ni{a-nab1}
		\open
			\hypo{b}{\meta{B}}
			\have{aob2}{\meta{A} \eor \meta{B}}\oi{b}
			\have{nab2}{\ered}\ri{aob2, nab}
		\close
		\have{nb}{\enot \meta{B}}\ni{b-nab2}
		\have{con}{\enot \meta{A} \eand \enot \meta{B}}\ai{na, nb}
	\end{proof}
}

\problempart
The proofs you offered in response to the practice exercises of \S\S\ref{s:Further}--\ref{s:ProofTheoreticConcepts} used derived rules. Replace the use of derived rules, in such proofs, with only basic rules. You will find some `repetition' in the resulting proofs; in such cases, offer a streamlined proof using only basic rules.  (This will give you a sense, both of the power of derived rules, and of how all the rules interact.)

\setcounter{chapter}{19}
\chapter{Soundness and Completeness}\setcounter{ProbPart}{0}

\practiceproblems
\noindent\problempart Use either a derivation or a truth table for each of the following.
\begin{enumerate}%[label=(\arabic*)]
\item Show that $A \eif [((B \eand C) \eor D) \eif A]$ is a tautology.
\item Show that $A \eif (A \eif B)$ is not a tautology
\item Show that the sentence $A \eif \enot{A}$ is not a contradiction.
\item Show that the sentence $A \eiff \enot A$ is a contradiction.
\item Show that the sentence $ \enot (W \eif (J \eor J)) $ is contingent
\item Show that the sentence $ \enot(X \eor (Y \eor Z)) \eor (X \eor (Y \eor Z))$ is not contingent
 \item Show that the sentence $B \eif \enot S$ is equivalent to the sentence $\enot \enot B \eif \enot S$
\item Show that the sentence $ \enot (X \eor O) $ is not equivalent to the sentence $X \eand O$
\item Show that the sentences $\enot(A \eor B)$, $C$, $C \eif A$  are jointly inconsistent.
\item Show that the sentences $\enot(A \eor B)$, $\enot{B}$, $B \eif A$ are jointly consistent
\item Show that $\enot(A \eor (B \eor C)) $ \therefore $ \enot{C}$ is valid.
\item Show that $\enot(A \eand (B \eor C))$ \therefore $ \enot{C}$ is invalid.
\end{enumerate}

\noindent\problempart Use either a derivation or a truth table for each of the following.
\begin{enumerate}%[label=(\arabic*)]
\item Show that $A \eif (B \eif A)$ is a tautology
\item Show that $\enot (((N \eiff Q) \eor Q) \eor N)$ is not a tautology
\item Show that $ Z \eor (\enot Z \eiff Z) $ is contingent
\item show that $ (L \eiff ((N \eif N) \eif L)) \eor H $ is not contingent
\item Show that $ (A \eiff A) \eand (B \eand \enot B)$ is a contradiction
\item Show that $ (B \eiff (C \eor B)) $ is not a contradiction.
\item Show that $ ((\enot X \eiff X) \eor X) $ is equivalent to $X$
\item Show that $F \eand (K \eand R) $ is not equivalent to $ (F \eiff (K \eiff R)) $
\item Show that the sentences $ \enot (W \eif W)$, $(W \eiff W) \eand W$, $E \eor (W \eif \enot (E \eand W))$ are inconsistent.
\item Show that the sentences  $\enot R \eor C $, $(C \eand R) \eif \enot R$, $(\enot (R \eor R) \eif R) $ are consistent.
\item Show that $\enot \enot (C \eiff \enot C), ((G \eor C) \eor G) \therefore ((G \eif C) \eand G) $ is valid.
\item Show that $ \enot \enot L,  (C \eif \enot L) \eif C) \therefore \enot C$ is invalid.
\end{enumerate}