# HG changeset patch # User wenzelm # Date 1455111310 -3600 # Node ID f054c364b53fe5df3f3e296169b25c020bdd0d88 # Parent c04e97be39d39efa207b0d9150d350efb848e5fa misc tuning; diff -r c04e97be39d3 -r f054c364b53f src/Doc/Isar_Ref/First_Order_Logic.thy --- a/src/Doc/Isar_Ref/First_Order_Logic.thy Wed Feb 10 14:14:43 2016 +0100 +++ b/src/Doc/Isar_Ref/First_Order_Logic.thy Wed Feb 10 14:35:10 2016 +0100 @@ -7,24 +7,21 @@ begin text \ - In order to commence a new object-logic within - Isabelle/Pure we introduce abstract syntactic categories \i\ - for individuals and \o\ for object-propositions. The latter - is embedded into the language of Pure propositions by means of a - separate judgment. + In order to commence a new object-logic within Isabelle/Pure we introduce + abstract syntactic categories \i\ for individuals and \o\ for + object-propositions. The latter is embedded into the language of Pure + propositions by means of a separate judgment. \ typedecl i typedecl o -judgment - Trueprop :: "o \ prop" ("_" 5) +judgment Trueprop :: "o \ prop" ("_" 5) text \ - Note that the object-logic judgment is implicit in the - syntax: writing @{prop A} produces @{term "Trueprop A"} internally. - From the Pure perspective this means ``@{prop A} is derivable in the - object-logic''. + Note that the object-logic judgment is implicit in the syntax: writing + @{prop A} produces @{term "Trueprop A"} internally. From the Pure + perspective this means ``@{prop A} is derivable in the object-logic''. \ @@ -32,23 +29,20 @@ text \ Equality is axiomatized as a binary predicate on individuals, with - reflexivity as introduction, and substitution as elimination - principle. Note that the latter is particularly convenient in a - framework like Isabelle, because syntactic congruences are - implicitly produced by unification of @{term "B x"} against - expressions containing occurrences of @{term x}. + reflexivity as introduction, and substitution as elimination principle. Note + that the latter is particularly convenient in a framework like Isabelle, + because syntactic congruences are implicitly produced by unification of + \B x\ against expressions containing occurrences of \x\. \ -axiomatization - equal :: "i \ i \ o" (infix "=" 50) -where - refl [intro]: "x = x" and - subst [elim]: "x = y \ B x \ B y" +axiomatization equal :: "i \ i \ o" (infix "=" 50) + where refl [intro]: "x = x" + and subst [elim]: "x = y \ B x \ B y" text \ - Substitution is very powerful, but also hard to control in - full generality. We derive some common symmetry~/ transitivity - schemes of @{term equal} as particular consequences. + Substitution is very powerful, but also hard to control in full generality. + We derive some common symmetry~/ transitivity schemes of @{term equal} as + particular consequences. \ theorem sym [sym]: @@ -87,10 +81,9 @@ subsection \Basic group theory\ text \ - As an example for equational reasoning we consider some bits of - group theory. The subsequent locale definition postulates group - operations and axioms; we also derive some consequences of this - specification. + As an example for equational reasoning we consider some bits of group + theory. The subsequent locale definition postulates group operations and + axioms; we also derive some consequences of this specification. \ locale group = @@ -125,20 +118,19 @@ qed text \ - Reasoning from basic axioms is often tedious. Our proofs - work by producing various instances of the given rules (potentially - the symmetric form) using the pattern ``@{command have}~\eq\~@{command "by"}~\(rule r)\'' and composing the chain of - results via @{command also}/@{command finally}. These steps may - involve any of the transitivity rules declared in - \secref{sec:framework-ex-equal}, namely @{thm trans} in combining - the first two results in @{thm right_inv} and in the final steps of - both proofs, @{thm forw_subst} in the first combination of @{thm + Reasoning from basic axioms is often tedious. Our proofs work by producing + various instances of the given rules (potentially the symmetric form) using + the pattern ``\<^theory_text>\have eq by (rule r)\'' and composing the chain of results + via \<^theory_text>\also\/\<^theory_text>\finally\. These steps may involve any of the transitivity + rules declared in \secref{sec:framework-ex-equal}, namely @{thm trans} in + combining the first two results in @{thm right_inv} and in the final steps + of both proofs, @{thm forw_subst} in the first combination of @{thm right_unit}, and @{thm back_subst} in all other calculational steps. - Occasional substitutions in calculations are adequate, but should - not be over-emphasized. The other extreme is to compose a chain by - plain transitivity only, with replacements occurring always in - topmost position. For example: + Occasional substitutions in calculations are adequate, but should not be + over-emphasized. The other extreme is to compose a chain by plain + transitivity only, with replacements occurring always in topmost position. + For example: \ (*<*) @@ -157,12 +149,11 @@ (*>*) text \ - Here we have re-used the built-in mechanism for unfolding - definitions in order to normalize each equational problem. A more - realistic object-logic would include proper setup for the Simplifier - (\secref{sec:simplifier}), the main automated tool for equational - reasoning in Isabelle. Then ``@{command unfolding}~@{thm - left_inv}~@{command ".."}'' would become ``@{command "by"}~\(simp only: left_inv)\'' etc. + Here we have re-used the built-in mechanism for unfolding definitions in + order to normalize each equational problem. A more realistic object-logic + would include proper setup for the Simplifier (\secref{sec:simplifier}), the + main automated tool for equational reasoning in Isabelle. Then ``\<^theory_text>\unfolding + left_inv ..\'' would become ``\<^theory_text>\by (simp only: left_inv)\'' etc. \ end @@ -172,33 +163,29 @@ text \ We axiomatize basic connectives of propositional logic: implication, - disjunction, and conjunction. The associated rules are modeled - after Gentzen's system of Natural Deduction @{cite "Gentzen:1935"}. + disjunction, and conjunction. The associated rules are modeled after + Gentzen's system of Natural Deduction @{cite "Gentzen:1935"}. \ -axiomatization - imp :: "o \ o \ o" (infixr "\" 25) where - impI [intro]: "(A \ B) \ A \ B" and - impD [dest]: "(A \ B) \ A \ B" +axiomatization imp :: "o \ o \ o" (infixr "\" 25) + where impI [intro]: "(A \ B) \ A \ B" + and impD [dest]: "(A \ B) \ A \ B" -axiomatization - disj :: "o \ o \ o" (infixr "\" 30) where - disjI\<^sub>1 [intro]: "A \ A \ B" and - disjI\<^sub>2 [intro]: "B \ A \ B" and - disjE [elim]: "A \ B \ (A \ C) \ (B \ C) \ C" +axiomatization disj :: "o \ o \ o" (infixr "\" 30) + where disjI\<^sub>1 [intro]: "A \ A \ B" + and disjI\<^sub>2 [intro]: "B \ A \ B" + and disjE [elim]: "A \ B \ (A \ C) \ (B \ C) \ C" -axiomatization - conj :: "o \ o \ o" (infixr "\" 35) where - conjI [intro]: "A \ B \ A \ B" and - conjD\<^sub>1: "A \ B \ A" and - conjD\<^sub>2: "A \ B \ B" +axiomatization conj :: "o \ o \ o" (infixr "\" 35) + where conjI [intro]: "A \ B \ A \ B" + and conjD\<^sub>1: "A \ B \ A" + and conjD\<^sub>2: "A \ B \ B" text \ - The conjunctive destructions have the disadvantage that - decomposing @{prop "A \ B"} involves an immediate decision which - component should be projected. The more convenient simultaneous - elimination @{prop "A \ B \ (A \ B \ C) \ C"} can be derived as - follows: + The conjunctive destructions have the disadvantage that decomposing @{prop + "A \ B"} involves an immediate decision which component should be projected. + The more convenient simultaneous elimination @{prop "A \ B \ (A \ B \ C) \ + C"} can be derived as follows: \ theorem conjE [elim]: @@ -210,13 +197,14 @@ qed text \ - Here is an example of swapping conjuncts with a single - intermediate elimination step: + Here is an example of swapping conjuncts with a single intermediate + elimination step: \ (*<*) lemma "\A. PROP A \ PROP A" proof - + fix A B (*>*) assume "A \ B" then obtain B and A .. @@ -226,23 +214,21 @@ (*>*) text \ - Note that the analogous elimination rule for disjunction - ``\\ A \ B \ A \ B\'' coincides with - the original axiomatization of @{thm disjE}. + Note that the analogous elimination rule for disjunction ``\<^theory_text>\assumes "A \ B" + obtains A \ B\'' coincides with the original axiomatization of @{thm + disjE}. \<^medskip> - We continue propositional logic by introducing absurdity - with its characteristic elimination. Plain truth may then be - defined as a proposition that is trivially true. + We continue propositional logic by introducing absurdity with its + characteristic elimination. Plain truth may then be defined as a proposition + that is trivially true. \ -axiomatization - false :: o ("\") where - falseE [elim]: "\ \ A" +axiomatization false :: o ("\") + where falseE [elim]: "\ \ A" -definition - true :: o ("\") where - "\ \ \ \ \" +definition true :: o ("\") + where "\ \ \ \ \" theorem trueI [intro]: \ unfolding true_def .. @@ -252,9 +238,8 @@ Now negation represents an implication towards absurdity: \ -definition - not :: "o \ o" ("\ _" [40] 40) where - "\ A \ A \ \" +definition not :: "o \ o" ("\ _" [40] 40) + where "\ A \ A \ \" theorem notI [intro]: assumes "A \ \" @@ -278,10 +263,10 @@ subsection \Classical logic\ text \ - Subsequently we state the principle of classical contradiction as a - local assumption. Thus we refrain from forcing the object-logic - into the classical perspective. Within that context, we may derive - well-known consequences of the classical principle. + Subsequently we state the principle of classical contradiction as a local + assumption. Thus we refrain from forcing the object-logic into the classical + perspective. Within that context, we may derive well-known consequences of + the classical principle. \ locale classical = @@ -312,17 +297,15 @@ qed text \ - These examples illustrate both classical reasoning and - non-trivial propositional proofs in general. All three rules - characterize classical logic independently, but the original rule is - already the most convenient to use, because it leaves the conclusion - unchanged. Note that @{prop "(\ C \ C) \ C"} fits again into our - format for eliminations, despite the additional twist that the - context refers to the main conclusion. So we may write @{thm - classical} as the Isar statement ``\\ \ thesis\''. - This also explains nicely how classical reasoning really works: - whatever the main \thesis\ might be, we may always assume its - negation! + These examples illustrate both classical reasoning and non-trivial + propositional proofs in general. All three rules characterize classical + logic independently, but the original rule is already the most convenient to + use, because it leaves the conclusion unchanged. Note that @{prop "(\ C \ C) + \ C"} fits again into our format for eliminations, despite the additional + twist that the context refers to the main conclusion. So we may write @{thm + classical} as the Isar statement ``\<^theory_text>\obtains \ thesis\''. This also explains + nicely how classical reasoning really works: whatever the main \thesis\ + might be, we may always assume its negation! \ end @@ -331,28 +314,25 @@ subsection \Quantifiers \label{sec:framework-ex-quant}\ text \ - Representing quantifiers is easy, thanks to the higher-order nature - of the underlying framework. According to the well-known technique - introduced by Church @{cite "church40"}, quantifiers are operators on - predicates, which are syntactically represented as \\\-terms - of type @{typ "i \ o"}. Binder notation turns \All (\x. B - x)\ into \\x. B x\ etc. + Representing quantifiers is easy, thanks to the higher-order nature of the + underlying framework. According to the well-known technique introduced by + Church @{cite "church40"}, quantifiers are operators on predicates, which + are syntactically represented as \\\-terms of type @{typ "i \ o"}. Binder + notation turns \All (\x. B x)\ into \\x. B x\ etc. \ -axiomatization - All :: "(i \ o) \ o" (binder "\" 10) where - allI [intro]: "(\x. B x) \ \x. B x" and - allD [dest]: "(\x. B x) \ B a" +axiomatization All :: "(i \ o) \ o" (binder "\" 10) + where allI [intro]: "(\x. B x) \ \x. B x" + and allD [dest]: "(\x. B x) \ B a" -axiomatization - Ex :: "(i \ o) \ o" (binder "\" 10) where - exI [intro]: "B a \ (\x. B x)" and - exE [elim]: "(\x. B x) \ (\x. B x \ C) \ C" +axiomatization Ex :: "(i \ o) \ o" (binder "\" 10) + where exI [intro]: "B a \ (\x. B x)" + and exE [elim]: "(\x. B x) \ (\x. B x \ C) \ C" text \ - The statement of @{thm exE} corresponds to ``\\ \x. B x \ x \ B x\'' in Isar. In the - subsequent example we illustrate quantifier reasoning involving all - four rules: + The statement of @{thm exE} corresponds to ``\<^theory_text>\assumes "\x. B x" obtains x + where "B x"\'' in Isar. In the subsequent example we illustrate quantifier + reasoning involving all four rules: \ theorem @@ -369,43 +349,42 @@ text \ The main rules of first-order predicate logic from - \secref{sec:framework-ex-prop} and \secref{sec:framework-ex-quant} - can now be summarized as follows, using the native Isar statement - format of \secref{sec:framework-stmt}. + \secref{sec:framework-ex-prop} and \secref{sec:framework-ex-quant} can now + be summarized as follows, using the native Isar statement format of + \secref{sec:framework-stmt}. \<^medskip> \begin{tabular}{l} - \impI: \ A \ B \ A \ B\ \\ - \impD: \ A \ B \ A \ B\ \\[1ex] + \<^theory_text>\impI: assumes "A \ B" shows "A \ B"\ \\ + \<^theory_text>\impD: assumes "A \ B" and A shows B\ \\[1ex] - \disjI\<^sub>1: \ A \ A \ B\ \\ - \disjI\<^sub>2: \ B \ A \ B\ \\ - \disjE: \ A \ B \ A \ B\ \\[1ex] + \<^theory_text>\disjI\<^sub>1: assumes A shows "A \ B"\ \\ + \<^theory_text>\disjI\<^sub>2: assumes B shows "A \ B"\ \\ + \<^theory_text>\disjE: assumes "A \ B" obtains A \ B\ \\[1ex] - \conjI: \ A \ B \ A \ B\ \\ - \conjE: \ A \ B \ A \ B\ \\[1ex] + \<^theory_text>\conjI: assumes A and B shows A \ B\ \\ + \<^theory_text>\conjE: assumes "A \ B" obtains A and B\ \\[1ex] - \falseE: \ \ \ A\ \\ - \trueI: \ \\ \\[1ex] + \<^theory_text>\falseE: assumes \ shows A\ \\ + \<^theory_text>\trueI: shows \\ \\[1ex] - \notI: \ A \ \ \ \ A\ \\ - \notE: \ \ A \ A \ B\ \\[1ex] + \<^theory_text>\notI: assumes "A \ \" shows "\ A"\ \\ + \<^theory_text>\notE: assumes "\ A" and A shows B\ \\[1ex] - \allI: \ \x. B x \ \x. B x\ \\ - \allE: \ \x. B x \ B a\ \\[1ex] + \<^theory_text>\allI: assumes "\x. B x" shows "\x. B x"\ \\ + \<^theory_text>\allE: assumes "\x. B x" shows "B a"\ \\[1ex] - \exI: \ B a \ \x. B x\ \\ - \exE: \ \x. B x \ a \ B a\ + \<^theory_text>\exI: assumes "B a" shows "\x. B x"\ \\ + \<^theory_text>\exE: assumes "\x. B x" obtains a where "B a"\ \end{tabular} \<^medskip> - This essentially provides a declarative reading of Pure - rules as Isar reasoning patterns: the rule statements tells how a - canonical proof outline shall look like. Since the above rules have - already been declared as @{attribute (Pure) intro}, @{attribute - (Pure) elim}, @{attribute (Pure) dest} --- each according to its - particular shape --- we can immediately write Isar proof texts as - follows: + This essentially provides a declarative reading of Pure rules as Isar + reasoning patterns: the rule statements tells how a canonical proof outline + shall look like. Since the above rules have already been declared as + @{attribute (Pure) intro}, @{attribute (Pure) elim}, @{attribute (Pure) + dest} --- each according to its particular shape --- we can immediately + write Isar proof texts as follows: \ (*<*) @@ -511,11 +490,10 @@ text \ \<^bigskip> - Of course, these proofs are merely examples. As - sketched in \secref{sec:framework-subproof}, there is a fair amount - of flexibility in expressing Pure deductions in Isar. Here the user - is asked to express himself adequately, aiming at proof texts of - literary quality. + Of course, these proofs are merely examples. As sketched in + \secref{sec:framework-subproof}, there is a fair amount of flexibility in + expressing Pure deductions in Isar. Here the user is asked to express + himself adequately, aiming at proof texts of literary quality. \ end %visible