# HG changeset patch # User wenzelm # Date 1448893382 -3600 # Node ID df6258b7e53f262d4ab83c3a0d15b682114c64b2 # Parent 0d399131008f51dfcc49f1d698c3142e5c0d5987 misc tuning and modernization; diff -r 0d399131008f -r df6258b7e53f src/FOL/ex/First_Order_Logic.thy --- a/src/FOL/ex/First_Order_Logic.thy Mon Nov 30 14:24:51 2015 +0100 +++ b/src/FOL/ex/First_Order_Logic.thy Mon Nov 30 15:23:02 2015 +0100 @@ -1,113 +1,121 @@ (* Title: FOL/ex/First_Order_Logic.thy - Author: Markus Wenzel, TU Munich + Author: Makarius *) section \A simple formulation of First-Order Logic\ -theory First_Order_Logic imports Pure begin - text \ - The subsequent theory development illustrates single-sorted - intuitionistic first-order logic with equality, formulated within - the Pure framework. Actually this is not an example of - Isabelle/FOL, but of Isabelle/Pure. + 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. \ -subsection \Syntax\ +theory First_Order_Logic +imports Pure +begin + +subsection \Abstract syntax\ typedecl i typedecl o -judgment - Trueprop :: "o \ prop" ("_" 5) +judgment Trueprop :: "o \ prop" ("_" 5) subsection \Propositional logic\ -axiomatization - false :: o ("\") and - imp :: "o \ o \ o" (infixr "\" 25) and - conj :: "o \ o \ o" (infixr "\" 35) and - disj :: "o \ o \ o" (infixr "\" 30) -where - falseE [elim]: "\ \ A" and +axiomatization false :: o ("\") + where falseE [elim]: "\ \ A" + - impI [intro]: "(A \ B) \ A \ B" and - mp [dest]: "A \ B \ A \ B" and +axiomatization imp :: "o \ o \ o" (infixr "\" 25) + where impI [intro]: "(A \ B) \ A \ B" + and mp [dest]: "A \ B \ A \ B" + - conjI [intro]: "A \ B \ A \ B" and - conjD1: "A \ B \ A" and - conjD2: "A \ B \ B" and - - disjE [elim]: "A \ B \ (A \ C) \ (B \ C) \ C" and - disjI1 [intro]: "A \ A \ B" and - disjI2 [intro]: "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) + 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 \ \" -definition iff :: "o \ o \ o" (infixr "\" 25) - where "A \ B \ (A \ B) \ (B \ A)" - - -theorem trueI [intro]: \ -proof (unfold true_def) - show "\ \ \" .. -qed - theorem notI [intro]: "(A \ \) \ \ A" -proof (unfold not_def) - assume "A \ \" - then show "A \ \" .. -qed + unfolding not_def .. theorem notE [elim]: "\ A \ A \ B" -proof (unfold not_def) + unfolding not_def +proof - assume "A \ \" and A then have \ .. then show B .. qed -theorem iffI [intro]: "(A \ B) \ (B \ A) \ A \ B" -proof (unfold iff_def) - assume "A \ B" then have "A \ B" .. - moreover assume "B \ A" then have "B \ A" .. - ultimately show "(A \ B) \ (B \ A)" .. + +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]: "A \ B \ A \ B" -proof (unfold iff_def) - assume "(A \ B) \ (B \ A)" +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" .. - then show "A \ B" .. + from this and \A\ show B .. qed -theorem iff2 [elim]: "A \ B \ B \ A" -proof (unfold iff_def) - assume "(A \ B) \ (B \ A)" +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" .. - then show "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" +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) @@ -115,43 +123,38 @@ theorem sym [sym]: "x = y \ y = x" proof - assume "x = y" - from this and refl show "y = x" by (rule subst) + from this and refl show "y = x" + by (rule subst) qed subsection \Quantifiers\ -axiomatization - All :: "(i \ o) \ o" (binder "\" 10) and - Ex :: "(i \ o) \ o" (binder "\" 10) -where - allI [intro]: "(\x. P x) \ \x. P x" and - allD [dest]: "\x. P x \ P a" and - exI [intro]: "P a \ \x. P x" and - exE [elim]: "\x. P x \ (\x. P x \ C) \ C" +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 show "\y. P y" - proof - fix x assume "P (f x)" - then show ?thesis .. - qed + 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 show "\y. \x. R x y" + then obtain x where "\y. R x y" .. + show "\y. \x. R x y" proof - fix x assume a: "\y. R x y" - show ?thesis - proof - fix y from a have "R x y" .. - then show "\x. R x y" .. - qed + fix y + from \\y. R x y\ have "R x y" .. + then show "\x. R x y" .. qed qed