# HG changeset patch # User wenzelm # Date 1484598030 -3600 # Node ID 354bfbb27fbbee8a54230aefcc15682e3b5edaae # Parent 49549acbf0250233681e9f44fd533f15ea557510 misc tuning and updates according to Curry-Club Dec-2016; diff -r 49549acbf025 -r 354bfbb27fbb src/HOL/Isar_Examples/Higher_Order_Logic.thy --- a/src/HOL/Isar_Examples/Higher_Order_Logic.thy Mon Jan 16 16:12:29 2017 +0100 +++ b/src/HOL/Isar_Examples/Higher_Order_Logic.thy Mon Jan 16 21:20:30 2017 +0100 @@ -9,15 +9,17 @@ 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 illustrates the foundations of Higher-Order + Logic. The ``HOL'' logic that is given here resembles @{cite + "Gordon:1985:HOL"} and its predecessor @{cite "church40"}, but the order of + axiomatizations and defined connectives has be adapted to modern + presentations of \\\-calculus and Constructive Type Theory. Thus it fits + nicely to the underlying Natural Deduction framework of Isabelle/Pure and + Isabelle/Isar. \ -subsection \Pure Logic\ +section \HOL syntax within Pure\ class type default_sort type @@ -26,10 +28,10 @@ instance o :: type .. instance "fun" :: (type, type) type .. +judgment Trueprop :: "o \ prop" ("_" 5) -subsubsection \Basic logical connectives\ -judgment Trueprop :: "o \ prop" ("_" 5) +section \Minimal logic (axiomatization)\ axiomatization imp :: "o \ o \ o" (infixr "\" 25) where impI [intro]: "(A \ B) \ A \ B" @@ -39,79 +41,48 @@ 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" - -abbreviation iff :: "o \ o \ o" (infixr "\" 25) - where "A \ B \ A = B" - -axiomatization - where ext [intro]: "(\x. f x = g x) \ f = g" - and iff [intro]: "(A \ B) \ (B \ A) \ A \ B" +lemma atomize_imp [atomize]: "(A \ B) \ Trueprop (A \ B)" + by standard (fact impI, fact impE) -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) - -lemma [trans]: "P x \ x = y \ P y" - by (rule subst) - -theorem trans [trans]: "x = y \ y = z \ x = z" - by (rule subst) - -theorem iff1 [elim]: "A \ B \ A \ B" - by (rule subst) - -theorem iff2 [elim]: "A \ B \ B \ A" - by (rule subst) (rule sym) +lemma atomize_all [atomize]: "(\x. P x) \ Trueprop (\x. P x)" + by standard (fact allI, fact allE) subsubsection \Derived connectives\ -definition false :: o ("\") - where "\ \ \A. A" +definition False :: o + where "False \ \A. A" -theorem falseE [elim]: - assumes "\" +lemma FalseE [elim]: + assumes "False" shows A proof - - from \\\ have "\A. A" by (simp only: false_def) + from \False\ have "\A. A" by (simp only: False_def) then show A .. qed -definition true :: o ("\") - where "\ \ \ \ \" +definition True :: o + where "True \ False \ False" -theorem trueI [intro]: \ - unfolding true_def .. +lemma TrueI [intro]: True + unfolding True_def .. definition not :: "o \ o" ("\ _" [40] 40) - where "not \ \A. A \ \" + where "not \ \A. A \ False" -abbreviation not_equal :: "'a \ 'a \ o" (infixl "\" 50) - where "x \ y \ \ (x = y)" - -theorem notI [intro]: - assumes "A \ \" +lemma notI [intro]: + assumes "A \ False" shows "\ A" using assms unfolding not_def .. -theorem notE [elim]: +lemma notE [elim]: assumes "\ A" and A shows B proof - - from \\ A\ have "A \ \" by (simp only: not_def) - from this and \A\ have "\" .. + from \\ A\ have "A \ False" by (simp only: not_def) + from this and \A\ have "False" .. then show B .. qed @@ -122,9 +93,9 @@ definition conj :: "o \ o \ o" (infixr "\" 35) - where "conj \ \A B. \C. (A \ B \ C) \ C" + where "A \ B \ \C. (A \ B \ C) \ C" -theorem conjI [intro]: +lemma conjI [intro]: assumes A and B shows "A \ B" unfolding conj_def @@ -139,7 +110,7 @@ qed qed -theorem conjE [elim]: +lemma conjE [elim]: assumes "A \ B" obtains A and B proof @@ -168,9 +139,9 @@ definition disj :: "o \ o \ o" (infixr "\" 30) - where "disj \ \A B. \C. (A \ C) \ (B \ C) \ C" + where "A \ B \ \C. (A \ C) \ (B \ C) \ C" -theorem disjI1 [intro]: +lemma disjI1 [intro]: assumes A shows "A \ B" unfolding disj_def @@ -184,7 +155,7 @@ qed qed -theorem disjI2 [intro]: +lemma disjI2 [intro]: assumes B shows "A \ B" unfolding disj_def @@ -200,7 +171,7 @@ qed qed -theorem disjE [elim]: +lemma disjE [elim]: assumes "A \ B" obtains (a) A | (b) B proof - @@ -223,7 +194,7 @@ 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" +lemma exI [intro]: "P a \ \x. P x" unfolding Ex_def proof fix C @@ -236,7 +207,7 @@ qed qed -theorem exE [elim]: +lemma exE [elim]: assumes "\x. P x" obtains (that) x where "P x" proof - @@ -255,6 +226,47 @@ qed +subsubsection \Extensional equality\ + +axiomatization equal :: "'a \ 'a \ o" (infixl "=" 50) + where refl [intro]: "x = x" + and subst: "x = y \ P x \ P y" + +abbreviation not_equal :: "'a \ 'a \ o" (infixl "\" 50) + where "x \ y \ \ (x = y)" + +abbreviation iff :: "o \ o \ o" (infixr "\" 25) + where "A \ B \ A = B" + +axiomatization + where ext [intro]: "(\x. f x = g x) \ f = g" + and iff [intro]: "(A \ B) \ (B \ A) \ A \ B" + +lemma sym [sym]: "y = x" if "x = y" + using that by (rule subst) (rule refl) + +lemma [trans]: "x = y \ P y \ P x" + by (rule subst) (rule sym) + +lemma [trans]: "P x \ x = y \ P y" + by (rule subst) + +lemma arg_cong: "f x = f y" if "x = y" + using that by (rule subst) (rule refl) + +lemma fun_cong: "f x = g x" if "f = g" + using that by (rule subst) (rule refl) + +lemma trans [trans]: "x = y \ y = z \ x = z" + by (rule subst) + +lemma iff1 [elim]: "A \ B \ A \ B" + by (rule subst) + +lemma iff2 [elim]: "A \ B \ B \ A" + by (rule subst) (rule sym) + + subsection \Cantor's Theorem\ text \ @@ -271,7 +283,7 @@ proof assume A with * have "\ A" .. - from this and \A\ show \ .. + from this and \A\ show False .. qed with * show A .. qed @@ -285,11 +297,11 @@ then obtain a where "?D = f a" .. then have "?D a \ f a a" using refl by (rule subst) then have "\ f a a \ f a a" . - then show \ by (rule iff_contradiction) + then show False by (rule iff_contradiction) qed -subsection \Classical logic\ +subsection \Characterization of Classical Logic\ text \ The subsequent rules of classical reasoning are all equivalent. @@ -297,8 +309,10 @@ locale classical = assumes classical: "(\ A \ A) \ A" + \ \predicate definition and hypothetical context\ +begin -theorem (in classical) Peirce's_Law: "((A \ B) \ A) \ A" +theorem Peirce's_Law: "((A \ B) \ A) \ A" proof assume *: "(A \ B) \ A" show A @@ -313,7 +327,7 @@ qed qed -theorem (in classical) double_negation: +lemma double_negation: assumes "\ \ A" shows A proof (rule classical) @@ -321,7 +335,7 @@ with \\ \ A\ show ?thesis by (rule contradiction) qed -theorem (in classical) tertium_non_datur: "A \ \ A" +lemma tertium_non_datur: "A \ \ A" proof (rule double_negation) show "\ \ (A \ \ A)" proof @@ -329,14 +343,14 @@ have "\ A" proof assume A then have "A \ \ A" .. - with \\ (A \ \ A)\ show \ by (rule contradiction) + with \\ (A \ \ A)\ show False by (rule contradiction) qed then have "A \ \ A" .. - with \\ (A \ \ A)\ show \ by (rule contradiction) + with \\ (A \ \ A)\ show False by (rule contradiction) qed qed -theorem (in classical) classical_cases: +lemma classical_cases: obtains A | "\ A" using tertium_non_datur proof @@ -347,14 +361,15 @@ then show thesis .. qed -lemma - assumes classical_cases: "\A C. (A \ C) \ (\ A \ C) \ C" - shows "PROP classical" +end + +lemma classical_if_cases: classical + if cases: "\A C. (A \ C) \ (\ A \ C) \ C" proof fix A assume *: "\ A \ A" show A - proof (rule classical_cases) + proof (rule cases) assume A then show A . next @@ -363,4 +378,124 @@ qed qed + +section \Hilbert's choice operator (axiomatization)\ + +axiomatization Eps :: "('a \ o) \ 'a" + where someI: "P x \ P (Eps P)" + +syntax "_Eps" :: "pttrn \ o \ 'a" ("(3SOME _./ _)" [0, 10] 10) +translations "SOME x. P" \ "CONST Eps (\x. P)" + +text \ + \<^medskip> + It follows a derivation of the classical law of tertium-non-datur by + means of Hilbert's choice operator (due to Berghofer, Beeson, Harrison, + based on a proof by Diaconescu). + \<^medskip> +\ + +theorem Diaconescu: "A \ \ A" +proof - + let ?P = "\x. (A \ x) \ \ x" + let ?Q = "\x. (A \ \ x) \ x" + + have a: "?P (Eps ?P)" + proof (rule someI) + have "\ False" .. + then show "?P False" .. + qed + have b: "?Q (Eps ?Q)" + proof (rule someI) + have True .. + then show "?Q True" .. + qed + + from a show ?thesis + proof + assume "A \ Eps ?P" + then have A .. + then show ?thesis .. + next + assume "\ Eps ?P" + from b show ?thesis + proof + assume "A \ \ Eps ?Q" + then have A .. + then show ?thesis .. + next + assume "Eps ?Q" + have neq: "?P \ ?Q" + proof + assume "?P = ?Q" + then have "Eps ?P \ Eps ?Q" by (rule arg_cong) + also note \Eps ?Q\ + finally have "Eps ?P" . + with \\ Eps ?P\ show False by (rule contradiction) + qed + have "\ A" + proof + assume A + have "?P = ?Q" + proof (rule ext) + show "?P x \ ?Q x" for x + proof + assume "?P x" + then show "?Q x" + proof + assume "\ x" + with \A\ have "A \ \ x" .. + then show ?thesis .. + next + assume "A \ x" + then have x .. + then show ?thesis .. + qed + next + assume "?Q x" + then show "?P x" + proof + assume "A \ \ x" + then have "\ x" .. + then show ?thesis .. + next + assume x + with \A\ have "A \ x" .. + then show ?thesis .. + qed + qed + qed + with neq show False by (rule contradiction) + qed + then show ?thesis .. + qed + qed +qed + +text \ + This means, the hypothetical predicate @{const classical} always holds + unconditionally (with all consequences). +\ + +interpretation classical +proof (rule classical_if_cases) + fix A C + assume *: "A \ C" + and **: "\ A \ C" + from Diaconescu [of A] show C + proof + assume A + then show C by (rule *) + next + assume "\ A" + then show C by (rule **) + qed +qed + +thm classical + Peirce's_Law + double_negation + tertium_non_datur + classical_cases + end diff -r 49549acbf025 -r 354bfbb27fbb src/HOL/Isar_Examples/document/root.bib --- a/src/HOL/Isar_Examples/document/root.bib Mon Jan 16 16:12:29 2017 +0100 +++ b/src/HOL/Isar_Examples/document/root.bib Mon Jan 16 21:20:30 2017 +0100 @@ -4,6 +4,14 @@ @string{Springer="Springer-Verlag"} @string{TUM="TU Munich"} +@article{church40, + author = "Alonzo Church", + title = "A Formulation of the Simple Theory of Types", + journal = "Journal of Symbolic Logic", + year = 1940, + volume = 5, + pages = "56-68"} + @Book{Concrete-Math, author = {R. L. Graham and D. E. Knuth and O. Patashnik}, title = {Concrete Mathematics},