\documentstyle[11pt]{article}

\setlength{\textheight}{9in}
\setlength{\textwidth}{6in}
\setlength{\evensidemargin}{0in}
\setlength{\oddsidemargin}{0in}
\setlength{\topmargin}{0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0.3in}

\newcommand{\ms}[1]{%
	\relax\ifmmode
		\mathord{\mathcode`\-="702D\it #1\mathcode`\-="2200}%
	\else
                {\it #1}%
	\fi
}

\begin{document}

\begin{titlepage}

\title{\bf Lecture 1: Basic Proof Methods}
\author{Nancy Lynch, David Karger}
\date{February 1, 2000}
\maketitle

\end{titlepage}
\renewcommand{\thepage}{\arabic{page}}

\section{Course Overview}

6.042, Mathematics for Computer Science \\
\\
Prerequisites: First year calculus. \\
\\
Introductions. \\
Faculty, TAs, secys

\subsection{Course Goals and Content}

What we want you to learn this term:
\begin{enumerate}
\item
Basic discrete math concepts.

Basic data types and structures used in programming and in reasoning
about programs (numbers, Booleans, strings; sets, functions;
relations, trees, graphs,...). \\
Their properties.

\item
Proofs.

\noindent
How to do them, how to read them, how to recognize correct/incorrect ones.

\noindent
Reasoning about propositions, predicates (with quantifiers). \\
Basic proof strategies: Direct proof, contradiction, cases...\\
Induction (very important in this course and other places in CS).\\
\\
Throughout the term. 

\item
Math foundations for software engineering (6170).

\noindent
Working with Profs. Chapin, Guttag to select material for this course...\\
Models for programs and their required behavior.\\
Showing a program satisfies its requirements.

\item
Analysis methods for algorithms (6046)

\noindent
Summations of series. \\
Asymptotic analysis, recurrences. \\
Counting methods and theorems; basic combinatorics. \\
Which leads into:

\item
Discrete probability (6046, 6033?)
\end{enumerate}

\noindent
Course also supports 6045 (theory of computation). \\

\noindent
Overall: \\
We want you to learn how to use mathematics to help you think about
concepts in computer science. 

\noindent
(E.g., define abstract models for real-world objects like programs,
computers, communication channels.
Reason about these models carefully, correctly.
Use the conclusions to help understand the real-world objects.)


\subsection{Administrivia}

\noindent
See Handout 1. \\
\\
Lectures, tutorials \\
\\
Handouts \\
\\
Books \\
Old lecture notes, see Fall99 Web site \\
\\
Exams \\
\\
Problem sets \\
\\
Collaboration policy \\
\\
Grading

%\newpage
\section{Basic data types}

\noindent
Reading: \\
Rosen Sections 1.4, 1.5, 1.6 \\
\\
The standard basic data types used in programming:  numbers, Booleans
(true/false), and strings. \\
\\
And other basic data types used in mathematics: sets, functions. \\
Used in reasoning about programs. \\
\\
This is review for most of you. \\
So I won't lecture about it. \\
Just list the basic notions: definitions, operations, some properties. \\
You will be expected to read these three sections carefully on your
own, making sure you can do all the study exercises. 

\subsection{Booleans}

\noindent
Rosen, Section 1.1 \\
\\
Values: 1 (true), 0 (false) \\
Operations: and ($\wedge$), or ($\vee$), not ($\neg$), exclusive-or
($\oplus$). \\
\\
Explain how they work with tables: \\
\\
$x$  $\neg x$ \\
1       0 \\
0       1 \\
\\
$x$   $y$   $x \wedge y$  $x \vee y$   $x \oplus y$ \\
1     1     1             1            1\\ 
1     0     1             0            0\\
0     1     1             0            0\\
0     0     0             0            1\\


\subsection{Numbers}

Rosen, Section 1.4 


\subsubsection{Natural numbers}

\noindent
$N = \{ 0, 1, 2, \ldots \}$ \\
\\
Most math books actually let N start at 1, not 0, but computer
scientists like to start counting with 0. \\
We'll stay consistent with Rosen. \\
I'll write $N^+$ for the positive naturals. \\
\\
Operations: +, - (partial), times, integer div (round down), remainder
(mod), exp \\
\\
Prime number = Any natural number greater than or equal to $2$ that
has no divisors (except itself and $1$). \\
\\
Even, odd ($2x$ vs. $2x + 1$).


\subsubsection{Integers}

\noindent
$Z$: $N$ and negatives 

\subsubsection{Rationals}

$Q$ \\
\\
Defined to be expressible as a ratio of two integers ${a \over b}$,
where $b \neq 0$. \\
\\
Basic property says can write in lowest terms.


\subsection{Strings}

Over alphabet $A$ of symbols \\
\\
Example: 
$A$ consists of $a, b, c$. \\
Strings: $abc$, $aaa$, $b$, empty string ($\lambda$, no symbols) \\
\\
Operations: concat(string, symbol), concat(string, string)


\subsection{Sets}

Rosen, Section 1.4, 1.5 \\
\\
$\emptyset$, universal set, subset, proper subset \\
power set (define) \\
Cartesian product \\
\\
Operations: union ($\cup$), intersection ($\cap$), complement (overbar) \\
Venn diagrams (show for 2 sets). \\
\\
Some laws about how the ops behave---see Rosen p. 49 \\
E.g.: $A \cup A = A$.


\subsection{Functions}

Rosen, Section 1.6 \\
\\
A rule that assigns an element of one set (range, codomain) to each element of
another set (domain). \\
\\
Properties of functions: \\
One-to-one (no two domain elements get the same range element) \\
Onto (every element of the range gets used) \\
\\
Function inverse, composition ($f \circ g(x) = f(g(x))$)
\\
Pointwise ops (e.g., add, for functions whose range is integers,
$f+g(x) = f(x) + g(x)$) 

\section{What are proofs?}

%[[[David:  I didn't see any particular reason to add back a lot of
%the words.  If you give the lecture, you can add what you like,
%though.]]]

Today's main topic is proofs. \\
A proof is a way of establishing truth of a statement (proposition). \\
\\
Logical deduction, as opposed to: \\
Accepting it on authority (Bible, horoscope, your professor says so). \\
Observing it by experiments. \\
\\
Involves a chain of logical reasoning, starting from some 
already-accepted statements, to conclude a new statement.\\
\\
This general description also applies to the kinds of reasoning used
in philosophy, law,... \\
\\
But in mathematics, it's more formal, stylized: \\
Statements are {\em propositions\/} with precise meanings. \\
Start from explicitly-assumed propositions called {\em axioms}. \\
Apply standardized {\em rules of deduction}. \\
\\
In the rest of this lecture, I'll explain what these things are, \\
present the most basic proof methods, and give examples.

\section{Propositions}

\subsection{What are propositions?}

A {\em proposition\/} is a statement that has a truth value,
$\ms{true}$ or $\ms{false}$. \\
\\
Examples:
\begin{enumerate}
\item
$5$ is a prime number. 

It's a proposition, and it's true. 

\item
$8$ is a prime number. 

A false proposition.

\item
$x$ is a prime number. 

Not a proposition. \\
Has no truth value, because we don't know what $x$ is. \\
It's said to be an {\em unbound variable}. \\

\item
There is an least one prime number. 

A true proposition. \\
In math notation, this can be written as $\exists x (x \mbox{ is a prime})$. \\
The quantifier $\exists$ ``binds'' $x$.

\item
All natural numbers $\geq 2$ are primes. 

A false proposition. \\
This can be written as $\forall x \in N, x \geq 2 (\ldots)$. \\
The quantifier $\forall$ also binds $x$. \\
\\
We will revisit the quantifiers soon (they have their own reasoning
methods). \\
For now, just using them as shorthand notation. \\

\item
All $x$ of the form $n^2 + n + 41$, where $n \in N$, are prime. 

A proposition, but not so immediate to determine if true or false. \\
Can test:  For $n = 0, 1, 2 \ldots$, $x$ is prime. \\
But if $n = 41$, get $41^1 + 41 + 41$ = $41(43)$, not prime. \\
So, false. \\

\item
$\exists x, y, z \in N^+, n \geq 3 (x^n + y^n = z^n)$. 

Fermat's last theorem, 1640s, says this is false, but he never proved it. \\
Only recently have we learned for sure that it's false (Andrew Wiles, 1994,
130-page proof). \\
But even while we didn't know if it's true or false, it was still a
proposition.

\item
T, F 

Regarded as special cases of propositions, with the obvious truth
values. 

\item
$\forall A, B (\bar{A} \cup \bar{B} = \bar{A \cup B})$. 

Propositions can be about other things besides numbers, e.g., sets. \\
This one is false. 

\item
$\forall A, B (\bar{A} \cup \bar{B} = \bar{A \cap B})$. \\
$\forall A, B (\bar{A} \cap \bar{B} = \bar{A \cup B})$. \\

De Morgan's laws, true.

\item
The original Pentium chip always divided correctly. 

A false proposition. 

%[[[David:  OK to add other three examples here, as you prefer.]]]

\end{enumerate}

\subsection{Compound propositions and truth tables}

Logical connectives are used to combine simple propositions: \\
And ($\wedge$), or ($\vee$), exclusive-or ($\oplus$), not ($\neg$) \\
As I already mentioned for Booleans. \\
\\
Also implication (if-then, $\Rightarrow$), double implication (equivalence,
$\Leftrightarrow$). \\
Very important in logical reasoning. \\
\\
Truth values of compound propositions are obtained from the 
truth values of the simpler propositions according to {\em truth
tables\/}: 

$P$   $\neg P$ \\
T     F \\
F     T \\

\noindent
If a proposition $P$ is true, its negation is said to be false, and
vice versa. 


$P$  $Q$     $P \wedge Q$   $P \vee Q$  $P \oplus Q$ \\
T    T       T              T           F\\
T    F       F              T           T\\
F    T       F              T           T\\
F    F       F              F           F\\


$P$  $Q$    $P \Rightarrow Q$   $P \Leftrightarrow Q$ \\
T    T          T                 T \\
T    F          F                 F \\
F    T          T                 F \\
F    F          T                 T \\

\noindent
The only slightly mysterious column here is the implication column. \\
We say that $P \Rightarrow Q$ is false only if the hypothesis $P$ is
true and the conclusion $Q$ is false. \\
\\
Example: \\
If Ricky gets at least six hours of sleep then he passes his 6042
final. \\
($P \Rightarrow Q$) \\
\\
Under what circumstances is this a true statement? \\
Well, it's clearly false if Ricky gets at least 6 hours of sleep and
doesn't pass ($P$ true, $Q$ false). \\
But it's a perfectly OK statement if he sleeps a lot and passes ($P$
and $Q$ both true), \\
or if he does not sleep (my statement did not promise anything about this case). \\
\\
One way to determine truth values for compound propositions is by 
adding new columns to the basic truth table(s): \\
\\
Example: $R = (P \Rightarrow Q) \Leftrightarrow (\neg Q \Rightarrow \neg P)$ \\
\\
Trace through the columns, using the expression structure. \\
Determine that the column contains all T. 


$P$  $Q$    $P \Rightarrow Q$   $\neg Q$  $\neg P$ $\neg Q\Rightarrow\neg P$  $R$ \\
T    T          T               F         F        T                 T\\
T    F          F               T         F        F                 T\\
F    T          T               F         T        T                 T\\
F    F          T               T         T        T                 T\\

\noindent
An expression (like this one) whose column contains all T is called a
{\em tautology}.


\section{Logical Systems}

\subsection{Axioms}

Propositions that are {\em assumed} to be true. \\
Not proved---just accepted as reasonable assumptions. \\
(``Axiom'' = (Greek)  ``to think worthy,'' not ``to be true''). \\
\\
To be rigorous, important to state assumptions explicitly. \\
\\
Typical examples of axioms from math:
\begin{itemize}
\item
If $a=b$ and $b=c$ then $a=c$.
\item
(Euclidean geometry parallel postulate) \\
Given a line $l$ and a point $p$ not on $l$, there is exactly one line
through $p$ parallel to $l$.
\item
(Spherical geometry parallel postulate) \\
Given a line $l$ and a point $p$ not on $l$, there is {\em no} line through $p$
parallel to $l$. \\
Contradicts the Euclidean axiom. 
\item
{Hyperbolic geometry parallel postulate) \\
Given a line $l$ and a point $p$ not on $l$, there are {\em infinitely
many} lines through $p$ parallel to $l$. \\
\\
All of these yield consistent logical proof systems.
\item
Mathematicians still argue about which axioms are ``right,''
e.g., the Axiom of Choice (whose assertion and denial are equally
consistent with other commonly agreed upon axioms).
\end{itemize}

Different axioms lead to different theorems. \\
Anyone who accepts your axioms and deduction rules has to accept your
theorems.

\subsection{Deduction Rules}

Deduction rules = inference rules.

These are rules for deducing (inferring) that some propositions are
true, assuming that others are true.
\begin{enumerate}
\item Modus ponens \\
Given (assumptions, axioms): $P$, $P \Rightarrow Q$ \\
We can conclude:  $Q$ 

%Modus ponens:
%Check in the truth table: \\
%Situations where $P$ is true are covered by rows 1 and 2. \\
%$Situations where $P \Rightarrow Q$ is true are covered by rows 1, 3, and 4. \\
%So, situations where both statements are true are covered by row 1 (only). \\
%But in that row, $Q$ is also true. 

\item Modus tolens (proof by contradiction) \\
Given:  $P \Rightarrow Q$, $\neg Q$ \\
We can conclude: $\neg P$ 

\item Syllogism \\
Given:  $P \Rightarrow Q$, $Q \Rightarrow R$ \\
We can conclude:  $P \Rightarrow R$ \\

\item Given: $P$, $\neg P$ \\
We can conclude: $\ms{false}$ 
%\\
%No tt rows satisfy the combination of conditions (they're contradictory). \\
%So from this utter nonsense, anything can be concluded (including ``false''). \\
%(A convention) \\

\item Given:  $\neg P \Rightarrow \ms{false}$ \\
We can conclude:  $P$ 

\item (Cases) \\
Given: $Q \Rightarrow P$, $\neg Q \Rightarrow P$ \\
We can conclude: $P$.
\end{enumerate}

Truth tables provide a source of deduction rules; all such rules are
accepted in mathematics. \\
Namely, if $P \Rightarrow Q$ is a tautology, then 
Given: $P$ \\
Conclude: $Q$ \\
is a valid inference rule. \\
\\
Example: 
\[
[(P \vee Q) \wedge \neg P] \implies Q
\]
is a tautology, which leads to the following inference rule: \\
\\
(Disjunctive Syllogism) 
Given: $P \vee Q$, $\neg P$ \\ 
Conclude: $Q$ 

\subsection{Formal proofs}

In a complete, formal proof of a theorem, each step follows from
previous steps using formal deduction rules. \\
So systematic that it could be checked mechanically by a program. \\
\\
Mathematicians generally don't write proofs that formally. \\
Rather, they write them in concise prose, but in such a way that others who
are knowledgeable about proof methods can understand how to fill in the
gaps. \\
\\
Since proofs are supposed to be mechanically checkable, 
you might think of using a computer to produce proofs of true
theorems automatically. \\
In fact, Hilbert posed (as one is his 23 famous problems) the problem
of finding such a method. \\
One of the great accomplishments of 20th century math is the proof
that no such method exists (Godel). \\
\\
%[[[I deleted the details here.]]]
\\
Even if we limit ourselves to things that can be proven, computers
won't be much help.  
Finding a proof---even, say, just a proof that a
given propositional logic statement is a tautology---is {\bf
NP-complete}, meaning that it is intractable in a certain formal
sense you will learn about in 6.045 or 6.046. \\
\\
So we will always rely on human intuition to find the proofs, although
we will be using computers more and more to check if they are right.

\section{Propositional reasoning examples}

Rosen, Section 3.1 \\
\\
Some common types of proofs are direct proof, proof by contradiction,
and proof by cases. \\
Here, I'll say what these are and give some tiny examples. \\
\\
Proof style: \\
I'm not presenting formal logical proofs, but rather, proofs at about
the level of detail commonly used by mathematicians. \\
\\
I'm using a pretty stylized, structured format, \\
listing statements and reasons, as in high school geometry proofs. \\
Uses of proof rules explicit. \\
Look like programs (but I don't have a formally-defined language). \\
\\
In math books (incl. the ones in this course), proofs don't look like this. \\
Written in paragraphs, with the logical structure implicit in the prose. \\
Caution: To really understand them, and write them yourself, you have to
understand the logical structure. \\
That's why I'm starting out by laying it out carefully. \\
\\
Later in the course, as we become surer that you understand the 
logical structure, we will present many proofs in less structured styles. \\
Paragraphs, semi-structured (laying out only the major steps). \\
But ideally, it should be possible to rewrite any of these proofs in
structured form (given enough time). \\
\\
For your own proofs: \\
You can write them in structured form, paragraphs, or somewhere in
between. \\
Just make sure you get the proof logic right. 

\subsection{Direct proof}

To prove that a proposition of the form $P \Rightarrow Q$ is true, it
is enough to assume $P$ and show $Q$. \\
Written in a structured style, the pattern of such a proof is: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove:  $P \Rightarrow Q$ \\
1. Assume $P$. \\
2. $Q$ \\
3. QED 
\> \> \> \> \> Implication \\
\end{tabbing}

QED = Quod Erat Demonstrandum = ``which was to be proved''. \\
Here, it's a shorthand for writing the goal out again as the final
step. \\
\\
%[[[I thought about trying to ``derive'' these rules also from the truth
%table, but, e.g., ``assume'' is confusing---you have to consider all
%the rows where the assumption is false...]]]
\\
Example: \\
\\
Prove: The sum of the first 100 numbers, $1 + ... + 100$, is 5050. \\
Rewrite as an implication: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove:  $S = 1 + ... + 100 \Rightarrow S = 5050$. \\
1. Assume  $S = 1 + ... + 100$. \\
2. $S = 5050$ 
\> \> \> \> \> ??? \\
3. QED        
\> \> \> \> \> Implication \\
\end{tabbing}
Of course, the interesting part is showing step 2, where I've put the ???. \\
Fill in steps (calculations): 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill\\
Prove:  $S = 1 + ... + 100 \Rightarrow S = 5050$. \\
1. Assume  $S = 1 + ... + 100$. \\
2. $S = 5050$ \\
\> 1. $S = 100 + 99 +...+ 1$  
   \> \> \> \> Commutativity of addition \\
\> 2. $2S = 101 + 101 + ... + 101$  (100 terms) 
   \> \> \> \> Add term-by-term \\
\> 3. $2S = 10,100$           
   \> \> \> \> Add the terms up \\
\> 4. QED  
   \> \> \> \> Divide by 2 \\
3. QED                       
\> \> \> \> \> Implication 
\end{tabbing}

\subsection{Proof by contradiction}

To prove that a proposition $P$ is true, it is enough to prove that 
$\neg P \Rightarrow \ms{false}$. \\
The pattern is: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove:  $P$ \\
1. $\neg P \Rightarrow \ms{false}$ \\
2. QED   
\> \> \> \> \> Contradiction
\end{tabbing}

\noindent
Some variants of this:

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove: $P$ \\
1. $\neg P \Rightarrow (Q \wedge \neg Q)$ \\
2. QED 
\> \> \> \> \> Contradiction \\
\\
\\
Prove: $P$ \\
1. $\neg P \Rightarrow Q$ \\
2. $\neg Q$ \\
3. QED       
\> \> \> \> \> Contradiction \\
\end{tabbing}

\noindent
Example:

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Assume: If Ricky gets at least six hours of sleep then he passes his 6042 final. \\
Ricky fails his 6042 final. \\
Prove: Ricky gets less than six hours of sleep.
\end{tabbing}

\noindent
Here, let $P= \mbox{``Ricky gets less than six hours sleep.''}$.\\
$Q= \mbox{``Ricky passes.''}$. So the proof steps for proving $P$ are:

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
1. If Ricky gets at least six hours of sleep then he passes. 
   ($\neg P \Rightarrow Q$). \\
\> \> \> \> \> Assumed \\
2. Ricky fails ($\neg Q$). 
\> \> \> \> \> Assumed \\
3. QED       
\> \> \> \> \> Contradiction 
\end{tabbing}

\subsection{Cases}

To prove that a proposition $P$ is true, it is enough to prove that
$Q$ and $\neg Q$ both imply $P$, 
where $Q$ is any other proposition. \\
Says $P$ is true in either case.

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove: $P$ \\
1. $Q \Rightarrow P$ \\
2. $\neg Q \Rightarrow P$ \\
3. QED                     
\> \> \> \> \> Cases 
\end{tabbing}

\noindent
Of course, generalize this to any number of predicates, provided that
together they cover all possibilities: \\
$Q_1 \vee Q_2 \vee \ldots \vee Q_k$ is true. \\
\\
Example: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Assume: $d =$ Britney's birth date (day of month, 1-31). \\
Prove: $d^2 + d$ is even. \\
1. $d = 1 \Rightarrow d^2 + d \mbox{ is even}$. \\
2. $d = 2 \Rightarrow d^2 + d \mbox{ is even}$. \\
3. $\ldots$ \\
31. $d = 31 \Rightarrow d^2 + d \mbox{ is even}$. \\
32. QED   
\> \> \> \> \> Cases 
\end{tabbing}
Of course we might imagine more clever proofs than this one, e.g., by 
breaking up the proof into only two cases based on whether $d$ is even/odd.

\section{Predicates}

\subsection{What are predicates?}

Predicates are similar to propositions but they depend on variables. \\
$P(x,y,z)$ denotes a predicate on variables $x,y,z$. \\
For example, define: 
\begin{itemize}
\item $R(x)$: $x$ is an odd number.
\item $Q(x)$: $x > 2$.
\item $P(x)$: $x$ is a prime number.
\end{itemize}
These predicates are {\em not} propositions, because they can be true
or false depending on $x$. \\
They are like functions from variables to propositions. 
\begin{itemize} 
\item $P(2)$ is true.
\item $R(2)$ is false.
\item $P(4) \vee R(3)$ is true.
\item $Q(3) \wedge R(4)$ is false.
\item $Q(1) \implies R(2)$ is true.
\end{itemize}

\subsection{Quantifiers}

Many propositions assert that something is true for all or some elements
of a given domain (e.g., all numbers).  The following quantifiers presume
a particular {\em universe of discourse} has been agreed upon in advance.

\begin{itemize}
\item ``$\forall$'' means ``for all.'' $\forall x P(x)$ is a statement
that is true iff $P(x)$ is true for {\em every} $x$ in the universe of
discourse. 
\item ``$\exists$'' means ``there exists.'' $\exists x P(x)$ is true
iff $P(x)$ is true for {\em at least one} $x$ in the universe of
discourse.
\item ``$\not\exists''$ mean ``there does not exist'' (``there is no'').
\item ``$\exists !$'' means ``there exists {\em exactly} one.''
\item ``$\forall x \in S$'' means ``for every $x$ in the set $S$.''
$(\forall x \in S) P(x)$ is equivalent to $(\forall x) (x \in S
\implies P(x)).$
\end{itemize}

Quantifiers can turn predicates into propositions, e.g.
\[
\forall x, P(x) \wedge Q(x) \implies R(x).
\]
Note that each appearance of $x$ is associated with the $\forall$
quantifier.  A variable associated with a quantifier in this way
is said to be {\em bound}.  Since every variable in the above expression
is bound, it is a proposition.  If $P$, $Q$, and $R$ are the predicates
defined above, this proposition is true.

{\bf Note:} $\forall x \exists y$ is {\em different} from $\exists y \forall
x$:
\begin{itemize}
\item $S(x,y):$ student $x$ will fall asleep in class $y$.
\item $\forall y \exists x P(x,y):$ ``In every class, some student will fall asleep.''
\item $\exists x \forall y P(x,y):$ ``There exists a student who will
fall asleep in every class.''
\end{itemize}

What is the universe of discourse above?

\subsection{Deduction rules involving quantifiers}

%[[[David:  There are others, I'm sure---need more here?  Victor
%suggested we need things like ~forall x  P(x)   means exists x
%notP(x)'']]]

Four main rules for manipulating quantifiers: \\
Rosen, p. 173 \\
Universal Generalization  UG \\
Universal Instantiation UI \\
Existential Generalization EG \\
Existential Instantiation EI \\
\\
We'll introduce these as we use them. \\

\section{Predicate reasoning examples}

Reading: \\
Proofs book \\
Rosen, Section 3.1 \\
\\
Manipulates sentences containing $\forall$ and $\exists$ quantifiers.
%(Variables all bound, though.) \\
\\
This section gives some examples.

\subsection{Britney's birthdate}

Illustrates: Quantifier reasoning (UG, EI, EG).  Cases.

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove: $\forall n \in N (n^2 + n \mbox{ is even})$. \\
1. Fix $n \in N$. \\
2. $n^2 + n$ is even. 
\> \> \> \> \> ??? \\
3. QED  
\> \> \> \> \> Universal Generalization (UG) 
\end{tabbing}
UG is the official fancy name for the rule that says, 
to show something is true for all elements of a set ($\forall$), 
you pick (``fix'') any arbitrary generic element and show it for that. \\
The name is hard to remember, don't worry too much about it. \\
\\
Pattern: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove: $\forall x \in X (P(x))$. \\
1. Fix $x \in X$. \\
2. $P(x)$ \\
3. QED  
\> \> \> \> \> Universal Generalization (UG) 
\end{tabbing}
\\
\\
Back to the proof: \\
To show step 2, can use cases: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove: $\forall n \in N (n^2 + n \mbox{ is even})$. \\
1. Fix $n \in N$. \\
2. $n^2 + n$ is even. \\
\> 1. If $n$ is odd then $n^2 + n$ is even.    
   \> \> \> \> ??? \\
\> 2. If $n$ is even then $n^2 + n$ is even.   
   \> \> \> \> ??? \\
\> 3. QED                                      
   \> \> \> \> Cases \\
3. QED 
\end{tabbing}
Now fill in steps for the odd case: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
\> 1. If $n$ is odd then $n^2 + n$ is even.   \\
\> \> 1. Assume $n$ is odd. \\
\> \> 2. $n^2 + n$ is even. \\
\> \> \> 1. $\exists x \in N (n = 2x + 1)$ 
         \> \> Definition of ``odd'' \\
\> \> \> 2. Choose $x \in N$, $n = 2x + 1$ 
         \> \> Existential Instantiation (EI) \\
\> \> \> \> \> (If there {\em exists\/} one, you can {\em choose\/} one.) \\
\> \> \> 3. $n^2 + n = 4x^2 + 4x + 1 + 2x + 1 = 2(2x^2 + 3x + 1)$ \\
\> \> \> \> \> Algebra \\
\> \> \> 4. $\exists y \in N (n^2 + n = 2y)$ 
         \> \> Existential Generalization (EG) \\
\> \> \> \> \> (If you {\em have\/} one, then one {\em exists}.) \\
\> \> \> 5. QED                 
         \> \> Definition of ``even'' \\
\> \> 3. QED                    
      \> \> \> Implication 
\end{tabbing}
Analogously for the ``even'' case: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
\> 2. If $n$ is even then $n^2 + n$ is even.   \\
\> \> 1. Assume $n$ is even. \\
\> \> 2. $n^2 + n$ is even. \\
\> \> \> 1. $\exists x \in N (n = 2x)$ 
         \> \> Definition of ``even'' \\
\> \> \> 2. Choose $x \in N$, $n = 2x$ 
         \> \> EI \\
\> \> \> 3. $n^2 + n = 4x^2 + 2x = 2(2x^2 + x)$ 
         \> \> Algebra \\
\> \> \> 4. $\exists y \in N (n^2 + n = 2y)$ 
         \> \> EG \\
\> \> \> 5. QED                 
         \> \> Definition of ``even''. \\
\> \> 3. QED                    
      \> \> \> Implication 
\end{tabbing}
Or, condensing a little: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
\> 2. If $n$ is even then $n^2 + n$ is even.   \\
\> \> 1. Assume $n$ is even. \\
\> \> 2. Choose $x \in N$, $n = 2x$
      \> \> \> Definition of ``even'', EI \\
\> \> 3. $n^2 + n = 4x^2 + 2x = 2(2x^2 + x)$ 
      \> \> \> Algebra \\
\> \> 4. $n^2 + n$ is even. 
      \> \> \> EG, definition of ``even'' \\
\> \> 5. QED        
      \> \> \> Implication 
\end{tabbing}

\subsection{Proofs by contradiction}

Illustrates: Contradiction, more quantifiers. \\

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove: $\sqrt{2}$ is irrational.\\
1. $\sqrt{2}$ rational $\Rightarrow \ms{false}$ \\
2. QED 
\> \> \> \> \> Contradiction. 
\end{tabbing}
Assume it's rational, play with the definitions, and try to get a
contradiction. 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove: $\sqrt{2}$ is irrational. \\
1. $\sqrt{2}$ rational $\Rightarrow \ms{false}$ \\
\> 1. Assume $\sqrt{2}$ rational. \\
\> 2. $\ms{false}$ \\
\> \> 1. Choose $a, b \in N^{+}$, $\sqrt{2} = {a \over b}$, lowest terms.
      \> \> \> Definition and basic properties of rationals, EI \\
\> \> 2. $2 b^2 = a^2$       
      \> \> \> Algebra \\
\> \> 3. $a^2$ is even.
      \> \> \> EG, Definition of ``even'' \\
\> \> 4. $a$ is even.      
      \> \> \> ??? \\
\> \> 5. Choose $c \in N$, $a = 2c$. 
      \> \> \> Definition of ``even'', EI \\
\> \> 6. $4 c^2 = a^2 = 2b^2$ 
      \> \> \> Algebra \\
\> \> 7. $2 c^2 = b^2$       
      \> \> \> Algebra \\
\> \> 8. $b^2$ is even.
      \> \> \> EG, Definition of ``even'' \\
\> \> 9. $b$ is even.
      \> \> \> ??? \\
\> \> 10. $a$ and $b$ aren't in lowest terms. 
      \> \> \> 1.2.4, 1.2.9 \\
\> \> 11. QED
      \> \> \> 1.2.1, 1.2.10, propositional logic \\
\> 3.  QED                 
   \> \> \> \> Implication. \\
2. QED  
\> \> \> \> \> Contradiction. \\
\end{tabbing}

\noindent
Little missing piece: Showing that $a$ and $b$ are even, because we know
their squares are even. \\
Reason is a general fact, which could itself be proved by
contradiction: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Assume: $x \in N$, $x^2$ is even. \\
Prove: $x$ is even. \\
1. $x \mbox{ is odd} \Rightarrow \ms{false}$ \\
\> 1. Assume $x$ is odd. \\
\> 2. $x^2$ is odd. 
   \> \> \> \> Do a proof like the one in the birthdate example. \\
\> 3. $\ms{false}$           
   \> \> \> \> Assumption, 1.2.4, Prop. logic \\
2. QED
\> \> \> \> \> Contradiction
\end{tabbing}

\subsection{De Morgan's Law}

Illustrates:  Set theory proof. 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove: $\forall A, B (\bar{A} \cap \bar{B} = \bar{A \cup B})$ \\
1. Fix $A$, $B$. \\
2. $\bar{A} \cap \bar{B} = \bar{A \cup B}$   
\> \> \> \> \> ??? \\
3. QED
\> \> \> \> \> UG 
\end{tabbing}

\noindent
To show two sets are equal, we show that they contain the same elements. \\
See Rosen, Def. 2, p. 40. 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
Prove: $\forall A, B (\bar{A} \cap \bar{B} = \bar{A \cup B})$. \\
1. Fix $A$, $B$. \\
2. $\bar{A} \cap \bar{B} = \bar{A \cup B}$ \\
\> 1. $\forall x (x\in \bar{A} \cap \bar{B}  \Leftrightarrow x\in\bar{A \cup B})$ \\
\> \> 1. Fix $x$. \\
\> \> 2. $x \in \bar{A} \cap \bar{B}  \Leftrightarrow x \in \bar{A \cup B}$ 
      \> \> \> ??? \\
\> \> 3. QED    
      \> \> \> UG \\
\> 2. QED           
   \> \> \> \>  Definition of set equality. \\
3. QED 
\> \> \> \> \> UG 
\end{tabbing}

\noindent
Equivalence can be shown by showing two implications, one in each
direction: 

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
\> \> 2. $x \in \bar{A} \cap \bar{B}  \Leftrightarrow x \in \bar{A \cup B}$ \\
\> \> \> 1. $x \in \bar{A} \cap \bar{B}  \Rightarrow x \in \bar{A\cup B}$ 
         \> \> ??? \\
\> \> \> 2. $x \in \bar{A \cup  B} \Rightarrow x \in \bar{A} \cap\bar{B}$ 
         \> \> ??? \\
\> \> \> 3. QED   
         \> \> Propositional logic 
\end{tabbing}
One direction:

\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
\> \> \> 1. $x \in \bar{A} \cap \bar{B}  \Rightarrow x \in \bar{A \cup  B}$ \\
\> \> \> \> 1. Assume $x \in \bar{A} \cap \bar{B}$. \\
\> \> \> \> 2. $x \in \bar{A}$, $x \in \bar{B}$ 
            \> Definition of intersection. \\
\> \> \> \> 3. $x \notin A$, $x \notin B$ 
            \> Definition of complement. \\
\> \> \> \> 4. $x \notin A \cup B$ 
            \> Definition of union. \\
\> \> \> \> 5. $x \in \bar{A \cup  B}$  
            \> Definition of complement. \\
\> \> \> \> 6. QED 
            \> Implication 
\end{tabbing}
Actually, the union step could be expanded to a little proof by
contradiction:  \\
if it is in the union, it's in one of the sets, etc. \\
The other direction essentially reverses the steps: 
\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
\> \> \> 2. $x \in \bar{A \cup  B} \Rightarrow x \in \bar{A} \cap\bar{B}$ \\
\> \> \> \> 1. Assume $x \in \bar{A \cup B}$. \\
\> \> \> \> 2. $x \notin A \cup B$
            \> Complement \\
\> \> \> \> 3. $x \notin A$, $x \notin B$
            \> Union \\
\> \> \> \> 4. $x \in \bar{A}$, $x \in \bar{B}$
            \> Complement \\
\> \> \> \> 5. $x \in \bar{A} \cap \bar{B}$
            \> Intersection \\
\> \> \> \> 6. QED 
            \> Implication 
\end{tabbing}


\subsection{Proof by counterexample}

Prove: All natural numbers $\geq 2$ are prime. \\
\\
This turns out to be false. \\
We can show this using a ``counterexample'', $10$. \\
That's all that's needed. \\
Really, we're proving the negation, which says $\exists$ a non-prime
$\geq 2$. \\
And this follows just by exhibiting one.
%(Existential Generalization).

\section{Good proofs}

Correct. \\
\\
Clear, understandable. \\
\\
Nice structure:  \\
Broken up into separate pieces to prove key intermediate properties.\\
Makes it easier to understand. \\
Reusable pieces.\\
\\
Pieces general, abstract. \\
Written to apply to many cases. \\
Avoid clutter of unnecessary assumptions. \\
\\
Doesn't leave ``gaps''---saying it's obvious when it isn't. \\
\\
Elegant, short, clever...\\
\\
A lot like criteria for good programs. \\
\\
A difference: \\
In math, proofs are sometimes valued for being deep, hard. \\
Not much of a consideration in programming:  here, the premium is more
on how well it works and how easy it is to understand. 

\end{document}

% Names (from teeny-bopper rock music):  Ricky, Enrique, Britney, Christina.
% Jessica, Kid, Lou
%
% Monica, Erica, Rita, Tina, Sandra, Mary, Jessica.

Slides: 

- What we want you to learn this term (5 bullets)

- List of 5 basic data types; under each, list the operations,...??

- Truth tables for Booleans

- List of proposition examples

- Truth tables for propositional logic

- Propositional logic sample proof rules


- Direct proof pattern

- Direct proof example, short version

- Direct proof example, full version

- Contradiction pattern 1

- Contra pattern 2, pattern 2

- Contra example, full version, but without the comments.

- Cases pattern

- Cases example


- Birthdate example, short proof; cases; odd; even

- De Morgan short proof; ... all the separate versions/pieces

- Contradiction proofs...













\\
