theory week11A_demo imports Main begin -- ------------------------------------------------------------------ text {* Motivation *} lemma "(A \ B) = (B \ \A)" by blast value "True \ False" value "False \ \ True" lemma "(A \ B) = (B \ \A)" apply (rule iffI) apply (cases A) apply (rule disjI1) apply (erule impE) apply assumption apply assumption apply (rule disjI2) apply assumption apply (rule impI) apply (erule disjE) apply assumption apply (erule notE) apply assumption done lemma "(A \ B) = (B \ \A)" proof (rule iffI) assume AimpB: "A\B" show "B \ \ A" proof (cases A) assume A: "A" from AimpB A have B:"B" by (rule impE) from B show "B \ \A" by (rule disjI1) next assume notA: "\ A" from notA show "B \ \A" by (rule disjI2) qed next assume BA: "B \ \ A" show "A\B" proof (rule impI) assume A: "A" from BA A show B proof (elim disjE) assume B: "B" from B show B by assumption next assume notA: "\ A" from A notA show B by (elim notE) qed qed qed -- ---------------------------------------- text {* Isar *} lemma "\ A; B \ \ A \ B" sorry lemma assumes A: "A" assumes B: "B" shows "A \ B" sorry lemma "(x::nat) + 1 = 1 + x" sorry -- ------------------------------------------------------------------ section "More Isar" text {* . = by assumption, .. = by rule *} lemma "\ A; B \ \ B \ A" proof assume A: "A" and B: "B" from A show "A" . from B show "B" . qed lemma "\ A; B \ \ B \ A" proof - assume A: "A" and B: "B" from B A show "B \ A" .. qed text {* backward/forward *} lemma "A \ B \ B \ A" sorry text{* fix *} lemma assumes P: "\x. P x" shows "\x. P (f x)" sorry text{* Proof text can only refer to global constants, free variables in the lemma, and local names introduced via fix or obtain. *} lemma assumes Pf: "\x. P (f x)" shows "\y. P y" sorry text {* obtain *} lemma assumes Pf: "\x. P (f x)" shows "\y. P y" sorry lemma assumes ex: "\x. \y. P x y" shows "\y. \x. P x y" sorry lemma assumes A: "\x y. P x y \ Q x y" shows "\x y. P x y \ Q x y" sorry (* apply style *) text {* moreover *} lemma "A \ B \ B \ A" sorry thm mono_def thm monoI lemma assumes mono_f: "mono (f::int\int)" and mono_g: "mono (g::int\int)" shows "mono (\i. f i + g i)" sorry -- --------------------------------------- lemma "\A; B\ \ A \ B" apply(rule conjI) proof - assume A thus A . assume B thus B . qed end