A review and continuation of Lecture 08.
Elim $\forall$ $\rule{\forall x. P(x)}{P(a) \text{ for any } a}$
Intro $\forall$ $\rule{P(a); a \text{ is } \color{MediumVioletRed}{\text{arbitrary}}}{\forall x. P(x)}$
The name $a$ stands for an arbitrary value in the domain. No other name in $P$ depends on $a$.
Intro $\exists$ $\rule{P(c) \text{ for some } c}{\exists x. P(x)}$
Elim $\exists$ $\rule{\exists x. P(x)}{P(c) \text{ for a } \color{MediumVioletRed}{\text{specific }} c }$
The name $c$ is fresh and stands for a value in the domain where $P(c)$ is true. List all dependencies for $c$.
Prove that there is an even prime number: $\exists x. \text{Even}(x) \wedge \text{Prime}(x)$.
1. | $\specific{2} = \specific{2}\cdot \hilite{SteelBlue}{1}$ | Arithmetic |
2. | $\exists \hilite{SteelBlue}{y}. \specific{2} = \specific{2}\cdot \hilite{SteelBlue}{y}$ | Intro $\exists$: 1 |
3. | $\text{Even}(\specific{2})$ | Definition of Even: 2 |
4. | $\text{Prime}(\specific{2})$ | Property of integer 2 |
5. | $\text{Even}(\specific{2}) \wedge \text{Prime}(\specific{2})$ | Intro $\wedge$: 3, 4 |
6. | $\exists \specific{x}. \text{Even}(\specific{x}) \wedge \text{Prime}(\specific{x})$ | Intro $\exists$: 5 |
We are using the logic definition of Even to establish that 2 is Even, and we are using domain property to establish that 2 is Prime.
Elim $\forall$ $\rule{\forall x. P(x)}{P(a) \text{ for any } a}$
Intro $\forall$ $\rule{P(a); a \text{ is } \color{MediumVioletRed}{\text{arbitrary}}}{\forall x. P(x)}$
Intro $\exists$ $\rule{P(c) \text{ for some } c}{\exists x. P(x)}$
Elim $\exists$ $\rule{\exists x. P(x)}{P(c) \text{ for a } \color{MediumVioletRed}{\text{specific }} c }$
We give an explicit logic definition of Even but use a black-box definition of Prime because the proof won’t need to break it down further.
Prove that $\forall y. \exists z. y = z$ follows from $\forall x. x = x$.
1. | $\forall x. x = x$ | Given |
2. | $\arbitrary{a}=\arbitrary{a}$ | Elim $\forall$: 1, $\arbitrary{a}$ is arbitrary |
3. | $\exists z. \arbitrary{a}=z$ | Intro $\exists$: 2 |
4. | $\forall y. \exists z. y=z$ | Intro $\forall$: 3 |
Elim $\forall$ $\rule{\forall x. P(x)}{P(a) \text{ for any } a}$
Intro $\forall$ $\rule{P(a); a \text{ is } \color{MediumVioletRed}{\text{arbitrary}}}{\forall x. P(x)}$
Intro $\exists$ $\rule{P(c) \text{ for some } c}{\exists x. P(x)}$
Elim $\exists$ $\rule{\exists x. P(x)}{P(c) \text{ for a } \color{MediumVioletRed}{\text{specific }} c }$
Prove that the square of every even number is even: $\forall x. \text{Even}(x) \rightarrow \text{Even}(x^2)$.
1. | Let $\arbitrary{a}$ be an arbitrary integer. |
2.1. | $\text{Even}(\arbitrary{a})$ | Assumption |
2.2. | $\exists \specific{y}. \arbitrary{a} = 2\specific{y}$ | Definition of Even: 2.1 |
2.3. | $\arbitrary{a} = 2\specific{b}$ | Elim $\exists$: 2.2, $\specific{b}$ depends on $\arbitrary{a}$ |
2.4. | $\arbitrary{a}^2 = 4\specific{b}^2 = 2(2\specific{b}^2)$ | Algebra |
2.5. | $\exists y. \arbitrary{a}^2 = 2y$ | Intro $\exists$: 2.4 |
2.6. | $\text{Even}(\arbitrary{a}^2)$ | Definition of Even: 2.5 |
3. | $\text{Even}(\arbitrary{a}) \rightarrow \text{Even}(\arbitrary{a}^2)$ | Direct Proof Rule |
4. | $\forall x. \text{Even}(x) \rightarrow \text{Even}(x^2)$ | Intro $\forall$: 1, 3 |
Elim $\forall$ $\rule{\forall x. P(x)}{P(a) \text{ for any } a}$
Intro $\forall$ $\rule{P(a); a \text{ is } \color{MediumVioletRed}{\text{arbitrary}}}{\forall x. P(x)}$
Intro $\exists$ $\rule{P(c) \text{ for some } c}{\exists x. P(x)}$
Elim $\exists$ $\rule{\exists x. P(x)}{P(c) \text{ for a } \color{MediumVioletRed}{\text{specific }} c }$
Over the integer domain: $\forall x. \exists y. y\geq x$ is True but $\exists y. \forall x. y\geq x$ is False.
1. | $\forall x. \exists y. y\geq x$ | Given |
2. | Let $\arbitrary{a}$ be an arbitrary integer. | |
3. | $\exists \specific{y}. \specific{y}\geq \arbitrary{a}$ | Elim $\forall$: 1 |
4. | $\specific{b}\geq \arbitrary{a}$ | Elim $\exists$: 3, $\specific{b}$ depends on $\arbitrary{a}$ |
5. | $\forall x. \specific{b}\geq x$ | Intro $\forall$: 2, 4 |
6. | $\exists y. \forall x. y\geq x$ | Intro $\exists$: 5 |
Example: an incorrect proof.
Can’t get rid of $\arbitrary{a}$ since another name, $\specific{b}$, in the same formula depends on it!
Elim $\forall$ $\rule{\forall x. P(x)}{P(a) \text{ for any } a}$
Intro $\forall$ $\rule{P(a); a \text{ is } \color{MediumVioletRed}{\text{arbitrary}}}{\forall x. P(x)}$
The name $a$ stands for an arbitrary value in the domain. No other name in $P$ depends on $a$.
Intro $\exists$ $\rule{P(c) \text{ for some } c}{\exists x. P(x)}$
Elim $\exists$ $\rule{\exists x. P(x)}{P(c) \text{ for a } \color{MediumVioletRed}{\text{specific }} c }$
The name $c$ is fresh and stands for a value in the domain where $P(c)$ is true. List all dependencies for $c$.
From formal proofs to natural language proofs.
Prove that there is an even integer.
$\specific{2} = \specific{2}\cdot \hilite{SteelBlue}{1}$ | |
so $\specific{2}$ equals $\specific{2}$ times an integer. | |
Therefore $\specific{2}$ is even. | |
Therefore there is an even integer. $\qed$ |
1. | $\specific{2} = \specific{2}\cdot \hilite{SteelBlue}{1}$ | Arithmetic |
2. | $\exists \hilite{SteelBlue}{y}. \specific{2} = \specific{2}\cdot \hilite{SteelBlue}{y}$ | Intro $\exists$: 1 |
3. | $\text{Even}(\specific{2})$ | Definition of Even: 2 |
4. | $\exists \specific{x}. \text{Even}(\specific{x})$ | Intro $\exists$: 3 |
Prove that the square of every even number is even.
Let $\arbitrary{a}$ be an arbitrary even integer. |
Then, by definition, $\arbitrary{a} = 2\specific{b}$ | |
for some integer $\specific{b}$, depending on $\arbitrary{a}$. | |
Squaring both sides, we get $\arbitrary{a}^2 = 4\specific{b}^2 = 2(2\specific{b}^2)$. | |
Since $2\specific{b}^2$ is an integer, by definition, | |
$\arbitrary{a}^2$ is even. |
Since $\arbitrary{a}$ was arbitrary, it follows that | |
the square of every even number is even. $\qed$ |
1. | Let $\arbitrary{a}$ be an arbitrary integer. |
2.1. | $\text{Even}(\arbitrary{a})$ | Assumption |
2.2. | $\exists \specific{y}. \arbitrary{a} = 2\specific{y}$ | Definition of Even: 2.1 |
2.3. | $\arbitrary{a} = 2\specific{b}$ | Elim $\exists$: 2.2, $\specific{b}$ depends on $\arbitrary{a}$ |
2.4. | $\arbitrary{a}^2 = 4\specific{b}^2 = 2(2\specific{b}^2)$ | Algebra |
2.5. | $\exists y. \arbitrary{a}^2 = 2y$ | Intro $\exists$: 2.4 |
2.6. | $\text{Even}(\arbitrary{a}^2)$ | Definition of Even: 2.5 |
3. | $\text{Even}(\arbitrary{a}) \rightarrow \text{Even}(\arbitrary{a}^2)$ | Direct Proof Rule |
4. | $\forall x. \text{Even}(x) \rightarrow \text{Even}(x^2)$ | Intro $\forall$: 1, 3 |
Prove that the square of every odd number is odd.
A real number $x$ is rational iff there exist integers $p$ and $q$ with $q\neq0$ such that $x=p/q$.
Prove: “If $x$ and $y$ are arbitrary rational numbers then $xy$ is rational.”
This is more work to write
%a = add %i, 1
%b = mod %a, %n
%c = add %arr, %b
%d = load %c
%e = add %arr, %i
store %e, %d
than this
arr[i] = arr[(i+1) % n];
Higher level language is easier because it skips details.
Formal proofs are the low level language: each part must be spelled out in precise detail.
English proofs are the high level language.
An English proof is correct if the reader is convinced they can “compile” it to a formal proof if necessary.
Proof by contrapositive, counterexamples, and proof by contradiction.
If we assume $\neg q$ and derive $\neg p$, then we have proven that $\neg q \rightarrow \neg p$, which is equivalent to proving $p \rightarrow q$.
1.1. | $\neg q$ | Assumption |
$\ldots$ | ||
1.3. | $\neg p$ |
2. | $\neg q \rightarrow \neg p$ | Direct Proof Rule |
3. | $p \rightarrow q$ | Contrapositive: 2 |
If we assume $p$ and derive $\F$ (a contradiction), then we have proven $\neg p$.
1.1. | $p$ | Assumption |
$\ldots$ | ||
1.3. | $\F$ |
2. | $p \rightarrow \F$ | Direct Proof Rule |
3. | $\neg p \vee \F$ | Law of Implication: 2 |
4. | $\neg p$ | Identity: 3 |
Use an automated theorem prover:
; No integer is both even and odd.
(define-fun even ((x Int)) Bool
(exists ((y Int)) (= x (* 2 y))))
(define-fun odd ((x Int)) Bool
(exists ((y Int)) (= x (+ (* 2 y) 1))))
(define-fun claim () Bool
(not (exists ((x Int)) (and (even x) (odd x)))))
(assert (not claim)) ; proof by contradiction
(check-sat)
While this example works, proofs of arbitrary formulas in predicate logic cannot be automated. But interactive theorem provers can still help by checking your formal proof and filling in some low-level details for you.