theory Demo05 imports Main begin section {* Isar *} lemma "\ A; B \ \ A \ B" proof (rule conjI) assume a: "A" from a show "A" by assumption next assume b: "B" from b show "B" by assumption qed lemma assumes a: "A" assumes b: "B" shows "A \ B" proof (rule conjI) from a show "A" by assumption from b show "B" by assumption qed lemma "(x::nat) + 1 = 1 + x" proof - have a: "x + 1 = Suc x" by simp have b: "1 + x = Suc x" by simp show "x + 1 = 1 + x" by (simp only: a b) qed -- ------------------------------------------------ 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 and a show "B \ A" .. qed text {* backward/forward *} lemma "A \ B \ B \ A" proof assume ab: "A \ B" from ab show "B \ A" proof assume a: "A" and b: "B" from b a show "B \ A" .. qed qed text {* dealing with cases *} lemma "A \ B \ B \ A" proof assume ab: "A \ B" from ab show "B \ A" proof assume a: "A" from a show "B \ A" .. next assume b: "B" from b show "B \ A" .. qed qed -- "Backtick: refer to facts without naming them" lemma "A \ B \ B \ A" proof assume "A \ B" from `A \ B` show "B \ A" proof assume "A" "B" from `B` `A` show "B \ A" .. qed qed -- "then = from this" lemma "A \ B \ B \ A" proof assume "A \ B" then show "B \ A" proof assume "B" "A" then show "B \ A" .. qed qed text{* fix *} lemma assumes P: "\x. P x" shows "\x. P (f x)" proof fix a from P show "P (f a)" .. qed 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" proof - from Pf show ?thesis proof fix x assume "P (f x)" then show ?thesis .. qed qed text {* obtain *} lemma assumes Pf: "\x. P (f x)" shows "\y. P y" proof - from Pf obtain x where "P(f x)" .. then show "\y. P y" .. qed lemma assumes ex: "\x. \y. P x y" shows "\y. \x. P x y" proof fix y from ex obtain x where "\y. P x y" .. then have "P x y" .. then show "\x. P x y" .. qed lemma assumes A: "\x y. P x y \ Q x y" shows "\x y. P x y \ Q x y" proof - from A obtain x y where P: "P x y" and Q: "Q x y" by blast then show ?thesis by blast qed lemma "\x. P x \ (\x. P x)" oops end