%This is a comment
%This is a sample LaTeX file you may use to produce homework solutions

\documentclass[11pt]{article} %11pt is the font size
                                                     %You may also use 12pt for a larger print
\usepackage{exscale}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{latexsym}
\usepackage{times,mathptm}
\usepackage{epsfig}

\textwidth 6.5truein          %The next four commands define the page size
\textheight 9.0truein
\oddsidemargin 0.0in
\topmargin -0.6in

\parindent 0pt             %No indentation at the start of each paragraph
\parskip 6pt                 %6pt is the gap between paragraphs
\def\baselinestretch{1.1}  %The larger the number, the more space between lines

\begin{document}

\title{CSci 243 Homework 1}
\author{Your name}
\date{Today's date}
\maketitle

{\bf PROBLEM 1.} Give the truth table for $\phi=(\lnot p\lor q\lor r)\land(p\lor q\lor \lnot r)$.

{\bf SOLUTION:}

\begin{center}
\begin{tabular}{ccc|c|c||c}
$p$ & $q $ & $r$ & $\lnot p\lor q\lor r$ & $p\lor q\lor \lnot r$ & $\phi$\\\hline
$0$ & $0$ & $0$ & $1$ & $1$ & $1$ \\
$0$ & $0$ & $1$ & $1$ & $0$ & $0$ \\
$0$ & $1$ & $0$ & $1$ & $1$ & $1$ \\
$0$ & $1$ & $1$ & $1$ & $1$ & $1$ \\
$1$ & $0$ & $0$ & $0$ & $1$ & $0$ \\
$1$ & $0$ & $1$ & $1$ & $1$ & $1$ \\
$1$ & $1$ & $0$ & $1$ & $1$ & $1$ \\
$1$ & $1$ & $1$ & $1$ & $1$ & $1$ 
\end{tabular}
\end{center}

{\bf PROBLEM 2.} Prove that any nonempty tree has one more nodes than it has edges.

{\bf PROOF.}
We prove by structual induction that for a nonempty tree $T$ with $n$
nodes and $e$ edges, $n = e + 1$.

{\bf Basis step:} The basis case is $n = 1$. Obviously, a tree with
only one node does not have any edges, suggesting $e = 0$. So $n = e + 1$.

{\bf Inductive step:} We assume that for any tree with less than $n$
nodes the equality holds true. Now onsider a tree $T$ with $n$ nodes. 
Assume that $T$ contains $k$ subtrees, $T_1, T_2, \ldots, T_k$ and that 
subtree $T_i$, for $i = 1, 2, \ldots, k$, has $n_i$ nodes and $e_i$ edges.
Notice that $e = \sum_{i=1}^k e_i + k$.
Since $n_i < n $, then by the induction hypothesis $n_i = e_i + 1$ for
all $i$'s. Therefore,
\begin{eqnarray*}
n &=& \sum_{i=1}^k n_i + 1\\
  &=& \sum_{i=1}^k (e_i + 1) +1\\
  &=& \sum_{i=1}^k e_i + k + 1\\
  &=& e + 1.
\end{eqnarray*}

This completes the induction.

{\bf PROBLEM 3.} Show an example of how to include a figure in LaTeX.

{\bf EXAMPLE:}  Figure 1 is a state diagram for an NFA, a model of 
computation that you will learn in CSci 423 Finite Automata.

\begin{figure}
\begin{center}
\includegraphics[height=0.7in,width=3in]{sample_nfa.pdf}
\caption{An NFA that accepts all strings with substring $01$.}
\end{center}
\end{figure}

%%Here is another way to include a figure
%\vskip 0.4cm 
%\centerline{\epsfig{figure=sample_nfa.eps,height=0.7in,width=3in}}
%\centerline{Figure 1. An NFA that accepts all strings with substring $01$.}

\end{document}
