# HG changeset patch # User wenzelm # Date 1451154466 -3600 # Node ID 6512e84cc9f5d3d21bb5fc889a72904949bed120 # Parent 02610a8064678251e5afc979d478dc6e2ee28290 clarified sessions; diff -r 02610a806467 -r 6512e84cc9f5 src/FOL/ROOT --- a/src/FOL/ROOT Sat Dec 26 16:10:00 2015 +0100 +++ b/src/FOL/ROOT Sat Dec 26 19:27:46 2015 +0100 @@ -25,7 +25,6 @@ Examples for First-Order Logic. *} theories - First_Order_Logic Natural_Numbers Intro Nat diff -r 02610a806467 -r 6512e84cc9f5 src/FOL/ex/First_Order_Logic.thy --- a/src/FOL/ex/First_Order_Logic.thy Sat Dec 26 16:10:00 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -(* Title: FOL/ex/First_Order_Logic.thy - Author: Makarius -*) - -section \A simple formulation of First-Order Logic\ - -text \ - The subsequent theory development illustrates single-sorted intuitionistic - first-order logic with equality, formulated within the Pure framework. So - this is strictly speaking an example of Isabelle/Pure, not Isabelle/FOL. -\ - -theory First_Order_Logic -imports Pure -begin - -subsection \Abstract syntax\ - -typedecl i -typedecl o - -judgment Trueprop :: "o \ prop" ("_" 5) - - -subsection \Propositional logic\ - -axiomatization false :: o ("\") - where falseE [elim]: "\ \ A" - - -axiomatization imp :: "o \ o \ o" (infixr "\" 25) - where impI [intro]: "(A \ B) \ A \ B" - and mp [dest]: "A \ B \ A \ B" - - -axiomatization conj :: "o \ o \ o" (infixr "\" 35) - where conjI [intro]: "A \ B \ A \ B" - and conjD1: "A \ B \ A" - and conjD2: "A \ B \ B" - -theorem conjE [elim]: - assumes "A \ B" - obtains A and B -proof - from \A \ B\ show A - by (rule conjD1) - from \A \ B\ show B - by (rule conjD2) -qed - - -axiomatization disj :: "o \ o \ o" (infixr "\" 30) - where disjE [elim]: "A \ B \ (A \ C) \ (B \ C) \ C" - and disjI1 [intro]: "A \ A \ B" - and disjI2 [intro]: "B \ A \ B" - - -definition true :: o ("\") - where "\ \ \ \ \" - -theorem trueI [intro]: \ - unfolding true_def .. - - -definition not :: "o \ o" ("\ _" [40] 40) - where "\ A \ A \ \" - -theorem notI [intro]: "(A \ \) \ \ A" - unfolding not_def .. - -theorem notE [elim]: "\ A \ A \ B" - unfolding not_def -proof - - assume "A \ \" and A - then have \ .. - then show B .. -qed - - -definition iff :: "o \ o \ o" (infixr "\" 25) - where "A \ B \ (A \ B) \ (B \ A)" - -theorem iffI [intro]: - assumes "A \ B" - and "B \ A" - shows "A \ B" - unfolding iff_def -proof - from \A \ B\ show "A \ B" .. - from \B \ A\ show "B \ A" .. -qed - -theorem iff1 [elim]: - assumes "A \ B" and A - shows B -proof - - from \A \ B\ have "(A \ B) \ (B \ A)" - unfolding iff_def . - then have "A \ B" .. - from this and \A\ show B .. -qed - -theorem iff2 [elim]: - assumes "A \ B" and B - shows A -proof - - from \A \ B\ have "(A \ B) \ (B \ A)" - unfolding iff_def . - then have "B \ A" .. - from this and \B\ show A .. -qed - - -subsection \Equality\ - -axiomatization equal :: "i \ i \ o" (infixl "=" 50) - where refl [intro]: "x = x" - and subst: "x = y \ P x \ P y" - -theorem trans [trans]: "x = y \ y = z \ x = z" - by (rule subst) - -theorem sym [sym]: "x = y \ y = x" -proof - - assume "x = y" - from this and refl show "y = x" - by (rule subst) -qed - - -subsection \Quantifiers\ - -axiomatization All :: "(i \ o) \ o" (binder "\" 10) - where allI [intro]: "(\x. P x) \ \x. P x" - and allD [dest]: "\x. P x \ P a" - -axiomatization Ex :: "(i \ o) \ o" (binder "\" 10) - where exI [intro]: "P a \ \x. P x" - and exE [elim]: "\x. P x \ (\x. P x \ C) \ C" - - -lemma "(\x. P (f x)) \ (\y. P y)" -proof - assume "\x. P (f x)" - then obtain x where "P (f x)" .. - then show "\y. P y" .. -qed - -lemma "(\x. \y. R x y) \ (\y. \x. R x y)" -proof - assume "\x. \y. R x y" - then obtain x where "\y. R x y" .. - show "\y. \x. R x y" - proof - fix y - from \\y. R x y\ have "R x y" .. - then show "\x. R x y" .. - qed -qed - -end diff -r 02610a806467 -r 6512e84cc9f5 src/HOL/Induct/Nested_Datatype.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Induct/Nested_Datatype.thy Sat Dec 26 19:27:46 2015 +0100 @@ -0,0 +1,61 @@ +section \Nested datatypes\ + +theory Nested_Datatype +imports Main +begin + +subsection \Terms and substitution\ + +datatype ('a, 'b) "term" = + Var 'a +| App 'b "('a, 'b) term list" + +primrec subst_term :: "('a \ ('a, 'b) term) \ ('a, 'b) term \ ('a, 'b) term" + and subst_term_list :: "('a \ ('a, 'b) term) \ ('a, 'b) term list \ ('a, 'b) term list" +where + "subst_term f (Var a) = f a" +| "subst_term f (App b ts) = App b (subst_term_list f ts)" +| "subst_term_list f [] = []" +| "subst_term_list f (t # ts) = subst_term f t # subst_term_list f ts" + +lemmas subst_simps = subst_term.simps subst_term_list.simps + +text \\<^medskip> A simple lemma about composition of substitutions.\ + +lemma + "subst_term (subst_term f1 \ f2) t = + subst_term f1 (subst_term f2 t)" + and + "subst_term_list (subst_term f1 \ f2) ts = + subst_term_list f1 (subst_term_list f2 ts)" + by (induct t and ts rule: subst_term.induct subst_term_list.induct) simp_all + +lemma "subst_term (subst_term f1 \ f2) t = subst_term f1 (subst_term f2 t)" +proof - + let "?P t" = ?thesis + let ?Q = "\ts. subst_term_list (subst_term f1 \ f2) ts = + subst_term_list f1 (subst_term_list f2 ts)" + show ?thesis + proof (induct t rule: subst_term.induct) + show "?P (Var a)" for a by simp + show "?P (App b ts)" if "?Q ts" for b ts + using that by (simp only: subst_simps) + show "?Q []" by simp + show "?Q (t # ts)" if "?P t" "?Q ts" for t ts + using that by (simp only: subst_simps) + qed +qed + + +subsection \Alternative induction\ + +lemma "subst_term (subst_term f1 \ f2) t = subst_term f1 (subst_term f2 t)" +proof (induct t rule: term.induct) + case (Var a) + show ?case by (simp add: o_def) +next + case (App b ts) + then show ?case by (induct ts) simp_all +qed + +end diff -r 02610a806467 -r 6512e84cc9f5 src/HOL/Isar_Examples/First_Order_Logic.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Isar_Examples/First_Order_Logic.thy Sat Dec 26 19:27:46 2015 +0100 @@ -0,0 +1,160 @@ +(* Title: HOL/Isar_Examples/First_Order_Logic.thy + Author: Makarius +*) + +section \A simple formulation of First-Order Logic\ + +text \ + The subsequent theory development illustrates single-sorted intuitionistic + first-order logic with equality, formulated within the Pure framework. +\ + +theory First_Order_Logic +imports Pure +begin + +subsection \Abstract syntax\ + +typedecl i +typedecl o + +judgment Trueprop :: "o \ prop" ("_" 5) + + +subsection \Propositional logic\ + +axiomatization false :: o ("\") + where falseE [elim]: "\ \ A" + + +axiomatization imp :: "o \ o \ o" (infixr "\" 25) + where impI [intro]: "(A \ B) \ A \ B" + and mp [dest]: "A \ B \ A \ B" + + +axiomatization conj :: "o \ o \ o" (infixr "\" 35) + where conjI [intro]: "A \ B \ A \ B" + and conjD1: "A \ B \ A" + and conjD2: "A \ B \ B" + +theorem conjE [elim]: + assumes "A \ B" + obtains A and B +proof + from \A \ B\ show A + by (rule conjD1) + from \A \ B\ show B + by (rule conjD2) +qed + + +axiomatization disj :: "o \ o \ o" (infixr "\" 30) + where disjE [elim]: "A \ B \ (A \ C) \ (B \ C) \ C" + and disjI1 [intro]: "A \ A \ B" + and disjI2 [intro]: "B \ A \ B" + + +definition true :: o ("\") + where "\ \ \ \ \" + +theorem trueI [intro]: \ + unfolding true_def .. + + +definition not :: "o \ o" ("\ _" [40] 40) + where "\ A \ A \ \" + +theorem notI [intro]: "(A \ \) \ \ A" + unfolding not_def .. + +theorem notE [elim]: "\ A \ A \ B" + unfolding not_def +proof - + assume "A \ \" and A + then have \ .. + then show B .. +qed + + +definition iff :: "o \ o \ o" (infixr "\" 25) + where "A \ B \ (A \ B) \ (B \ A)" + +theorem iffI [intro]: + assumes "A \ B" + and "B \ A" + shows "A \ B" + unfolding iff_def +proof + from \A \ B\ show "A \ B" .. + from \B \ A\ show "B \ A" .. +qed + +theorem iff1 [elim]: + assumes "A \ B" and A + shows B +proof - + from \A \ B\ have "(A \ B) \ (B \ A)" + unfolding iff_def . + then have "A \ B" .. + from this and \A\ show B .. +qed + +theorem iff2 [elim]: + assumes "A \ B" and B + shows A +proof - + from \A \ B\ have "(A \ B) \ (B \ A)" + unfolding iff_def . + then have "B \ A" .. + from this and \B\ show A .. +qed + + +subsection \Equality\ + +axiomatization equal :: "i \ i \ o" (infixl "=" 50) + where refl [intro]: "x = x" + and subst: "x = y \ P x \ P y" + +theorem trans [trans]: "x = y \ y = z \ x = z" + by (rule subst) + +theorem sym [sym]: "x = y \ y = x" +proof - + assume "x = y" + from this and refl show "y = x" + by (rule subst) +qed + + +subsection \Quantifiers\ + +axiomatization All :: "(i \ o) \ o" (binder "\" 10) + where allI [intro]: "(\x. P x) \ \x. P x" + and allD [dest]: "\x. P x \ P a" + +axiomatization Ex :: "(i \ o) \ o" (binder "\" 10) + where exI [intro]: "P a \ \x. P x" + and exE [elim]: "\x. P x \ (\x. P x \ C) \ C" + + +lemma "(\x. P (f x)) \ (\y. P y)" +proof + assume "\x. P (f x)" + then obtain x where "P (f x)" .. + then show "\y. P y" .. +qed + +lemma "(\x. \y. R x y) \ (\y. \x. R x y)" +proof + assume "\x. \y. R x y" + then obtain x where "\y. R x y" .. + show "\y. \x. R x y" + proof + fix y + from \\y. R x y\ have "R x y" .. + then show "\x. R x y" .. + qed +qed + +end diff -r 02610a806467 -r 6512e84cc9f5 src/HOL/Isar_Examples/Higher_Order_Logic.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Isar_Examples/Higher_Order_Logic.thy Sat Dec 26 19:27:46 2015 +0100 @@ -0,0 +1,327 @@ +(* Title: HOL/Isar_Examples/Higher_Order_Logic.thy + Author: Makarius +*) + +section \Foundations of HOL\ + +theory Higher_Order_Logic +imports Pure +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. +\ + + +subsection \Pure Logic\ + +class type +default_sort type + +typedecl o +instance o :: type .. +instance "fun" :: (type, type) type .. + + +subsubsection \Basic logical connectives\ + +judgment Trueprop :: "o \ prop" ("_" 5) + +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 + where ext [intro]: "(\x. f x = g x) \ f = g" + and iff [intro]: "(A \ B) \ (B \ A) \ A = B" + +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) + + +subsubsection \Derived connectives\ + +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 \ \" + +abbreviation not_equal :: "'a \ 'a \ o" (infixl "\" 50) + where "x \ y \ \ (x = y)" + +theorem notI [intro]: + assumes "A \ \" + shows "\ A" + using assms unfolding not_def .. + +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\ + + +definition conj :: "o \ o \ o" (infixr "\" 35) + where "conj \ \A B. \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 + assume "A \ B \ C" + also note \A\ + also note \B\ + finally show C . + qed +qed + +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 show ?thesis . + qed + show B + proof - + note * [of B] + also have "A \ B \ B" + proof + show "B \ B" .. + qed + finally show ?thesis . + qed +qed + + +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 + 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 + assume "B \ C" + from this and \B\ show C .. + qed + qed +qed + +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 thesis by (rule a) + qed + also have "B \ thesis" + proof + assume B + then show thesis by (rule b) + qed + 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" + unfolding Ex_def +proof + fix C + assume "P a" + show "(\x. P x \ C) \ C" + proof + assume "\x. P x \ C" + then have "P a \ C" .. + from this and \P a\ show C .. + qed +qed + +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 \ thesis" + proof + assume "P x" + then show thesis by (rule that) + qed + qed + finally show thesis . +qed + + +subsection \Classical logic\ + +text \ + The subsequent rules of classical reasoning are all equivalent. +\ + +locale classical = + assumes classical: "(\ A \ A) \ A" + +theorem (in classical) Peirce's_Law: "((A \ B) \ A) \ A" +proof + assume a: "(A \ B) \ A" + show A + proof (rule classical) + assume "\ A" + have "A \ B" + proof + assume A + with \\ A\ show B by (rule contradiction) + qed + with a show A .. + qed +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" +proof (rule double_negation) + show "\ \ (A \ \ A)" + proof + assume "\ (A \ \ A)" + have "\ A" + proof + assume A then have "A \ \ A" .. + with \\ (A \ \ A)\ show \ by (rule contradiction) + qed + then have "A \ \ A" .. + with \\ (A \ \ A)\ show \ by (rule contradiction) + qed +qed + +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 A . + next + assume "\ A" + then show A by (rule *) + qed +qed + +end diff -r 02610a806467 -r 6512e84cc9f5 src/HOL/Isar_Examples/Nested_Datatype.thy --- a/src/HOL/Isar_Examples/Nested_Datatype.thy Sat Dec 26 16:10:00 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -section \Nested datatypes\ - -theory Nested_Datatype -imports Main -begin - -subsection \Terms and substitution\ - -datatype ('a, 'b) "term" = - Var 'a -| App 'b "('a, 'b) term list" - -primrec subst_term :: "('a \ ('a, 'b) term) \ ('a, 'b) term \ ('a, 'b) term" - and subst_term_list :: "('a \ ('a, 'b) term) \ ('a, 'b) term list \ ('a, 'b) term list" -where - "subst_term f (Var a) = f a" -| "subst_term f (App b ts) = App b (subst_term_list f ts)" -| "subst_term_list f [] = []" -| "subst_term_list f (t # ts) = subst_term f t # subst_term_list f ts" - -lemmas subst_simps = subst_term.simps subst_term_list.simps - -text \\<^medskip> A simple lemma about composition of substitutions.\ - -lemma - "subst_term (subst_term f1 \ f2) t = - subst_term f1 (subst_term f2 t)" - and - "subst_term_list (subst_term f1 \ f2) ts = - subst_term_list f1 (subst_term_list f2 ts)" - by (induct t and ts rule: subst_term.induct subst_term_list.induct) simp_all - -lemma "subst_term (subst_term f1 \ f2) t = subst_term f1 (subst_term f2 t)" -proof - - let "?P t" = ?thesis - let ?Q = "\ts. subst_term_list (subst_term f1 \ f2) ts = - subst_term_list f1 (subst_term_list f2 ts)" - show ?thesis - proof (induct t rule: subst_term.induct) - show "?P (Var a)" for a by simp - show "?P (App b ts)" if "?Q ts" for b ts - using that by (simp only: subst_simps) - show "?Q []" by simp - show "?Q (t # ts)" if "?P t" "?Q ts" for t ts - using that by (simp only: subst_simps) - qed -qed - - -subsection \Alternative induction\ - -lemma "subst_term (subst_term f1 \ f2) t = subst_term f1 (subst_term f2 t)" -proof (induct t rule: term.induct) - case (Var a) - show ?case by (simp add: o_def) -next - case (App b ts) - then show ?case by (induct ts) simp_all -qed - -end diff -r 02610a806467 -r 6512e84cc9f5 src/HOL/Isar_Examples/document/root.bib --- a/src/HOL/Isar_Examples/document/root.bib Sat Dec 26 16:10:00 2015 +0100 +++ b/src/HOL/Isar_Examples/document/root.bib Sat Dec 26 19:27:46 2015 +0100 @@ -44,6 +44,14 @@ publisher = CUP, year = 1990} +@TechReport{Gordon:1985:HOL, + author = {M. J. C. Gordon}, + title = {{HOL}: A machine oriented formulation of higher order logic}, + institution = {University of Cambridge Computer Laboratory}, + year = 1985, + number = 68 +} + @manual{isabelle-HOL, author = {Tobias Nipkow and Lawrence C. Paulson and Markus Wenzel}, title = {{Isabelle}'s Logics: {HOL}}, diff -r 02610a806467 -r 6512e84cc9f5 src/HOL/Isar_Examples/document/root.tex --- a/src/HOL/Isar_Examples/document/root.tex Sat Dec 26 16:10:00 2015 +0100 +++ b/src/HOL/Isar_Examples/document/root.tex Sat Dec 26 19:27:46 2015 +0100 @@ -15,7 +15,7 @@ \begin{document} -\title{Miscellaneous Isabelle/Isar examples for Higher-Order Logic} +\title{Miscellaneous Isabelle/Isar examples} \author{Makarius Wenzel \\[2ex] With contributions by Gertrud Bauer and Tobias Nipkow} \maketitle diff -r 02610a806467 -r 6512e84cc9f5 src/HOL/ROOT --- a/src/HOL/ROOT Sat Dec 26 16:10:00 2015 +0100 +++ b/src/HOL/ROOT Sat Dec 26 19:27:46 2015 +0100 @@ -99,6 +99,7 @@ theories [quick_and_dirty] Common_Patterns theories + Nested_Datatype QuoDataType QuoNestedDataType Term @@ -548,7 +549,6 @@ Adhoc_Overloading_Examples Iff_Oracle Coercion_Examples - Higher_Order_Logic Abstract_NAT Guess Fundefs @@ -622,11 +622,13 @@ session "HOL-Isar_Examples" in Isar_Examples = HOL + description {* - Miscellaneous Isabelle/Isar examples for Higher-Order Logic. + Miscellaneous Isabelle/Isar examples. *} theories [document = false] "~~/src/HOL/Library/Lattice_Syntax" "../Number_Theory/Primes" + theories [quick_and_dirty] + Structured_Statements theories Basic_Logic Cantor @@ -639,12 +641,11 @@ Hoare_Ex Knaster_Tarski Mutilated_Checkerboard - Nested_Datatype Peirce Puzzle Summation - theories [quick_and_dirty] - Structured_Statements + First_Order_Logic + Higher_Order_Logic document_files "root.bib" "root.tex" diff -r 02610a806467 -r 6512e84cc9f5 src/HOL/ex/Higher_Order_Logic.thy --- a/src/HOL/ex/Higher_Order_Logic.thy Sat Dec 26 16:10:00 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,327 +0,0 @@ -(* Title: HOL/ex/Higher_Order_Logic.thy - Author: Makarius -*) - -section \Foundations of HOL\ - -theory Higher_Order_Logic -imports Pure -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. -\ - - -subsection \Pure Logic\ - -class type -default_sort type - -typedecl o -instance o :: type .. -instance "fun" :: (type, type) type .. - - -subsubsection \Basic logical connectives\ - -judgment Trueprop :: "o \ prop" ("_" 5) - -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 - where ext [intro]: "(\x. f x = g x) \ f = g" - and iff [intro]: "(A \ B) \ (B \ A) \ A = B" - -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) - - -subsubsection \Derived connectives\ - -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 \ \" - -abbreviation not_equal :: "'a \ 'a \ o" (infixl "\" 50) - where "x \ y \ \ (x = y)" - -theorem notI [intro]: - assumes "A \ \" - shows "\ A" - using assms unfolding not_def .. - -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\ - - -definition conj :: "o \ o \ o" (infixr "\" 35) - where "conj \ \A B. \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 - assume "A \ B \ C" - also note \A\ - also note \B\ - finally show C . - qed -qed - -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 show ?thesis . - qed - show B - proof - - note * [of B] - also have "A \ B \ B" - proof - show "B \ B" .. - qed - finally show ?thesis . - qed -qed - - -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 - 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 - assume "B \ C" - from this and \B\ show C .. - qed - qed -qed - -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 thesis by (rule a) - qed - also have "B \ thesis" - proof - assume B - then show thesis by (rule b) - qed - 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" - unfolding Ex_def -proof - fix C - assume "P a" - show "(\x. P x \ C) \ C" - proof - assume "\x. P x \ C" - then have "P a \ C" .. - from this and \P a\ show C .. - qed -qed - -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 \ thesis" - proof - assume "P x" - then show thesis by (rule that) - qed - qed - finally show thesis . -qed - - -subsection \Classical logic\ - -text \ - The subsequent rules of classical reasoning are all equivalent. -\ - -locale classical = - assumes classical: "(\ A \ A) \ A" - -theorem (in classical) Peirce's_Law: "((A \ B) \ A) \ A" -proof - assume a: "(A \ B) \ A" - show A - proof (rule classical) - assume "\ A" - have "A \ B" - proof - assume A - with \\ A\ show B by (rule contradiction) - qed - with a show A .. - qed -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" -proof (rule double_negation) - show "\ \ (A \ \ A)" - proof - assume "\ (A \ \ A)" - have "\ A" - proof - assume A then have "A \ \ A" .. - with \\ (A \ \ A)\ show \ by (rule contradiction) - qed - then have "A \ \ A" .. - with \\ (A \ \ A)\ show \ by (rule contradiction) - qed -qed - -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 A . - next - assume "\ A" - then show A by (rule *) - qed -qed - -end diff -r 02610a806467 -r 6512e84cc9f5 src/HOL/ex/document/root.bib --- a/src/HOL/ex/document/root.bib Sat Dec 26 16:10:00 2015 +0100 +++ b/src/HOL/ex/document/root.bib Sat Dec 26 19:27:46 2015 +0100 @@ -1,11 +1,3 @@ -@TechReport{Gordon:1985:HOL, - author = {M. J. C. Gordon}, - title = {{HOL}: A machine oriented formulation of higher order logic}, - institution = {University of Cambridge Computer Laboratory}, - year = 1985, - number = 68 -} - @inproceedings{HuttonW04,author={Graham Hutton and Joel Wright}, title={Compiling Exceptions Correctly}, booktitle={Proc.\ Conf.\ Mathematics of Program Construction},