theory Lec04 imports Main begin section {* Some Isar Basics *} text {* Conjunctions *} thm conjI[no_vars] lemma assumes a: "P" "Q" shows "P \ Q" using a by (auto) lemma assumes a: "P" "Q" shows "P \ Q" using a by (simp) lemma assumes a: "P" "Q" shows "P \ Q" using a by (blast) text {* A detailed proof *} lemma assumes a: "P" "Q" shows "P \ Q" using a proof - have "P" by fact moreover have "Q" by fact ultimately show "P \ Q" by (rule conjI) qed text {* Disjunction *} thm disjI1 lemma assumes a: "P" shows "P \ Q" proof - have "P" by fact then show "P \ Q" by (rule disjI1) qed text {* Compound Goals *} lemma assumes a: "A" "B" "C" shows "(A \ B) \ C" proof - have a: "C" by fact have "A" by fact moreover have "B" by fact ultimately have "A \ B" by (rule conjI) then show "(A \ B) \ C" using a by (rule conjI) qed text {* Decomposing assumptions *} thm conjunct1 thm conjunct2 text {* The order in which facts are chained is important *} lemma assumes a: "A \ B" shows "B \ A" using a proof - have a: "A \ B" by fact have "B" using a by (rule conjunct2) moreover have "A" using a by (rule conjunct1) ultimately show "B \ A" by (rule conjI) qed text {* The order in which facts are chained is important for rule. *} lemma assumes a: "A \ B" shows "B \ A" using a proof - have a: "A \ B" by fact have "A" using a by (rule conjunct1) moreover have "B" using a by (rule conjunct2) ultimately show "B \ A" proof - thm conjI oops text {* Implications *} thm impI lemma shows "A \ A" proof - { assume "A" then have "A" by assumption } then show "A \ A" by (rule impI) qed text {* Notice the difference between \ and \: *} lemma shows "A \ A" by (rule impI) (assumption) lemma shows "A \ A" by (assumption) lemma assumes a: "A" shows "A" using a by (assumption) text {* Disjunctions are a special case of case distinctions. *} lemma assumes a: "P \ Q" and b1: "P \ C" and b2: "Q \ C" shows "C" using a proof - have "P \ Q" by fact moreover { assume "P" then have "C" by (rule b1) } moreover { assume "Q" then have "C" by (rule b2) } ultimately show "C" by (rule disjE) qed text {* Again the order of chained facts is important *} lemma assumes a: "P \ Q" and b\<^isub>1: "P \ C" and b\<^isub>2: "Q \ C" shows "C" using b\<^isub>1 b\<^isub>2 a oops end