# HG changeset patch # User wenzelm # Date 1448907128 -3600 # Node ID 49353865e5395827a6b0d6d38509abd9bf3204ef # Parent df6258b7e53f262d4ab83c3a0d15b682114c64b2 misc tuning and modernization; diff -r df6258b7e53f -r 49353865e539 src/HOL/ex/Higher_Order_Logic.thy --- a/src/HOL/ex/Higher_Order_Logic.thy Mon Nov 30 15:23:02 2015 +0100 +++ b/src/HOL/ex/Higher_Order_Logic.thy Mon Nov 30 19:12:08 2015 +0100 @@ -1,5 +1,5 @@ (* Title: HOL/ex/Higher_Order_Logic.thy - Author: Gertrud Bauer and Markus Wenzel, TU Muenchen + Author: Makarius *) section \Foundations of HOL\ @@ -9,12 +9,11 @@ begin text \ - The following theory development demonstrates Higher-Order Logic - itself, represented directly within the Pure framework of Isabelle. - The ``HOL'' logic given here is essentially that of Gordon - @{cite "Gordon:1985:HOL"}, although we prefer to present basic concepts - in a slightly more conventional manner oriented towards plain - Natural Deduction. + The following theory development demonstrates Higher-Order Logic itself, + represented directly within the Pure framework of Isabelle. The ``HOL'' + logic given here is essentially that of Gordon @{cite "Gordon:1985:HOL"}, + although we prefer to present basic concepts in a slightly more conventional + manner oriented towards plain Natural Deduction. \ @@ -30,35 +29,31 @@ subsubsection \Basic logical connectives\ -judgment Trueprop :: "o \ prop" ("_" 5) +judgment Trueprop :: "o \ prop" ("_" 5) -axiomatization - imp :: "o \ o \ o" (infixr "\" 25) and - All :: "('a \ o) \ o" (binder "\" 10) -where - impI [intro]: "(A \ B) \ A \ B" and - impE [dest, trans]: "A \ B \ A \ B" and - allI [intro]: "(\x. P x) \ \x. P x" and - allE [dest]: "\x. P x \ P a" +axiomatization imp :: "o \ o \ o" (infixr "\" 25) + where impI [intro]: "(A \ B) \ A \ B" + and impE [dest, trans]: "A \ B \ A \ B" + +axiomatization All :: "('a \ o) \ o" (binder "\" 10) + where allI [intro]: "(\x. P x) \ \x. P x" + and allE [dest]: "\x. P x \ P a" subsubsection \Extensional equality\ -axiomatization - equal :: "'a \ 'a \ o" (infixl "=" 50) -where - refl [intro]: "x = x" and - subst: "x = y \ P x \ P y" +axiomatization equal :: "'a \ 'a \ o" (infixl "=" 50) + where refl [intro]: "x = x" + and subst: "x = y \ P x \ P y" -axiomatization where - ext [intro]: "(\x. f x = g x) \ f = g" and - iff [intro]: "(A \ B) \ (B \ A) \ A = B" +axiomatization + where ext [intro]: "(\x. f x = g x) \ f = g" + and iff [intro]: "(A \ B) \ (B \ A) \ A = B" -theorem sym [sym]: "x = y \ y = x" -proof - - assume "x = y" - then show "y = x" by (rule subst) (rule refl) -qed +theorem sym [sym]: + assumes "x = y" + shows "y = x" + using assms by (rule subst) (rule refl) lemma [trans]: "x = y \ P y \ P x" by (rule subst) (rule sym) @@ -80,173 +75,187 @@ definition false :: o ("\") where "\ \ \A. A" +theorem falseE [elim]: + assumes "\" + shows A +proof - + from \\\ have "\A. A" unfolding false_def . + then show A .. +qed + + definition true :: o ("\") where "\ \ \ \ \" +theorem trueI [intro]: \ + unfolding true_def .. + + definition not :: "o \ o" ("\ _" [40] 40) where "not \ \A. A \ \" -definition conj :: "o \ o \ o" (infixr "\" 35) - where "conj \ \A B. \C. (A \ B \ C) \ C" - -definition disj :: "o \ o \ o" (infixr "\" 30) - where "disj \ \A B. \C. (A \ C) \ (B \ C) \ C" - -definition Ex :: "('a \ o) \ o" (binder "\" 10) - where "\x. P x \ \C. (\x. P x \ C) \ C" - abbreviation not_equal :: "'a \ 'a \ o" (infixl "\" 50) where "x \ y \ \ (x = y)" -theorem falseE [elim]: "\ \ A" -proof (unfold false_def) - assume "\A. A" - then show A .. -qed - -theorem trueI [intro]: \ -proof (unfold true_def) - show "\ \ \" .. -qed +theorem notI [intro]: + assumes "A \ \" + shows "\ A" + using assms unfolding not_def .. -theorem notI [intro]: "(A \ \) \ \ A" -proof (unfold not_def) - assume "A \ \" - then show "A \ \" .. -qed - -theorem notE [elim]: "\ A \ A \ B" -proof (unfold not_def) - assume "A \ \" and A - then have \ .. +theorem notE [elim]: + assumes "\ A" and A + shows B +proof - + from \\ A\ have "A \ \" unfolding not_def . + from this and \A\ have "\" .. then show B .. qed lemma notE': "A \ \ A \ B" by (rule notE) -lemmas contradiction = notE notE' -- \proof by contradiction in any order\ +lemmas contradiction = notE notE' \ \proof by contradiction in any order\ + + +definition conj :: "o \ o \ o" (infixr "\" 35) + where "conj \ \A B. \C. (A \ B \ C) \ C" -theorem conjI [intro]: "A \ B \ A \ B" -proof (unfold conj_def) - assume A and B - show "\C. (A \ B \ C) \ C" +theorem conjI [intro]: + assumes A and B + shows "A \ B" + unfolding conj_def +proof + fix C + show "(A \ B \ C) \ C" proof - fix C show "(A \ B \ C) \ C" - proof - assume "A \ B \ C" - also note \A\ - also note \B\ - finally show C . - qed + assume "A \ B \ C" + also note \A\ + also note \B\ + finally show C . qed qed -theorem conjE [elim]: "A \ B \ (A \ B \ C) \ C" -proof (unfold conj_def) - assume c: "\C. (A \ B \ C) \ C" - assume "A \ B \ C" - moreover { - from c have "(A \ B \ A) \ A" .. +theorem conjE [elim]: + assumes "A \ B" + obtains A and B +proof + from \A \ B\ have *: "(A \ B \ C) \ C" for C + unfolding conj_def .. + show A + proof - + note * [of A] also have "A \ B \ A" proof assume A then show "B \ A" .. qed - finally have A . - } moreover { - from c have "(A \ B \ B) \ B" .. + finally show ?thesis . + qed + show B + proof - + note * [of B] also have "A \ B \ B" proof show "B \ B" .. qed - finally have B . - } ultimately show C . -qed - -theorem disjI1 [intro]: "A \ A \ B" -proof (unfold disj_def) - assume A - show "\C. (A \ C) \ (B \ C) \ C" - proof - fix C show "(A \ C) \ (B \ C) \ C" - proof - assume "A \ C" - also note \A\ - finally have C . - then show "(B \ C) \ C" .. - qed + finally show ?thesis . qed qed -theorem disjI2 [intro]: "B \ A \ B" -proof (unfold disj_def) - assume B - show "\C. (A \ C) \ (B \ C) \ C" + +definition disj :: "o \ o \ o" (infixr "\" 30) + where "disj \ \A B. \C. (A \ C) \ (B \ C) \ C" + +theorem disjI1 [intro]: + assumes A + shows "A \ B" + unfolding disj_def +proof + fix C + show "(A \ C) \ (B \ C) \ C" proof - fix C show "(A \ C) \ (B \ C) \ C" + assume "A \ C" + from this and \A\ have C .. + then show "(B \ C) \ C" .. + qed +qed + +theorem disjI2 [intro]: + assumes B + shows "A \ B" + unfolding disj_def +proof + fix C + show "(A \ C) \ (B \ C) \ C" + proof + show "(B \ C) \ C" proof - show "(B \ C) \ C" - proof - assume "B \ C" - also note \B\ - finally show C . - qed + assume "B \ C" + from this and \B\ show C .. qed qed qed -theorem disjE [elim]: "A \ B \ (A \ C) \ (B \ C) \ C" -proof (unfold disj_def) - assume c: "\C. (A \ C) \ (B \ C) \ C" - assume r1: "A \ C" and r2: "B \ C" - from c have "(A \ C) \ (B \ C) \ C" .. - also have "A \ C" +theorem disjE [elim]: + assumes "A \ B" + obtains (a) A | (b) B +proof - + from \A \ B\ have "(A \ thesis) \ (B \ thesis) \ thesis" + unfolding disj_def .. + also have "A \ thesis" proof assume A - then show C by (rule r1) + then show thesis by (rule a) qed - also have "B \ C" + also have "B \ thesis" proof assume B - then show C by (rule r2) + then show thesis by (rule b) qed - finally show C . + finally show thesis . qed + +definition Ex :: "('a \ o) \ o" (binder "\" 10) + where "\x. P x \ \C. (\x. P x \ C) \ C" + theorem exI [intro]: "P a \ \x. P x" -proof (unfold Ex_def) + unfolding Ex_def +proof + fix C assume "P a" - show "\C. (\x. P x \ C) \ C" + show "(\x. P x \ C) \ C" proof - fix C show "(\x. P x \ C) \ C" - proof - assume "\x. P x \ C" - then have "P a \ C" .. - also note \P a\ - finally show C . - qed + assume "\x. P x \ C" + then have "P a \ C" .. + from this and \P a\ show C .. qed qed -theorem exE [elim]: "\x. P x \ (\x. P x \ C) \ C" -proof (unfold Ex_def) - assume c: "\C. (\x. P x \ C) \ C" - assume r: "\x. P x \ C" - from c have "(\x. P x \ C) \ C" .. - also have "\x. P x \ C" +theorem exE [elim]: + assumes "\x. P x" + obtains (that) x where "P x" +proof - + from \\x. P x\ have "(\x. P x \ thesis) \ thesis" + unfolding Ex_def .. + also have "\x. P x \ thesis" proof - fix x show "P x \ C" + fix x + show "P x \ thesis" proof assume "P x" - then show C by (rule r) + then show thesis by (rule that) qed qed - finally show C . + finally show thesis . qed subsection \Classical logic\ +text \ + The subsequent rules of classical reasoning are all equivalent. +\ + locale classical = assumes classical: "(\ A \ A) \ A" @@ -265,14 +274,12 @@ qed qed -theorem (in classical) double_negation: "\ \ A \ A" -proof - - assume "\ \ A" - show A - proof (rule classical) - assume "\ A" - with \\ \ A\ show ?thesis by (rule contradiction) - qed +theorem (in classical) double_negation: + assumes "\ \ A" + shows A +proof (rule classical) + assume "\ A" + with \\ \ A\ show ?thesis by (rule contradiction) qed theorem (in classical) tertium_non_datur: "A \ \ A" @@ -290,27 +297,30 @@ qed qed -theorem (in classical) classical_cases: "(A \ C) \ (\ A \ C) \ C" -proof - - assume r1: "A \ C" and r2: "\ A \ C" - from tertium_non_datur show C - proof +theorem (in classical) classical_cases: + obtains A | "\ A" + using tertium_non_datur +proof + assume A + then show thesis .. +next + assume "\ A" + then show thesis .. +qed + +lemma + assumes classical_cases: "\A C. (A \ C) \ (\ A \ C) \ C" + shows "PROP classical" +proof + fix A + assume *: "\ A \ A" + show A + proof (rule classical_cases) assume A - then show ?thesis by (rule r1) + then show A . next assume "\ A" - then show ?thesis by (rule r2) - qed -qed - -lemma (in classical) "(\ A \ A) \ A" (* FIXME *) -proof - - assume r: "\ A \ A" - show A - proof (rule classical_cases) - assume A then show A . - next - assume "\ A" then show A by (rule r) + then show A by (rule *) qed qed