21.05.2014 Views

Summary of Logic and Mathematical Inquiry (80-211 ... - Phil Cmu

Summary of Logic and Mathematical Inquiry (80-211 ... - Phil Cmu

Summary of Logic and Mathematical Inquiry (80-211 ... - Phil Cmu

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Summary</strong> <strong>of</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> (<strong>80</strong>-<strong>211</strong>), Spring 2011<br />

Instructor: Jeremy Avigad<br />

T.A.: Dan Auerbach<br />

Course goals<br />

Teach students to read <strong>and</strong> write mathematical pro<strong>of</strong>s<br />

Teach students the syntax <strong>and</strong> (informal) semantics <strong>of</strong> first-order logic<br />

Teach students to carry out logical calculations <strong>and</strong> manipulations<br />

Teach students to carry out formal pro<strong>of</strong>s (in natural deduction, <strong>and</strong> in an interactive pro<strong>of</strong>assistant)<br />

Teach students basic mathematical concepts (sets, functions, relations, ...)<br />

Teach students about axiomatic foundations<br />

Textbooks <strong>and</strong> s<strong>of</strong>tware<br />

Velleman, How to Prove It<br />

Tarski's World<br />

Notes on natural deduction <strong>and</strong> Isabelle<br />

The Isabelle pro<strong>of</strong> assistant<br />

Excerpts from Enderton, Set Theory<br />

Topics covered<br />

Informal mathematical pro<strong>of</strong><br />

Propositional logic <strong>and</strong> truth table semantics<br />

Proving propositional identities <strong>and</strong> simple set identities<br />

Natural deduction for propositional logic<br />

Natural deduction for first-order logic with equality<br />

<strong>Mathematical</strong> induction <strong>and</strong> recursion (both informal <strong>and</strong> formal)<br />

Relations: order relations, equivalence relations, equivalence classes<br />

Functions: injections, surjections, bijections, etc.<br />

Axiomatic set theory<br />

Cardinality <strong>and</strong> the infinite<br />

The set-theoretic construction <strong>of</strong> the real numbers<br />

Contents <strong>of</strong> this package<br />

Syllabus<br />

Notes on natural deduction <strong>and</strong> Isabelle<br />

Homework assignments <strong>and</strong> solutions<br />

Exams<br />

Isabelle scripts (including homework assignments <strong>and</strong> solutions)<br />

Isabelle cheat sheet


<strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong><br />

Course <strong>80</strong>-<strong>211</strong><br />

Spring, 2011<br />

Course information<br />

Time: Tuesday <strong>and</strong> Thursday, 9:00-10:20<br />

Room: Porter Hall A18C<br />

Course announcements, assignments, h<strong>and</strong>outs, <strong>and</strong> grades will be posted<br />

on Blackboard: http://www.cmu.edu/blackboard/<br />

Instructor<br />

Name: Pr<strong>of</strong>. Jeremy Avigad<br />

Office: Baker Hall 161D<br />

Mailbox: Baker Hall 135<br />

e-mail: avigad@cmu.edu<br />

Office hours: Wednesdays, 9-10am <strong>and</strong> 4-5pm<br />

Teaching Assistant<br />

Name: Daniel Auerbach<br />

Office: Dohery Hall 4302E<br />

Mailbox: Baker Hall 135<br />

e-mail: dauerbac@<strong>and</strong>rew.cmu.edu<br />

Office hours: Tuesday 6-7pm, Wednesday 6-7pm<br />

Texts<br />

Velleman, How to Prove It<br />

Barker-Plummer, Barwise, <strong>and</strong> Etchemendy, Tarski’s World<br />

We will also make use <strong>of</strong> the Isabelle theorem prover, which can be found<br />

online:<br />

http://www.cl.cam.ac.uk/research/hvg/Isabelle/.


Additional notes <strong>and</strong> readings will be posted on Blackboard.<br />

Requirements<br />

Problem sets (50%):<br />

Due every Thursday<br />

Midterm exam (20%): In class, Thursday, March 3<br />

Final exam (30%):<br />

During the final exam period<br />

Please read the relevant sections <strong>of</strong> the text before class so that we can<br />

discuss them during the lecture.<br />

Description<br />

Among the range <strong>of</strong> human pursuits, mathematics is distinguished by the<br />

use <strong>of</strong> precise, regimented language <strong>and</strong> methods <strong>of</strong> argumentation. In other<br />

words, there are implicit rules that govern how mathematical assertions are<br />

made, <strong>and</strong> how they are proved. One <strong>of</strong> the great achievements <strong>of</strong> twentieth<br />

century logic has been to analyze mathematical language <strong>and</strong> methods <strong>of</strong><br />

inference in great detail, <strong>and</strong> represent them with precise formal calculi.<br />

There are a number <strong>of</strong> benefits to doing so:<br />

• <strong>Phil</strong>osophical: logical analysis serves to clarify <strong>and</strong> sharpen debates<br />

as to the nature <strong>of</strong> mathematical objects, assumptions, inference, <strong>and</strong><br />

truth.<br />

• <strong>Mathematical</strong>: the modeling provides useful mathematical information<br />

about mathematical language <strong>and</strong> inference, including their limitations<br />

• Computational: it also makes it possible to use computers to help<br />

carry out <strong>and</strong> check mathematical reasoning.<br />

This course is an introduction to the language <strong>and</strong> methods <strong>of</strong> mathematics,<br />

<strong>and</strong> to the logical study there<strong>of</strong>. We will work on your ability to read <strong>and</strong><br />

write clear mathematical pro<strong>of</strong>s; at the same time, we will study the formal<br />

logical modeling <strong>of</strong> language <strong>and</strong> pro<strong>of</strong> in symbolic terms. In addition, you<br />

will experiment with s<strong>of</strong>tware that relies on this formal logical modeling.<br />

Background<br />

This course has substantial mathematical content, but it does not assume<br />

any background beyond high school mathematics.


Tentative Outline<br />

1. <strong>Mathematical</strong> language <strong>and</strong> reasoning (Velleman 1–2, Tarski’s world)<br />

(a) Propositional logic<br />

(b) Sets<br />

(c) First-order logic<br />

2. Formal <strong>and</strong> informal pro<strong>of</strong> (Velleman 3 <strong>and</strong> 6, Isabelle)<br />

(a) Natural deduction for propositional logic<br />

(b) Interactive theorem proving in Isabelle<br />

(c) Natural deduction for first-order logic with equality<br />

(d) The natural numbers <strong>and</strong> pro<strong>of</strong> by induction<br />

3. Foundations (Velleman 4, 5, <strong>and</strong> 7, Isabelle)<br />

(a) Relations <strong>and</strong> functions<br />

(b) Axioms for set theory<br />

(c) Cardinality <strong>and</strong> Cantor’s theorem<br />

(d) Axiomatic structures<br />

(e) The construction <strong>of</strong> the real numbers<br />

Grading <strong>and</strong> lateness policy<br />

Homework is due at the beginning <strong>of</strong> class on Thursday. It can be turned<br />

in late, until noon on Friday, to Dan Auerbach’s mailbox in Baker Hall 135,<br />

with a nominal penalty to your grade (roughly a third to a half <strong>of</strong> a letter<br />

grade). Note that this is much better than not turning it in at all, which<br />

counts as a score <strong>of</strong> 0. For the s<strong>of</strong>tware component <strong>of</strong> the course, you will<br />

be asked to turn in portions <strong>of</strong> your assignment electronically. Unless asked<br />

to do so, however, please submit a hardcopy <strong>of</strong> your solutions.<br />

The total point score on the homework assignments will vary from week<br />

to week. But each homework assignment is ultimately scaled to a score from<br />

0 to 5 (4–5 is an A, 3–4 is a B, etc.) <strong>and</strong> all count equally towards the final<br />

grade. This is done to ensure fairness. The course is not curved, in that<br />

everyone may earn an A, or everyone may fail.


Things invariably crop up during the semester: illness, travel, <strong>and</strong> so on.<br />

Taking that into account, I will drop your lowest two homework scores. Since<br />

you are responsible for all the material on the exams, however, I encourage<br />

you to do all the assignments.<br />

Grades are determined based on clarity as well as correctness. You may<br />

turn in an answer to a question that, arguably, has all the components <strong>of</strong> a<br />

correct answer; but if the grader has to struggle to underst<strong>and</strong> what you are<br />

saying, or read between the lines, or weed out false or irrelevant information,<br />

you are unlikely to receive full credit.<br />

You are allowed to work together on the homework assignments, <strong>and</strong>,<br />

in fact, this is encouraged. The only restriction is that when you write up<br />

the actual solution you turn in you must do so alone, so that the answer<br />

reflects your own underst<strong>and</strong>ing. Failure to obey these guidelines constitutes<br />

cheating.<br />

The Isabelle interactive theorem prover<br />

We will experiment with an interactive pro<strong>of</strong> system called Isabelle. This is<br />

a cutting-edge research-grade pro<strong>of</strong> tool rather than educational s<strong>of</strong>tware,<br />

used to check mathematical pro<strong>of</strong>s as well as s<strong>of</strong>tware <strong>and</strong> systems design;<br />

so using it in an introductory course is a bit <strong>of</strong> a stretch. But it is a powerful<br />

<strong>and</strong> remarkable system, <strong>and</strong> worth getting to know.<br />

You have three options for using Isabelle:<br />

• Use it in any <strong>of</strong> the Linux clusters on campus; see:<br />

http://www.cmu.edu/computing/clusters/s<strong>of</strong>tware/linux/index.html<br />

• Install it on your computer. The instructions are here:<br />

http://www.cl.cam.ac.uk/research/hvg/isabelle/download.html<br />

The installations are easy on a Mac or Linux system, but, unfortunately,<br />

not as easy on Windows.<br />

• Run it remotely. For example, if you use Windows, go to http://my.cmu.edu,<br />

go to “computing/ download s<strong>of</strong>tware” <strong>and</strong> install “X-Win32.” You<br />

can then use that to log on to your Andrew account at unix.<strong>and</strong>rew.cmu.edu<br />

<strong>and</strong> run Isabelle from there.


Once you have Isabelle set up, try running it. For example, at a cluster<br />

machine type<br />

isabelle emacs Test.thy<br />

When the editor opens up, copy the following file exactly:<br />

theory Test<br />

imports Main<br />

begin<br />

lemma "(2::nat) + 2 = 4"<br />

by auto<br />

Then press the “process buffer” button (the downwards-pointing triangle).<br />

If the text background turns light blue, the system is working.


<strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong><br />

Lecture notes<br />

Jeremy Avigad<br />

Version: Spring 2011


Contents<br />

1 Natural deduction for propositional logic 1<br />

1.1 Natural deduction . . . . . . . . . . . . . . . . . . . . . . . . 1<br />

1.2 Some propositional validities . . . . . . . . . . . . . . . . . . 5<br />

1.3 Pro<strong>of</strong> by contradiction . . . . . . . . . . . . . . . . . . . . . . 7<br />

1.4 Excercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7<br />

1.5 Pro<strong>of</strong> short cuts . . . . . . . . . . . . . . . . . . . . . . . . . . 8<br />

1.6 Sequent notation . . . . . . . . . . . . . . . . . . . . . . . . . 9<br />

2 Propositional logic in Isabelle 11<br />

2.1 Using Isabelle . . . . . . . . . . . . . . . . . . . . . . . . . . . 11<br />

2.2 The propositional rules . . . . . . . . . . . . . . . . . . . . . . 14<br />

2.3 Additional pro<strong>of</strong> methods . . . . . . . . . . . . . . . . . . . . 17<br />

2.4 Reasoning with sets . . . . . . . . . . . . . . . . . . . . . . . 17<br />

2.5 Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . 18<br />

3 Natural deduction for first-order logic 21<br />

3.1 Quantifiers in natural deduction . . . . . . . . . . . . . . . . 21<br />

3.2 Some first-order validities . . . . . . . . . . . . . . . . . . . . 22<br />

3.3 Equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23<br />

3.4 First-order theories . . . . . . . . . . . . . . . . . . . . . . . . 24<br />

3.5 Completeness for first-order logic . . . . . . . . . . . . . . . . 24<br />

4 First-order logic in Isabelle 27<br />

4.1 Quantifiers in Isabelle . . . . . . . . . . . . . . . . . . . . . . 27<br />

4.2 Equality in Isabelle . . . . . . . . . . . . . . . . . . . . . . . . 29<br />

4.3 Using lemmas <strong>and</strong> the library . . . . . . . . . . . . . . . . . . 30<br />

4.4 Using Isabelle’s automated tools . . . . . . . . . . . . . . . . 31


ii<br />

CONTENTS<br />

5 The natural numbers 33<br />

5.1 Induction <strong>and</strong> recursion on the natural numbers . . . . . . . . 33<br />

5.2 The natural numbers in Isabelle . . . . . . . . . . . . . . . . . 35


Chapter 1<br />

Natural deduction for<br />

propositional logic<br />

1.1 Natural deduction<br />

The formulas <strong>of</strong> propositional logic are obtained by starting with propositional<br />

variables p, q, r, . . ., <strong>and</strong> then using propositional connectives (ϕ ∧ ψ),<br />

(ϕ ∨ ψ), (ϕ → ψ), <strong>and</strong> (¬ϕ) to build up more complicated formulas. The<br />

symbols ∧, ∨, →, <strong>and</strong> ¬ st<strong>and</strong> for “<strong>and</strong>,” “or,” “implies,” <strong>and</strong> “not,” respectively.<br />

I will also use ⊤ for “true,” ⊥ for “false,” <strong>and</strong> ↔ for “if <strong>and</strong> only<br />

if.”<br />

Remember that, under truth-table semantics, a propositional formula ϕ<br />

is said to be valid, or a tautology, if ϕ is true under every assignment. This<br />

is written |= ϕ. More generally, if Γ is a set <strong>of</strong> formulas <strong>and</strong> ϕ is a formula,<br />

Γ entails ϕ, written Γ |= ϕ, if ϕ is true under every truth assignment that<br />

makes every formula in Γ true. In other words, Γ entails ϕ if the inference<br />

“from Γ, conclude ϕ” is valid. For example, computing truth tables shows<br />

that the following hold:<br />

• |= p ∧ q → q ∨ r<br />

• {q, p ∧ r} |= q ∧ r<br />

The purpose <strong>of</strong> a pro<strong>of</strong> system is to provide a system <strong>of</strong> rules which<br />

is sufficient to verify all valid formulas <strong>and</strong> entailments. Once we have<br />

described our pro<strong>of</strong> system, we will write ⊢ ϕ to indicate the ϕ is provable,<br />

<strong>and</strong>, more generally, write Γ ⊢ ϕ to mean that ϕ is provable from Γ. A good<br />

pro<strong>of</strong> system should have the property that it makes provability coincide<br />

1


2 CHAPTER 1. PROPOSITIONAL LOGIC<br />

with semantic entailment. That is, if there is a pro<strong>of</strong> <strong>of</strong> ϕ from Γ, then Γ<br />

should entail ϕ (this is known as “soundness”). Conversely, if Γ entails ϕ,<br />

then it should be possible to prove ϕ from Γ. In fact, the system I am about<br />

to describe is sound <strong>and</strong> complete.<br />

We will use a system <strong>of</strong> natural deduction, due to Gerhard Gentzen. In<br />

this system, the basic object is a pro<strong>of</strong> <strong>of</strong> a formula from some hypotheses;<br />

the rules <strong>of</strong> the system enable us to construct complex pro<strong>of</strong>s from simpler<br />

ones. Rules are associated to each connective, characterizing its proper<br />

usage. In particular, each logical connective has an associated introduction<br />

rule, which tells us what is needed to justify an assertion involving this<br />

connective; <strong>and</strong> an elimination rule, which tell what we may legitimately<br />

infer from such an assertion.<br />

To start with, you are allowed to make any assumption. This is just the<br />

assumption rule:<br />

The way to read this is as follows: assuming ϕ, you have proved ϕ.<br />

Here are the rules for conjunction:<br />

ϕ ψ ∧I<br />

ϕ ∧ ψ<br />

ϕ<br />

ϕ ∧ ψ ∧E1<br />

ϕ<br />

ϕ ∧ ψ ∧E2<br />

ψ<br />

The first rule says “in order to prove ϕ ∧ ψ from some assumptions, prove<br />

ϕ from those assumptions, <strong>and</strong> prove ψ from those assumptions.” In other<br />

words, whatever assumptions you have make to prove ϕ <strong>and</strong> ψ are assumptions<br />

in the resulting pro<strong>of</strong>. The other two rules are elimination rules. They<br />

say “if you have proved (or assumed) ϕ ∧ ψ, then you can conclude ϕ, <strong>and</strong><br />

you can conclude ψ.”<br />

Turning to the rules for implication, the elimination rule is easy:<br />

ϕ → ψ<br />

ψ<br />

ϕ →E<br />

This says, “if you know ϕ → ψ, <strong>and</strong> you know ϕ, then you can conclude ψ.”<br />

Once again, all the assumptions you made in the pro<strong>of</strong>s <strong>of</strong> ϕ → ψ <strong>and</strong> ϕ<br />

are in force. The introduction rule for implication is more subtle, because<br />

in this rule a hypothesis can be cancelled.<br />

ϕ<br />

.<br />

ψ<br />

ϕ → ψ<br />

→I


1.1. NATURAL DEDUCTION 3<br />

This says that in order to prove ϕ → ψ, it suffices to assume ϕ <strong>and</strong> conclude<br />

ψ. The three dots suggest a pro<strong>of</strong> <strong>of</strong> ψ in which the assumption ϕ can be<br />

used any number <strong>of</strong> times. In concluding ϕ → ψ, this assumption is made<br />

explicit. In the resulting pro<strong>of</strong>, then, ϕ is no longer an assumption; it has<br />

been cancelled.<br />

Reading a natural deduction pro<strong>of</strong> can be difficult because hypotheses<br />

are introduced <strong>and</strong> cancelled at various times. In particular, it is useful to<br />

know at which points in a pro<strong>of</strong> particular hypotheses have been cancelled.<br />

This information is conveyed by labelling the hypothesis <strong>and</strong> the point that<br />

it is cancelled with a letter x, y, z, . . .. For example, the following is a pro<strong>of</strong><br />

<strong>of</strong> ψ → (ϕ ∧ ψ) from hypothesis ϕ:<br />

ϕ ψ<br />

ϕ ∧ ψ<br />

ψ → ϕ ∧ ψ<br />

One more instance <strong>of</strong> →I yields a pro<strong>of</strong> <strong>of</strong> ϕ → (ψ → ϕ ∧ ψ):<br />

y<br />

ϕ ψ<br />

ϕ ∧ ψ<br />

ψ → ϕ ∧ ψ<br />

x<br />

x<br />

x<br />

x<br />

ϕ → (ψ → ϕ ∧ ψ)<br />

Returning to the rules, here are the ones for negation:<br />

ϕ<br />

.<br />

⊥ ¬I ¬ϕ<br />

y<br />

¬ϕ ϕ ¬E<br />

⊥<br />

To underst<strong>and</strong> this, think <strong>of</strong> ⊥, or “false,” as being a contradiction. So, if<br />

you have proved ϕ <strong>and</strong> ¬ϕ, you have derived a contradiction. On the other<br />

h<strong>and</strong>, to prove ¬ϕ, you should assume ϕ <strong>and</strong> show that a contradiction<br />

follows.<br />

It is also the case that anything follows from a contradiction:<br />

⊥<br />

ϕ<br />

This has the fancy Latin name, “ex falso sequitur quodlibet,” which means<br />

“anything you want follows from falsity.” Conversely, you can always assert<br />

⊤ as an axiom.<br />

Here are the rules for disjunction:


4 CHAPTER 1. PROPOSITIONAL LOGIC<br />

ϕ<br />

ϕ ∨ ψ<br />

∨I 1<br />

ψ<br />

ϕ ∨ ψ<br />

∨I 2<br />

. .<br />

ϕ ∨ ψ θ<br />

θ<br />

θ ∨E<br />

The introduction rule is straightforward: to prove ϕ ∨ ψ, prove either one.<br />

The elimination rule is more confusing, but it is supposed to model the<br />

natural process <strong>of</strong> proving θ from ϕ ∨ ψ by branching on cases: “Suppose<br />

ϕ ∨ ψ. Case 1: ϕ holds. . . . <strong>and</strong> θ follows. Case 2: ψ holds. . . . <strong>and</strong> θ<br />

follows. Either way, we have θ.” Notice that in the resulting inference, the<br />

hypotheses ϕ <strong>and</strong> ψ are cancelled.<br />

Finally, these are the rules for ↔:<br />

ϕ<br />

ψ<br />

. .<br />

ψ ϕ ↔ I<br />

ϕ ↔ ψ<br />

ϕ ↔ ψ<br />

ψ<br />

ϕ ↔ E1<br />

ϕ<br />

ϕ ↔ ψ<br />

ϕ<br />

ψ<br />

ψ ↔ E2<br />

You should check that if we defined ϕ ↔ ψ to be (ϕ → ψ) ∧ (ψ → ϕ), these<br />

rules could be justified in terms <strong>of</strong> the rules for ∧ <strong>and</strong> →.<br />

There is one more rule that is needed to ensure that we can derive all<br />

the valid propositional formulas. It is reductio ad absurdum, or pro<strong>of</strong> by<br />

contradiction.<br />

¬ϕ<br />

.<br />

⊥<br />

ϕ<br />

Notice that this is different from the negation introduction rule: rather than<br />

assume ϕ in order to prove ¬ϕ, it works the other way around.<br />

There is some legalistic fine print associated with the implication introduction<br />

rule (similar considerations apply to disjunction elimination as<br />

well). Properly stated, the rule should be read as follows: “Given ψ, you are<br />

may conclude ϕ → ψ. Furthermore, if ϕ occurs as a hypothesis, you may<br />

cancel any instances <strong>of</strong> this hypothesis.” Note that you do not need the<br />

hypothesis ϕ to conclude ϕ → ψ; if you know ψ outright, you know ϕ → ψ.<br />

For example, this is a legal pro<strong>of</strong>:<br />

x<br />

ψ<br />

ϕ → ψ<br />

ψ → (ϕ → ψ)<br />

x


1.2. SOME PROPOSITIONAL VALIDITIES 5<br />

1.2 Some propositional validities<br />

Here are some propositional validities:<br />

1. Commutativity <strong>of</strong> ∧: ϕ ∧ ψ ↔ ψ ∧ ϕ<br />

2. Commutativity <strong>of</strong> ∨: ϕ ∨ ψ ↔ ψ ∨ ϕ<br />

3. Associativity <strong>of</strong> ∧: (ϕ ∧ ψ) ∧ θ ↔ ϕ ∧ (ψ ∧ θ)<br />

4. Associativity <strong>of</strong> ∨: (ϕ ∨ ψ) ∨ θ ↔ ϕ ∨ (ψ ∨ θ)<br />

5. Distributivity <strong>of</strong> ∧ over ∨: ϕ ∧ (ψ ∨ θ) ↔ (ϕ ∧ ψ) ∨ (ϕ ∧ θ)<br />

6. Distributivity <strong>of</strong> ∨ over ∧: ϕ ∨ (ψ ∧ θ) ↔ (ϕ ∨ ψ) ∧ (ϕ ∨ θ)<br />

7. (ϕ → (ψ → θ)) ↔ (ϕ ∧ ψ → θ).<br />

8. (ϕ → ψ) → ((ψ → θ) → (ϕ → θ))<br />

9. ((ϕ ∨ ψ) → θ) ↔ (ϕ → θ) ∧ (ψ → θ)<br />

10. ¬(ϕ ∨ ψ) ↔ ¬ϕ ∧ ¬ψ<br />

11. ¬(ϕ ∧ ψ) ↔ ¬ϕ ∨ ¬ψ<br />

12. ¬(ϕ ∧ ¬ϕ)<br />

13. ¬(ϕ → ψ) ↔ ϕ ∧ ¬ψ<br />

14. ¬ϕ → (ϕ → ψ)<br />

15. (¬ϕ ∨ ψ) ↔ (ϕ → ψ)<br />

16. ϕ ∨ ⊥ ↔ ϕ<br />

17. ϕ ∧ ⊥ ↔ ⊥<br />

18. ϕ ∨ ¬ϕ<br />

19. ¬(ϕ ↔ ¬ϕ)<br />

20. (ϕ → ψ) ↔ (¬ψ → ¬ϕ)<br />

21. (ϕ → θ ∨ η) → ((ϕ → θ) ∨ (ϕ → η))<br />

22. (((ϕ → ψ) → ϕ) → ϕ)


6 CHAPTER 1. PROPOSITIONAL LOGIC<br />

There is a simple heuristic for searching for pro<strong>of</strong>s: work backwards from<br />

the goal using introduction rules, <strong>and</strong> work forwards from the hypothesis<br />

using elimination rules, until all the pieces come together. For example,<br />

here is a pro<strong>of</strong> <strong>of</strong> the forward direction <strong>of</strong> (5):<br />

ϕ ∧ (ψ ∨ σ)<br />

ψ ∨ σ<br />

y<br />

y<br />

ϕ ∧ (ψ ∨ σ)<br />

x ϕ ∧ (ψ ∨ σ)<br />

ϕ ψ ϕ σ<br />

x<br />

ϕ ∧ ψ<br />

(ϕ ∧ ψ) ∨ (ϕ ∧ σ)<br />

(ϕ ∧ ψ) ∨ (ϕ ∧ σ)<br />

ϕ ∧ σ<br />

(ϕ ∧ ψ) ∨ (ϕ ∧ σ)<br />

x<br />

(ϕ ∧ (ψ ∨ σ)) → ((ϕ ∧ ψ) ∨ (ϕ ∧ σ))<br />

y<br />

y<br />

Here is a pro<strong>of</strong> <strong>of</strong> the forward direction <strong>of</strong> (7):<br />

ϕ → (ψ → θ)<br />

ψ → θ<br />

y<br />

ϕ ∧ ψ<br />

ϕ<br />

x<br />

θ<br />

ϕ ∧ ψ → θ<br />

x<br />

ϕ ∧ ψ<br />

ψ<br />

(ϕ → (ψ → θ)) → (ϕ ∧ ψ → θ)<br />

x<br />

y<br />

Here is a pro<strong>of</strong> <strong>of</strong> the forward direction <strong>of</strong> (10):<br />

z<br />

¬(ϕ ∨ ψ)<br />

⊥<br />

¬ϕ<br />

x<br />

ϕ<br />

z<br />

ϕ ∨ ψ<br />

¬(ϕ ∨ ψ)<br />

⊥<br />

x<br />

¬ψ<br />

¬ϕ ∧ ¬ψ<br />

z<br />

¬(ϕ ∨ ψ) → ¬ϕ ∧ ¬ψ<br />

y<br />

y<br />

ψ<br />

ϕ ∨ ψ<br />

Here is one more example:<br />

ϕ ¬ϕ<br />

z<br />

⊥<br />

ϕ ∨ ψ ψ<br />

ψ<br />

y<br />

¬ϕ → ψ<br />

ϕ ∨ ψ → (¬ϕ → ψ)<br />

x<br />

y<br />

z<br />

x<br />

ψ x


1.3. PROOF BY CONTRADICTION 7<br />

1.3 Pro<strong>of</strong> by contradiction<br />

Sometimes you follow the heuristic described above, <strong>and</strong> simply get stuck.<br />

In that case, there is one more thing to try: pro<strong>of</strong> by contradiction. That<br />

is, assume the negation <strong>of</strong> what you are trying to prove, <strong>and</strong> show that that<br />

yields a contradiction.<br />

For example, here is a pro<strong>of</strong> <strong>of</strong> the law <strong>of</strong> the excluded middle:<br />

y<br />

¬(ϕ ∨ ¬ϕ)<br />

⊥<br />

x<br />

¬ϕ<br />

ϕ ∨ ¬ϕ<br />

x<br />

ϕ<br />

ϕ ∨ ¬ϕ<br />

⊥<br />

ϕ ∨ ¬ϕ<br />

¬(ϕ ∨ ¬ϕ)<br />

Here is a pro<strong>of</strong> <strong>of</strong> a principle known as “double-negation elimination”:<br />

y<br />

x<br />

¬¬ϕ<br />

y<br />

⊥ x<br />

¬ϕ<br />

x<br />

Here is another example:<br />

ϕ<br />

¬¬ϕ → ϕ<br />

(RAA)<br />

y<br />

¬(ϕ ∧ ¬ψ)<br />

z<br />

y<br />

ϕ ¬ψ<br />

ϕ ∧ ¬ψ<br />

x<br />

⊥ x<br />

(RAA)<br />

y<br />

ψ<br />

ϕ → ψ<br />

¬(ϕ ∧ ¬ψ) → (ϕ → ψ)<br />

z<br />

1.4 Excercises<br />

To get used to natural deduction, try finding natural deduction pro<strong>of</strong>s <strong>of</strong><br />

any or all <strong>of</strong> the following.<br />

1. (ϕ → (ψ → θ)) → (ϕ ∧ ψ → θ).<br />

2. (ϕ ∨ ψ) ∨ θ → ϕ ∨ (ψ ∨ θ)<br />

3. ¬(ϕ → ψ) → ¬ψ


8 CHAPTER 1. PROPOSITIONAL LOGIC<br />

4. ¬(ϕ → ψ) → ϕ<br />

5. (¬ϕ ∨ ψ) ↔ (ϕ → ψ)<br />

6. (ϕ → ψ) ∨ (ψ → ϕ)<br />

7. ((ϕ → ψ) → ϕ) → ϕ)<br />

8. ¬(ϕ ↔ ¬ϕ).<br />

1.5 Pro<strong>of</strong> short cuts<br />

The pro<strong>of</strong>s in the last section can be confusing <strong>and</strong> hard to underst<strong>and</strong>.<br />

It is also <strong>of</strong>ten hard to use negative statements in a hypothesis. In fact, in<br />

informal mathematical argumentation, one <strong>of</strong>ten uses a number <strong>of</strong> additional<br />

tricks to make life easier. All <strong>of</strong> the things I am about to describe can<br />

be justified on the basis <strong>of</strong> the rules presented in Section 1.1, but, strictly<br />

speaking, they are not part <strong>of</strong> the pro<strong>of</strong> rules. One a homework assignment,<br />

if I say “give a natural deduction pro<strong>of</strong> <strong>of</strong> . . . ,” I mean give a pro<strong>of</strong> using the<br />

rules in Section 1.1. On the other h<strong>and</strong>, if I say “you may use the additional<br />

rules <strong>and</strong> equivalences described in the notes,” you may use the tricks I am<br />

about to describe. Notice that many <strong>of</strong> the informal pro<strong>of</strong> strategies in<br />

Velleman’s book rely on tricks like these. You should try to think about<br />

Velleman’s strategies in these terms.<br />

One trick is to use the law <strong>of</strong> the excluded middle: for any formula, one<br />

can prove ϕ ∨ ¬ϕ. So, at any point in a pro<strong>of</strong>, you can reason by cases:<br />

first show that your conclusion follows from ϕ, <strong>and</strong> then show that it follows<br />

from ¬ϕ.<br />

If you have a hypothesis ϕ → ψ, it is sometimes useful to use the following<br />

equivalence:<br />

(ϕ → ψ) ≡ (¬ϕ ∨ ψ).<br />

Once again, this can be proved using the ordinary pro<strong>of</strong> rules, but it isn’t<br />

easy! If you just assume the equivalence, however, it means that you can use<br />

the hypothesis ϕ → ψ be reasoning on cases: if you can show you conclusion<br />

follows from ¬ϕ, <strong>and</strong> also that it follows from ψ, you are done.<br />

Similarly, if you know ϕ ↔ ψ, you know that ϕ <strong>and</strong> ψ are either both<br />

true <strong>of</strong> both false. So once again, you can reason by cases, first assuming<br />

they are both true, then assuming they are both false.


1.6. SEQUENT NOTATION 9<br />

Finally, the following equivalences involving negation can be used to push<br />

a negation sign inwards:<br />

¬¬ϕ ≡ ϕ<br />

¬(ϕ ∧ ψ) ≡ ¬ϕ ∨ ¬ψ<br />

¬(ϕ ∨ ψ) ≡ ¬ϕ ∧ ¬ψ<br />

¬(ϕ → ψ) ≡ ϕ ∧ ¬ψ<br />

¬(ϕ ↔ ψ) ≡ (ϕ ∧ ¬ψ) ∨ (ψ ∧ ¬ϕ).<br />

So, for example, if you know ¬(ϕ∧ψ), you can then reason on cases, assuming<br />

¬ϕ, <strong>and</strong> then ¬ψ.<br />

Finally, it is <strong>of</strong>ten useful to make use <strong>of</strong> the fact that an implication is<br />

equivalent to its contrapositive:<br />

(ϕ → ψ) ≡ (¬ψ → ¬ϕ).<br />

So, to prove ϕ → ψ, you can assume ¬ψ <strong>and</strong> show that ¬ϕ follows. You<br />

should check that this is as essentially the same as assuming ϕ <strong>and</strong> ¬ψ <strong>and</strong><br />

deriving a contradiction, which is another common pro<strong>of</strong> strategy.<br />

The canonical way <strong>of</strong> proving ϕ ↔ ψ is to show that each proves the<br />

other. But it is <strong>of</strong>ten quicker to prove a chain <strong>of</strong> equivalences, say ϕ ↔ θ ↔<br />

η ↔ π ↔ ψ. In other words, one proves, in turn, that each statement is<br />

equivalent to the next, relying implicitly on the transitivity <strong>of</strong> ↔.<br />

1.6 Sequent notation<br />

It will be helpful to have a description <strong>of</strong> natural deduction that keeps<br />

track <strong>of</strong> the open hypotheses at each stage <strong>of</strong> the pro<strong>of</strong>. To do so, let us<br />

express that ϕ follows from the hypotheses in Γ by writing Γ ⇒ ϕ. Such an<br />

expression is sometimes called a sequent.<br />

If Γ is a set <strong>of</strong> formulas <strong>and</strong> ψ is a formula, it is convenient to write Γ, ψ<br />

for Γ ∪ {ψ}; <strong>and</strong>, more generally, it is convenient to leave <strong>of</strong>f curly braces<br />

when listing the elements <strong>of</strong> a finite set. With this new mode <strong>of</strong> presentation,<br />

the natural deduction rules are expressed as follows:


10 CHAPTER 1. PROPOSITIONAL LOGIC<br />

Γ, ϕ ⇒ ϕ<br />

Assumption<br />

Γ ⇒ ϕ Γ ⇒ ψ ∧I<br />

Γ ⇒ ϕ ∧ ψ<br />

Γ ⇒ ϕ 0 ∧ ϕ 1<br />

Γ ⇒ ϕ i<br />

∧E i<br />

Γ ⇒ ϕ i<br />

Γ ⇒ ϕ ∨ ψ Γ, ϕ ⇒ θ Γ, ψ ⇒ θ<br />

∨I i<br />

∨E<br />

Γ ⇒ ϕ 0 ∨ ϕ 1 Γ ⇒ θ<br />

Γ, ϕ ⇒ ψ<br />

Γ ⇒ ϕ → ψ<br />

→I<br />

Γ ⇒ ϕ → ψ<br />

Γ ⇒ ψ<br />

Γ ⇒ ϕ →E<br />

Γ, ¬ϕ ⇒ ⊥ RAA<br />

Γ ⇒ ϕ<br />

One can show that if it is possible to prove Γ ⇒ ϕ then it is possible<br />

to prove Γ ∪ ∆ ⇒ ϕ for any set ∆. This is known as “weakening” the<br />

set <strong>of</strong> hypotheses. In practice, it is more convenient to fold weakening into<br />

the rules by allowing any subset <strong>of</strong> Γ in the hypotheses. For example, the<br />

following pro<strong>of</strong> tree shows that ϕ → (ψ → ϕ ∧ ψ) is provable:<br />

ϕ ⇒ ϕ ψ ⇒ ψ ∧I<br />

ϕ, ψ ⇒ ϕ ∧ ψ<br />

→I<br />

ϕ ⇒ ψ → ϕ ∧ ψ<br />

⇒ ϕ → (ψ → ϕ ∧ ψ)<br />

→I


Chapter 2<br />

Propositional logic in Isabelle<br />

2.1 Using Isabelle<br />

Now let’s start experimenting with Isabelle. If you are sitting at one <strong>of</strong><br />

the machines in the clusters, you should log on to your Andrew account,<br />

<strong>and</strong> start a terminal console within the Xwindows environment. Then type<br />

isabelle emacs to start the system.<br />

First, some generalities. Isabelle is a research-grade pro<strong>of</strong> system, used<br />

by experts to verify computer hardware <strong>and</strong> s<strong>of</strong>tware design as well as to<br />

check complex mathematical pro<strong>of</strong>s. Fortunately, there are a lot <strong>of</strong> places<br />

you can turn to for more information. For example, Isabelle’s “documentation”<br />

web page includes a book-long tutorial introduction. See “course<br />

information” under Blackboard for links <strong>and</strong> references.<br />

Expressions need to be typed into Isabelle following a very precise syntax.<br />

Pay close attention to the format <strong>of</strong> your input, including quotation marks,<br />

parentheses, <strong>and</strong> so on. Use the examples in the example files for guidance.<br />

Notice that conjunction, disjunction, implication, <strong>and</strong> negation are indicates<br />

with the symbols<br />

&, |, ->, ~<br />

respectively. To indicate provability from hypotheses, one uses the sequent<br />

arrow ==>, as in<br />

P & Q ==> Q<br />

For multiple hypotheses, you would write something like<br />

[| P & Q; Q --> R; S |] ==> P & S<br />

11


12 CHAPTER 2. PROPOSITIONAL LOGIC IN ISABELLE<br />

Text between “(*” <strong>and</strong> “*)” are comments, as in:<br />

(* This is a comment.*)<br />

The following sets up a theory in Isabelle:<br />

theory Examples1<br />

imports Main<br />

begin<br />

(* your work goes here *)<br />

end<br />

The first line gives your theory a name (you can pick any name you want, as<br />

long as it does not conflict with a theory name in the library that you use.<br />

The second line imports the main library, meaning that you can use any <strong>of</strong><br />

the facts or concepts defined there. (This is a very large library – see the<br />

Isabelle documentation pages.) Isabelle “theories” are saved in files with<br />

the extension “.thy” It is a good idea to use the same name as the theory.<br />

So, for example, you could save the theory above as “Examples1.thy” Use<br />

the Pro<strong>of</strong> General arrows (below the editor’s menu bar) to process the first<br />

three lines. Once a line has been processed, the editor shades it blue, <strong>and</strong><br />

“freezes” it so that you cannot modify it. Pressing the backwards arrow<br />

“undoes” the comm<strong>and</strong>s, so you can go back to editing them.<br />

Let us work through an intial pro<strong>of</strong>. Start by typing<br />

lemma "P & Q --> Q & P"<br />

<strong>and</strong> use the arrow to process it. You thereby state your intent to prove that<br />

statement. Isabelle responds:<br />

pro<strong>of</strong> (prove): step 0<br />

goal (1 subgoal):<br />

1. P & Q --> Q & P<br />

This tells you that you have one goal to fill. Type<br />

apply (rule impI)<br />

to apply the “implication introduction” rule, <strong>and</strong> the goal becomes:


2.1. USING ISABELLE 13<br />

goal (1 subgoal):<br />

1. P & Q ==> Q & P<br />

If you look carefully, you will notice that the implication arrow became a<br />

sequent arrow. In other words, now you need to prove Q & P from the<br />

hypothesis P & Q. Type<br />

apply (erule conjE)<br />

to use the conjunction elimination rule, <strong>and</strong> the goal becomes<br />

goal (1 subgoal):<br />

1. [| P; Q |] ==> Q & P<br />

indicating that you have to prove Q&P using the two hypotheses P <strong>and</strong> Q.<br />

Type<br />

apply (rule conjI)<br />

to use the conjunction introduction rule<br />

goal (2 subgoals):<br />

1. [| P; Q |] ==> Q<br />

2. [| P; Q |] ==> P<br />

<strong>and</strong> now you have two subgoals, namely, proving P <strong>and</strong> Q, each from hypotheses<br />

P <strong>and</strong> Q. But this is easy; just type<br />

apply assumption<br />

twice, <strong>and</strong> Isabelle declares<br />

goal:<br />

No subgoals!<br />

Type the word<br />

done<br />

to finish the pro<strong>of</strong>. Thus your pro<strong>of</strong> should look like this:<br />

lemma "P & Q --> Q & P"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done


14 CHAPTER 2. PROPOSITIONAL LOGIC IN ISABELLE<br />

Isabelle will let you use the symbol + to repeat a comm<strong>and</strong>. For example, the<br />

last two lines could be abbreviated apply assumption+, which tells Isabelle<br />

to apply the assumption comm<strong>and</strong> until it no longer succeeds.<br />

You may notice that Isabelle has funny conventions for dropping parentheses.<br />

For example, in the expression P & Q & R the parentheses associate<br />

to the right, so the expression is parsed as (P & (Q & R)). If you are ever<br />

in doubt, you can always select the option “show brackets” from the Isabelle/Settings<br />

menu, which displays all the parentheses.<br />

Incidentally, the pro<strong>of</strong> comm<strong>and</strong> sorry is a way <strong>of</strong> cheating: you tell<br />

the system to accept the lemma or theorem without pro<strong>of</strong>. On homework<br />

assignments, we will enter some theorems “sorried out” for you to fill in.<br />

2.2 The propositional rules<br />

We will start using Isabelle with five basic methods, or “tactics,” for building<br />

pro<strong>of</strong>s.<br />

• apply assumption<br />

• apply (rule ...)<br />

• apply (erule ...)<br />

• apply (frule ...)<br />

• apply (drule ...)<br />

Roughly, use the “rule” tactic to apply an introduction rule to the conclusion<br />

<strong>of</strong> a sequent. For example, suppose your goal is a conjunction:<br />

1. [| R; S; T |] ==> P & Q<br />

Typing the comm<strong>and</strong> apply (rule conjI) reduces that to two subgoals,<br />

1. [| R; S; T |] ==> P<br />

2. [| R; S; T |] ==> Q<br />

Try typing the comm<strong>and</strong><br />

thm conjI<br />

to ask Isabelle to show you the contents <strong>of</strong> the “theorem” conjI. Generally<br />

speaking, the “rule” tactic matches the conclusion <strong>of</strong> the theorem to the<br />

conclusion <strong>of</strong> your goal, <strong>and</strong> asks you to prove the antecedents.


2.2. THE PROPOSITIONAL RULES 15<br />

In the other direction, the “frule” tactic allows you to work forwards<br />

from hypotheses. For example, if you type apply (frule conjunct1) with<br />

the goal<br />

1. [| P & Q; R; S |] ==> T<br />

you are left with the goal<br />

1. [| P & Q; R; S; P |] ==> T<br />

In other words, the tactic uses P & Q to add P to the list <strong>of</strong> hypotheses. The<br />

comm<strong>and</strong> apply (drule conjunct1) does almost the same thing, except<br />

that it throws away the hypothesis after using it, leaving you with<br />

1. [| R; S; P |] ==> T<br />

The “erule” tactic is more confusing, because it matches patterns on<br />

both sides <strong>of</strong> the conditional. Rather than explain how it works, let me<br />

just point out the general heuristic that logical rules that end with an “E”<br />

are intended to be used with this tactic (whereas rules that end with “I”<br />

are intended to be used with the rule tactic (in both cases, the “e” st<strong>and</strong>s<br />

for “elimination”. For example, if you type apply (erule conjE) with the<br />

goal<br />

1. [| P & Q; R; S |] ==> T<br />

you are left with the goal<br />

1. [| R; S; P; Q |] ==> T<br />

Here is a list <strong>of</strong> basic comm<strong>and</strong>s you can use to build propositional pro<strong>of</strong>s:<br />

apply assumption<br />

apply (rule conjI)<br />

apply (erule conjE)<br />

apply (frule conjunct1)<br />

apply (frule conjunct2)<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI1)<br />

apply (rule disjI2)<br />

apply (erule disjE)<br />

apply (rule notI)<br />

apply (erule notE)


16 CHAPTER 2. PROPOSITIONAL LOGIC IN ISABELLE<br />

apply (rule iffI)<br />

apply (erule iffE)<br />

apply (rule classical)<br />

apply (rule ccontr)<br />

In class, I will go over this list, <strong>and</strong> explain what each one does. I will also<br />

make sure that the file “Examples1.thy” on Blackboard uses all <strong>of</strong> these, so<br />

you can see them in action: just use the arrow keys in Pro<strong>of</strong> General to step<br />

through the pro<strong>of</strong>s <strong>and</strong> see how the comm<strong>and</strong>s change the current goal.<br />

Here are a few more Isabelle comm<strong>and</strong>s you can try. First, typing<br />

thm conjI<br />

displays the “theorem” conjI as it appears in Isabelle’s library. Isabelle has<br />

a number <strong>of</strong> built in automated reasoners; in particular<br />

apply auto<br />

is strong enough to prove any propositional tautology. This is useful for<br />

debugging a pro<strong>of</strong>; if you have applied some rules <strong>and</strong> think you have arrived<br />

at an unprovable goal, calling auto will determine whether or not the goal<br />

is valid.<br />

Finally, every once in a while issuing a comm<strong>and</strong> may not have the<br />

desired effect. For example, if you type apply (frule conjunct1) <strong>and</strong><br />

there are two conjunctions on the left side <strong>of</strong> the sequent arrow, Isabelle<br />

may exp<strong>and</strong> the wrong one. Typing<br />

back<br />

tells Isabelle to try again.<br />

2.3 Additional pro<strong>of</strong> methods<br />

You will quickly come to learn that doing pro<strong>of</strong>s by contradiction, or using<br />

negative hypotheses, is difficult when you are restricted to low-level pro<strong>of</strong><br />

rules. Fortunately, Isabelle knows most common equivalences. For example,<br />

if you type thm de_Morgan_conj, Isabelle will show you one <strong>of</strong> the de<br />

Morgan laws:<br />

(~ (?P & ?Q)) = (~ ?P | ~ ?Q)<br />

Now you can type:


2.4. REASONING WITH SETS 17<br />

• subst de_Morgan_conj to replace the left-h<strong>and</strong> side by the right-h<strong>and</strong><br />

side in the conclusion <strong>of</strong> a goal<br />

• subst de_Morgan_conj [symmetric] to replace the right-h<strong>and</strong> side<br />

by the left-h<strong>and</strong> side in the conclusion <strong>of</strong> a goal<br />

• subst (asm) de_Morgan_conj to replace the left-h<strong>and</strong> side by the<br />

right-h<strong>and</strong> side in one <strong>of</strong> the hypotheses in a goal<br />

• subst (asm) de_Morgan_conj [symmetric] to replace the right-h<strong>and</strong><br />

side by the left-h<strong>and</strong> side in one <strong>of</strong> the in a goal<br />

The comm<strong>and</strong> subst is short for “substitute.” We will come back to this<br />

rule when we talk about equality in Isabelle. In the meanwhile, you can use<br />

the variants above with any <strong>of</strong> the following identities:<br />

de_Morgan_conj<br />

de_Morgan_disj<br />

not_not<br />

not_imp<br />

imp_conv_disj<br />

Use the thm comm<strong>and</strong> to see what they are.<br />

2.4 Reasoning with sets<br />

Isabelle also knows about sets. For example:<br />

lemma "A - (B Un C) = (A - B) Int (A - C)"<br />

asserts the identify “A \ (B ∪ C) = (A \ B) ∩ (A \ C).” Notice the symbolic<br />

notations for set union, intersection, <strong>and</strong> set difference.<br />

The comm<strong>and</strong><br />

apply (rule set_ext)<br />

yields the goal:<br />

goal (1 subgoal):<br />

1. !!x. (x : A - (B Un C)) = (x : (A - B) Int (A - C))<br />

Here, the notation x : A, for example, means x ∈ A, <strong>and</strong> the equality<br />

symbol is an “iff.” The symbols !!x mean that x is supposed to be arbitrary.<br />

In other words, the comm<strong>and</strong> allows you to prove two sets are identical by


18 CHAPTER 2. PROPOSITIONAL LOGIC IN ISABELLE<br />

picking an arbitrary x, <strong>and</strong> showing that x is an element <strong>of</strong> one side iff it is<br />

an element <strong>of</strong> the other. (In the latest release <strong>of</strong> Isabelle, set_ext has been<br />

renamed set_eqI.)<br />

Use the comm<strong>and</strong>s<br />

apply (subst Diff_iff)<br />

apply (subst Int_iff)<br />

apply (subst Un_iff)<br />

to unfold what it means to be an element <strong>of</strong> a difference, intersection, or<br />

union. For example, if your goal contains x : A Un B, applying the third<br />

comm<strong>and</strong> rewrites the expression to x : A | x : B.<br />

2.5 Completeness<br />

Experimentation may serve to convince you that Isabelle’s rules <strong>and</strong> comm<strong>and</strong>s<br />

are sufficient to prove any tautology. But how can we be sure that<br />

this is the case? That is exactly what a completeness pro<strong>of</strong> is supposed to<br />

establish.<br />

Here I will briefly sketch a pro<strong>of</strong> that any valid sequent is provable,<br />

or, equivalently, that if a sequent is not valid, there is a truth assignment<br />

that makes the hypotheses true but the conclusion false. First, verify that<br />

Isabelle’s rules are enough to show that any sequent Γ ⇒ ϕ is equivalent<br />

to Γ, ¬ϕ ⇒ ⊥, <strong>and</strong> Γ ⇒ ¬ϕ is equivalent to Γ, ϕ ⇒ ⊥. In other words, we<br />

can use Isabelle’s rules to go back <strong>and</strong> forth between the sequents in each<br />

pair. Since Isabelle can also show that ¬¬ϕ is equivalent to ϕ, we never<br />

have to deal with more than one negation at the top level. And the previous<br />

observation means that we can always remove a negation by moving it to<br />

the other side <strong>of</strong> the sequent.<br />

The strategy behind the pro<strong>of</strong> <strong>of</strong> completeness is to show that we can<br />

unwrap all the other connectives until we are reduced to sequents that have<br />

only propositional variables, negations <strong>of</strong> propositional variables, ⊥, <strong>and</strong><br />

⊤. But then it is easy to see that if such a sequent is not provable by the<br />

“assumption” rule, it is not valid.<br />

The following rules let us “unwrap” a connective on the right side <strong>of</strong> a<br />

sequent:<br />

Γ ⇒ ϕ Γ ⇒ ψ<br />

Γ ⇒ ϕ ∧ ψ<br />

Γ¬ϕ, ¬ψ ⇒ ⊥<br />

Γ ⇒ ϕ ∨ ψ


2.5. COMPLETENESS 19<br />

Γ, ϕ ⇒ ψ<br />

Γ ⇒ ϕ → ψ<br />

In other words, in each case Isabelle’s rules allow us to derive the conclusion<br />

from the hypotheses, <strong>and</strong> if the conclusion is not valid, then one <strong>of</strong> the<br />

hypothesis is necessary invalid as well. The following rules to the same for<br />

connectives on the left:<br />

Γ, ϕ, ψ ⇒ θ<br />

Γ, ϕ ∧ ψ ⇒ θ<br />

Γ, ϕ ⇒ θ Γ, ψ ⇒ θ<br />

Γ, ϕ ∨ ψ ⇒ θ<br />

Γ, ¬ϕ ⇒ θ Γ, ψ ⇒ θ<br />

Γ, ϕ → ψ ⇒ θ<br />

We need only iterate this unwrapping, moving formulas from side to side<br />

<strong>of</strong> the sequent as necessary, until all the connectives other than negation<br />

have been eliminated. Some <strong>of</strong> Isabelle’s automated reasoners follow such a<br />

strategy.


20 CHAPTER 2. PROPOSITIONAL LOGIC IN ISABELLE


Chapter 3<br />

Natural deduction for<br />

first-order logic<br />

3.1 Quantifiers in natural deduction<br />

As a model for mathematical reasoning, propositional logic is too limited.<br />

First-order logic does much better in that respect. Remember that one<br />

specifies a first-order language by giving a list <strong>of</strong> function <strong>and</strong> relation symbols<br />

<strong>of</strong> various arities. These determine a set <strong>of</strong> terms, that is, syntactic<br />

expressions that name elements in an intended domain interpretation, <strong>and</strong><br />

formulas, that is, expressions that make assertions about that domain. Also,<br />

keep in mind the distinction between free <strong>and</strong> bound variables. For example,<br />

in the formula ∃y (x = 2 ∗ y), y is a bound variable, but x is free. This is<br />

evidenced that natural-language expressions make it clear that the formula<br />

is about x, but not y, as in “x is twice some number.” You can always<br />

rename a bound variable without changing the meaning <strong>of</strong> a formula, but<br />

never a free one.<br />

I will use notation ϕ(x) to indicate that ϕ is a formula in which x is free<br />

(or, at least, might be free). Then, if t is any term, ϕ(t) denotes the result <strong>of</strong><br />

replacing x by t. For exmaple, if ϕ(x) is the formula in the last paragraph,<br />

then ϕ(z + 1) is ∃y (z + 1 = 2 ∗ y), <strong>and</strong> ϕ(17) is ∃y (17 = 2 ∗ y).<br />

To extend our systems <strong>of</strong> natural deduction to first-order logic, add the<br />

following rules:<br />

ϕ(y)<br />

∀x ϕ(x)<br />

∀I<br />

∀x ϕ(x) ∀E<br />

ϕ(t)<br />

where in the introduction rule, we require that y is not free in any open<br />

hypothesis. Similarly, we have the rules for the existential quantifier:<br />

21


22 CHAPTER 3. FIRST-ORDER LOGIC<br />

ϕ(t)<br />

∃x ϕ(x)<br />

∃I<br />

∃x ϕ(x)<br />

ψ<br />

ϕ(y)<br />

.<br />

ψ ∃E<br />

where again, in the elimination rule, we assume that y is not free in ψ or<br />

any hypothesis other than ϕ(y). The elimination rule exhibits a pattern <strong>of</strong><br />

reasoning that is similar to that <strong>of</strong> disjunction elimination: to show that<br />

ψ holds on assumption ∃x ϕ(x), let y be an “arbitrary” object satisfying<br />

ϕ(y), <strong>and</strong> show that ψ follows. Note that the universal introduction <strong>and</strong><br />

existential elimination rules allow you to rename the quantified variable.<br />

In sequent form, the natural deduction rules are expressed as follows:<br />

Γ ⇒ ϕ(y)<br />

Γ ⇒ ∀x ϕ(x)<br />

∀I<br />

Γ ⇒ ∀x ϕ(x) ∀E<br />

Γ ⇒ ϕ(t)<br />

Γ ⇒ ϕ(t)<br />

Γ ⇒ ∃x ϕ(x) Γ, ϕ(y) ⇒ ψ<br />

∃I<br />

∃E<br />

Γ ⇒ ∃x ϕ(x)<br />

Γ ⇒ ψ<br />

with the same restrictions above.<br />

3.2 Some first-order validities<br />

Once again, let’s consider some valid formulas, <strong>and</strong> examples <strong>of</strong> pro<strong>of</strong>s.<br />

1. ∀x ϕ ↔ ϕ if x is not free in ϕ<br />

2. ∃x ϕ ↔ ϕ if x is not free in ϕ<br />

3. ∀x (ϕ ∧ ψ) ↔ ∀x ϕ ∧ ∀x ψ<br />

4. ∃x (ϕ ∧ ψ) ↔ ∃x ϕ ∧ ψ if x is not free in ψ<br />

5. ∃x (ϕ ∨ ψ) ↔ ∃x ϕ ∨ ∃x ψ<br />

6. ∀x (ϕ ∨ ψ) ↔ ∀x ϕ ∨ ψ if x is not free in ψ<br />

7. ∀x (ϕ → ψ) ↔ (∃x ϕ → ψ) if x is not free in ψ<br />

8. ∃x (ϕ → ψ) ↔ (∀x ϕ → ψ) if x is not free in ψ<br />

9. ∀x (ϕ → ψ) ↔ (ϕ → ∀x ψ) if x is not free in ϕ


3.3. EQUALITY 23<br />

10. ∃x (ϕ → ψ) ↔ (ϕ → ∃x ψ) if x is not free in ψ<br />

11. ∃x ϕ ↔ ¬∀x ¬ϕ<br />

12. ∀x ϕ ↔ ¬∃x ¬ϕ<br />

13. ¬∃x ϕ ↔ ∀x ¬ϕ<br />

14. ¬∀x ϕ ↔ ∃x ¬ϕ<br />

For example, assuming x is not free in ψ, here is a pro<strong>of</strong> <strong>of</strong> the forward<br />

direction <strong>of</strong> (4):<br />

ϕ ∧ ψ<br />

ϕ ϕ ∧ ψ<br />

y ∃x ϕ ψ<br />

∃x (ϕ ∧ ψ)<br />

∃x ϕ ∧ ψ<br />

∃x ϕ ∧ ψ<br />

x<br />

∃x (ϕ ∧ ψ) → ∃x ϕ ∧ ψ<br />

Here is pro<strong>of</strong> <strong>of</strong> the converse direction:<br />

3.3 Equality<br />

∃x ϕ ∧ ψ<br />

∃x ϕ<br />

y<br />

ϕ<br />

x<br />

y<br />

∃x ϕ ∧ ψ<br />

x<br />

ψ<br />

ϕ ∧ ψ<br />

∃x (ϕ ∧ ψ)<br />

x<br />

∃x (ϕ ∧ ψ)<br />

y<br />

∃x ϕ ∧ ψ → ∃x (ϕ ∧ ψ)<br />

The nature <strong>of</strong> the equality relation has traditionally posed a host <strong>of</strong> philosophical<br />

<strong>and</strong> logical puzzles, but at least in the context <strong>of</strong> first-order logic,<br />

the appropriate treatment is straightforward. First, we need to express that<br />

equality is an equivalence relation, namely, it is reflexive, symmetric, <strong>and</strong><br />

transitive; <strong>and</strong>, second, we need to express the fact that one can substitute<br />

equal terms in any term or expression.<br />

t = t<br />

s = t<br />

t = s<br />

¯s = ¯t<br />

r(¯s) = r(¯t)<br />

y<br />

r = s s = t<br />

r = t<br />

¯s = ¯t ϕ(¯s)<br />

ϕ(¯t)<br />

x


24 CHAPTER 3. FIRST-ORDER LOGIC<br />

3.4 First-order theories<br />

There are two ways first-order logic can be used:<br />

• To reason about a particular structure, like the natural numbers, the<br />

real numbers, the universe <strong>of</strong> sets, etc.<br />

• To reason about a class <strong>of</strong> structures, like groups, rings, linear orders,<br />

<strong>and</strong> so on.<br />

Note that there is no theoretical difference between the two: in either case,<br />

one writes down some axioms <strong>and</strong> reasons about their consequences. Eventually,<br />

in class, we will discuss first-order axioms for the following:<br />

• Orderings (partial orders, linear orders, <strong>and</strong> so on).<br />

• Algebraic structures, like groups, rings, <strong>and</strong> fields.<br />

• The natural numbers.<br />

• The real numbers.<br />

3.5 Completeness for first-order logic<br />

Recall that when it came to propositional logic, we had a notion <strong>of</strong> what<br />

it means for a formula to be true under a particular truth assignment to<br />

its variables; we were then able to say that a formula is valid if <strong>and</strong> only if<br />

it is true under all truth assignments. When it comes to first-order logic,<br />

instead <strong>of</strong> truth assignments, we speak <strong>of</strong> models. A first-order sentence is<br />

then said to be valid if it is true in all models. The notion <strong>of</strong> entailment<br />

lifts to first-order logic in a similar way. Just as for propositional logic, one<br />

can show that Isabelle’s first-order rules are complete.<br />

In contrast to first-order logic, however, there is no algorithm that will<br />

decide whether or not a given sentence is valid. There is a “semi-decision<br />

procedure”: given a sentence, one can search systematically for a pro<strong>of</strong><br />

in a first-order deductive calculus. If the sentence is valid, the search will<br />

terminate; but there is no general method for detecting when one should give<br />

up, in situations when the sentence turns out to be invalid. This means, in<br />

particular, that Isabelle’s automated tools can sometimes fall into infinite<br />

searches, in which case, you need to terminate them by h<strong>and</strong>.


Chapter 4<br />

First-order logic in Isabelle<br />

4.1 Quantifiers in Isabelle<br />

In addition to propositional logic, Isabelle can h<strong>and</strong>le first-order logic (<strong>and</strong><br />

much, much more — but more on that later). But Isabelle has a very precise<br />

syntax that may take getting used to. To say that “property P holds <strong>of</strong> x,”<br />

you write P x, <strong>and</strong> do say “relation R holds <strong>of</strong> x <strong>and</strong> y,” you write R x y<br />

without parentheses, both without parentheses. So where, in class, we wrote<br />

in Isabelle you would write<br />

∀x (ϕ(x) ∧ ψ(x)) → ∀x ϕ(x) ∧ ∀x ψ(x),<br />

(ALL x. P x & Q x) --> (ALL x. P x) & (ALL x. Q x)<br />

<strong>and</strong> where we wrote<br />

in Isabelle you would write<br />

∀x ∃y R(x, y)<br />

ALL x. EX y. R x y<br />

Isabelle is smart enough to figure out that P <strong>and</strong> Q are predicates, R is a<br />

binary relation, <strong>and</strong> x <strong>and</strong> y range over some (unspecified) domains. Note<br />

the following differences, though:<br />

• In Isabelle, if an expression depends on a variable, you have to make<br />

it explicit. For example, in class we <strong>of</strong>ten wrote ∀x ϕ where ϕ is a<br />

formula that might have variables other than x free. In the expressions<br />

above, however, the only variable free in P x is x (<strong>and</strong> P, but that’s<br />

another story).<br />

25


26 CHAPTER 4. FIRST-ORDER LOGIC<br />

• Isabelle uses a period to separate the quantifier from the expression.<br />

• In Isabelle, quantifiers are given the widest scope possible, that is,<br />

they are assumed to extend to the end <strong>of</strong> the formula, unless they<br />

are blocked by a parenthesis. In our informal notation, we assumed<br />

just the opposite. So pay close attention to the placement <strong>of</strong> the<br />

parentheses in the example above.<br />

• Isabelle uses the same parentheses-free notation for function application;<br />

for example, you would write f x in Isabelle, where we would<br />

write f(x).<br />

• You can combine quantifiers <strong>and</strong> write, for example, ALL x y z.<br />

x y z instead <strong>of</strong> ALL x. ALL y. ALL z. R x y z.<br />

R<br />

There are four rules you should know regarding the quantifiers:<br />

apply (rule allI)<br />

apply (frule spec) (* or drule *)<br />

apply (rule exI)<br />

apply (erule exE)<br />

For the most part, these do what you would expect, but some comments<br />

are in order. Use rule allI when you are trying to prove something <strong>of</strong> the<br />

form ∀xϕ(x). Isabelle picks a variable, typically x in this example, <strong>and</strong> asks<br />

you to prove ϕ(x).<br />

Use frule spec when you have a hypothesis <strong>of</strong> the form ∀x ϕ(x), <strong>and</strong><br />

you want to use it. In that case, you are allowed to plug in any term you<br />

want. In that case, Isabelle plugs in a placeholder (which can appear as<br />

something cryptic, like ?x7), <strong>and</strong> then will try to figure out the right term<br />

later. If you want to tell Isabelle explicitly what term you want, type, instead<br />

apply (frule_tac x = "t" in spec)<br />

where t is the term you want. Notice that the term appears in quotation<br />

marks (but if it is a variable, let x or y, you can leave them <strong>of</strong>f), frule<br />

has become frule_tac, <strong>and</strong> it is always x on the left side <strong>of</strong> the equality<br />

sign (which refers to the variable in the rule spec). (You can also use the<br />

comm<strong>and</strong> apply (erule allE), which has the same effect as drule spec.)<br />

Similarly, use rule exI to prove something <strong>of</strong> the form ∃x ϕ(x). If you<br />

want to specify the particular term, use<br />

apply (rule_tac x = "t" in exI)


4.2. EQUALITY IN ISABELLE 27<br />

instead. The comm<strong>and</strong> erule exE executes the elimination rule for the<br />

existential quantifier.<br />

Remember that sometimes Isabelle will do the wrong thing where there<br />

is an ambiguity; for example, frule spec might apply to the wrong formula<br />

if there are two universally quantified formulas in the hypotheses. In that<br />

case, you can repeatedly write back to make Isabelle consider the other<br />

possibilities.<br />

In Isabelle, actually, variables can range over different domains, or “types.”<br />

If you do not specify types, Isabelle implicitly leaves them generic. But sometimes<br />

you want to specify that a variable ranges over the natural numbers,<br />

say. You can do that by writing, for example,<br />

ALL (x::nat) y. x + y = y + x<br />

In this case, Isabelle infers that y is supposed to be a natural number, too.<br />

4.2 Equality in Isabelle<br />

Suppose you have an equation s = t as a hypothesis, <strong>and</strong> t occurs in the<br />

conclusion. Typing<br />

apply (erule subst)<br />

replaces t by s. If, instead, you have s in the conclusion, <strong>and</strong> want to replace<br />

it by t, type<br />

apply (erule ssubst)<br />

But Isabelle has a much more versatile equality “rewriting” comm<strong>and</strong>,<br />

subst. The example, the theorem add_commute says x + y = y + x, <strong>and</strong><br />

holds for many important classes <strong>of</strong> types, including the natural numbers.<br />

If you have the expression x + 5 in the conclusion <strong>of</strong> a sequent, typing<br />

apply (subst add_commute)<br />

changes it to 5 + x. Typing<br />

apply (subst add_commute [symmetric])<br />

orients the equation in the other direction, though for add_commute this<br />

doesn’t change it. Typing<br />

apply (subst (asm) add_commute)


28 CHAPTER 4. FIRST-ORDER LOGIC<br />

applies the equation in a hypothesis. You can even specify which instances<br />

to apply the substitution to. For example, if there are three plusses in the<br />

goal, typing<br />

apply (subst (1 3) add_commute)<br />

applies substitution to the first <strong>and</strong> the third. (Sometimes you have to<br />

experiment to figure out what order Isabelle uses for its counting.)<br />

4.3 Using lemmas <strong>and</strong> the library<br />

At this stage, you know enough about Isabelle that you can benefit from<br />

looking at the documentation<br />

http://www.cl.cam.ac.uk/research/hvg/isabelle/documentation.html<br />

on the Isabelle web pages. In particular, the tutorial is very helpful.<br />

One reason the system is so powerful is that any theorem you prove can<br />

become part <strong>of</strong> your own personal “library” that can be used to prove other<br />

theorems. For example, suppose you prove a theorem such as<br />

lemma my_theorem: "P --> P & P"<br />

If you add the phrase [rule_format], as in<br />

lemma my_theorem [rule_format]: "P --> P & P"<br />

the system records it as a sequent implication, P ==> P & P. Henceforth it<br />

becomes a rule you can use: for example, typing<br />

apply (rule my_theorem)<br />

at a goal <strong>of</strong> the form Q & Q reduces the goal to Q. Similarly for identities:<br />

any equation you prove can be used with subst, to your heart’s desire.<br />

The question then becomes this: how do you find useful theorems <strong>and</strong><br />

identities? One answer is to browse the documenation on the web. You can<br />

find the libraries here:<br />

http://www.cl.cam.ac.uk/research/hvg/isabelle/dist/library/HOL/index.html<br />

You can also get to this page from the Isabelle documentation page, by<br />

choosing “Higher-order logic” under “Theory libraries.” Also, Isabelle has<br />

a flexible “find theorems” comm<strong>and</strong>, discussed on page 34 <strong>of</strong> the tutorial.<br />

You call it by choosing “Find theorems” under the “Pro<strong>of</strong> general” menu.


4.4. USING ISABELLE’S AUTOMATED TOOLS 29<br />

4.4 Using Isabelle’s automated tools<br />

After a while, it becomes tedious to fill in every little step <strong>of</strong> a pro<strong>of</strong> in<br />

Isabelle. One thing that makes Isabelle especially powerful is that there are<br />

a number <strong>of</strong> automated reasoning methods that are built in to the system.<br />

For example, a method called auto is a workhorse. You can check that the<br />

comm<strong>and</strong><br />

apply auto<br />

solves all <strong>of</strong> the homework problems <strong>and</strong> examples you have seen so far!<br />

There are other algorithms that work better in different situations. For<br />

example, apply blast sometimes work where apply auto fails.<br />

Isabelle also have a very good “simplifier” which uses identities to try<br />

to rewrite terms <strong>and</strong> expressions into a simpler form. You an invoke it by<br />

typing<br />

apply simp<br />

You can also give the simplifier extra lists <strong>of</strong> rules to use when simplifying<br />

expressions. For example, typing<br />

apply (simp add: algebra_simps)<br />

adds some st<strong>and</strong>ard algebraic simplifications that are <strong>of</strong>ten useful. Typing<br />

apply (simp only: algebra_simps)<br />

tells the simplifier to use only these rules. You can also tell auto to use<br />

additional simplification rules by typing<br />

apply (auto simp add: algebra_simps)<br />

<strong>and</strong> so on.<br />

There is also a built in arithmetic reasoner,<br />

apply arith<br />

that does well on problems involving equalities <strong>and</strong> inequalities on natural<br />

numbers, integers, <strong>and</strong> real numbers.<br />

All <strong>of</strong> these are tools discussed at length in the Isabelle tutorial, at the<br />

end <strong>of</strong> Chapter 5, <strong>and</strong> also at the beginning <strong>of</strong> Chapter 3. In addition, there<br />

are various other tricks that are <strong>of</strong>ten helpful. For example, sometimes you<br />

find yourself in a situtation where you want to break up a pro<strong>of</strong> into two<br />

steps. Typing


30 CHAPTER 4. FIRST-ORDER LOGIC<br />

apply (subgoal_tac "...")<br />

amounts to temporary asserting the formula “. . . .” You are left with two<br />

subgoals: first, you are asked to prove your original goal, using the formula<br />

you have added; then you are asked to prove the formula you have added.


Chapter 5<br />

The natural numbers<br />

5.1 Induction <strong>and</strong> recursion on the natural numbers<br />

Let N be the set <strong>of</strong> natural numbers, with least element 0, <strong>and</strong> let succ(x) =<br />

x + 1 be the successor function. The structure, (N, 0, succ) is characterized<br />

uniquely, up to isomorphism, by the following clauses:<br />

• 0 ≠ succ(x) for any x in N.<br />

• For every x <strong>and</strong> y in N, if x ≠ y, then succ(x) ≠ succ(y). In other<br />

words, s is injective.<br />

• If A is any subset <strong>of</strong> N with the property that 0 is in A <strong>and</strong> whenever<br />

x is in A then succ(x) is in A, then A = N.<br />

The last clause can be reformulated as the principle <strong>of</strong> induction:<br />

Suppose P (x) is any property <strong>of</strong> natural numbers, such that P<br />

holds <strong>of</strong> 0, <strong>and</strong> for every x, P (x) implies P (s(x)). Then every P<br />

holds <strong>of</strong> every natural number.<br />

This principle can be used to justify definitions by primitive recursion:<br />

Let X be any set, a be any element <strong>of</strong> X, <strong>and</strong> let g(n, x) be<br />

any function from N × X to X. Then there is a unique function<br />

f : N → X satisfying the following two clauses:<br />

• f(0) = a<br />

• f(succ(n)) = g(n, f(n)) for every n in N.<br />

31


32 CHAPTER 5. THE NATURAL NUMBERS<br />

For example, one can define addition with the following two clauses:<br />

x + 0 = x<br />

x + succ(y) = succ(x + y)<br />

Having done so, one can define multiplication using the following two clauses:<br />

x · 0 = 0<br />

x · succ(y) = x · y + x<br />

If we write 1 = succ(0), 2 = succ(1), <strong>and</strong> so on, it is easy to prove x + 1 =<br />

succ(x) from the definition <strong>of</strong> addition. One can also define a predecessor<br />

function by<br />

<strong>and</strong> “truncated subtraction” by<br />

p(0) = 0<br />

p(succ(x)) = x,<br />

x . − 0 = 0<br />

x . − (succ(y)) = p(x . − y).<br />

With these definitions <strong>and</strong> the induction principle, <strong>and</strong> can prove all the<br />

following identities:<br />

1. x ≠ 0 → succ(p(x)) = x<br />

2. 0 + x = x<br />

3. succ(x) + y = succ(x + y), where 1 is defined to be succ(0)<br />

4. (x + y) + z = x + (y + z)<br />

5. x + y = y + x<br />

6. x(y + z) = xy + xz<br />

7. 0 · x = 0<br />

8. 1 · x = x<br />

9. (xy)z = x(yz)<br />

10. xy = yx


5.2. THE NATURAL NUMBERS IN ISABELLE 33<br />

I did the first five <strong>of</strong> these in class; you will be asked to do some <strong>of</strong> the others<br />

for homework.<br />

One can proceed to define


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #1<br />

Due Thursday, January 13<br />

1. Get the books <strong>and</strong> s<strong>of</strong>tware required for this course, <strong>and</strong> log on to the<br />

course site on Blackboard.<br />

2. Read the preface <strong>and</strong> introduction to Velleman.<br />

3. Get Tarski’s World running <strong>and</strong> start playing with it. Do exercise 1.1,<br />

which has you submit a test file. Enter “Dan Auerbach” for the instructor,<br />

<strong>and</strong> “dauerbac@<strong>and</strong>rew.cmu.edu” as the e-mail address.<br />

Notice that you do not need to turn anything in this week, other than the<br />

online test.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #2<br />

Due Thursday, January 20<br />

Note: you only need to turn in solutions to problems that are starred. The<br />

other problems are good practice (<strong>and</strong> fair game) for exams.<br />

1. Read Chapter 1 <strong>of</strong> Velleman.<br />

⋆ 2.<br />

⋆ 3.<br />

Do exercise 2.5 on page 12 <strong>of</strong> Tarski’s World, <strong>and</strong> submit it to the Grade<br />

Grinder.<br />

Do exercise 2.6 on page 12 <strong>of</strong> Tarski’s World, <strong>and</strong> submit it to the Grade<br />

Grinder.<br />

4. Do as much <strong>of</strong> exercises 2.7 <strong>and</strong> 2.8 <strong>of</strong> Tarki’s World as you can.<br />

5. Do as many <strong>of</strong> the exercises to Section 1.1 <strong>of</strong> Velleman as you can.<br />

⋆ 6.<br />

Do exercises 7 (a) <strong>and</strong> (b) on page 14 <strong>of</strong> Velleman, by writing out a<br />

truth table <strong>and</strong> determining whether the conclusion <strong>of</strong> the argument is<br />

true whenever the premises are true (as in example 1.2.3 in the text).<br />

Indicate clearly what propositional variables you are using <strong>and</strong> what<br />

they represent. For part (a), since one <strong>of</strong> the premises is that Jane will<br />

win the math prize, you can leave out all the lines <strong>of</strong> the truth table<br />

where that premise is false. For part (b), notice that you only need to<br />

use one propositional variable to determine whether the main course is<br />

fish or beef; <strong>and</strong> similarly for the vegetable.<br />

7. Do as many <strong>of</strong> the exercises to Section 1.2 <strong>of</strong> Velleman as you can.<br />

⋆ 8. Do exercise 6 on page 24.<br />

⋆ 9. Do exercise 12 on page 25.<br />

⋆ 10. Do exercise 13 on page 25.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #2<br />

6. For 7(a), let JM st<strong>and</strong> for “Jane will win the math prize,” P M mean<br />

“Pete will win the math prize,” <strong>and</strong> let JC <strong>and</strong> P C be the corresponding<br />

statements for the chemistry prize. The premises are ¬(JM ∧ P M),<br />

P M ∨ P C, <strong>and</strong> JM, <strong>and</strong> the conclusion is P C. The truth table, leaving<br />

out the lines where JM is false, is as follows:<br />

JM P M JC P C JM ∧ P M ¬(JM ∧ P M) P M ∨ P C<br />

T T T T T F T<br />

T T T F T F T<br />

T T F T T F T<br />

T T F F T F T<br />

T F T T F T T<br />

T F T F F T F<br />

T F F T F T T<br />

T F F F F T F<br />

All three premises are true on the fifth <strong>and</strong> seventh line, <strong>and</strong> on those<br />

lines the conclusion is true as well. So, the inference is valid.<br />

For 7(b), let MB say that the main course will be beef (so ¬MB says<br />

that the main course will be fish), <strong>and</strong> let V P say that the vegetable<br />

will be peas. The first premise is MB ∨ ¬MB, which is always true, so<br />

I will leave it out. Similarly for the second premise. The third premise<br />

is ¬(¬MB ∧ ¬V P ). The conclusion is ¬(MB ∧ V P ). Here is the truth<br />

table:<br />

MB V P ¬MB ¬V P ¬MP ∧ ¬V P ¬(¬MB ∧ ¬V P ) MB ∧ V P ¬(MB ∧ V P )<br />

T T F F F T T F<br />

T F F T F T F T<br />

F T T F F T F T<br />

F F T T T F F T<br />

The third premise is true on the first three lines, but on the first line the<br />

conclusion is false. So the argument is not valid.<br />

8. a. Here is a truth table for n<strong>and</strong>:<br />

P Q P |Q<br />

T T F<br />

T F T<br />

F T T<br />

F F T


. P |Q ≡ ¬(P ∧ Q)<br />

c. ¬P ≡ P |P , P ∧Q ≡ ¬(P |Q) ≡ (P |Q)|(P |Q), <strong>and</strong> P ∨Q ≡ (P |P )|(Q|Q).<br />

9. a.<br />

¬(¬P ∨ Q) ∨ (P ∧ ¬R) ≡ (¬¬P ∧ ¬Q) ∨ (P ∧ ¬R)<br />

≡ (P ∧ ¬Q) ∨ (P ∧ ¬R)<br />

≡ P ∧ (¬Q ∨ ¬R)<br />

≡ P ∧ ¬(Q ∧ R)<br />

b.<br />

(Either <strong>of</strong> the last two lines is fine.)<br />

¬(¬P ∧ Q) ∨ (P ∧ ¬R) ≡ (¬¬P ∨ ¬Q) ∨ (P ∧ ¬R)<br />

≡ P ∨ ¬Q ∨ (P ∧ ¬R)<br />

≡ ¬Q ∨ (P ∨ (P ∧ ¬R))<br />

≡ ¬Q ∨ P<br />

c.<br />

The last step uses the absorption law on page 21.<br />

(P ∧ R) ∨ (¬R ∧ (P ∨ Q)) ≡ (P ∧ R) ∨ (¬R ∧ P ) ∨ (¬R ∧ Q)<br />

≡ ((P ∧ R) ∨ (P ∧ ¬R)) ∨ (¬R ∧ Q)<br />

≡ (P ∧ (R ∨ ¬R)) ∨ (¬R ∧ Q)<br />

≡ (P ∧ T ) ∨ (¬R ∧ Q)<br />

≡ P ∨ (¬R ∧ Q)<br />

10. Assume you know the first DeMorgan law, ¬(P ∧ Q) ≡ ¬P ∨ ¬Q. Then<br />

¬P ∧ ¬Q ≡ ¬¬(¬P ∧ ¬Q) ≡ ¬(¬¬P ∨ ¬¬Q) ≡ ¬(P ∨ Q),<br />

which is just the other DeMorgan law turned around.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #3<br />

Due Thursday, January 27<br />

1. Read Chapter 2 <strong>of</strong> Velleman, <strong>and</strong> start reading Chapter 3.<br />

⋆ 2.<br />

⋆ 3.<br />

Do exercise 2.10 on page 14 <strong>of</strong> Tarski’s World, <strong>and</strong> submit it to the<br />

Grade Grinder.<br />

Do exercise 2.15 on pages 17–18 <strong>of</strong> Tarski’s World, <strong>and</strong> submit it to the<br />

Grade Grinder.<br />

4. Do as much <strong>of</strong> exercises 2.11–2.14 <strong>and</strong> 2.16–2.17 <strong>of</strong> Tarki’s World as you<br />

can.<br />

5. Do as many <strong>of</strong> the exercises to Section 1.3, 1.4, <strong>and</strong> 1.5 <strong>of</strong> Velleman as<br />

you can.<br />

⋆ 6.<br />

Do exercise 4 on page 33. In other words, describe the sets using the<br />

“set-builder” notation we discussed in class.<br />

⋆ 7. Do exercise 6 on page 42.<br />

⋆ 8. Do exercise 7 on page 42.<br />

⋆ 9.<br />

Write ordinary mathematical pro<strong>of</strong>s <strong>of</strong> the identities in the previous two<br />

exercises, as best you can.<br />

⋆ 10. Do exercise 9 on page 42.<br />

⋆ 11. Make sure you are able to run Isabelle, for example, by following the<br />

instructions on the course information sheet <strong>and</strong> h<strong>and</strong>out, “Running<br />

Isabelle in the clusters,” that appear under “Course information” on<br />

Blackboard. If you are successful at typing <strong>and</strong> checking the example<br />

there, simply write “Ran Isabelle” on your homework assignment. If you<br />

have any problems, please let me <strong>and</strong> Dan know, either after class, in<br />

<strong>of</strong>fice hours, or by e-mail.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #3<br />

6. Velleman, exercise 4 on page 33.<br />

a. {x ∈ N | x > 0 <strong>and</strong> x is a perfect square}, or {x ∈ N | x = y 2 for some y > 0}<br />

b. {x ∈ N | x = 2 y for some y}<br />

c. {x ∈ N | 10 ≤ x < 20}<br />

7. Velleman, exercise 6 on page 42. (Draw Venn diagrams.)<br />

8. Velleman, exercise 7 on page 42.<br />

a.<br />

b.<br />

x ∈ (A ∪ B) \ C ≡ (x ∈ A ∪ B) ∧ (x ∉ C)<br />

≡ (x ∈ A ∨ x ∈ B) ∧ (x ∉ C)<br />

≡ (x ∈ A ∧ x ∉ C) ∨ (x ∈ B ∧ x ∉ C)<br />

≡ (x ∈ A \ C) ∨ (x ∈ B \ C)<br />

≡ x ∈ (A \ C) ∪ (B \ C)<br />

x ∈ A ∪ (B \ C) ≡ x ∈ A ∨ (x ∈ B \ C)<br />

≡ x ∈ A ∨ (x ∈ B ∧ x ∉ C)<br />

≡ (x ∈ A ∨ x ∈ B) ∧ (x ∈ A ∨ x ∉ C)<br />

≡ (x ∈ A ∪ B) ∧ ¬(x ∉ A ∧ x ∈ C)<br />

≡ (x ∈ A ∪ B) ∧ (x ∉ C \ A)<br />

≡ x ∈ (A ∪ B) \ (C \ A)<br />

9. a. Suppose x is in (A ∪ B) \ C. Then x is in A ∪ B, but x is not in C.<br />

So x is in A, or x is in B. If x is in A, then x is in A \ C, <strong>and</strong> hence<br />

(A \ C) ∪ (B \ C), as required. On the other h<strong>and</strong>, if x is in B, then<br />

x is in B \ C, <strong>and</strong> hence (A \ C) ∪ (B \ C), as required. So, in either<br />

case, we have the desired conclusion.<br />

For the reverse inclusion, suppose x is in (A \ C) ∪ (B \ C). Then<br />

either x is in A \ C, or x is in B \ C. Consider both cases. If x is in<br />

A \ C, then x is in A but not in C. But then x is in A ∪ B, <strong>and</strong> so in<br />

(A ∪ B) \ C. On the other h<strong>and</strong>, if x is in B \ C, then x is in B but<br />

not C, <strong>and</strong> so x is in (A ∪ B) \ C in that case too.


. Suppose x is in A ∪ (B \ C). Then either x is in A, or x is in B but<br />

not C. Consider both cases. If x is in A, then x is in A ∪ B, but x is<br />

not in C \ A. So x is in (A ∪ B) \ (C \ A), as desired. On the other<br />

h<strong>and</strong>, if x is in B but not C, then again x is in A ∪ B but not C \ A,<br />

which implies that x is in (A ∪ B) \ (C \ A), as desired.<br />

For the reverse inclusion, suppose x is in (A ∪ B) \ (C \ A). Then x<br />

is in A ∪ B, but x is not in C \ A. So x is in A, or x is in B. If x<br />

is in A, then x is in A ∪ (B \ C), as required. So suppose we are in<br />

the other case, i.e., x is in B. Since x is not in C \ A, we know that<br />

either x is not in C, or x is in A. If x is not in C, then x is in B \ C,<br />

<strong>and</strong> so x is in A ∪ (B \ C), as required. On the other h<strong>and</strong>, if x is in<br />

A, then x is in A ∪ (B \ C), as before. So, either way, we have the<br />

desired conclusion.<br />

10. Velleman, exercise 9, page 42. Let A = {1, 2} <strong>and</strong> let B = {2}. Then<br />

(A ∪ B) \ B = {1, 2} \ {2} = {1}, which is not equal to A.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #4<br />

Due Thursday, February 3<br />

1. Continue reading Chapter 3 <strong>of</strong> Velleman. Also read the h<strong>and</strong>out on<br />

natural deduction that I will post early next week.<br />

⋆ 2.<br />

⋆ 3.<br />

Do exercise 3.5 on page 26 <strong>of</strong> Tarski’s World, <strong>and</strong> submit it to the Grade<br />

Grinder.<br />

Do exercise 3.9 on pages 27–28 <strong>of</strong> Tarski’s World, <strong>and</strong> submit it to the<br />

Grade Grinder.<br />

4. Do as as many <strong>of</strong> the other exercises through exercise 3.13 <strong>of</strong> Tarki’s<br />

World as you can.<br />

5. Do as many <strong>of</strong> the exercises to Section 1.5, 2.1, 2.2, <strong>and</strong> 2.3 <strong>of</strong> Velleman<br />

as you can.<br />

⋆ 6.<br />

⋆ 7.<br />

⋆ 8.<br />

⋆ 9.<br />

Do exercise 2 on page 53, explaining the variables that you use. (See<br />

the solutions to problem 1 on 332 for an example.)<br />

Do exercise 5 on page 54, both by writing out the truth table <strong>and</strong> checking<br />

that the two formulas always have the same truth values, <strong>and</strong> using<br />

propositional identities <strong>and</strong> calculating.<br />

Do exercise 3 on page 63. In other words, write down first-order expressions<br />

in a language with all the relevant symbols, assuming the variables<br />

range over real numbers. Don’t forget to indicate the free variables.<br />

Do exercise 2 on page 72. For parts (a) <strong>and</strong> (b), give both a symbolic<br />

expression <strong>and</strong> a natural language expression, as in the solution to part<br />

1 on page 332.<br />

⋆ 10. Do exercise 6 on page 81.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #4<br />

6. Velleman, exercise 2 on page 53.<br />

a. S → P ∧ A, where S is “Mary will sell her house,” P is “Mary can<br />

get a good price,” <strong>and</strong> A is “Mary can find a nice apartment.”<br />

b. M → C ∧ D, where M is “one can get a mortgage,” C is “one has a<br />

good credit history,” <strong>and</strong> D is “one has an adequate down payment.”<br />

c. ¬S → K, where S is “someone stops John” <strong>and</strong> K is “John will kill<br />

himself.”<br />

d. F ∨ S → ¬P where F is “x is divisible by 4,” S is “x is divisible by<br />

6,” <strong>and</strong> P is “x is prime.” (The sentence is better represented using<br />

first-order logic, <strong>and</strong> it is o.k. if you that is what you did.)<br />

7. Velleman, exercise 5 on page 54.<br />

a. The truth table is straightforward. Here is a calculation:<br />

(P ↔ Q) ≡ (P → Q) ∧ (Q → P )<br />

≡ (¬P ∨ Q) ∧ (¬Q ∨ P )<br />

≡ (¬P ∧ (¬Q ∨ P )) ∨ (Q ∧ (¬Q ∨ P ))<br />

≡ (¬P ∧ ¬Q) ∨ (¬P ∧ P ) ∨ (Q ∧ ¬Q) ∨ (Q ∧ P )<br />

≡ (¬P ∧ ¬Q) ∨ (P ∧ Q)<br />

b. Again, the truth table is straightfoward. Here is a calculation:<br />

(P → Q) ∨ (P → R) ≡ (¬P ∨ Q) ∨ (¬P ∨ R)<br />

8. Velleman, exercise 3 on page 63.<br />

a. ∀z (z > x → z > y). x <strong>and</strong> y are free.<br />

≡ ¬P ∨ (Q ∨ R)<br />

≡<br />

(P → Q ∨ R).<br />

b. ∀a (∃x (ax 2 + 4x − 2 = 0) ↔ (a ≥ −2)). There are no free variables.<br />

c. ∀x (x 3 − 3x < 3 → x < 10). There are no free variables.<br />

d. ∃x (x 2 + 5x = w) ∧ ∃y (4 − y 2 = w) → −10 ≤ w ∧ w ≤ 10. w is free.<br />

9. Velleman, exercise 2 on page 72.


a. ∀x (F (x) → R(x)), where F (x) is “x is in the Freshman class” <strong>and</strong><br />

R(x) is “x has a roommate.” “Everyone in the Freshman class has a<br />

roommate.”<br />

b. ∃x ∀y ¬L(x, y) ∨ ∃x ∀y L(x, y), where L(x, y) is “x likes y.” “Either<br />

someone doesn’t like anyone, or someone likes everyone.”<br />

c. ∃a ∈ A ∀b ∈ B ((a ∈ C ∧ b ∉ C) ∨ (b ∈ C ∧ a ∉ C)) (or some variant).<br />

d. ∃y > 0 ∀x (ax 2 + bx + c ≠ y).<br />

10. Velleman, exercise 6 on page 81.<br />

a. A 2 = {2, 3, 1, 4}, A 3 = {3, 4, 2, 6}, A 4 = {4, 5, 3, 8}, <strong>and</strong> A 5 =<br />

{5, 6, 4, 10}<br />

⋂<br />

b.<br />

i∈I A i = {4}, ⋃ i∈I A i = {1, 2, 3, 4, 5, 6, 8, 10}.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #5<br />

Due Thursday, February 10<br />

⋆ 3.<br />

⋆ 4.<br />

⋆ 5.<br />

1. Finish reading Chapter 3 <strong>of</strong> Velleman.<br />

2. Read the h<strong>and</strong>out “Natural deduction for propositional logic” that is<br />

posted on Blackboard, under “Course documents.”<br />

Do exercise 3.19 on page 34 <strong>of</strong> Tarski’s World, <strong>and</strong> submit it to the<br />

Grade Grinder.<br />

Do exercise 3.25 on page 36 <strong>of</strong> Tarski’s World, <strong>and</strong> submit it to the<br />

Grade Grinder.<br />

Do exercise 3.26 on page 36 <strong>of</strong> Tarski’s World, <strong>and</strong> submit it to the<br />

Grade Grinder.<br />

6. Do as as many <strong>of</strong> the other exercises through exercise 3.26 <strong>of</strong> Tarki’s<br />

World as you can. (This will be the last assignment that uses it.)<br />

7. Do as many <strong>of</strong> the exercises to Sections 3.1-3.2 <strong>and</strong> 3.4-3.5 <strong>of</strong> Velleman<br />

as you can.<br />

⋆ 8. Do exercise 4 on page 106 <strong>of</strong> Velleman. Give an ordinary, informal<br />

pro<strong>of</strong>. Note that this means using clear, grammatically correct English<br />

sentences, <strong>and</strong> avoiding logical symbols! This is the form in which mathematical<br />

arguments are written, <strong>and</strong> you will be graded accordingly.<br />

⋆ 9.<br />

Do exercise 19 on page 134 <strong>of</strong> Velleman. Again, give an ordinary, informal<br />

pro<strong>of</strong>. (Hints: since saying that two sets are not disjoint means<br />

that there is an element that is in both <strong>of</strong> them, it may be easier to<br />

prove that the first statement is false iff the second statement is false.<br />

Remember that if F is a family <strong>of</strong> sets, saying x ∈ ⋃ F means that x is<br />

in A for some set A ∈ F.)<br />

⋆ 10. Give a natural deduction pro<strong>of</strong> <strong>of</strong> ¬(¬p ∧ q) from the hypothesis p.<br />

⋆ 11. Give a natural deduction pro<strong>of</strong> <strong>of</strong> p ∨ (q ∧ r) → ((p ∨ q) ∧ (p ∨ r)).<br />

⋆ 12. Give a natural deduction pro<strong>of</strong> <strong>of</strong> s from p → s <strong>and</strong> ¬p → s. (Hint:<br />

you can derive p ∨ ¬p first, as we did in class, <strong>and</strong> use that. For a more<br />

direct pro<strong>of</strong>, try a pro<strong>of</strong> by contradiction.)<br />

⋆ 13. Give a natural deduction pro<strong>of</strong> <strong>of</strong> ¬p ∧ ¬s from p → q, ¬(q ∧ r), r, <strong>and</strong><br />

s → p.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #5<br />

8. Velleman, exercise 4 on page 106. Suppose A \ B is disjoint from C <strong>and</strong><br />

x ∈ A. Prove that if x ∈ C then x ∈ B.<br />

Pro<strong>of</strong>. Suppose A \ B is disjoint from C <strong>and</strong> x is in A, <strong>and</strong> suppose x is<br />

in C. If x is in not in B, then x is in A \ B, which contradicts the fact<br />

that A \ B is disjoint from C. So x is in B.<br />

7. Velleman, exercise 19 on page 134. Suppose F <strong>and</strong> G are families <strong>of</strong> sets.<br />

Prove that ⋃ F <strong>and</strong> ⋃ G are disjoint iff for all A ∈ F <strong>and</strong> B ∈ G, A <strong>and</strong><br />

B are disjoint.<br />

10.<br />

Pro<strong>of</strong>. Suppose the second statement is false. Then for some A ∈ F<br />

<strong>and</strong> B ∈ G, A <strong>and</strong> B are not disjoint. That means that there is some<br />

element, x, in both A <strong>and</strong> B. But then x is in ⋃ F <strong>and</strong> ⋃ G, so the first<br />

statement is false as well.<br />

Conversely, suppose the first statement is false. Then there is an element,<br />

x, in both ⋃ F <strong>and</strong> ⋃ G. But x ∈ ⋃ F means that x is in A for some A<br />

in F, <strong>and</strong> x ∈ ⋃ G means that x is in B for some B in G. This means<br />

that A <strong>and</strong> B are not disjoint, so the second statement is false as well.<br />

11.<br />

x<br />

¬p ∧ q<br />

¬p p<br />

⊥<br />

¬(¬p ∧ q)<br />

x<br />

p ∨ (q ∧ r)<br />

q ∧ r q ∧ r<br />

x<br />

x<br />

p p q r<br />

p ∨ q p ∨ r (p ∨ q) (p ∨ r)<br />

y<br />

(p ∨ q) ∧ (p ∨ r) (p ∨ q) ∧ (p ∨ r)<br />

x<br />

(p ∨ q) ∧ (p ∨ r)<br />

y<br />

p ∨ (q ∧ r) → (p ∨ q) ∧ (p ∨ r)<br />

x<br />

x


12. As suggested by the hints, one solution is to use the pro<strong>of</strong> <strong>of</strong> p ∨ ¬p<br />

on page 7 <strong>of</strong> the notes “Natural deduction for propositional logic,” <strong>and</strong><br />

proceed as follows:<br />

13.<br />

p ∨ ¬p<br />

Here is a more direct pro<strong>of</strong>:<br />

¬s<br />

y<br />

p → s<br />

s<br />

s<br />

¬p → s<br />

⊥ y<br />

s<br />

s<br />

p<br />

¬s<br />

x<br />

y<br />

¬p → s<br />

s x<br />

p → s<br />

s<br />

⊥<br />

¬p x<br />

¬p<br />

p<br />

x<br />

x<br />

¬(q ∧ r)<br />

p → q<br />

q<br />

⊥<br />

¬p<br />

x<br />

p<br />

x<br />

q ∧ r<br />

r<br />

¬p ∧ ¬s<br />

¬(q ∧ r)<br />

p → q<br />

⊥<br />

¬s<br />

x<br />

q<br />

s → p s<br />

p<br />

q ∧ r<br />

x<br />

r


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #6<br />

Due Thursday, February 17<br />

1. Start reading Chapter 6 <strong>of</strong> Velleman. (We will come back to Chapter 4<br />

<strong>and</strong> 5 afterwards.)<br />

2. Read the h<strong>and</strong>out “Propositional logic in Isabelle” that is posted on<br />

Blackboard, under “Course documents.”<br />

⋆ 3.<br />

Page 18 in Velleman considers the following argument:<br />

The butler <strong>and</strong> the cook are not both innocent.<br />

Either the butler is lying or the cook is innocent.<br />

Therefore, the butler is either lying or guilty.<br />

Using letters B for “the butler is innocent,” C for “the cook is innocent,”<br />

<strong>and</strong> L for “the butler is lying,“ formalize this inference <strong>and</strong> give a natural<br />

deduction pro<strong>of</strong> to establish its validity. (In the pro<strong>of</strong>, the first two<br />

lines should be uncancelled hypotheses, <strong>and</strong> the third line should be the<br />

conclusion.)<br />

⋆ 4.<br />

⋆ 5.<br />

⋆ 6.<br />

Give a natural deduction pro<strong>of</strong> <strong>of</strong> ((ϕ ∨ ψ) → θ) → (ϕ → θ) ∧ (ψ → θ).<br />

Give a natural deduction pro<strong>of</strong> <strong>of</strong> ϕ → ψ from ¬(ϕ ∧ ¬ψ).<br />

For this part <strong>of</strong> the assignment, you need to verify some propositional<br />

logic pro<strong>of</strong>s using Isabelle. The instructions below assume you are using<br />

Isabelle in one <strong>of</strong> the clusters. If you are using another installation,<br />

adapt them accordingly.<br />

• Open a browser window, find “homework6.thy” under “Homework<br />

assignments” on blackboard, <strong>and</strong> save it to a directory, e.g. your<br />

home directory.<br />

• Open up a terminal window (via Applications -> Accessories -><br />

Terminal), <strong>and</strong> from that directory type<br />

isabelle emacs homework6.thy<br />

to open the file. (In Unix, you can type ls to list directories, <strong>and</strong><br />

cd [directory-name] to change directory. Typing cd alone puts<br />

you in your home directory.)


• Complete the pro<strong>of</strong>s in the file, following the instructions in the<br />

comments.<br />

• Save the file <strong>and</strong> exit Isabelle.<br />

• Rename the file to homework6_[your-last-name].thy. For example,<br />

at the terminal window, type<br />

mv homework6.thy homework6_smith.thy<br />

• Mail the file to Dan, at dauerbac@<strong>and</strong>rew.cmu.edu. For example,<br />

you can open a browser <strong>and</strong> use gmail or go to my.cmu.edu <strong>and</strong><br />

use web mail. Make sure you put “isabelle homework6 [your-lastname]”<br />

in the subject line <strong>and</strong> make sure you attach the renamed<br />

file.<br />

⋆ 7.<br />

⋆ 8.<br />

Do exercise 13 on page 144 <strong>of</strong> Velleman, giving an ordinary, informal<br />

pro<strong>of</strong>.<br />

Do exercise 19 on page 144 <strong>of</strong> Velleman. Again, give an ordinary, informal<br />

pro<strong>of</strong>. Keep in mind that, by definition, A△B = (A \ B) ∪ (B \ A).


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #6<br />

3. Use the letters B, C, <strong>and</strong> L as in the text.<br />

4.<br />

5.<br />

L ∨ C<br />

B C<br />

¬(B ∧ C) B ∧ C<br />

x<br />

⊥ y<br />

L<br />

¬B<br />

L ∨ ¬B<br />

L ∨ ¬B x<br />

L ∨ ¬B<br />

ϕ<br />

z<br />

z<br />

(ϕ ∨ ψ) → θ ϕ ∨ ψ (ϕ ∨ ψ) → θ<br />

θ<br />

x<br />

θ<br />

ϕ → θ<br />

ψ → θ<br />

(ϕ → θ) ∧ (ψ → θ)<br />

((ϕ ∨ ψ) → θ) → (ϕ → θ) ∧ (ψ → θ)<br />

¬(ϕ ∧ ¬ψ)<br />

x<br />

y<br />

ϕ ¬ψ<br />

ϕ ∧ ¬ψ<br />

z<br />

y<br />

y<br />

z<br />

x<br />

y<br />

ψ<br />

ϕ ∨ ψ<br />

⊥ z<br />

ψ<br />

ϕ → ψ<br />

y<br />

7. Prove that for every integer x, x 2 + x is even.<br />

Let x be any integer. If x is even, then x 2 is also even, <strong>and</strong> x 2 + x is<br />

even. If x is odd, then x 2 is odd, <strong>and</strong> again x 2 + x is even. Either way,<br />

x 2 + x is even.<br />

(This pro<strong>of</strong> presupposes the fact that if x is even, then x 2 is even, <strong>and</strong><br />

similarly for x odd. If you spelled out the pro<strong>of</strong> in greater detail, e.g. by<br />

writing x as 2k in the first case <strong>and</strong> 2k + 1 in the second case, that is<br />

even better. You could also prove the theorem by factoring x 2 + x as<br />

x(x + 1) <strong>and</strong> again splitting on cases.)


8. Suppose A, B, <strong>and</strong> C are sets. Show that A△B <strong>and</strong> C are disjoint iff<br />

A ∩ C = B ∩ C.<br />

Suppose A△B <strong>and</strong> C are disjoint. Let x be an element <strong>of</strong> A ∩ C. Then<br />

x is in both A <strong>and</strong> C. If x is not in B, then x is in A△B, contradicting<br />

the fact that A△B <strong>and</strong> C are disjoint. So x is in B, <strong>and</strong> hence in B ∩ C.<br />

Conversely, if x is in B ∩ C, a similar argument shows that x is in A ∩ C.<br />

Since x was arbitrary, we have A ∩ C = B ∩ C.<br />

In the other direction, suppose A ∩ C = B ∩ C, but A△B <strong>and</strong> C are<br />

not disjoint. Let x be an element <strong>of</strong> both A△B <strong>and</strong> C. Then either x<br />

is in A \ B, or x is in B \ A. If x is in A \ B, then x is in A but not<br />

B; but then x is in A ∩ C but not B ∩ C, contradicting the hypothesis.<br />

Similarly, if x is in B \ A, then x is in B ∩ C but not A ∩ C, again a<br />

contradiction. So A△B <strong>and</strong> C are disjoint.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #7<br />

Due Thursday, February 24<br />

1. Remember that there is an in-class midterm on Thursday, March 3.<br />

2. Finish reading Chapter 6 <strong>of</strong> Velleman.<br />

3. Read the h<strong>and</strong>out “Natural deduction for first-order logic” that is posted<br />

on Blackboard, under “Course documents.”<br />

⋆ 4.<br />

Using Isabelle, carry out the instructions in “homework7.thy” under<br />

“Homework assignments” on Blackboard. Follow the same instructions<br />

as last week:<br />

• Save the file to a directory, e.g. your home directory.<br />

• Run Isabelle by typing isabelle emacs homework7.thy<br />

• Complete the pro<strong>of</strong>s in the file, following the instructions in the<br />

comments.<br />

• Save the file <strong>and</strong> exit Isabelle.<br />

• Rename the file to homework7_[your-last-name].thy. For example,<br />

at the terminal window, type<br />

mv homework7.thy homework7_smith.thy<br />

• E-mail the file to Dan, at dauerbac@<strong>and</strong>rew.cmu.edu, with “isabelle<br />

homework7 [your-last-name]” in the subject line.<br />

⋆ 5.<br />

Give natural deduction pro<strong>of</strong>s <strong>of</strong> the following:<br />

• ∀x ϕ(x) ∨ ∀x ψ(x) → ∀x (ϕ(x) ∨ ψ(x))<br />

• ∀x ϕ(x) → ¬∃x ¬ϕ(x)<br />

⋆ 6.<br />

Formalize the following statements, <strong>and</strong> give a natural deduction pro<strong>of</strong><br />

in which the first three statements appear as (uncancelled) hypotheses,<br />

<strong>and</strong> the last line is the conclusion:<br />

Every young <strong>and</strong> healthy person likes baseball.<br />

Every active person is healthy.<br />

Someone is young <strong>and</strong> active.<br />

Therefore, someone likes baseball.


Use Y (x) for “is young,” H(x) for “is healthy,” A(x) for “is active,” <strong>and</strong><br />

B(x) for “likes baseball.<br />

⋆ 7.<br />

⋆ 8.<br />

Do exercise 4 on page 265 <strong>of</strong> Velleman, giving an ordinary, informal<br />

pro<strong>of</strong>. As usual, style counts.<br />

Do exercise 11 on page 266 <strong>of</strong> Velleman. (Hint: in the inductive step,<br />

rewrite 4 n+1 as 4(4 n + 6n − 1) − 24n + 4, in order to use the inductive<br />

hypothesis.)


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #7<br />

5. a.<br />

b.<br />

∀x ϕ(x) ∨ ∀x ψ(x)<br />

a<br />

∀x ϕ(x)<br />

ϕ(y)<br />

ϕ(y) ∨ ψ(y)<br />

∀x (ϕ(x) ∨ ψ(x))<br />

∀x (ϕ(x) ∨ ψ(x))<br />

∀x ϕ(x) ∨ ∀x ψ(x) → ∀x (ϕ(x) ∨ ψ(x))<br />

b<br />

b<br />

∀x ψ(x)<br />

ψ(y)<br />

ϕ(y) ∨ ψ(y)<br />

∀x (ϕ(x) ∨ ψ(x))<br />

b<br />

a<br />

6.<br />

¬ϕ(y)<br />

b<br />

∃x ¬ϕ(x)<br />

⊥<br />

b<br />

¬∃x ¬ϕ(x)<br />

∀x ϕ(x) → ¬∃x ¬ϕ(x)<br />

c<br />

⊥<br />

c<br />

a<br />

∀x ϕ(x)<br />

ϕ(y)<br />

a<br />

∃x (Y (x) ∧ A(x))<br />

∀x (Y (x) ∧ H(x) → B(x))<br />

Y (z) ∧ H(z) → B(z)<br />

∃x B(x)<br />

Y (z) ∧ A(z)<br />

Y (z)<br />

B(z)<br />

∃x B(x)<br />

a<br />

∀x (A(x) → H(x))<br />

a<br />

A(z) → H(z)<br />

H(z)<br />

Y (z) ∧ H(z)<br />

Y (z) ∧ A(z)<br />

A(z)<br />

a<br />

7. Claim: For every n ≥ 1, 1 + 3 + 5 + . . . + (2n − 1) = n 2 .<br />

Pro<strong>of</strong>: by induction on n. In the base case, when n = 1, <strong>and</strong> both sides<br />

are equal to 1. Assuming the claim is true <strong>of</strong> n, we have<br />

1 + . . . + (2(n + 1) − 1) = (1 + . . . + (2n − 1)) + 2n + 1<br />

= n 2 + 2n + 1<br />

= (n + 1) 2 .


8. Claim: for every n ≥ 1, 9|(4 n + 6n − 1).<br />

Pro<strong>of</strong>: by induction on n. In the base case, when n = 0, 4 n +6n−1 = 0,<br />

which is divisible by 9.<br />

In the induction step, suppose the claim is true for n. Then<br />

4 n+1 + 6(n + 1) − 1 = (4(4 n + 6n − 1) − 24n + 4) + 6n + 5<br />

= 4(4 n + 6n − 1) − 18n + 9.<br />

By the inductive hypothesis, the first term is divisible by 9, <strong>and</strong> 18n <strong>and</strong><br />

9 are clearly both divisible by 9.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #8<br />

Due Thursday, March 17<br />

Notice that this assignment is not due until after spring break.<br />

1. Study for the in-class midterm on Thursday, March 3. It will cover all<br />

the material we discuss in class through Tuesday, March 1, including<br />

Chapters 1–3 <strong>and</strong> 6 <strong>of</strong> Velleman, as well as natural deduction for propositional<br />

logic <strong>and</strong> first-order logic with equality. (Note that we did not<br />

cover section 6.5 in Velleman.)<br />

2. Start reading Chapter 4 <strong>of</strong> Velleman. Also read the h<strong>and</strong>out, “Firstorder<br />

logic in Isabelle,” that is posted on Blackboard, under “Course<br />

documents.”<br />

⋆ 3.<br />

Remember that both the following express ∃!x ϕ(x), that is, the statment<br />

that there is a unique x satisfying ϕ(x):<br />

• ∃x (ϕ(x) ∧ ∀y (ϕ(y) → y = x))<br />

• ∃x ϕ(x) ∧ ∀y ∀y ′ (ϕ(y) ∧ ϕ(y ′ ) → y = y ′ )<br />

Do the following:<br />

a. Give a natural deduction pro<strong>of</strong> <strong>of</strong> the second, assuming the first as a<br />

hypothesis.<br />

b. Give a natural deduction pro<strong>of</strong> <strong>of</strong> the first, asssuming the second as<br />

a hypothesis.<br />

(Warning: these are long.)<br />

⋆ 4.<br />

Using Isabelle, carry out the instructions in “homework8.thy” under<br />

“Homework assignments” on Blackboard. Follow the same instructions<br />

in previous weeks week:<br />

• Save the file to a directory, e.g. your home directory.<br />

• Run Isabelle by typing isabelle emacs homework8.thy<br />

• Complete the pro<strong>of</strong>s in the file, following the instructions in the<br />

comments.<br />

• Save the file <strong>and</strong> exit Isabelle.


• Rename the file to homework8_[your-last-name].thy. For example,<br />

at the terminal window, type<br />

mv homework8.thy homework8_smith.thy<br />

• E-mail the file to Dan, at dauerbac@<strong>and</strong>rew.cmu.edu, with “isabelle<br />

homework8 [your-last-name]” in the subject line.<br />

5. Do as many exercises in Sections 6.1–6.4 <strong>of</strong> Velleman as you can.<br />

⋆ 6.<br />

⋆ 7.<br />

⋆ 8.<br />

Do exercise 9 on page 287 <strong>of</strong> Velleman.<br />

Do exercise 10 on page 287 <strong>of</strong> Velleman.<br />

Do exercise 4 on page 296 <strong>of</strong> Velleman.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #8<br />

3. a.<br />

a<br />

ϕ(z) ∧ ∀y (ϕ(y) → y = z)<br />

ϕ(z)<br />

(∗)<br />

∃x ϕ(x)<br />

∀y ∀y ′ (ϕ(y) ∧ ϕ(y ′ ) → y = y ′ )<br />

∃x (ϕ(x) ∧ ∀y (ϕ(y) → y = x))<br />

∃x ϕ(x) ∧ ∀y ∀y ′ (ϕ(y) ∧ ϕ(y ′ ) → y = y ′ )<br />

a<br />

∃x ϕ(x) ∧ ∀y ∀y ′ (ϕ(y) ∧ ϕ(y ′ ) → y = y ′ )<br />

where (∗) is the pro<strong>of</strong><br />

ϕ(z) ∧ ∀y (ϕ(y) → y = z)<br />

ϕ(z) ∧ ∀y (ϕ(y) → y = z)<br />

a<br />

b<br />

ϕ(y) ∧ ϕ(y ′ )<br />

∀y (ϕ(y) → y = z)<br />

ϕ(y) ∧ ϕ(y ′ )<br />

ϕ(y)<br />

b<br />

∀y (ϕ(y) → y = z)<br />

ϕ(y) → y = z<br />

y = z<br />

ϕ(y ′ )<br />

ϕ(y ′ ) → y ′ = z<br />

y ′ = z<br />

z = y ′<br />

y = y ′<br />

b<br />

ϕ(y) ∧ ϕ(y ′ ) → y = y ′<br />

∀y ′ (ϕ(y) ∧ ϕ(y ′ ) → y = y ′ )<br />

∀y ∀y ′ (ϕ(y) ∧ ϕ(y ′ ) → y = y ′ )<br />

b. Let θ be the formula ∃x ϕ(x) ∧ ∀y ∀y ′ (ϕ(y) ∧ ϕ(y ′ ) → y = y ′ ).<br />

a<br />

θ<br />

∃x ϕ(x)<br />

ϕ(x)<br />

x<br />

θ<br />

∀y, y ′ (ϕ(y) ∧ ϕ(y ′ ) → y = y ′ )<br />

ϕ(y) ∧ ϕ(x) → y = x<br />

y = x<br />

ϕ(x) ∧ ∀y (ϕ(y) → y = x)<br />

∃x (ϕ(x) ∧ ∀y (ϕ(y) → y = x))<br />

∃x (ϕ(x) ∧ ∀y (ϕ(y) → y = x))<br />

ϕ(y) → y = x<br />

∀y (ϕ(y) → y = x)<br />

x<br />

ϕ(y)<br />

y<br />

y<br />

ϕ(y) ∧ ϕ(x)<br />

ϕ(x)<br />

x<br />

6. Claim: For every n ≥ 2, ∑ n−1<br />

k=1 H k = nH n − n.<br />

Pro<strong>of</strong>. First notice that for every n, H n+1 = H n + 1<br />

n+1 , so H n = H n+1 −<br />

1<br />

n+1<br />

. Now use induction on n. In the base case, when n = 2, we have<br />

∑ 2−1<br />

k=1 H k = H 1 = 1, <strong>and</strong> 2H 2 − 2 = 2(1 + 1/2) − 2 = 3 − 2 = 1, so the<br />

identity holds.


In the inductive step, suppose the claim is true for n. Then we have<br />

as required.<br />

n∑<br />

H k =<br />

k=1<br />

n−1<br />

∑<br />

H k + H n<br />

k=1<br />

= nH n − n + H n by the IH<br />

= (n + 1)H n − n<br />

= (n + 1)(H n+1 − 1<br />

n + 1 ) − n<br />

= (n + 1)H n+1 − 1 − n<br />

= (n + 1)H n+1 − (n + 1),<br />

7. Claim: For every n ≥ 1, ∑ n<br />

i=1<br />

i · i! = (n + 1)! − 1.<br />

Pro<strong>of</strong>: Use induction on n. When n = 1, both sides are equal to 1.<br />

In the induction step, suppose the claim is true for n. Then we have<br />

n+1<br />

∑<br />

i · i! =<br />

i=1<br />

n∑<br />

i · i! + (n + 1) · (n + 1)!<br />

i=1<br />

= (n + 1)! − 1 + (n + 1) · (n + 1)!<br />

= (1 + n + 1) · (n + 1)! − 1<br />

= (n + 2)! − 1.<br />

8. Let us use complete induction to show that for every n ≥ 12, n can be<br />

obtained by adding multiplies <strong>of</strong> 3 <strong>and</strong> 7.<br />

First, notice that we have 12 = 4·3, 13 = 7·1+2·3, <strong>and</strong> 14 = 7+7. If n<br />

is greater than or equal to 15, the inductive hypothesis implies that n−3<br />

can be obtained by adding multiples <strong>of</strong> 3 <strong>and</strong> 7. Since n = (n − 3) + 3,<br />

can can be obtained that way as well.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #9<br />

Due Thursday, March 24<br />

1. Continue reading Chapter 4 <strong>of</strong> Velleman. Also read the h<strong>and</strong>out, “The<br />

natural numbers,” which is posted on Blackboard, under “Course documents.”<br />

⋆ 2.<br />

Using Isabelle, carry out the instructions in “homework9.thy” under<br />

“Homework assignments” on Blackboard. Follow the same instructions<br />

as in previous weeks:<br />

• Save the file to a directory, e.g. your home directory.<br />

• Run Isabelle by typing isabelle emacs homework9.thy<br />

• Complete the pro<strong>of</strong>s in the file, save the file, <strong>and</strong> exit Isabelle.<br />

• Rename the file to homework9_[your-last-name].thy. For example,<br />

at the terminal window, type<br />

mv homework9.thy homework9_smith.thy<br />

• E-mail the file to Dan, at dauerbac@<strong>and</strong>rew.cmu.edu, with “isabelle<br />

homework9 [your-last-name]” in the subject line.<br />

⋆ 3.<br />

⋆ 4.<br />

⋆ 5.<br />

⋆ 6.<br />

Do problem 7(a) on page 296 <strong>of</strong> Velleman.<br />

In class, we gave recursive definitions <strong>of</strong> operations like addition <strong>and</strong><br />

multiplication on the natural numbers, <strong>and</strong> then showed how to define<br />

relations like


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #9<br />

3. Remember F 0 = 0 <strong>and</strong> F 1 = 1. Use complete induction on n. In the<br />

base case, we have F m−1 F 0 + F m F 1 = F m−1 · 0 + F m · 1 = F m .<br />

In the induction step, suppose the formula holds for m <strong>and</strong> all n ′ less<br />

than n + 1, <strong>and</strong> let us show that the claim holds <strong>of</strong> m <strong>and</strong> n + 1. We<br />

have<br />

F m+(n+1) = F m+n + F m+(n−1)<br />

as required.<br />

= (F m−1 F n + F m F n+1 ) + (F m−1 F n−1 + F m F n ) by the IH<br />

= F m−1 (F n + F n−1 ) + F m (F n+1 + F n )<br />

= F m−1 F n+1 + F m F n+2 ,<br />

4. a. ∀x (x ≥ 1 → ∃y (Prime(y) ∧ x ≤ y ∧ y ≤ 2 · x))<br />

b. ∃w, y, z (Prime(w) ∧ Prime(y) ∧ Prime(z) ∧ w|x ∧ y|x ∧ z|x ∧ w ≠<br />

y ∧ w ≠ z ∧ y ≠ z)<br />

c. ∀y (Prime(y) ∧ y|x → y = 2)<br />

5. Fix x <strong>and</strong> y, <strong>and</strong> use induction on z. In the base case, we have<br />

x · (y + 0) = x · y<br />

by the definition <strong>of</strong> addition<br />

= x · y + 0 by the definition <strong>of</strong> addition<br />

= x · y + x · 0 by the definition <strong>of</strong> multiplication<br />

In the inductive step, assume x · (y + z) = x · y + x · z. Then<br />

x · (y + succ(z)) = x · succ(y + z) def +<br />

= x · (y + z) + x def ·<br />

= (x · y + x · z) + x IH<br />

= x · y + (x · z + x) associativity<br />

= x · y + x · succ(z) def ·


6. Fix x <strong>and</strong> y <strong>and</strong> use induction on z. In the base case, we have<br />

x · (y · 0) = x · 0<br />

= 0<br />

= (x · y) · 0.<br />

In the inductive step, we have<br />

x · (y · succ(z)) = x · (y · z + y)<br />

= x · (y · z) + x · y by the previous problem<br />

= (x · y) · z + x · y by the IH<br />

= (x · y) · succ(z).


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #10<br />

Due Thursday, March 31<br />

Note: for the problems on this assignment, other than 3, you should be<br />

giving ordinary mathematical pro<strong>of</strong>s, not symbolic calculations. That means<br />

that you should be using words rather than symbols for logical connectives,<br />

<strong>and</strong> using clear, readable, mathematical language.<br />

1. Finish reading Chapter 4 <strong>of</strong> Velleman, <strong>and</strong> start reading Chapter 5.<br />

2. Do as many exercises from Sections 4.1–4.4 as you can.<br />

⋆ 3.<br />

⋆ 4.<br />

⋆ 5.<br />

⋆ 6.<br />

⋆ 7.<br />

⋆ 8.<br />

Do the following:<br />

a. Prove 0 · x = 0.<br />

b. Prove succ(x) · y = x · y + y by induction on y. (This is tricky.)<br />

c. Prove x · y = y · x.<br />

Use only the definitions <strong>of</strong> addition <strong>and</strong> multiplication <strong>and</strong> other facts<br />

proved in class <strong>and</strong> on the last homework assignment. (In other words,<br />

you may use the definition <strong>and</strong> properties 1–6 <strong>and</strong> 9 on the h<strong>and</strong>out,<br />

“The natural numbers.”)<br />

Do problem 9 on page 171 <strong>of</strong> Velleman.<br />

Do problem 6(d) on page 179 <strong>of</strong> Velleman.<br />

Do problem 14 on page 187 <strong>of</strong> Velleman.<br />

Do problem 2 on page 199 <strong>of</strong> Velleman.<br />

Do problem 6 on page <strong>211</strong> <strong>of</strong> Velleman.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #10<br />

3. a. Prove 0 · x = 0 by induction on x. When x = 0, we have 0 · 0 = 0 by<br />

the definition <strong>of</strong> multiplication. In the successor case, we have<br />

0 · succ(x) = 0 · x + 0<br />

= 0 + 0<br />

= 0.<br />

b. Prove succ(x) · y = x · y + y by induction on y. When y = 0, both<br />

sides are equal to 0 by the definition <strong>of</strong> multiplication <strong>and</strong> addition.<br />

In the successor case, we have<br />

succ(x) · succ(y) = succ(x) · y + succ(x)<br />

= (x · y + y) + succ(x)<br />

= x · y + (y + succ(x))<br />

= x · y + (succ(y + x))<br />

= x · y + (succ(x + y))<br />

= x · y + (x + succ(y))<br />

= (x · y + x) + succ(y)<br />

= x · succ(y) + succ(y)<br />

c. Prove x · y = y · x by induction on x. In the base case, we have<br />

0 · y = 0 = 0 · y by the first part. In the induction step, we have<br />

succ(x) · y = x · y + y<br />

= y · x + y<br />

= y · succ(x).<br />

4. Show (A × B) \ (C × D) = (A × (B \ D)) ∪ ((A \ C) × B).<br />

Let A, B, C, <strong>and</strong> D be arbitrary sets. Suppose p is in (A×B)\(C ×D).<br />

Then p is in A × B, but not in C × D. This means that p is a pair,<br />

(a, b), where a is in A <strong>and</strong> b is in B, but (a, b) is not in C × D. This last<br />

assertion means that either a is not in C, or b is not in D. In the first<br />

case, (a, b) is in (A \ C) × B, <strong>and</strong> in the second case, it is in A × (B \ D).<br />

So (a, b) is in (A × (B \ D)) ∪ ((A \ C) × B).


Conversely, suppose p is in (A × (B \ D)) ∪ ((A \ C) × B). Then either<br />

p is in (A × (B \ D)) or p is in ((A \ C) × B). In the first case, p is a<br />

pair (a, b), where a is in A <strong>and</strong> b is in B but not D. In the second case,<br />

p is a pair (a, b), where a is in A but not C, <strong>and</strong> b is in B. Either way,<br />

p is in A × B, but p is not in C × D. Thus p is in (A × B) \ (C × D), as<br />

required.<br />

5. Show (S ◦ R) −1 = S −1 ◦ R −1 .<br />

Suppose (x, y) is in (S ◦ R) −1 . Then (y, x) is in S ◦ R. This means that<br />

for some z, (y, z) is in S, <strong>and</strong> (z, x) is in R. But that means that (x, z)<br />

is in R −1 <strong>and</strong> (z, y) is in S −1 , so (x, y) is in S −1 ◦ R −1 .<br />

Conversely, suppose (x, y) is in S −1 ◦ R −1 . Then for some z, (x, z) is in<br />

S −1 <strong>and</strong> (z, y) is in R −1 , which means that (y, z) is in R <strong>and</strong> (z, x) is in<br />

S. This means that (y, x) is in R ◦ S, <strong>and</strong> so (x, y) is in (R ◦ S) −1 .<br />

6. Suppose R 1 <strong>and</strong> R 2 are relations on A.<br />

a. If R 1 <strong>and</strong> R 2 are both reflexive, so is R 1 ∩ R 2 . To prove this, let x<br />

be any element <strong>of</strong> A. Then (x, x) is in both R 1 <strong>and</strong> R 2 , <strong>and</strong> so in<br />

R 1 ∩ R 2 .<br />

b. If R 1 <strong>and</strong> R 2 are both symmetric, so is R 1 ∩ R 2 . To prove this,<br />

suppose (x, y) is an element <strong>of</strong> R 1 ∩ R 2 . Then it is an element <strong>of</strong><br />

both R 1 <strong>and</strong> R 2 . Since R 1 <strong>and</strong> R 2 are both symmetric, (y, x) is an<br />

element <strong>of</strong> both as well. So (y, x) is an element <strong>of</strong> R 1 ∩ R 2 .<br />

c. If R 1 <strong>and</strong> R 2 are both transitive, so is R 1 ∩R 2 . To prove this, suppose<br />

(x, y) <strong>and</strong> (y, z) are in R 1 ∩ R 2 . Then they are in both R 1 <strong>and</strong> R 2 .<br />

Since R 1 <strong>and</strong> R 2 are transitive, (x, z) is an element <strong>of</strong> both, <strong>and</strong><br />

hence it is an element <strong>of</strong> R 1 ∩ R 2 .<br />

7. a. This is a total order (the order that words appear in the dictionary).<br />

b. This is not a partial order, because anti-symmetry fails: “bat” <strong>and</strong><br />

“big” are related to one another both ways, but are not the same.<br />

c. This is a total order, assuming no two countries have exactly the same<br />

population. (If there are two countries with the same population, it<br />

is not a partial order).<br />

8. a. pSq means that p is an ancestor <strong>of</strong> q.<br />

b. p(S ◦ S −1 )q means that p <strong>and</strong> q have a common descendent.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #11<br />

Due Thursday, April 7<br />

1. Finish reading Chapter 5 <strong>of</strong> Velleman, <strong>and</strong> start reading Chapter 7.<br />

2. Do as many exercises from Chapter 4 <strong>and</strong> 5 as you can.<br />

⋆ 3.<br />

Using Isabelle, carry out the instructions in “homework11.thy” under<br />

“Homework assignments” on Blackboard. Follow the same instructions<br />

as in previous weeks:<br />

• Save the file to a directory, e.g. your home directory.<br />

• Run Isabelle by typing isabelle emacs homework11.thy<br />

• Complete the pro<strong>of</strong>s in the file, save the file, <strong>and</strong> exit Isabelle.<br />

• Rename the file to homework11_[your-last-name].thy. For example,<br />

at the terminal window, type<br />

mv homework11.thy homework11_smith.thy<br />

• E-mail the file to Dan, at dauerbac@<strong>and</strong>rew.cmu.edu, with “isabelle<br />

homework11 [your-last-name]” in the subject line.<br />

The additional Isabelle file, “orders.thy,” posted with the homework<br />

assignment is simply for reference <strong>and</strong> enjoyment. (It contains formal<br />

versions <strong>of</strong> the next two exercises.)<br />

⋆ 4.<br />

Suppose ≤ is a partial order on a set A, <strong>and</strong> define another order,


trans(≤) a ≤ b b ≤ c<br />

a ≤ c<br />

Also, to unfold the definition <strong>of</strong>


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #11<br />

4. To show < is transitive, suppose a < b <strong>and</strong> b < c. Then a ≤ b, a ≠ b,<br />

b ≤ c, <strong>and</strong> b ≠ c. Since ≤ is transitive, we have a ≤ c. Thus it suffices<br />

to show a ≠ c, since this implies a < c.<br />

To that end, suppose a = c. Then from the assumptions we have c ≤ b<br />

<strong>and</strong> b ≤ c, <strong>and</strong> antisymmetry implies b = c. But this contradicts the<br />

fact that b ≠ c. So a ≠ c, as required.<br />

5. Given a <strong>and</strong> b, we need to show that either a < b, a = b, or b < a. If<br />

a = b, then we are done. So we can assume a ≠ b. Since ≤ is a total<br />

order, we have a ≤ b or b ≤ a. In the first case, since a ≠ b, we have<br />

a < b. In the second case, similarly, we have b < a. So either way, one<br />

<strong>of</strong> a < b, a = b, or b < a holds.<br />

6. By the usual natural deduction rules, it suffices to prove a < c from<br />

a < b <strong>and</strong> b < c.<br />

trans(≤)<br />

a < b<br />

a ≤ b<br />

a ≤ c<br />

b < c<br />

b ≤ c<br />

antisym(≤)<br />

a < c<br />

7. Suppose R 1 <strong>and</strong> R 2 are partial orders on a set A.<br />

b < c<br />

b ≤ c<br />

c = b<br />

b = c<br />

u<br />

a = c<br />

c ≤ b<br />

⊥<br />

a ≠ c<br />

a < b<br />

a ≤ b<br />

a. Let S = R 1 ∩R 2 . Then S is also a partial order. Pro<strong>of</strong>: For every a in<br />

A, aR 1 a <strong>and</strong> aR 2 a, so aSa. So S is reflexive. Suppose aSb <strong>and</strong> bSc.<br />

Then aR 1 b, aR 2 b, bR 1 c, <strong>and</strong> bR 2 c. By the transitivity <strong>of</strong> R 1 <strong>and</strong> R 2 ,<br />

aR 1 c <strong>and</strong> aR 2 c, so aSc. So S is transitive. Finally, suppose aSb <strong>and</strong><br />

bSa. Then, in particular, aR 1 b <strong>and</strong> bR 1 a. Since R 1 is antisymmetric,<br />

a = b. So S is antisymmetric.<br />

b. R 1 ∪ R 2 need not be a partial order. For example, suppose R 1 is ≤<br />

<strong>and</strong> R 2 is ≥ on the natural numbers, <strong>and</strong> let T = R 1 ∪ R 2 . Then<br />

0T 1 <strong>and</strong> 1T 0, but 0 ≠ 1. So T is not antisymmetric.<br />

u<br />

b < c<br />

b ≠ c


8. a. Show S is an equivalence relation on B. Let a, b, <strong>and</strong> c be any<br />

elements <strong>of</strong> B. Then aSa, because aRa. So S is reflexive. If aSb then<br />

aRb, <strong>and</strong> by the symmetry <strong>of</strong> R, we have bRa. Since (b, a) ∈ B × B,<br />

we have bSa. So S is symmetric. Finally, suppose aSb <strong>and</strong> bSc. The<br />

transitivity <strong>of</strong> R implies aRc, <strong>and</strong> since (a, c) is in B × B, we have<br />

aSc. So S is symmetric.<br />

b. Show that if x is in B, [x] S = [x] R ∩ B. Suppose y is in [x] S . Then<br />

xSy. By definition, xRy, <strong>and</strong> (x, y) is in B × B. This implies y is in<br />

B, so y is in [x] R ∩ B.<br />

Conversely, suppose y is in [x] R ∩ B. Then xRy <strong>and</strong> y is in B. But<br />

then (x, y) is in B × B, so xSy.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #12<br />

Due Tuesday, April 19<br />

Notice that this assignment is due on a Tuesday, after Carnival. Late assignments<br />

will be accepted until noon on Wednesday.<br />

1. We have now completed Chapters 1–6 <strong>of</strong> Velleman, excluding sections<br />

5.4 <strong>and</strong> 6.5. Read the two excerpts from Enderton’s book, Set Theory,<br />

titled “Axioms” <strong>and</strong> “The natural numbers.” These are posted under<br />

“Course documents” on Blackboard. Then read Chapter 7 <strong>of</strong> Velleman.<br />

2. Do as many exercises from Chapter 5 <strong>of</strong> Velleman as you can.<br />

⋆ 3.<br />

⋆ 4.<br />

⋆ 5.<br />

⋆ 6.<br />

⋆ 7.<br />

⋆ 8.<br />

⋆ 9.<br />

Do parts (b) <strong>and</strong> (c) <strong>of</strong> exercise 16 on page 224 <strong>of</strong> Velleman. (Part (a)<br />

is easy <strong>and</strong> just tedious.)<br />

Do exercise 14 on page 235 <strong>of</strong> Velleman.<br />

Do exercise 15 on page 235 <strong>of</strong> Velleman.<br />

Do exercise 6 on page 253 <strong>of</strong> Velleman.<br />

Do exercise 12 on page 254 <strong>of</strong> Velleman.<br />

Remember that the formal language <strong>of</strong> set theory contains only the<br />

symbol ∈, where x ∈ y represents “x is an element <strong>of</strong> y.” In addition,<br />

the language has all the symbols <strong>of</strong> first-order logic, including equality,<br />

logical connectives, <strong>and</strong> quantifiers. In class we saw that in this language<br />

one can define new notions. For example, we can define “x = {y}” to<br />

mean ∀z (z ∈ x ↔ z = y). In a similar way, write down formulas in the<br />

language <strong>of</strong> set theory to represent all <strong>of</strong> the following notions:<br />

a. x = y \ z<br />

b. x = ⋃ y<br />

c. x is nonempty<br />

d. x has exactly two elements<br />

e. x consists <strong>of</strong> all the nonempty subsets <strong>of</strong> y<br />

In class we defined the ordered pair 〈x, y〉 to be the set {{x}, {x, y}}.<br />

Prove that if 〈x, y〉 = 〈w, z〉 then x = w <strong>and</strong> y = z. (Hint: you should<br />

consider two cases, one where x = y, <strong>and</strong> the other where x ≠ y.)


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #12<br />

3. Suppose R is an equivalence relation on A, S is an equivalence relation<br />

on B, <strong>and</strong> A <strong>and</strong> B are disjoint.<br />

a. (not required)<br />

b. Suppose x ∈ A. Then for any y if y is in [x] R , then (x, y) ∈ R, <strong>and</strong><br />

so (x, y) ∈ R ∪ S. But this implies y ∈ [x] R∪S . Conversely, if y is in<br />

[x] R∪S , then (x, y) ∈ R or (x, y) ∈ S. But since S is a relation on B<br />

<strong>and</strong> A <strong>and</strong> B are disjoint, (x, y) can’t be in S, so (x, y) is in R. So<br />

y ∈ [x] R . The corresponding claim for S is proved in the same way.<br />

c. Suppose X ∈ (A∪B)/(R∪S). Then for some x in A∪B, X = [x] R∪S .<br />

But then x ∈ R or x ∈ S, so the previous part implies X = [x] R or<br />

X = [x] S , so X ∈ A/R or X ∈ A/S. Conversely, if X ∈ A/R,<br />

then X = [x] R = [x] R∪S for some x in A, <strong>and</strong> hence in A ∪ B. So<br />

X ∈ A ∪ B/R ∪ S. If X ∈ B/S, the argument is similar.<br />

4. Suppose A is a nonempty set, <strong>and</strong> f : A → A.<br />

a. Suppose for every x in A, f(x) = a. Then for all x in A, (f ◦ g)(x) =<br />

f(g(x)) = a = f(x).<br />

b. Conversely, suppose for every g : A → A, f ◦ g = f. Let a be any<br />

element <strong>of</strong> a, <strong>and</strong> let g be the constant function g(x) = a. Suppose<br />

f = f ◦ g. Then for every x, f(x) = (f ◦ g)(x) = f(g(x)) = f(a). So<br />

f is the constant function with value f(a).<br />

5. With the definitions in this problem, we have fRg is <strong>and</strong> only if there<br />

is some a such that for every x ≥ a, f(x) = g(x).<br />

a. For every x ≥ 0, f(x) = |x| = x = g(x), so fRg.<br />

b. To see that R is an equivalence relation, first show it is reflexive: for<br />

any x ≥ 0, f(x) = f(x). (Anything would work in place <strong>of</strong> 0.) If is<br />

symmetric: if f(x) = g(x) for every x ≥ a, then g(x) = f(x) for every<br />

x ≥ a. Finally, let us show it is transitive. Suppose f(x) = g(x) for<br />

every x ≥ a, <strong>and</strong> let g(x) = h(x) for every x ≥ b. Let c = max(a, b).<br />

Then for every x ≥ c, f(x) = g(x) <strong>and</strong> g(x) = h(x), so for every<br />

x ≥ c, f(x) = h(x).<br />

6. Let f(x) = 3x<br />

x−2 .


a. f(x) can never be 3, since otherwise we would have 3x − 6 = 3x, a<br />

contradiction. f is injective <strong>and</strong> surjective as a function from R to<br />

R \ {3}. To show that it is injective, suppose f(x) = f(x ′ ). Crossmultiplying,<br />

we have 3xx ′ − 6x = 3x ′ x − 6x ′ , which implies 6x = 6x ′<br />

<strong>and</strong> so x = x ′ . To show that it is surjective, suppose y is not equal<br />

to 3. Then an easy calculation shows y = f(2y/(y − 3)).<br />

b. The previous calculation shows f −1 (y) = 2y<br />

y−3 .<br />

7. Given f : A → B injective, let B ′ = rangef. Then f : A → B ′ is<br />

injective <strong>and</strong> surjective, <strong>and</strong> so, by Theorem 5.3.4, f −1 : B ′ → A.<br />

8.<br />

a. ∀w (w ∈ x ↔ w ∈ y ∧ w ∉ z).<br />

b. ∀w (w ∈ x ↔ ∃u ∈ y (w ∈ u)).<br />

c. ∃w (w ∈ x).<br />

d. ∀y, z (y ≠ z ∧ ∀w (w ∈ x ↔ w = y ∨ w = z).<br />

e. ∀w (w ∈ x ↔ w ⊆ y ∧ ∃u (u ∈ w)), where w ⊆ y means ∀v (v ∈ w →<br />

v ∈ y).<br />

9. Suppose (x, y) = (w, z). I need to show that x = y <strong>and</strong> w = z.<br />

Case 1: x = y. Then (x, y) is a set containing a single element, {x}.<br />

Since (x, y) = (w, z), the right h<strong>and</strong> side is also a set with a single<br />

element, {x}. But this can only happen if w = z (because otherwise<br />

(w, z) contains two elements) <strong>and</strong> so (w, z) is a set with a single element<br />

{w}. But if {x} = {w} then x must be equal to w.<br />

Case 2: x ≠ y. Then (x, y) is a set containing two elements: a oneelement<br />

set {x} <strong>and</strong> a two-element set {x, y}. Since (x, y) = (w, z), the<br />

latter also has two elements, {w} <strong>and</strong> {w, z}. So w ≠ z, {x} = {w}, <strong>and</strong><br />

{x, y} = {w, z}. But this shows that x = w <strong>and</strong> y = z.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Homework #13<br />

Due Tuesday, April 26<br />

This is the last homework assignment! Note the following:<br />

• Class is cancelled on Thursday, April 28.<br />

• This assignment is due Tuesday, April 26, the last day <strong>of</strong> class. (As<br />

usual, we’ll accept late assignments until noon the next day.)<br />

• The final exam will be on Friday, May 6, from 1 to 3 pm.<br />

• Dan <strong>and</strong> I will hold extra <strong>of</strong>fice hours for review before the exam (we’ll<br />

announce them on Blackboard).<br />

1. Finish reading Chapter 7 <strong>of</strong> Velleman’s book, <strong>and</strong> read the excerpt,<br />

“Construction <strong>of</strong> the Real Numbers,” from Enderton.<br />

2. Do as many exercises as you can from Sections 7.1 <strong>and</strong> 7.2 <strong>of</strong> Velleman.<br />

⋆ 3.<br />

⋆ 4.<br />

⋆ 5.<br />

Let R be an equivalence relation on A. Explain how the axioms <strong>of</strong> set<br />

theory (as listed in class, or in the “Axioms” chapter <strong>of</strong> Enderton) imply<br />

the following:<br />

a. For every a ∈ A, the set [a] R exists.<br />

b. The set A/R exists.<br />

Remember that we defined the successor <strong>of</strong> x, succ(x), to be x ∪ {x}.<br />

(Enderton writes this as x + .) A set A is said to be inductive if ∅ is in<br />

A, <strong>and</strong> whenever a set x is in A, succ(x) is in A. The axiom <strong>of</strong> infinity<br />

says that there is an inductive set. We then define the natural numbers,<br />

N, to be the intersection <strong>of</strong> all inductive sets. This means that for any<br />

set x, x is in N if <strong>and</strong> only if x is in every inductive set.<br />

a. Show that N is inductive.<br />

b. Show that if A is inductive <strong>and</strong> A ⊆ N, then A = N.<br />

To exercise 5 on page 312 <strong>of</strong> Velleman. This is tricky. Given that f is a<br />

bijection from A to B, define an explicit function from P (A) to P (B),<br />

<strong>and</strong> prove that it is a bijection.


⋆ 6.<br />

⋆ 7.<br />

Do exercise 6(a) on page 312 <strong>of</strong> Velleman. (You can use the pro<strong>of</strong> in the<br />

appendix, but then you should also prove that the function g defined<br />

there is one-to-one <strong>and</strong> onto. It helps to draw a picture.)<br />

Do exercise 3 on page 321 <strong>of</strong> Velleman.


<strong>80</strong>-<strong>211</strong> <strong>Logic</strong> <strong>and</strong> <strong>Mathematical</strong> <strong>Inquiry</strong> Spring 2011<br />

Solutions to Homework #13<br />

3. a. [a] R = {x ∈ A | (a, x) ∈ R}, so this set exists by the subset axiom.<br />

b. A/R = {y ∈ P (A) | ∃a ∈ A (y = [a] R )}, so this set exists by the<br />

power set axiom <strong>and</strong> the subset axiom.<br />

4. a. Show N is inductive. 0 is in N, because 0 is in every inductive set.<br />

To show that N is closed under sucessor, suppose x is in N. Then if<br />

A is any inductive set, x is in A. Since A is inductive, succ(x) is in<br />

A. Thus succ(x) is in N as well.<br />

b. Suppose A is inductive. Then every element <strong>of</strong> N is in A, so N ⊆ A.<br />

Since we are assuming A ⊆ N, A = N.<br />

5. Given a bijection f from A to B, define g : P (A) → P (B) by g(X) =<br />

{f(x) | x ∈ X}. Let us show that this is a bijection.<br />

To show g is injective, suppose g(X) = g(Y ). Let x be in X. Then<br />

f(x) is in g(X), <strong>and</strong> so f(x) is in g(Y ). This means that f(x) = f(y)<br />

for some y in Y . But f is injective, so x = y. So x is in Y . The same<br />

argument shows that every element <strong>of</strong> Y is in X, so X = Y , as required.<br />

To show g is surjective, let Y be any subset <strong>of</strong> B. Let X = {f −1 (y) | y ∈<br />

Y }. Then g(X) = {f(f −1 (y)) | y ∈ Y } = {y | y ∈ Y } = Y , as required.<br />

6. Use the pro<strong>of</strong> on page 365 in the textbook. To see that g is injective,<br />

let i <strong>and</strong> i ′ be any elements <strong>of</strong> I n , <strong>and</strong> suppose g(i) = g(i ′ ). If neither i<br />

nor i ′ is equal to j, then f(i) = f(i ′ ), which implies i = i ′ , because f is<br />

injective. Suppose i = j. Then g(i) = k. Since i ′ is in I n , we can’t have<br />

f(i ′ ) = k, because f(n + 1) = k <strong>and</strong> f is injective. So i ′ must be equal<br />

to j as well.<br />

To see that g is surjective, let y be any element <strong>of</strong> I m−1 . Since f is<br />

surjective, there is an x in I n+1 such that f(x) = y. If y is not equal to<br />

k, then x is not equal to n + 1, so x is in I n <strong>and</strong> g(x) = y. If y is equal<br />

to k, then g(j) = y. Either way, there is an element x <strong>of</strong> I n such that<br />

g(x) = y.<br />

7. Show that the set <strong>of</strong> finite subsets <strong>of</strong> Z + is countable. For every n ∈ Z + ,<br />

the set S n <strong>of</strong> subsets <strong>of</strong> {0, . . . , n} is finite (with 2 n+1 elements), <strong>and</strong><br />

hence countable. By Theorem 7.2.2, ⋃ S n is countable. Every finite<br />

subset <strong>of</strong> Z + is in S n for some n, so we are done.


LOGIC AND MATHEMATICAL INQUIRY<br />

Midterm Exam<br />

Name:<br />

March 3, 2011<br />

Write your answers in the space provided, using the back <strong>of</strong> the page if necessary.<br />

You can use additional scratch paper. Justify your answers, <strong>and</strong> provide clear,<br />

readable explanations.<br />

Problem Points Score<br />

1 6<br />

2 10<br />

3 10<br />

4 10<br />

5 8<br />

6 10<br />

7 10<br />

Total 64<br />

GOOD LUCK


Problem 1. (6 points)<br />

Use calculations with propositional logic to simplify the expression<br />

¬(p ∧ ¬q) ∨ (¬p ∧ q).


Problem 2. (10 points)<br />

Consider the following inference:<br />

• Either John isn’t stupid <strong>and</strong> he is lazy, or he is stupid.<br />

• John is stupid.<br />

• Therefore, John isn’t lazy.<br />

Part a) (3 points) Represent this inference in propositional logic, using the variables<br />

S for “John is stupid” <strong>and</strong> L for “John is lazy.”<br />

Part b) (4 points) What does it mean to say that a propositional inference is<br />

valid? (Be clear <strong>and</strong> precise.)<br />

Part c) (3 points) Determine whether the inference above is valid, <strong>and</strong> justify<br />

your answer.


Problem 3. (10 points)<br />

Part a) (5 points) Write down a first-order sentence expressing:<br />

Everyone who lives in Pittsburgh knows someone who lives in California.<br />

Use the predicate symbols C(x) <strong>and</strong> P (x) for “lives in California,” <strong>and</strong> “lives in<br />

Pittsburgh,” respectively, <strong>and</strong> the relation symbol K(x, y) for “x knows y.” Also,<br />

assume that quantifiers <strong>and</strong> variables range over people.<br />

Part b) (5 points) Using the language <strong>of</strong> Tarski’s World, write down a first-order<br />

sentence that is true <strong>of</strong> a world exactly when there is a large cube between two<br />

tetrahedra, one <strong>of</strong> which is small.


Problem 4. (10 points)<br />

Give a clear, readable, pro<strong>of</strong> <strong>of</strong> the following identity: A\(B∩C) = (A\B)∪(A\C).


Problem 5. (8 points)<br />

Let F <strong>and</strong> G be families <strong>of</strong> sets. Show that if F ⊆ G, then ⋂ G ⊆ ⋂ F.


Problem 6. (10 points) For Problems 6 <strong>and</strong> 7, use only the basic natural deduction<br />

rules.<br />

Part a) (5 points) Give a natural deduction pro<strong>of</strong> <strong>of</strong> ¬q → ¬p from p → q.<br />

Part b) (5 points) Give a natural deduction pro<strong>of</strong> <strong>of</strong> p ∧ q from ¬(¬p ∨ ¬q).


Problem 7. (10 points)<br />

Part a) (5 points) Give a natural deduction pro<strong>of</strong> <strong>of</strong> ∀x B(x) from ∀x A(x) <strong>and</strong><br />

∀x (A(x) → B(x)).<br />

Part b) (5 points) Give a natural deduction pro<strong>of</strong> <strong>of</strong> ∃x A(x) ∨ ∃x B(x) from<br />

∃x (A(x) ∨ B(x)).


Midterm Solutions<br />

1. We have<br />

¬(p ∧ ¬q) ∨ (¬p ∧ q) ≡ (¬p ∨ ¬¬q) ∨ (¬p ∧ q)<br />

≡<br />

≡<br />

¬p ∨ (q ∨ (¬p ∧ q))<br />

¬p ∨ q<br />

2. a. The hypotheses are (¬S ∧ L) ∨ S <strong>and</strong> S. The conclusion is ¬L.<br />

b. An inference in propositional logic is valid if the following holds: for<br />

every truth assignment to the variables, if the hypotheses come out<br />

true under that assignment, so does the conclusion. (Less formally:<br />

for every line <strong>of</strong> the truth table, if the premises are true, so is the<br />

conclusion.)<br />

c. The inference is not valid. If we assign S the value “true” <strong>and</strong> L the<br />

value “true,” then both hypotheses are true, but the conclusion is<br />

false.<br />

3. a. ∀x (P (x) → ∃y (C(y) ∧ K(x, y)).<br />

b. ∃x, y, z (Cube(x)∧Large(x)∧Tet(y)∧Tet(z)∧Small(z)∧Between(x, y, z).<br />

4. Suppose x is in A \ (B ∩ C). Then x is in A, but x is not in both B<br />

<strong>and</strong> C. Then either x is not in B, or x is not in C. In the first case, x<br />

is in A \ B, <strong>and</strong> in the second case, x is in A \ C. Either way, x is in<br />

(A \ B) ∪ (A \ C).<br />

Conversely, suppose x is in (A \ B) ∪ (A \ C). Then either x is in A \ B<br />

or x is in A \ C. In the first case, x is in A but not B, <strong>and</strong> hence x is<br />

not in B ∩ C. So, in that case x is in A \ (B ∩ C). In the second case, x<br />

is in A but not C, so again x is not in B ∩ C. So, in the ase too, x is in<br />

A \ (B ∩ C).<br />

5. Suppose x is in ⋂ G. Then for every set A in G, x is in A. Let B be<br />

any set in F. Since F ⊆ G, B is in G, <strong>and</strong> so x is in B. Since B is an<br />

arbitrary set in F, x is in ⋂ F.<br />

6.<br />

a.


.<br />

p → q<br />

¬q<br />

b<br />

q<br />

⊥<br />

¬p a<br />

b<br />

¬q → ¬p<br />

p<br />

a<br />

¬(¬p ∨ ¬q)<br />

a<br />

¬p<br />

¬p ∨ ¬q<br />

¬(¬p ∨ ¬q)<br />

b<br />

¬q<br />

¬p ∨ ¬q<br />

⊥ a<br />

p<br />

p ∧ q<br />

⊥ b<br />

q<br />

7.<br />

a.<br />

b.<br />

∀x A(x)<br />

A(y)<br />

∀x (A(x) → B(x))<br />

A(y) → B(y)<br />

B(y)<br />

∀x B(x)<br />

∃x (A(x) ∨ B(x))<br />

A(y)<br />

∃x A(x)<br />

A(y) ∨ B(y)<br />

b<br />

∃x A(x) ∨ ∃x B(x)<br />

∃x A(x) ∨ ∃x B(x)<br />

b<br />

∃x A(x) ∨ ∃x B(x)<br />

a<br />

a<br />

B(y)<br />

∃x B(x)<br />

∃x A(x) ∨ ∃x B(x)<br />

a


LOGIC AND MATHEMATICAL INQUIRY<br />

Final Exam<br />

Name:<br />

May 6, 2011<br />

Write your answers in the space provided, using the back <strong>of</strong> the page if necessary.<br />

You can use additional scratch paper. Justify your answers, <strong>and</strong> provide clear,<br />

readable explanations.<br />

Problem Points Score<br />

1 12<br />

2 12<br />

3 12<br />

4 12<br />

5 12<br />

6 12<br />

Total 72<br />

GOOD LUCK


Problem 1. (12 points)<br />

Part a) (2 points) Let A <strong>and</strong> B be sets, <strong>and</strong> let f be a function from A to B.<br />

What does it mean to say that f is injective?<br />

Part b) (2 points) Let A <strong>and</strong> B be sets, <strong>and</strong> let f be a function from A to B.<br />

What does it mean to say that f is surjective?<br />

Part c) (4 points) Show that if f : A → B is injective, <strong>and</strong> g : B → C is injective,<br />

then g ◦ f is injective.<br />

Part d) (4 points) Show that if f : A → B is surjective, <strong>and</strong> g : B → C is<br />

surjective, then g ◦ f is surjective.


Problem 2. (12 points) Let A be a set <strong>and</strong> let ≡ be an equivalence relation on A.<br />

Recall that for any element a in A, the equivalence class <strong>of</strong> a, written [a], is defined<br />

by [a] = {b ∈ A | a ≡ b}. Recall also that A/≡ is defined to be {[a] | a ∈ A}, the set<br />

<strong>of</strong> equivalence classes. For these problems, do not use any background facts other<br />

than these definitions <strong>and</strong> the definition <strong>of</strong> an equivalence relation.<br />

Part a) (4 points) Show that for any a <strong>and</strong> b in A, b ∈ [a] if <strong>and</strong> only if [a] = [b].<br />

Part b) (4 points) Show that if X <strong>and</strong> Y are elements <strong>of</strong> A/ ≡, then either X<br />

<strong>and</strong> Y are disjoint (that is, X ∩ Y = ∅) or X = Y .<br />

Part c) (4 points) Show A = ⋃ (A/≡).


Problem 3. (12 points) Let N denote the natural numbers, with initial element 0<br />

<strong>and</strong> successor function s(x). Addition is characterized by the following two clauses:<br />

1. for every x, x + 0 = x<br />

2. for every x <strong>and</strong> y, x + s(y) = s(x + y).<br />

Using induction <strong>and</strong> nothing beyond the two facts above, prove that for every x <strong>and</strong><br />

y, x + y = y + x. Note that to make the induction work, you will have to prove<br />

auxilliary facts along the way.


Problem 4. (12 points) Prove the following using natural deduction.<br />

Part a) (4 points) ∀x P (x) ∨ ∀x Q(x) → ∀x (P (x) ∨ Q(x))<br />

Part b) (4 points) (p → q) → ¬(p ∧ ¬q)


Part c) (4 points) ¬(p ∧ ¬q) → (p → q)


Problem 5. (12 points) Express all <strong>of</strong> the following in the language <strong>of</strong> set theory,<br />

using only the relations ∈ <strong>and</strong> = <strong>and</strong> first-order logic. (In later parts, you can freely<br />

use symbols that you define in earlier parts.)<br />

Part a) (2 points) x ⊆ y<br />

Part b) (2 points) x = ∅<br />

Part c) (2 points) x = y ∩ z<br />

Part d) (2 points) x = P(y) (the power set <strong>of</strong> y)<br />

Part e) (2 points) x = y ∪ {y}<br />

Part f) (2 points) x has exactly two elements


Problem 6. (12 points)<br />

Part a) (2 points) What does it mean to say that A ∼ B, that is, A <strong>and</strong> B are<br />

equinumerous?<br />

Part b) (2 points) What does it mean to say that A is countably infinite?<br />

Part c) (4 points) Prove that the set <strong>of</strong> rational numbers, Q, is countably infinite.


Part d) (4 points) Prove that P(N) is not countably infinite.


05/18/11 Examples1.thy 1<br />

theory Examples1<br />

imports Main<br />

begin<br />

(* Here is a list <strong>of</strong> basic comm<strong>and</strong>s for propositional logic:<br />

apply assumption<br />

apply (rule conjI)<br />

apply (erule conjE)<br />

apply (frule conjunct1)<br />

apply (frule conjunct2)<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI1)<br />

apply (rule disjI2)<br />

apply (erule disjE)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule iffI)<br />

apply (erule iffE)<br />

apply (rule classical)<br />

apply (rule ccontr)<br />

- or "drule"<br />

- or "drule"<br />

You can get more information about any <strong>of</strong> these using "thm", as in<br />

thm conjI<br />

*)<br />

lemma ex1: "P & Q --> Q & P"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex2: "(P & Q) & R --> P & (Q & R)"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex3: "[| (P --> Q); (Q --> R)|] ==> P --> R"<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply assumption<br />

apply (erule impE)<br />

apply assumption<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/Examples1.thy


05/18/11 Examples1.thy 2<br />

apply assumption<br />

done<br />

lemma ex4: "P | Q --> Q | P"<br />

apply (rule impI)<br />

apply (erule disjE)<br />

apply (rule disjI2)<br />

apply assumption<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex5: "P & P P"<br />

apply (rule iffI)<br />

apply (erule conjE)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption+<br />

done<br />

lemma ex6: "~ (P | Q) --> ~P"<br />

apply (rule impI)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex7: "P | ~P"<br />

apply (rule classical)<br />

apply (rule disjI2)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex8: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule conjI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule disjI2)<br />

apply assumption<br />

done<br />

(* some pro<strong>of</strong> shortcuts *)<br />

thm de_Morgan_conj<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/Examples1.thy


05/18/11 Examples1.thy 3<br />

thm de_Morgan_conj [symmetric]<br />

thm de_Morgan_disj<br />

thm not_not<br />

thm not_imp<br />

thm imp_conv_disj<br />

lemma ex9: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (subst (asm) de_Morgan_conj)<br />

apply assumption<br />

done<br />

lemma ex10: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (subst de_Morgan_conj [symmetric])<br />

apply assumption<br />

done<br />

(* examples <strong>of</strong> reasoning with sets *)<br />

thm set_ext<br />

thm subsetI<br />

thm Int_iff<br />

thm Un_iff<br />

thm Diff_iff<br />

lemma ex11: "A - (B Un C) = (A - B) Int (A - C)"<br />

apply (rule set_ext)<br />

apply (subst Diff_iff)<br />

apply (subst Int_iff)<br />

apply (subst Un_iff)<br />

apply (subst Diff_iff)+<br />

apply (rule iffI)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI2)<br />

apply assumption<br />

apply (erule conjE)+<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule disjE)<br />

apply (erule notE)<br />

apply assumption<br />

apply (erule notE) back<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/Examples1.thy


05/18/11 Examples1.thy 4<br />

apply assumption<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/Examples1.thy


05/18/11 Examples2.thy 1<br />

theory Examples2<br />

imports Main<br />

begin<br />

(*<br />

For first-order logic, you can use the following comm<strong>and</strong>s:<br />

apply (rule allI)<br />

apply (frule spec) (* or drule *)<br />

apply (erule allE)<br />

apply (rule exI)<br />

apply (erule exE)<br />

If you want to specify a particular term, like "f y", for a universal<br />

quantifier in a hypothesis, type<br />

apply (frule_tac x ="f y" in spec)<br />

Similarly, if you want to specify "f y" for the existential introduction<br />

rule, type<br />

apply (rule_tac x = "f y" in exI)<br />

If the term is just a variable, you can leave <strong>of</strong>f the quotation marks.<br />

*)<br />

lemma ex1: "(ALL x. P x & Q x) --> (ALL x. P x) & (ALL x. Q x)"<br />

apply (rule impI)<br />

apply (rule conjI)<br />

apply (rule allI)<br />

apply (drule_tac x = x in spec)<br />

apply (erule conjE)<br />

apply assumption<br />

apply (rule allI)<br />

apply (drule_tac x = x in spec)<br />

apply (erule conjE)<br />

apply assumption<br />

done<br />

(* note: if you leave out the terms, Isabelle can infer them *)<br />

lemma ex1b: "(ALL x. P x & Q x) --> (ALL x. P x) & (ALL x. Q x)"<br />

apply (rule impI)<br />

apply (rule conjI)<br />

apply (rule allI)<br />

apply (drule spec)<br />

apply (erule conjE)<br />

apply assumption<br />

apply (rule allI)<br />

apply (drule spec)<br />

apply (erule conjE)<br />

apply assumption<br />

done<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/Examples2.thy


05/18/11 Examples2.thy 2<br />

lemma ex2: "(EX x. P (f x)) --> (EX x. P x)"<br />

apply (rule impI)<br />

apply (erule exE)<br />

apply (rule_tac x = "f x" in exI)<br />

apply assumption<br />

done<br />

lemma ex3: "(EX x. P x | Q x) --> (EX x. P x) | (EX x. Q x)"<br />

apply (rule impI)<br />

apply (erule exE)<br />

apply (erule disjE)<br />

apply (rule disjI1)<br />

apply (rule_tac x = "x" in exI)<br />

apply assumption<br />

apply (rule disjI2)<br />

apply (rule_tac x = "x" in exI)<br />

apply assumption<br />

done<br />

lemma ex4: "(ALL x. P x --> Q x) --> ((ALL x. P x) --> (ALL x. Q x))"<br />

apply (rule impI)<br />

apply (rule impI)<br />

apply (rule allI)<br />

apply (drule_tac x = "x" in spec)<br />

apply (drule_tac x = "x" in spec)<br />

apply (erule impE)<br />

apply assumption+<br />

done<br />

lemma ex5: "(EX (x::'a). ALL y. R x y) --> (ALL y. EX x. R x y)"<br />

apply (rule impI)<br />

apply (rule allI)<br />

apply (erule exE)<br />

apply (drule_tac x = "y" in spec)<br />

apply (rule_tac x = "x" in exI)<br />

apply assumption<br />

done<br />

lemma "x = y & P x --> P y"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (erule subst)<br />

apply assumption<br />

done<br />

lemma "(x :: nat) + (y + z) = z + (x + y)"<br />

apply (subst add_assoc [symmetric])<br />

apply (subst (3) add_commute)<br />

apply (rule refl)<br />

done<br />

lemma "((x :: nat) + 1)^2 = x^2 + 2 * x + 1"<br />

apply (simp only: power2_eq_square algebra_simps)<br />

done<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/Examples2.thy


05/18/11 Examples2.thy 3<br />

lemma "((x::'a::comm_ring) + y) * (x + y) = x * x + x * y + x * y + y * y"<br />

apply (simp add: algebra_simps)<br />

done<br />

lemma "(-(x::'a::comm_ring) * - y) = x * y"<br />

apply simp<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/Examples2.thy


05/18/11 homework6.thy 1<br />

theory homework6<br />

imports Main<br />

begin<br />

(*<br />

Replace the next four "sorry"'s with pro<strong>of</strong>s, using only the following<br />

comm<strong>and</strong>s:<br />

apply assumption<br />

apply (rule conjI)<br />

apply (erule conjE)<br />

apply (frule conjunct1)<br />

apply (frule conjunct2)<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI1)<br />

apply (rule disjI2)<br />

apply (erule disjE)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule iffI)<br />

apply (erule iffE)<br />

apply (rule classical)<br />

apply (rule ccontr)<br />

- or "drule"<br />

- or "drule"<br />

Remember that you can get more information about any <strong>of</strong> these using "thm",<br />

as in<br />

thm conjI<br />

Don't forget to type the word "done" at the end <strong>of</strong> the pro<strong>of</strong>.<br />

For reference, some examples <strong>of</strong> pro<strong>of</strong>s appear at the end <strong>of</strong> this file.<br />

*)<br />

lemma exercise1: "P & (Q | R) --> (P & Q) | (P & R)"<br />

sorry<br />

lemma exercise2: "(P | Q --> R) --> ((P --> R) & (Q --> R))"<br />

sorry<br />

lemma exercise3: "(P --> Q) --> (~Q --> ~P)"<br />

sorry<br />

lemma butler: "[| ~(B & C); L | C |] ==> L | ~B"<br />

sorry<br />

(*<br />

These are sample pro<strong>of</strong>s from the file Examples1.thy<br />

*)<br />

lemma ex1: "P & Q --> Q & P"<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework6.thy


05/18/11 homework6.thy 2<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex2: "(P & Q) & R --> P & (Q & R)"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex3: "[| (P --> Q); (Q --> R)|] ==> P --> R"<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply assumption<br />

apply (erule impE)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex4: "P | Q --> Q | P"<br />

apply (rule impI)<br />

apply (erule disjE)<br />

apply (rule disjI2)<br />

apply assumption<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex5: "P & P P"<br />

apply (rule iffI)<br />

apply (erule conjE)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption+<br />

done<br />

lemma ex6: "~ (P | Q) --> ~P"<br />

apply (rule impI)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex7: "P | ~P"<br />

apply (rule classical)<br />

apply (rule disjI2)<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework6.thy


05/18/11 homework6.thy 3<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex8: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule conjI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule disjI2)<br />

apply assumption<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework6.thy


05/18/11 solutions6.thy 1<br />

theory homework6<br />

imports Main<br />

begin<br />

(*<br />

Replace the next four "sorry"'s with pro<strong>of</strong>s, using only the following<br />

comm<strong>and</strong>s:<br />

apply assumption<br />

apply (rule conjI)<br />

apply (erule conjE)<br />

apply (frule conjunct1)<br />

apply (frule conjunct2)<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI1)<br />

apply (rule disjI2)<br />

apply (erule disjE)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule iffI)<br />

apply (erule iffE)<br />

apply (rule classical)<br />

apply (rule ccontr)<br />

- or "drule"<br />

- or "drule"<br />

Remember that you can get more information about any <strong>of</strong> these using "thm",<br />

as in<br />

thm conjI<br />

Don't forget to type the word "done" at the end <strong>of</strong> the pro<strong>of</strong>.<br />

For reference, some examples <strong>of</strong> pro<strong>of</strong>s appear at the end <strong>of</strong> this file.<br />

*)<br />

lemma exercise1: "P & (Q | R) --> (P & Q) | (P & R)"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (erule disjE)<br />

apply (rule disjI1)<br />

apply (rule conjI)<br />

apply assumption+<br />

apply (rule disjI2)<br />

apply (rule conjI)<br />

apply assumption+<br />

done<br />

lemma exercise2: "(P | Q --> R) --> ((P --> R) & (Q --> R))"<br />

apply (rule impI)<br />

apply (rule conjI)<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI1)<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions6.thy


05/18/11 solutions6.thy 2<br />

apply assumption+<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI2)<br />

apply assumption+<br />

done<br />

lemma exercise3: "(P --> Q) --> (~Q --> ~P)"<br />

apply (rule impI)<br />

apply (rule impI)<br />

apply (rule notI)<br />

apply (erule impE)<br />

apply assumption<br />

apply (erule notE)<br />

apply assumption<br />

done<br />

lemma butler: "[| ~(B & C); L | C |] ==> L | ~B"<br />

apply (erule disjE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule disjI2)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule conjI)<br />

apply assumption+<br />

done<br />

(*<br />

These are sample pro<strong>of</strong>s from the file Examples1.thy<br />

*)<br />

lemma ex1: "P & Q --> Q & P"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex2: "(P & Q) & R --> P & (Q & R)"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex3: "[| (P --> Q); (Q --> R)|] ==> P --> R"<br />

apply (rule impI)<br />

apply (erule impE)<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions6.thy


05/18/11 solutions6.thy 3<br />

apply assumption<br />

apply (erule impE)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex4: "P | Q --> Q | P"<br />

apply (rule impI)<br />

apply (erule disjE)<br />

apply (rule disjI2)<br />

apply assumption<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex5: "P & P P"<br />

apply (rule iffI)<br />

apply (erule conjE)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption+<br />

done<br />

lemma ex6: "~ (P | Q) --> ~P"<br />

apply (rule impI)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex7: "P | ~P"<br />

apply (rule classical)<br />

apply (rule disjI2)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex8: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule conjI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule disjI2)<br />

apply assumption<br />

done<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions6.thy


05/18/11 solutions6.thy 4<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions6.thy


05/18/11 homework7.thy 1<br />

theory homework7<br />

imports Main<br />

begin<br />

(*<br />

Replace the next three "sorry"'s with pro<strong>of</strong>s, using only the following<br />

comm<strong>and</strong>s:<br />

apply assumption<br />

apply (rule conjI)<br />

apply (erule conjE)<br />

apply (frule conjunct1)<br />

apply (frule conjunct2)<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI1)<br />

apply (rule disjI2)<br />

apply (erule disjE)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule iffI)<br />

apply (erule iffE)<br />

apply (rule classical)<br />

apply (rule ccontr)<br />

- or "drule"<br />

- or "drule"<br />

Remember that you can get more information about any <strong>of</strong> these using "thm",<br />

as in<br />

thm conjI<br />

Don't forget to type the word "done" at the end <strong>of</strong> the pro<strong>of</strong>.<br />

For reference, some examples <strong>of</strong> pro<strong>of</strong>s appear at the end <strong>of</strong> this file.<br />

*)<br />

(* hint: for this one, you need to use "classical" or "ccontr" *)<br />

lemma exercise1: "~(P --> Q) --> P & ~Q"<br />

sorry<br />

lemma exercise2: "~(P | Q) --> ~P & ~Q"<br />

sorry<br />

lemma exercise3: "[| P --> Q; ~(Q & R); R; S --> P|] ==> ~P & ~S"<br />

sorry<br />

(* this one is extra credit *)<br />

lemma extra_credit: "~(P ~P)"<br />

sorry<br />

(*<br />

Now prove the following, keeping in mind that "x : A" means "x is an<br />

element <strong>of</strong> A" (see the notes on using propositional logic in Isabelle<br />

that are posted on Blackboard).<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework7.thy


05/18/11 homework7.thy 2<br />

In addition to the comm<strong>and</strong>s above, you will have to use comm<strong>and</strong>s like<br />

apply (rule set_ext) -- renamed set_eqI in the latest version <strong>of</strong> Isabelle<br />

apply (rule subsetI)<br />

apply (subst Int_iff)<br />

apply (subst Un_iff)<br />

apply (subst Diff_iff)<br />

to unwrap what it means for two sets to be equal, what it means for<br />

an element to be in an intersection, <strong>and</strong> so on.<br />

You will also need to use<br />

apply (subst (asm) ...)<br />

to unwrap a definition that occurs as a hypothesis, that is, on the<br />

left side <strong>of</strong> a sequent.<br />

You can also use any <strong>of</strong> the shortcuts described in the examples below,<br />

<strong>and</strong> in the notes.<br />

*)<br />

(* Hint: remember that sometimes, the "=" symbol in Isabelle means "iff" *)<br />

(* (but not in the statement <strong>of</strong> this lemma, where it means set equality) *)<br />

lemma exercise4: "A Int B = B Int A"<br />

sorry<br />

(* Note that here " P & (Q & R)"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework7.thy


05/18/11 homework7.thy 3<br />

lemma ex3: "[| (P --> Q); (Q --> R)|] ==> P --> R"<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply assumption<br />

apply (erule impE)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex4: "P | Q --> Q | P"<br />

apply (rule impI)<br />

apply (erule disjE)<br />

apply (rule disjI2)<br />

apply assumption<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex5: "P & P P"<br />

apply (rule iffI)<br />

apply (erule conjE)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption+<br />

done<br />

lemma ex6: "~ (P | Q) --> ~P"<br />

apply (rule impI)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex7: "P | ~P"<br />

apply (rule classical)<br />

apply (rule disjI2)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex8: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule conjI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework7.thy


05/18/11 homework7.thy 4<br />

apply (rule disjI2)<br />

apply assumption<br />

done<br />

(* some pro<strong>of</strong> shortcuts *)<br />

thm de_Morgan_conj<br />

thm de_Morgan_conj [symmetric]<br />

thm de_Morgan_disj<br />

thm not_not<br />

thm not_imp<br />

thm imp_conv_disj<br />

lemma ex9: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (subst (asm) de_Morgan_conj)<br />

apply assumption<br />

done<br />

lemma ex10: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (subst de_Morgan_conj [symmetric])<br />

apply assumption<br />

done<br />

(* examples <strong>of</strong> reasoning with sets *)<br />

thm set_ext<br />

thm subsetI<br />

thm Int_iff<br />

thm Un_iff<br />

thm Diff_iff<br />

lemma ex11: "A - (B Un C) = (A - B) Int (A - C)"<br />

apply (rule set_ext)<br />

apply (subst Diff_iff)<br />

apply (subst Int_iff)<br />

apply (subst Un_iff)<br />

apply (subst Diff_iff)+<br />

apply (rule iffI)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI2)<br />

apply assumption<br />

apply (erule conjE)+<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework7.thy


05/18/11 homework7.thy 5<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule disjE)<br />

apply (erule notE)<br />

apply assumption<br />

apply (erule notE) back<br />

apply assumption<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework7.thy


05/18/11 solutions7.thy 1<br />

theory homework7<br />

imports Main<br />

begin<br />

(*<br />

Replace the next four "sorry"'s with pro<strong>of</strong>s, using only the following<br />

comm<strong>and</strong>s:<br />

apply assumption<br />

apply (rule conjI)<br />

apply (erule conjE)<br />

apply (frule conjunct1)<br />

apply (frule conjunct2)<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI1)<br />

apply (rule disjI2)<br />

apply (erule disjE)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule iffI)<br />

apply (erule iffE)<br />

apply (rule classical)<br />

apply (rule ccontr)<br />

- or "drule"<br />

- or "drule"<br />

Remember that you can get more information about any <strong>of</strong> these using "thm",<br />

as in<br />

thm conjI<br />

Don't forget to type the word "done" at the end <strong>of</strong> the pro<strong>of</strong>.<br />

For reference, some examples <strong>of</strong> pro<strong>of</strong>s appear at the end <strong>of</strong> this file.<br />

*)<br />

(* hint: for this one, you need to use "classical" or "ccontr" *)<br />

lemma exercise1: "~(P --> Q) --> P & ~Q"<br />

apply (rule impI)<br />

apply (rule conjI)<br />

apply (rule ccontr) (* or (rule classical) *)<br />

apply (erule notE)<br />

apply (rule impI)<br />

apply (erule notE)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule impI)<br />

apply assumption<br />

done<br />

lemma exercise2: "~(P | Q) --> ~P & ~Q"<br />

apply (rule impI)<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions7.thy


05/18/11 solutions7.thy 2<br />

apply (rule conjI)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI2)<br />

apply assumption<br />

done<br />

lemma exercise3: "[| P --> Q; ~(Q & R); R; S --> P|] ==> ~P & ~S"<br />

apply (rule conjI)<br />

apply (rule notI)<br />

apply (erule impE)<br />

apply assumption<br />

apply (erule notE)<br />

apply (rule conjI)<br />

apply assumption+<br />

apply (rule notI)<br />

apply (erule impE)<br />

apply (erule impE)<br />

apply assumption+<br />

apply (erule notE)<br />

apply (rule conjI)<br />

apply assumption+<br />

done<br />

lemma extra_credit: "~(P ~P)"<br />

apply (rule notI)<br />

apply (erule iffE)<br />

apply (erule impE)<br />

apply (rule classical)<br />

apply (erule impE)<br />

apply assumption+<br />

apply (erule notE)<br />

apply (rule classical)<br />

apply (erule impE)<br />

apply assumption+<br />

done<br />

(*<br />

Now prove the following, keeping in mind that "x : A" means "x is an<br />

element <strong>of</strong> A" (see the notes on using propositional logic in Isabelle<br />

that are posted on Blackboard).<br />

In addition to the comm<strong>and</strong>s above, you will have to use comm<strong>and</strong>s like<br />

apply (rule set_ext) -- renamed set_eqI in the latest version <strong>of</strong> Isabelle<br />

apply (rule subsetI)<br />

apply (subst Int_iff)<br />

apply (subst Un_iff)<br />

apply (subst Diff_iff)<br />

as well as<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions7.thy


05/18/11 solutions7.thy 3<br />

*)<br />

apply (subst (asm) ...)<br />

to unwrap a definition<br />

to unwrap what it means for two sets to be equal, what it means for<br />

an element to be in an intersection, <strong>and</strong> so on. You can also use any <strong>of</strong> the<br />

shortcuts described in the examples below, <strong>and</strong> in the notes.<br />

(* Hint: remember that sometimes, the "=" symbol in Isabelle means "iff" *)<br />

(* (but not in the statement <strong>of</strong> this lemma, where it means set equality) *)<br />

lemma exercise4: "A Int B = B Int A"<br />

apply (rule set_ext)<br />

apply (rule iffI)<br />

apply (subst Int_iff)<br />

apply (subst (asm) Int_iff)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption+<br />

apply (subst Int_iff)<br />

apply (subst (asm) Int_iff)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption+<br />

done<br />

(* Note that here "


05/18/11 solutions7.thy 4<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply (rule conjI)<br />

apply assumption+<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI2)<br />

apply assumption<br />

done<br />

(*<br />

These are sample pro<strong>of</strong>s from the file Examples1.thy<br />

*)<br />

lemma ex1: "P & Q --> Q & P"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex2: "(P & Q) & R --> P & (Q & R)"<br />

apply (rule impI)<br />

apply (erule conjE)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex3: "[| (P --> Q); (Q --> R)|] ==> P --> R"<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply assumption<br />

apply (erule impE)<br />

apply assumption<br />

apply assumption<br />

done<br />

lemma ex4: "P | Q --> Q | P"<br />

apply (rule impI)<br />

apply (erule disjE)<br />

apply (rule disjI2)<br />

apply assumption<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex5: "P & P P"<br />

apply (rule iffI)<br />

apply (erule conjE)<br />

apply assumption<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions7.thy


05/18/11 solutions7.thy 5<br />

apply (rule conjI)<br />

apply assumption+<br />

done<br />

lemma ex6: "~ (P | Q) --> ~P"<br />

apply (rule impI)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex7: "P | ~P"<br />

apply (rule classical)<br />

apply (rule disjI2)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

done<br />

lemma ex8: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule conjI)<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule ccontr)<br />

apply (erule notE)<br />

apply (rule disjI2)<br />

apply assumption<br />

done<br />

(* some pro<strong>of</strong> shortcuts *)<br />

thm de_Morgan_conj<br />

thm de_Morgan_conj [symmetric]<br />

thm de_Morgan_disj<br />

thm not_not<br />

thm not_imp<br />

thm imp_conv_disj<br />

lemma ex9: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (subst (asm) de_Morgan_conj)<br />

apply assumption<br />

done<br />

lemma ex10: "~(P & Q) --> ~P | ~Q"<br />

apply (rule impI)<br />

apply (subst de_Morgan_conj [symmetric])<br />

apply assumption<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions7.thy


05/18/11 solutions7.thy 6<br />

done<br />

(* examples <strong>of</strong> reasoning with sets *)<br />

thm set_ext<br />

thm subsetI<br />

thm Int_iff<br />

thm Un_iff<br />

thm Diff_iff<br />

lemma ex11: "A - (B Un C) = (A - B) Int (A - C)"<br />

apply (rule set_ext)<br />

apply (subst Diff_iff)<br />

apply (subst Int_iff)<br />

apply (subst Un_iff)<br />

apply (subst Diff_iff)+<br />

apply (rule iffI)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule disjI2)<br />

apply assumption<br />

apply (erule conjE)+<br />

apply (rule conjI)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule disjE)<br />

apply (erule notE)<br />

apply assumption<br />

apply (erule notE) back<br />

apply assumption<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions7.thy


05/18/11 homework8.thy 1<br />

theory homework8<br />

imports Main<br />

begin<br />

(*<br />

Replace the next four "sorry"'s with pro<strong>of</strong>s, using only the following<br />

comm<strong>and</strong>s:<br />

apply assumption<br />

apply (rule conjI)<br />

apply (erule conjE)<br />

apply (frule conjunct1)<br />

apply (frule conjunct2)<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI1)<br />

apply (rule disjI2)<br />

apply (erule disjE)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule iffI)<br />

apply (erule iffE)<br />

apply (rule classical)<br />

apply (rule ccontr)<br />

- or "drule"<br />

- or "drule"<br />

apply (rule allI)<br />

apply (frule spec) (* or drule *)<br />

apply (frule_tac x ="f y" in spec) (* or any other term *)<br />

apply (erule allE)<br />

apply (rule exI)<br />

apply (rule_tac x = "f y" in exI) (* or any other term *)<br />

apply (erule exE)<br />

Some examples from Examples2.thy are appended below. If you are in<br />

doubt about how Isabelle is interpreting implicit parentheses, choose<br />

Settings / Show Brackets<br />

from the "Isabelle" menu.<br />

*)<br />

lemma exercise1: "[| (ALL x. A x --> B x); (ALL x. B x --> C x) |] ==><br />

ALL x. A x --> C x"<br />

sorry<br />

lemma exercise2: "(ALL x. P x) | (ALL x. Q x) --> (ALL x. P x | Q x)"<br />

sorry<br />

lemma exercise3: "(ALL x. P x) --> ~ (EX x. ~P x)"<br />

sorry<br />

lemma exercise4: "[| ALL x. Y(x) & H(x) --> B(x); ALL x. A(x) --> H(x);<br />

EX x. Y(x) & A(x)|] ==> EX x. B(x)"<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework8.thy


05/18/11 homework8.thy 2<br />

sorry<br />

(* Here are the examples *)<br />

lemma ex1: "(ALL x. P x & Q x) --> (ALL x. P x) & (ALL x. Q x)"<br />

apply (rule impI)<br />

apply (rule conjI)<br />

apply (rule allI)<br />

apply (drule_tac x = x in spec)<br />

apply (erule conjE)<br />

apply assumption<br />

apply (rule allI)<br />

apply (drule_tac x = x in spec)<br />

apply (erule conjE)<br />

apply assumption<br />

done<br />

(* note: if you leave out the terms, Isabelle can infer them *)<br />

lemma ex1b: "(ALL x. P x & Q x) --> (ALL x. P x) & (ALL x. Q x)"<br />

apply (rule impI)<br />

apply (rule conjI)<br />

apply (rule allI)<br />

apply (drule spec)<br />

apply (erule conjE)<br />

apply assumption<br />

apply (rule allI)<br />

apply (drule spec)<br />

apply (erule conjE)<br />

apply assumption<br />

done<br />

lemma ex2: "(EX x. P (f x)) --> (EX x. P x)"<br />

apply (rule impI)<br />

apply (erule exE)<br />

apply (rule_tac x = "f x" in exI)<br />

apply assumption<br />

done<br />

lemma ex3: "(EX x. P x | Q x) --> (EX x. P x) | (EX x. Q x)"<br />

apply (rule impI)<br />

apply (erule exE)<br />

apply (erule disjE)<br />

apply (rule disjI1)<br />

apply (rule_tac x = "x" in exI)<br />

apply assumption<br />

apply (rule disjI2)<br />

apply (rule_tac x = "x" in exI)<br />

apply assumption<br />

done<br />

lemma ex4: "(ALL x. P x --> Q x) --> ((ALL x. P x) --> (ALL x. Q x))"<br />

apply (rule impI)<br />

apply (rule impI)<br />

apply (rule allI)<br />

apply (drule_tac x = "x" in spec)<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework8.thy


05/18/11 homework8.thy 3<br />

apply (drule_tac x = "x" in spec)<br />

apply (erule impE)<br />

apply assumption+<br />

done<br />

lemma ex5: "(EX (x::'a). ALL y. R x y) --> (ALL y. EX x. R x y)"<br />

apply (rule impI)<br />

apply (rule allI)<br />

apply (erule exE)<br />

apply (drule_tac x = "y" in spec)<br />

apply (rule_tac x = "x" in exI)<br />

apply assumption<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework8.thy


05/18/11 solutions8.thy 1<br />

theory homework8<br />

imports Main<br />

begin<br />

(*<br />

Replace the next four "sorry"'s with pro<strong>of</strong>s, using only the following<br />

comm<strong>and</strong>s:<br />

apply assumption<br />

apply (rule conjI)<br />

apply (erule conjE)<br />

apply (frule conjunct1)<br />

apply (frule conjunct2)<br />

apply (rule impI)<br />

apply (erule impE)<br />

apply (rule disjI1)<br />

apply (rule disjI2)<br />

apply (erule disjE)<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (rule iffI)<br />

apply (erule iffE)<br />

apply (rule classical)<br />

apply (rule ccontr)<br />

- or "drule"<br />

- or "drule"<br />

apply (rule allI)<br />

apply (frule spec) (* or drule *)<br />

apply (frule_tac x ="f y" in spec) (* or any other term *)<br />

apply (erule allE)<br />

apply (rule exI)<br />

apply (rule_tac x = "f y" in exI) (* or any other term *)<br />

apply (erule exE)<br />

Some examples from Examples2.thy are appended below. If you are in<br />

doubt about how Isabelle is interpreting implicit parentheses, choose<br />

Settings / Show Brackets<br />

from the "Isabelle" menu.<br />

*)<br />

lemma exercise1: "[| (ALL x. A x --> B x); (ALL x. B x --> C x) |] ==><br />

ALL x. A x --> C x"<br />

apply (rule allI)<br />

apply (rule impI)<br />

apply (drule_tac x = x in spec)+<br />

apply (erule impE)<br />

apply assumption<br />

apply (erule impE)<br />

apply assumption+<br />

done<br />

lemma exercise2: "(ALL x. P x) | (ALL x. Q x) --> (ALL x. P x | Q x)"<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions8.thy


05/18/11 solutions8.thy 2<br />

apply (rule impI)<br />

apply (rule allI)<br />

apply (erule disjE)<br />

apply (rule disjI1)<br />

apply (erule allE)<br />

apply assumption<br />

apply (rule disjI2)<br />

apply (erule allE)<br />

apply assumption<br />

done<br />

lemma exercise3: "(ALL x. P x) --> ~ (EX x. ~P x)"<br />

apply (rule impI)<br />

apply (rule notI)<br />

apply (erule exE)<br />

apply (erule notE)<br />

apply (erule allE)<br />

apply assumption<br />

done<br />

lemma exercise4: "[| ALL x. Y(x) & H(x) --> B(x); ALL x. A(x) --> H(x);<br />

EX x. Y(x) & A(x)|] ==> EX x. B(x)"<br />

apply (erule exE)<br />

apply (rule_tac x = x in exI)<br />

apply (drule_tac x = x in spec)+<br />

apply (erule conjE)<br />

apply (erule impE)<br />

apply (erule conjI)<br />

apply (erule impE)<br />

apply assumption+<br />

done<br />

(* Here are the examples *)<br />

lemma ex1: "(ALL x. P x & Q x) --> (ALL x. P x) & (ALL x. Q x)"<br />

apply (rule impI)<br />

apply (rule conjI)<br />

apply (rule allI)<br />

apply (drule_tac x = x in spec)<br />

apply (erule conjE)<br />

apply assumption<br />

apply (rule allI)<br />

apply (drule_tac x = x in spec)<br />

apply (erule conjE)<br />

apply assumption<br />

done<br />

(* note: if you leave out the terms, Isabelle can infer them *)<br />

lemma ex1b: "(ALL x. P x & Q x) --> (ALL x. P x) & (ALL x. Q x)"<br />

apply (rule impI)<br />

apply (rule conjI)<br />

apply (rule allI)<br />

apply (drule spec)<br />

apply (erule conjE)<br />

apply assumption<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions8.thy


05/18/11 solutions8.thy 3<br />

apply (rule allI)<br />

apply (drule spec)<br />

apply (erule conjE)<br />

apply assumption<br />

done<br />

lemma ex2: "(EX x. P (f x)) --> (EX x. P x)"<br />

apply (rule impI)<br />

apply (erule exE)<br />

apply (rule_tac x = "f x" in exI)<br />

apply assumption<br />

done<br />

lemma ex3: "(EX x. P x | Q x) --> (EX x. P x) | (EX x. Q x)"<br />

apply (rule impI)<br />

apply (erule exE)<br />

apply (erule disjE)<br />

apply (rule disjI1)<br />

apply (rule_tac x = "x" in exI)<br />

apply assumption<br />

apply (rule disjI2)<br />

apply (rule_tac x = "x" in exI)<br />

apply assumption<br />

done<br />

lemma ex4: "(ALL x. P x --> Q x) --> ((ALL x. P x) --> (ALL x. Q x))"<br />

apply (rule impI)<br />

apply (rule impI)<br />

apply (rule allI)<br />

apply (drule_tac x = "x" in spec)<br />

apply (drule_tac x = "x" in spec)<br />

apply (erule impE)<br />

apply assumption+<br />

done<br />

lemma ex5: "(EX (x::'a). ALL y. R x y) --> (ALL y. EX x. R x y)"<br />

apply (rule impI)<br />

apply (rule allI)<br />

apply (erule exE)<br />

apply (drule_tac x = "y" in spec)<br />

apply (rule_tac x = "x" in exI)<br />

apply assumption<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions8.thy


05/18/11 homework9.thy 1<br />

theory Homework9<br />

imports Main<br />

begin<br />

(*<br />

Remember that for first-order logic, you can use the following comm<strong>and</strong>s:<br />

apply (rule allI)<br />

apply (frule spec) (* or drule *)<br />

apply (erule allE)<br />

apply (rule exI)<br />

apply (erule exE)<br />

If you want to specify a particular term, like "f y", for a universal<br />

quantifier in a hypothesis, type<br />

apply (frule_tac x ="f y" in spec)<br />

Similarly, if you want to specify "f y" for the existential introduction<br />

rule, type<br />

apply (rule_tac x = "f y" in exI)<br />

If the term is just a variable, you can leave <strong>of</strong>f the quotation marks.<br />

*)<br />

lemma ex1: "(ALL x. P x) & (ALL x. Q x) --> (ALL x. P x & Q x)"<br />

sorry<br />

lemma ex2: "(EX x. P x) | (EX x. Q x) --> (EX x. P x | Q x)"<br />

sorry<br />

lemma ex3: "(EX x. P x) & (ALL x. P x --> Q x) --> (EX x. Q x)"<br />

sorry<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework9.thy


05/18/11 solutions9.thy 1<br />

theory Homework9<br />

imports Main<br />

begin<br />

(*<br />

Remember that for first-order logic, you can use the following comm<strong>and</strong>s:<br />

apply (rule allI)<br />

apply (frule spec) (* or drule *)<br />

apply (erule allE)<br />

apply (rule exI)<br />

apply (erule exE)<br />

If you want to specify a particular term, like "f y", for a universal<br />

quantifier in a hypothesis, type<br />

apply (frule_tac x ="f y" in spec)<br />

Similarly, if you want to specify "f y" for the existential introduction<br />

rule, type<br />

apply (rule_tac x = "f y" in exI)<br />

If the term is just a variable, you can leave <strong>of</strong>f the quotation marks.<br />

*)<br />

lemma ex1: "(ALL x. P x) & (ALL x. Q x) --> (ALL x. P x & Q x)"<br />

apply (rule impI)<br />

apply (rule allI)<br />

apply (erule conjE)<br />

apply (rule conjI)<br />

apply (drule_tac x = x in spec)<br />

apply assumption<br />

apply (drule_tac x = x in spec)<br />

back<br />

apply assumption<br />

done<br />

lemma ex2: "(EX x. P x) | (EX x. Q x) --> (EX x. P x | Q x)"<br />

apply (rule impI)<br />

apply (erule disjE)<br />

apply (erule exE)<br />

apply (rule_tac x = x in exI)<br />

apply (rule disjI1)<br />

apply assumption<br />

apply (erule exE)<br />

apply (rule_tac x = x in exI)<br />

apply (rule disjI2)<br />

apply assumption<br />

done<br />

lemma ex3: "(EX x. P x) & (ALL x. P x --> Q x) --> (EX x. Q x)"<br />

apply (rule impI)<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions9.thy


05/18/11 solutions9.thy 2<br />

apply (erule conjE)<br />

apply (erule exE)<br />

apply (drule_tac x = x in spec)<br />

apply (erule impE)<br />

apply assumption<br />

apply (rule_tac x = x in exI)<br />

apply assumption<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions9.thy


05/18/11 homework11.thy 1<br />

theory Homework11<br />

imports Main<br />

begin<br />

(*<br />

These are axioms for the natural numbers -- the recursive definitions <strong>of</strong><br />

addition <strong>and</strong> multiplication, <strong>and</strong> the definition <strong>of</strong> 1.<br />

*)<br />

lemma pl_0: "x + (0::nat) = x"<br />

by auto<br />

lemma pl_Suc: "x + Suc y = Suc (x + y)"<br />

by auto<br />

lemma ti_0: "x * (0::nat) = 0"<br />

by auto<br />

lemma ti_Suc: "x * (Suc y) = x * y + x"<br />

by auto<br />

lemma one_def: "1 = Suc 0"<br />

by auto<br />

(*<br />

This file contains formal pro<strong>of</strong>s <strong>of</strong> all the properties on the h<strong>and</strong>out<br />

"The natural numbers," except for two, which have only a "sorry."<br />

Replace these "sorry"'s by pro<strong>of</strong>s.<br />

You should only need the following comm<strong>and</strong>s:<br />

apply (induct x) - do induction on x<br />

apply (subst blah) - do a substitution in the goal using equality "blah"<br />

apply (subst blah [symmetric]) - do a substitution in the goal using equality<br />

in the other direction<br />

apply (erule ssubst) - do a substitution in the goal using an equality in<br />

the hypotheses<br />

apply (erule subst) - do a substitution in the other direction<br />

back - try a different substitution (if there is more than one)<br />

apply (rule refl) - apply reflexivity (x = x)<br />

apply (rule sym) - apply symmetry<br />

For "blah," you can use any <strong>of</strong> the axioms above, or any <strong>of</strong> the previous<br />

lemmas.<br />

*)<br />

lemma pl_x_one : "x + 1 = Suc x"<br />

apply (subst one_def)<br />

apply (subst pl_Suc)<br />

apply (subst pl_0)<br />

apply (rule refl)<br />

done<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework11.thy


05/18/11 homework11.thy 2<br />

lemma pl_0_x : "(0::nat) + x = x"<br />

apply (induct x)<br />

apply (subst pl_0)<br />

apply (rule refl)<br />

apply (subst pl_Suc)<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

lemma pl_Suc_x : "(Suc x) + y = Suc (x + y)"<br />

apply (induct y)<br />

apply (subst pl_0)+<br />

apply (rule refl)<br />

apply (subst pl_Suc)+<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

lemma pl_assoc : "((x::nat) + y) + z = x + (y + z)"<br />

apply (induct z)<br />

apply (subst pl_0)+<br />

apply (rule refl)<br />

apply (subst pl_Suc)+<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

lemma pl_commute : "(x::nat) + y = y + x"<br />

apply (induct y)<br />

apply (subst pl_0)<br />

apply (subst pl_0_x)<br />

apply (rule refl)<br />

apply (subst pl_Suc)<br />

apply (erule ssubst)<br />

apply (subst pl_Suc_x)<br />

apply (rule refl)<br />

done<br />

lemma ti_pl_dist : "(x::nat) * (y + z) = (x * y) + (x * z)"<br />

sorry<br />

lemma ti_assoc : "((x::nat) * y) * z = x * (y * z)"<br />

sorry<br />

lemma ti_0_x : "(0::nat) * x = 0"<br />

apply (induct x)<br />

apply (subst ti_0)<br />

apply (rule refl)<br />

apply (subst ti_Suc)<br />

apply (erule ssubst)<br />

apply (rule pl_0)<br />

done<br />

lemma ti_Suc_x : "(Suc x) * y = (x * y) + y"<br />

apply (induct y)<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework11.thy


05/18/11 homework11.thy 3<br />

apply (subst ti_0)+<br />

apply (subst pl_0)<br />

apply (rule refl)<br />

apply (subst ti_Suc)+<br />

apply (erule ssubst)<br />

apply (subst pl_Suc)+<br />

apply (subst pl_assoc)+<br />

apply (subst pl_commute) back<br />

apply (rule refl)<br />

done<br />

lemma ti_commute: "(x::nat) * y = y * x"<br />

apply (induct x)<br />

apply (subst ti_0)<br />

apply (subst ti_0_x)<br />

apply (rule refl)<br />

apply (subst ti_Suc)<br />

apply (subst ti_Suc_x)<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/homework11.thy


05/18/11 solutions11.thy 1<br />

theory Homework11<br />

imports Main<br />

begin<br />

(*<br />

These are axioms for the natural numbers -- the recursive definitions <strong>of</strong><br />

addition <strong>and</strong> multiplication, <strong>and</strong> the definition <strong>of</strong> 1.<br />

*)<br />

lemma pl_0: "x + (0::nat) = x"<br />

by auto<br />

lemma pl_Suc: "x + Suc y = Suc (x + y)"<br />

by auto<br />

lemma ti_0: "x * (0::nat) = 0"<br />

by auto<br />

lemma ti_Suc: "x * (Suc y) = x * y + x"<br />

by auto<br />

lemma one_def: "1 = Suc 0"<br />

by auto<br />

(*<br />

This file contains formal pro<strong>of</strong>s <strong>of</strong> all the properties on the h<strong>and</strong>out<br />

"The natural numbers," except for two, which have only a "sorry."<br />

Replace these "sorry"'s by pro<strong>of</strong>s.<br />

You should only need the following comm<strong>and</strong>s:<br />

apply (induct x) - do induction on x<br />

apply (subst blah) - do a substitution in the goal using equality "blah"<br />

apply (subst blah [symmetric]) - do a substitution in the goal using equality<br />

in the other direction<br />

apply (erule ssubst) - do a substitution in the goal using an equality in<br />

the hypotheses<br />

apply (erule subst) - do a substitution in the other direction<br />

back - try a different substitution (if there is more than one)<br />

apply (rule refl) - apply reflexivity (x = x)<br />

apply (rule sym) - apply symmetry<br />

For "blah," you can use any <strong>of</strong> the axioms above, or any <strong>of</strong> the previous<br />

lemmas.<br />

*)<br />

lemma pl_x_one : "x + 1 = Suc x"<br />

apply (subst one_def)<br />

apply (subst pl_Suc)<br />

apply (subst pl_0)<br />

apply (rule refl)<br />

done<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions11.thy


05/18/11 solutions11.thy 2<br />

lemma pl_0_x : "(0::nat) + x = x"<br />

apply (induct x)<br />

apply (subst pl_0)<br />

apply (rule refl)<br />

apply (subst pl_Suc)<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

lemma pl_Suc_x : "(Suc x) + y = Suc (x + y)"<br />

apply (induct y)<br />

apply (subst pl_0)+<br />

apply (rule refl)<br />

apply (subst pl_Suc)+<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

lemma pl_assoc : "((x::nat) + y) + z = x + (y + z)"<br />

apply (induct z)<br />

apply (subst pl_0)+<br />

apply (rule refl)<br />

apply (subst pl_Suc)+<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

lemma pl_commute : "(x::nat) + y = y + x"<br />

apply (induct y)<br />

apply (subst pl_0)<br />

apply (subst pl_0_x)<br />

apply (rule refl)<br />

apply (subst pl_Suc)<br />

apply (erule ssubst)<br />

apply (subst pl_Suc_x)<br />

apply (rule refl)<br />

done<br />

lemma ti_pl_dist : "(x::nat) * (y + z) = (x * y) + (x * z)"<br />

apply (induct z)<br />

apply (subst ti_0)<br />

apply (subst pl_0)+<br />

apply (rule refl)<br />

apply (subst pl_Suc)<br />

apply (subst ti_Suc)+<br />

apply (erule ssubst)<br />

apply (subst pl_assoc)<br />

apply (rule refl)<br />

done<br />

lemma ti_assoc : "((x::nat) * y) * z = x * (y * z)"<br />

apply (induct z)<br />

apply (subst ti_0)+<br />

apply (rule refl)<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions11.thy


05/18/11 solutions11.thy 3<br />

apply (subst ti_Suc)+<br />

apply (erule ssubst)<br />

apply (subst ti_pl_dist)<br />

apply (rule refl)<br />

done<br />

lemma ti_0_x : "(0::nat) * x = 0"<br />

apply (induct x)<br />

apply (subst ti_0)<br />

apply (rule refl)<br />

apply (subst ti_Suc)<br />

apply (erule ssubst)<br />

apply (rule pl_0)<br />

done<br />

lemma ti_Suc_x : "(Suc x) * y = (x * y) + y"<br />

apply (induct y)<br />

apply (subst ti_0)+<br />

apply (subst pl_0)<br />

apply (rule refl)<br />

apply (subst ti_Suc)+<br />

apply (erule ssubst)<br />

apply (subst pl_Suc)+<br />

apply (subst pl_assoc)+<br />

apply (subst pl_commute) back<br />

apply (rule refl)<br />

done<br />

lemma ti_commute: "(x::nat) * y = y * x"<br />

apply (induct x)<br />

apply (subst ti_0)<br />

apply (subst ti_0_x)<br />

apply (rule refl)<br />

apply (subst ti_Suc)<br />

apply (subst ti_Suc_x)<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/solutions11.thy


05/18/11 arith.thy 1<br />

theory arith<br />

imports Main<br />

begin<br />

lemma pl_0: "x + (0::nat) = x"<br />

by auto<br />

lemma pl_Suc: "x + Suc y = Suc (x + y)"<br />

by auto<br />

lemma ti_0: "x * (0::nat) = 0"<br />

by auto<br />

lemma ti_Suc: "x * (Suc y) = x * y + x"<br />

by auto<br />

lemma one_def: "1 = Suc 0"<br />

by auto<br />

lemma pl_x_one : "x + 1 = Suc x"<br />

apply (subst one_def)<br />

apply (subst pl_Suc)<br />

apply (subst pl_0)<br />

apply (rule refl)<br />

done<br />

lemma pl_0_x : "(0::nat) + x = x"<br />

apply (induct x)<br />

apply (subst pl_0)<br />

apply (rule refl)<br />

apply (subst pl_Suc)<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

lemma pl_Suc_x : "(Suc x) + y = Suc (x + y)"<br />

apply (induct y)<br />

apply (subst pl_0)+<br />

apply (rule refl)<br />

apply (subst pl_Suc)+<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

lemma pl_assoc : "((x::nat) + y) + z = x + (y + z)"<br />

apply (induct z)<br />

apply (subst pl_0)+<br />

apply (rule refl)<br />

apply (subst pl_Suc)+<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/arith.thy


05/18/11 arith.thy 2<br />

lemma pl_commute : "(x::nat) + y = y + x"<br />

apply (induct y)<br />

apply (subst pl_0)<br />

apply (subst pl_0_x)<br />

apply (rule refl)<br />

apply (subst pl_Suc)<br />

apply (erule ssubst)<br />

apply (subst pl_Suc_x)<br />

apply (rule refl)<br />

done<br />

lemma ti_pl_dist : "(x::nat) * (y + z) = (x * y) + (x * z)"<br />

apply (induct z)<br />

apply (subst ti_0)<br />

apply (subst pl_0)+<br />

apply (rule refl)<br />

apply (subst pl_Suc)<br />

apply (subst ti_Suc)+<br />

apply (erule ssubst)<br />

apply (subst pl_assoc)<br />

apply (rule refl)<br />

done<br />

lemma ti_assoc : "((x::nat) * y) * z = x * (y * z)"<br />

apply (induct z)<br />

apply (subst ti_0)+<br />

apply (rule refl)<br />

apply (subst ti_Suc)+<br />

apply (erule ssubst)<br />

apply (subst ti_pl_dist)<br />

apply (rule refl)<br />

done<br />

lemma ti_0_x : "(0::nat) * x = 0"<br />

apply (induct x)<br />

apply (subst ti_0)<br />

apply (rule refl)<br />

apply (subst ti_Suc)<br />

apply (erule ssubst)<br />

apply (rule pl_0)<br />

done<br />

lemma ti_Suc_x : "(Suc x) * y = (x * y) + y"<br />

apply (induct y)<br />

apply (subst ti_0)+<br />

apply (subst pl_0)<br />

apply (rule refl)<br />

apply (subst ti_Suc)+<br />

apply (erule ssubst)<br />

apply (subst pl_Suc)+<br />

apply (subst pl_assoc)+<br />

apply (subst pl_commute) back<br />

apply (rule refl)<br />

done<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/arith.thy


05/18/11 arith.thy 3<br />

lemma ti_commute: "(x::nat) * y = y * x"<br />

apply (induct x)<br />

apply (subst ti_0)<br />

apply (subst ti_0_x)<br />

apply (rule refl)<br />

apply (subst ti_Suc)<br />

apply (subst ti_Suc_x)<br />

apply (erule ssubst)<br />

apply (rule refl)<br />

done<br />

end<br />

file:///home/jeremy/Documents/Teaching/Spring 11/L&MI 2011/Isabelle/arith.thy


05/18/11 orders.thy 1<br />

theory Orders<br />

imports Main<br />

begin<br />

locale order =<br />

fixes<br />

R :: "'a => 'a => bool" (infix "


05/18/11 orders.thy 2<br />

(* apply (auto intro: trans asym) *)<br />

apply (erule conjE)+<br />

apply (rule conjI)<br />

apply (erule trans)<br />

apply assumption<br />

apply (rule notI)<br />

apply (erule notE)<br />

apply (erule asym)<br />

apply (erule ssubst)<br />

apply assumption<br />

done<br />

lemma "total ==> a


Isabelle / Pro<strong>of</strong> General Cheat Sheet<br />

Applying rules <strong>and</strong> theorems<br />

apply (rule theorem): use when the conclusion <strong>of</strong> theorem matches the conclusion<br />

<strong>of</strong> the current goal<br />

apply (erule theorem): use when the conclusion <strong>of</strong> theorem matches the conclusion<br />

<strong>of</strong> the current goal <strong>and</strong> the first premise <strong>of</strong> theorem matches a premise<br />

<strong>of</strong> the current goal<br />

apply (frule theorem): use when the first premise <strong>of</strong> theorem matches a premise<br />

<strong>of</strong> the current goal<br />

apply (drule theorem): like frule except it deletes the matching premise<br />

back: useful if erule/drule/frule are choosing the wrong premise<br />

apply assumption: when the conclusion <strong>of</strong> the current goal is also a premise<br />

Automated methods<br />

apply auto: applies automated tools to look for solution<br />

apply force: like auto, but “do or die” (<strong>and</strong> only applies to the first goal)<br />

apply clarify: like auto, but less aggressive<br />

apply simp: simplifies current goal using term rewriting<br />

apply (simp add:theorems): like the simplifier, but tells the simplifier to use additional<br />

theorems as well (useful groups <strong>of</strong> theorems for calculation are ring simps<br />

<strong>and</strong> field simps)<br />

apply clarsimp: a combination <strong>of</strong> clarify <strong>and</strong> simp<br />

apply blast: a powerful first-order prover<br />

apply arith: automatically solves linear arithmetic problems<br />

Other methods<br />

apply (insert theorem): adds theorem as an additional premise<br />

1


apply (subgoal tac formula): adds formula as an additional premise, <strong>and</strong> also<br />

as a new goal to be proven later<br />

apply (induct tac variable): splits into the appropriate cases to do induction<br />

on variable (when variable has a natural notion <strong>of</strong> induction, for instance, it is<br />

a natural number)<br />

apply (rule tac v 1 = t 1 <strong>and</strong> . . . <strong>and</strong> v n = t n in theorem): like rule, but<br />

allows the certain variables to be chosen manually (also erule tac,drule tac, <strong>and</strong><br />

frule tac are analagous)<br />

apply (case tac . . . ): splits on cases<br />

H<strong>and</strong>ling equality<br />

apply (subst theorem): applies a substitution (theorem should be an equality)<br />

apply (subst (asm) theorem): applies a substitution to one <strong>of</strong> the hypotheses<br />

apply (subst (i. . . j) theorem): applies a substitution at the positions indicated<br />

apply (subst (asm) (i. . . j) theorem): applies a substitution at the positions<br />

indicated in the hypotheses<br />

apply (erule ssubst): applies a substitution from the hypotheses (useful in<br />

conjunction with insert).<br />

apply (erule subst): applies a substitution from the hypotheses (in the rightto-left<br />

direction <strong>of</strong> the equality).<br />

<strong>Logic</strong>al rules<br />

Propositional <strong>Logic</strong>:<br />

notI : (A ⇒ F alse) ⇒ ¬A<br />

notE: [|¬A; A|] ⇒ B<br />

conjI : [|A; B|] ⇒ A ∧ B<br />

conjE: [|A ∧ B; [|A; B|] ⇒ C|] ⇒ C<br />

conjunct1 : P ∧ Q ⇒ P<br />

conjunct2 : P ∧ Q ⇒ Q<br />

context conjI : [|P ; P ⇒ Q|] ⇒ P ∧ Q<br />

disjI1 : A ⇒ A ∨ B<br />

disjI2 : A ⇒ B ∨ A<br />

disjCI : (¬Q ⇒ P ) ⇒ P ∨ Q<br />

excluded middle: ¬P ∨ P<br />

disjE: [|A ∨ B; A ⇒ C; B ⇒ C|] ⇒ C<br />

impI : (A ⇒ B) ⇒ (A → B)<br />

2


impE: [|A → B; A; B ⇒ C|] ⇒ C<br />

impCE: [|P → Q; ¬P ⇒ R; Q ⇒ R|] ⇒ R<br />

mp: [|A → B; A|] ⇒ B<br />

iffI : [|A ⇒ B; B ⇒ A|] ⇒ A = B<br />

iffE: [|A = B; [|A → B; B → A|] ⇒ C|] ⇒ C<br />

classical: (¬A ⇒ A) ⇒ A<br />

notnotD: ¬¬P ⇒ P<br />

de Morgan disj : (¬(P ∨ Q)) = (¬P ∧ ¬Q)<br />

de Morgan conj : (¬(P ∧ Q)) = (¬P ∨ ¬Q)<br />

disj not1 : (¬P ∨ Q) = (P → Q)<br />

disj not2 : (P ∨ ¬Q) = (Q → P )<br />

First Order <strong>Logic</strong>:<br />

exI : P a ⇒ ∃x.P x<br />

exE: [|∃x.P x; !!x.P x ⇒ C|] ⇒ C<br />

allI : (!!x.P x) ⇒ ∀x.P x<br />

spec: ∀x.P x ⇒ P x<br />

allE: [|∀x.P x; P x ⇒ R|] ⇒ R<br />

Equality:<br />

sym: x = y ⇒ y = x<br />

trans: [|x = y; y = z|] ⇒ x = z<br />

Emacs/Pro<strong>of</strong> General<br />

“C” st<strong>and</strong>s for the control key, <strong>and</strong> “C-key” means holding down the control<br />

key together with key.<br />

C-k: delete the rest <strong>of</strong> the line<br />

C-a: jump to the beginning <strong>of</strong> the current line<br />

C-e: jump to the end <strong>of</strong> the current line<br />

C-c C-n: process the next line in Isabelle (the next button)<br />

C-c C-u: push back the processed part <strong>of</strong> the text by one line (the undo button)<br />

C-c C-return: evaluate up to where the cursor is<br />

C-c C-p: show the current state <strong>of</strong> a pro<strong>of</strong> (for instance, in place <strong>of</strong> an error<br />

message currently being shown)<br />

Other tips<br />

Use the browser pages to find theorems.<br />

3


You can derive your own theorems, <strong>and</strong> use them as rules.<br />

Use the “find theorems” comm<strong>and</strong> in Pro<strong>of</strong> General.<br />

Under the Pro<strong>of</strong> General menu, if you choose options/electric-terminator, the<br />

next line <strong>of</strong> the pro<strong>of</strong> is sent to Isabelle automatically whenever you end a line<br />

with a semicolon.<br />

4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!