# HG changeset patch # User wenzelm # Date 1455313008 -3600 # Node ID 1fd4831e9f93643cfe7506218b6abb853075f764 # Parent 9343649abb090550ca5fe90c5f037d550a8c2a9b# Parent f005a691df1fa8aad60291654924e86312ec4c26 merged diff -r 9343649abb09 -r 1fd4831e9f93 .hgtags --- a/.hgtags Wed Feb 10 15:49:05 2016 +0100 +++ b/.hgtags Fri Feb 12 22:36:48 2016 +0100 @@ -32,3 +32,7 @@ 5ae2a2e74c93eafeb00b1ddeef0404256745ebba Isabelle2015 e18444532fce734c2508ccffd84a4b9f166901e3 Isabelle2016-RC0 155d30f721dd7e465b9640b550b7f44ecf8b1970 Isabelle2016-RC1 +5d513565749e6818ce3bbd1b40739ddc314e17a5 Isabelle2016-RC2 +81cbea2babd968353655a825645914672529b310 Isabelle2016-RC3 +f4baefee57768cf00b1a9e003770c7573b5d7378 Isabelle2016-RC4 +45adb8dc84e1279f415cc00ee7c5e0a542fd339e Isabelle2016-RC5 diff -r 9343649abb09 -r 1fd4831e9f93 Admin/Release/CHECKLIST --- a/Admin/Release/CHECKLIST Wed Feb 10 15:49:05 2016 +0100 +++ b/Admin/Release/CHECKLIST Fri Feb 12 22:36:48 2016 +0100 @@ -28,9 +28,9 @@ - update https://bitbucket.org/isabelle_project/isabelle-website -- maintain doc/Contents; +- check doc/Contents, src/Tools/jEdit/dist/doc/Contents; -- maintain Logics: +- check Logics: ROOTS lib/html/library_index_content.template diff -r 9343649abb09 -r 1fd4831e9f93 Admin/components/components.sha1 --- a/Admin/components/components.sha1 Wed Feb 10 15:49:05 2016 +0100 +++ b/Admin/components/components.sha1 Fri Feb 12 22:36:48 2016 +0100 @@ -112,10 +112,12 @@ b4b624fb5f34d1dc814fb4fb469fafd7d7ea018a polyml-5.5.3-20150908.tar.gz b668e1f43a41608a8eb365c5e19db6c54c72748a polyml-5.5.3-20150911.tar.gz 1f5cd9b1390dab13861f90dfc06d4180cc107587 polyml-5.5.3-20150916.tar.gz +f78896e588e8ebb4da57bf0c95210b0f0fa9e551 polyml-5.6-1.tar.gz 03ba81e595fa6d6df069532d67ad3195c37d9046 polyml-5.6-20151123.tar.gz 822f489c18e38ce5ef979ec21dccce4473e09be6 polyml-5.6-20151206.tar.gz bd6a448f0e0d5787747f4f30ca661f9c1868e4a7 polyml-5.6-20151223.tar.gz 5b70c12c95a90d858f90c1945011289944ea8e17 polyml-5.6-20160118.tar.gz +5b19dc93082803b82aa553a5cfb3e914606c0ffd polyml-5.6.tar.gz 8ee375cfc38972f080dbc78f07b68dac03efe968 ProofGeneral-3.7.1.1.tar.gz 847b52c0676b5eb0fbf0476f64fc08c2d72afd0c ProofGeneral-4.1.tar.gz 8e0b2b432755ef11d964e20637d1bc567d1c0477 ProofGeneral-4.2-1.tar.gz diff -r 9343649abb09 -r 1fd4831e9f93 Admin/components/main --- a/Admin/components/main Wed Feb 10 15:49:05 2016 +0100 +++ b/Admin/components/main Fri Feb 12 22:36:48 2016 +0100 @@ -10,7 +10,7 @@ jfreechart-1.0.14-1 jortho-1.0-2 kodkodi-1.5.2 -polyml-5.6-20160118 +polyml-5.6-1 scala-2.11.7 spass-3.8ds xz-java-1.2-1 diff -r 9343649abb09 -r 1fd4831e9f93 Admin/polyml/README --- a/Admin/polyml/README Wed Feb 10 15:49:05 2016 +0100 +++ b/Admin/polyml/README Fri Feb 12 22:36:48 2016 +0100 @@ -1,8 +1,19 @@ Poly/ML for Isabelle ==================== -This is a preview of Poly/ML 5.6, based on -https://github.com/polyml/polyml/ commit 72a1c60e3d00. +This compilation of Poly/ML 5.6 (http://www.polyml.org) is based on the source +distribution from https://github.com/polyml/polyml/releases/tag/v5.6/. + +On Linux the sources have changed as follows, in order to evade a +potential conflict of /bin/bash versus /bin/sh -> dash (notably on +Ubuntu and Debian): + +diff -r src-orig/libpolyml/process_env.cpp src/libpolyml/process_env.cpp +228c228 +< execve("/bin/sh", argv, environ); +--- +> execvp("bash", argv); + The included build script is used like this: @@ -14,8 +25,8 @@ ./build src x86_64-windows --with-gmp Also note that the separate "sha1" library module is required for -efficient digesting of strings according to SHA-1. +efficient digestion of strings according to SHA-1. Makarius - 18-Jan-2016 + 11-Feb-2016 diff -r 9343649abb09 -r 1fd4831e9f93 CONTRIBUTORS --- a/CONTRIBUTORS Wed Feb 10 15:49:05 2016 +0100 +++ b/CONTRIBUTORS Fri Feb 12 22:36:48 2016 +0100 @@ -14,10 +14,6 @@ Support for real exponentiation ("powr") in the "approximation" method. (This was removed in Isabelle 2015 due to a changed definition of "powr") -* Summer 2014: Jeremy Avigad, Luke Serafin, CMU, and Johannes Hölzl, TUM - Proof of the central limit theorem: includes weak convergence, - characteristic functions, and Levy's uniqueness and continuity theorem. - * Summer 2015 - Winter 2016: Lawrence C Paulson, Cambridge General, homology form of Cauchy's integral theorem and supporting material (ported from HOL Light). @@ -25,6 +21,13 @@ * Winter 2015/16: Gerwin Klein, NICTA New print_record command. +* May - December 2015: Makarius Wenzel + Prover IDE improvements. + More Isar language elements. + Document language refinements. + Poly/ML debugger integration. + Improved multi-platform and multi-architecture support. + * Winter 2015: Manuel Eberl, TUM The radius of convergence of power series and various summability tests. Harmonic numbers and the Euler-Mascheroni constant. @@ -63,6 +66,10 @@ Command to lift a BNF structure on the raw type to the abstract type for typedefs. +* Summer 2014: Jeremy Avigad, Luke Serafin, CMU, and Johannes Hölzl, TUM + Proof of the central limit theorem: includes weak convergence, + characteristic functions, and Levy's uniqueness and continuity theorem. + Contributions to Isabelle2015 ----------------------------- diff -r 9343649abb09 -r 1fd4831e9f93 NEWS --- a/NEWS Wed Feb 10 15:49:05 2016 +0100 +++ b/NEWS Fri Feb 12 22:36:48 2016 +0100 @@ -66,13 +66,13 @@ *** Prover IDE -- Isabelle/Scala/jEdit *** * IDE support for the source-level debugger of Poly/ML, to work with -Isabelle/ML and official Standard ML. Configuration option "ML_debugger" -and commands 'ML_file_debug', 'ML_file_no_debug', 'SML_file_debug', -'SML_file_no_debug' control compilation of sources with debugging -information. The Debugger panel allows to set breakpoints (via context -menu), step through stopped threads, evaluate local ML expressions etc. -At least one Debugger view needs to be active to have any effect on the -running ML program. +Isabelle/ML and official Standard ML. Option "ML_debugger" and commands +'ML_file_debug', 'ML_file_no_debug', 'SML_file_debug', +'SML_file_no_debug' control compilation of sources with or without +debugging information. The Debugger panel allows to set breakpoints (via +context menu), step through stopped threads, evaluate local ML +expressions etc. At least one Debugger view needs to be active to have +any effect on the running ML program. * The State panel manages explicit proof state output, with dynamic auto-update according to cursor movement. Alternatively, the jEdit @@ -95,8 +95,8 @@ due to ad-hoc updates by auxiliary GUI components, such as the State panel. -* Improved scheduling for urgent print tasks (e.g. command state output, -interactive queries) wrt. long-running background tasks. +* Slightly improved scheduling for urgent print tasks (e.g. command +state output, interactive queries) wrt. long-running background tasks. * Completion of symbols via prefix of \ or \<^name> or \name is always possible, independently of the language context. It is never @@ -106,6 +106,11 @@ $ISABELLE_HOME/etc/abbrevs and $ISABELLE_HOME_USER/etc/abbrevs, with support for simple templates using ASCII 007 (bell) as placeholder. +* Symbols \, \, \, \, \, \, \, \ no longer provide abbreviations for +completion like "+o", "*o", ".o" etc. -- due to conflicts with other +ASCII syntax. INCOMPATIBILITY, use plain backslash-completion or define +suitable abbreviations in $ISABELLE_HOME_USER/etc/abbrevs. + * Action "isabelle-emph" (with keyboard shortcut C+e LEFT) controls emphasized text style; the effect is visible in document output, not in the editor. @@ -183,8 +188,8 @@ * Antiquotation @{verbatim [display]} supports option "indent". * Antiquotation @{theory_text} prints uninterpreted theory source text -(outer syntax with command keywords etc.). This may be used in the short -form \<^theory_text>\...\. @{theory_text [display]} supports option "indent". +(Isar outer syntax with command keywords etc.). This may be used in the +short form \<^theory_text>\...\. @{theory_text [display]} supports option "indent". * Antiquotation @{doc ENTRY} provides a reference to the given documentation, with a hyperlink in the Prover IDE. @@ -594,8 +599,8 @@ - New commands "lift_bnf" and "copy_bnf" for lifting (copying) a BNF structure on the raw type to an abstract type defined using typedef. - Always generate "case_transfer" theorem. - - For mutual types, generate slightly stronger "rel_induct", "rel_coinduct", - and "coinduct" theorems. INCOMPATIBLITY. + - For mutual types, generate slightly stronger "rel_induct", + "rel_coinduct", and "coinduct" theorems. INCOMPATIBLITY. - Allow discriminators and selectors with the same name as the type being defined. - Avoid various internal name clashes (e.g., 'datatype f = f'). @@ -682,8 +687,8 @@ less_eq_multiset.rep_eq ~> subseteq_mset_def INCOMPATIBILITY - Removed lemmas generated by lift_definition: - less_eq_multiset.abs_eq, less_eq_multiset.rsp less_eq_multiset.transfer - less_eq_multiset_def + less_eq_multiset.abs_eq, less_eq_multiset.rsp, + less_eq_multiset.transfer, less_eq_multiset_def INCOMPATIBILITY * Library/Omega_Words_Fun: Infinite words modeled as functions nat \ 'a. @@ -708,6 +713,9 @@ import of parent, as for general 'locale' expressions. INCOMPATIBILITY, remove '!' and add '?' as required. +* HOL-Decision_Procs: The "approximation" method works with "powr" +(exponentiation on real numbers) again. + * HOL-Multivariate_Analysis: theory Cauchy_Integral_Thm with Contour integrals (= complex path integrals), Cauchy's integral theorem, winding numbers and Cauchy's integral formula, Liouville theorem, Fundamental @@ -1249,9 +1257,6 @@ method. See HOL/Decision_Procs/ex/Approximation_Quickcheck_Ex.thy for examples. -* HOL-Decision_Procs: The "approximation" method works with "powr" - (exponentiation on real numbers) again. - * HOL-Probability: Reworked measurability prover - applies destructor rules repeatedly - removed application splitting (replaced by destructor rule) diff -r 9343649abb09 -r 1fd4831e9f93 etc/settings --- a/etc/settings Wed Feb 10 15:49:05 2016 +0100 +++ b/etc/settings Fri Feb 12 22:36:48 2016 +0100 @@ -14,7 +14,7 @@ ISABELLE_SCALA_BUILD_OPTIONS="-encoding UTF-8 -nowarn -target:jvm-1.7 -Xmax-classfile-name 130" -ISABELLE_JAVA_SYSTEM_OPTIONS="-server -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -Dfile.encoding=UTF-8 -Disabelle.threads=0" +ISABELLE_JAVA_SYSTEM_OPTIONS="-server -Dfile.encoding=UTF-8 -Disabelle.threads=0" classpath "$ISABELLE_HOME/lib/classes/Pure.jar" diff -r 9343649abb09 -r 1fd4831e9f93 etc/symbols --- a/etc/symbols Wed Feb 10 15:49:05 2016 +0100 +++ b/etc/symbols Fri Feb 12 22:36:48 2016 +0100 @@ -295,14 +295,14 @@ \ code: 0x0025b9 group: relation \ code: 0x0025b3 group: relation \ code: 0x00225c group: relation -\ code: 0x002295 group: operator abbrev: +o -\ code: 0x002a01 group: operator abbrev: +O -\ code: 0x002297 group: operator abbrev: *o -\ code: 0x002a02 group: operator abbrev: *O -\ code: 0x002299 group: operator abbrev: .o -\ code: 0x002a00 group: operator abbrev: .O -\ code: 0x002296 group: operator abbrev: -o -\ code: 0x002298 group: operator abbrev: /o +\ code: 0x002295 group: operator +\ code: 0x002a01 group: operator +\ code: 0x002297 group: operator +\ code: 0x002a02 group: operator +\ code: 0x002299 group: operator +\ code: 0x002a00 group: operator +\ code: 0x002296 group: operator +\ code: 0x002298 group: operator \ code: 0x002026 group: punctuation abbrev: ... \ code: 0x0022ef group: punctuation \ code: 0x002211 group: operator abbrev: SUM @@ -357,7 +357,7 @@ \ code: 0x0003f5 \ code: 0x002311 \ code: 0x0023ce -\ code: 0x002015 font: IsabelleText +\ code: 0x002015 group: document font: IsabelleText \ code: 0x002039 group: punctuation font: IsabelleText abbrev: << \ code: 0x00203a group: punctuation font: IsabelleText abbrev: >> \ code: 0x002302 font: IsabelleText diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/Base.thy --- a/src/Doc/Isar_Ref/Base.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/Base.thy Fri Feb 12 22:36:48 2016 +0100 @@ -2,8 +2,14 @@ theory Base imports Pure +keywords "\" :: "qed" % "proof" begin +ML \ + Outer_Syntax.command @{command_keyword "\"} "dummy proof" + (Scan.succeed Isar_Cmd.skip_proof); +\ + ML_file "../antiquote_setup.ML" end diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/Document_Preparation.thy --- a/src/Doc/Isar_Ref/Document_Preparation.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/Document_Preparation.thy Fri Feb 12 22:36:48 2016 +0100 @@ -409,6 +409,49 @@ \ +section \Markdown-like text structure\ + +text \ + The markup commands @{command_ref text}, @{command_ref txt}, @{command_ref + text_raw} (\secref{sec:markup}) consist of plain text. Its internal + structure consists of paragraphs and (nested) lists, using special Isabelle + symbols and some rules for indentation and blank lines. This quasi-visual + format resembles \<^emph>\Markdown\\<^footnote>\@{url "http://commonmark.org"}\, but the + full complexity of that notation is avoided. + + This is a summary of the main principles of minimal Markdown in Isabelle: + + \<^item> List items start with the following markers + \<^descr>[itemize:] \<^verbatim>\\<^item>\ + \<^descr>[enumerate:] \<^verbatim>\\<^enum>\ + \<^descr>[description:] \<^verbatim>\\<^descr>\ + + \<^item> Adjacent list items with same indentation and same marker are grouped + into a single list. + + \<^item> Singleton blank lines separate paragraphs. + + \<^item> Multiple blank lines escape from the current list hierarchy. + + Notable differences to official Markdown: + + \<^item> Indentation of list items needs to match exactly. + + \<^item> Indentation is unlimited (official Markdown interprets four spaces as + block quote). + + \<^item> List items always consist of paragraphs --- there is no notion of + ``tight'' list. + + \<^item> Section headings are expressed via Isar document markup commands + (\secref{sec:markup}). + + \<^item> URLs, font styles, other special content is expressed via antiquotations + (\secref{sec:antiq}), usually with proper nesting of sub-languages via + text cartouches. +\ + + section \Markup via command tags \label{sec:tags}\ text \ diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/First_Order_Logic.thy --- a/src/Doc/Isar_Ref/First_Order_Logic.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/First_Order_Logic.thy Fri Feb 12 22:36:48 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: \ (*<*) @@ -418,47 +397,47 @@ have "A \ B" proof assume A - show B sorry %noproof + show B \ qed text_raw \\end{minipage}\qquad\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) - have "A \ B" and A sorry %noproof + have "A \ B" and A \ then have B .. text_raw \\end{minipage}\\[3ex]\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) - have A sorry %noproof + have A \ then have "A \ B" .. - have B sorry %noproof + have B \ then have "A \ B" .. text_raw \\end{minipage}\qquad\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) - have "A \ B" sorry %noproof + have "A \ B" \ then have C proof assume A - then show C sorry %noproof + then show C \ next assume B - then show C sorry %noproof + then show C \ qed text_raw \\end{minipage}\\[3ex]\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) - have A and B sorry %noproof + have A and B \ then have "A \ B" .. text_raw \\end{minipage}\qquad\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) - have "A \ B" sorry %noproof + have "A \ B" \ then obtain A and B .. text_raw \\end{minipage}\\[3ex]\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) - have "\" sorry %noproof + have "\" \ then have A .. text_raw \\end{minipage}\qquad\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) @@ -470,12 +449,12 @@ have "\ A" proof assume A - then show "\" sorry %noproof + then show "\" \ qed text_raw \\end{minipage}\qquad\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) - have "\ A" and A sorry %noproof + have "\ A" and A \ then have B .. text_raw \\end{minipage}\\[3ex]\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) @@ -483,24 +462,24 @@ have "\x. B x" proof fix x - show "B x" sorry %noproof + show "B x" \ qed text_raw \\end{minipage}\qquad\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) - have "\x. B x" sorry %noproof + have "\x. B x" \ then have "B a" .. text_raw \\end{minipage}\\[3ex]\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) have "\x. B x" proof - show "B a" sorry %noproof + show "B a" \ qed text_raw \\end{minipage}\qquad\begin{minipage}[t]{0.4\textwidth}\(*<*)next(*>*) - have "\x. B x" sorry %noproof + have "\x. B x" \ then obtain a where "B a" .. text_raw \\end{minipage}\ @@ -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 diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/Framework.thy --- a/src/Doc/Isar_Ref/Framework.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/Framework.thy Fri Feb 12 22:36:48 2016 +0100 @@ -8,75 +8,115 @@ text \ Isabelle/Isar @{cite "Wenzel:1999:TPHOL" and "Wenzel-PhD" and - "Nipkow-TYPES02" and "Wenzel-Paulson:2006" and "Wenzel:2006:Festschrift"} - is intended as a generic framework for developing formal - mathematical documents with full proof checking. Definitions and - proofs are organized as theories. An assembly of theory sources may - be presented as a printed document; see also - \chref{ch:document-prep}. + "Nipkow-TYPES02" and "Wiedijk:1999:Mizar" and "Wenzel-Paulson:2006" and + "Wenzel:2006:Festschrift"} is a generic framework for developing formal + mathematical documents with full proof checking. Definitions, statements and + proofs are organized as theories. A collection of theories sources may be + presented as a printed document; see also \chref{ch:document-prep}. + + The main concern of Isar is the design of a human-readable structured proof + language, which is called the ``primary proof format'' in Isar terminology. + Such a primary proof language is somewhere in the middle between the + extremes of primitive proof objects and actual natural language. - The main objective of Isar is the design of a human-readable - structured proof language, which is called the ``primary proof - format'' in Isar terminology. Such a primary proof language is - somewhere in the middle between the extremes of primitive proof - objects and actual natural language. In this respect, Isar is a bit - more formalistic than Mizar @{cite "Trybulec:1993:MizarFeatures" and - "Rudnicki:1992:MizarOverview" and "Wiedijk:1999:Mizar"}, - using logical symbols for certain reasoning schemes where Mizar - would prefer English words; see @{cite "Wenzel-Wiedijk:2002"} for - further comparisons of these systems. + Thus Isar challenges the traditional way of recording informal proofs in + mathematical prose, as well as the common tendency to see fully formal + proofs directly as objects of some logical calculus (e.g.\ \\\-terms in a + version of type theory). Technically, Isar is an interpreter of a simple + block-structured language for describing the data flow of local facts and + goals, interspersed with occasional invocations of proof methods. Everything + is reduced to logical inferences internally, but these steps are somewhat + marginal compared to the overall bookkeeping of the interpretation process. + Thanks to careful design of the syntax and semantics of Isar language + elements, a formal record of Isar commands may later appear as an + intelligible text to the human reader. + + The Isar proof language has emerged from careful analysis of some inherent + virtues of the logical framework Isabelle/Pure @{cite "paulson-found" and + "paulson700"}, notably composition of higher-order natural deduction rules, + which is a generalization of Gentzen's original calculus @{cite + "Gentzen:1935"}. The approach of generic inference systems in Pure is + continued by Isar towards actual proof texts. See also + \figref{fig:natural-deduction} + + \begin{figure}[htb] + + \begin{center} + \begin{minipage}[t]{0.9\textwidth} - So Isar challenges the traditional way of recording informal proofs - in mathematical prose, as well as the common tendency to see fully - formal proofs directly as objects of some logical calculus (e.g.\ - \\\-terms in a version of type theory). In fact, Isar is - better understood as an interpreter of a simple block-structured - language for describing the data flow of local facts and goals, - interspersed with occasional invocations of proof methods. - Everything is reduced to logical inferences internally, but these - steps are somewhat marginal compared to the overall bookkeeping of - the interpretation process. Thanks to careful design of the syntax - and semantics of Isar language elements, a formal record of Isar - instructions may later appear as an intelligible text to the - attentive reader. + \textbf{Inferences:} + \begin{center} + \begin{tabular}{l@ {\qquad}l} + \infer{\B\}{\A \ B\ & \A\} & + \infer{\A \ B\}{\infer*{\B\}{\[A]\}} \\ + \end{tabular} + \end{center} + + \textbf{Isabelle/Pure:} + \begin{center} + \begin{tabular}{l@ {\qquad}l} + \(A \ B) \ A \ B\ & + \(A \ B) \ A \ B\ + \end{tabular} + \end{center} - The Isar proof language has emerged from careful analysis of some - inherent virtues of the existing logical framework of Isabelle/Pure - @{cite "paulson-found" and "paulson700"}, notably composition of higher-order - natural deduction rules, which is a generalization of Gentzen's - original calculus @{cite "Gentzen:1935"}. The approach of generic - inference systems in Pure is continued by Isar towards actual proof - texts. + \textbf{Isabelle/Isar:} + \begin{center} + \begin{minipage}[t]{0.4\textwidth} + @{theory_text [display, indent = 2] + \have "A \ B" \ +also have A \ +finally have B .\} + \end{minipage} + \begin{minipage}[t]{0.4\textwidth} + @{theory_text [display, indent = 2] + \have "A \ B" +proof + assume A + then show B \ +qed\} + \end{minipage} + \end{center} - Concrete applications require another intermediate layer: an - object-logic. Isabelle/HOL @{cite "isa-tutorial"} (simply-typed - set-theory) is being used most of the time; Isabelle/ZF - @{cite "isabelle-ZF"} is less extensively developed, although it would - probably fit better for classical mathematics. + \end{minipage} + \end{center} + + \caption{Natural Deduction via inferences according to Gentzen, rules in + Isabelle/Pure, and proofs in Isabelle/Isar}\label{fig:natural-deduction} + + \end{figure} \<^medskip> - In order to illustrate natural deduction in Isar, we shall - refer to the background theory and library of Isabelle/HOL. This - includes common notions of predicate logic, naive set-theory etc.\ - using fairly standard mathematical notation. From the perspective - of generic natural deduction there is nothing special about the - logical connectives of HOL (\\\, \\\, \\\, - \\\, etc.), only the resulting reasoning principles are - relevant to the user. There are similar rules available for - set-theory operators (\\\, \\\, \\\, \\\, etc.), or any other theory developed in the library (lattice - theory, topology etc.). + Concrete applications require another intermediate layer: an object-logic. + Isabelle/HOL @{cite "isa-tutorial"} (simply-typed set-theory) is most + commonly used; elementary examples are given in the directory @{file + "~~/src/HOL/Isar_Examples"}. Some examples demonstrate how to start a fresh + object-logic from Isabelle/Pure, and use Isar proofs from the very start, + despite the lack of advanced proof tools at such an early stage (e.g.\ see + @{file "~~/src/HOL/Isar_Examples/Higher_Order_Logic.thy"}). Isabelle/FOL + @{cite "isabelle-logics"} and Isabelle/ZF @{cite "isabelle-ZF"} also work, + but are much less developed. - Subsequently we briefly review fragments of Isar proof texts - corresponding directly to such general deduction schemes. The - examples shall refer to set-theory, to minimize the danger of - understanding connectives of predicate logic as something special. + In order to illustrate natural deduction in Isar, we shall subsequently + refer to the background theory and library of Isabelle/HOL. This includes + common notions of predicate logic, naive set-theory etc.\ using fairly + standard mathematical notation. From the perspective of generic natural + deduction there is nothing special about the logical connectives of HOL + (\\\, \\\, \\\, \\\, etc.), only the resulting reasoning principles are + relevant to the user. There are similar rules available for set-theory + operators (\\\, \\\, \\\, \\\, etc.), or any other theory developed in the + library (lattice theory, topology etc.). + + Subsequently we briefly review fragments of Isar proof texts corresponding + directly to such general deduction schemes. The examples shall refer to + set-theory, to minimize the danger of understanding connectives of predicate + logic as something special. \<^medskip> - The following deduction performs \\\-introduction, - working forwards from assumptions towards the conclusion. We give - both the Isar text, and depict the primitive rule involved, as - determined by unification of the problem against rules that are - declared in the library context. + The following deduction performs \\\-introduction, working forwards from + assumptions towards the conclusion. We give both the Isar text, and depict + the primitive rule involved, as determined by unification of fact and goal + statements against rules that are declared in the library context. \ text_raw \\medskip\begin{minipage}{0.6\textwidth}\ @@ -84,6 +124,7 @@ (*<*) notepad begin + fix x :: 'a and A B (*>*) assume "x \ A" and "x \ B" then have "x \ A \ B" .. @@ -94,25 +135,25 @@ text_raw \\end{minipage}\begin{minipage}{0.4\textwidth}\ text \ - \infer{@{prop "x \ A \ B"}}{@{prop "x \ A"} & @{prop "x \ B"}} + \infer{\x \ A \ B\}{\x \ A\ & \x \ B\} \ text_raw \\end{minipage}\ text \ \<^medskip> - Note that @{command assume} augments the proof - context, @{command then} indicates that the current fact shall be - used in the next step, and @{command have} states an intermediate - goal. The two dots ``@{command ".."}'' refer to a complete proof of - this claim, using the indicated facts and a canonical rule from the - context. We could have been more explicit here by spelling out the - final proof step via the @{command "by"} command: + Note that \<^theory_text>\assume\ augments the proof context, \<^theory_text>\then\ indicates that the + current fact shall be used in the next step, and \<^theory_text>\have\ states an + intermediate goal. The two dots ``\<^theory_text>\..\'' refer to a complete proof of this + claim, using the indicated facts and a canonical rule from the context. We + could have been more explicit here by spelling out the final proof step via + the \<^theory_text>\by\ command: \ (*<*) notepad begin + fix x :: 'a and A B (*>*) assume "x \ A" and "x \ B" then have "x \ A \ B" by (rule IntI) @@ -121,14 +162,14 @@ (*>*) text \ - The format of the \\\-introduction rule represents - the most basic inference, which proceeds from given premises to a - conclusion, without any nested proof context involved. + The format of the \\\-introduction rule represents the most basic inference, + which proceeds from given premises to a conclusion, without any nested proof + context involved. - The next example performs backwards introduction on @{term "\\"}, - the intersection of all sets within a given set. This requires a - nested proof of set membership within a local context, where @{term - A} is an arbitrary-but-fixed member of the collection: + The next example performs backwards introduction of \\\\, the intersection + of all sets within a given set. This requires a nested proof of set + membership within a local context, where \A\ is an arbitrary-but-fixed + member of the collection: \ text_raw \\medskip\begin{minipage}{0.6\textwidth}\ @@ -136,12 +177,13 @@ (*<*) notepad begin + fix x :: 'a and \ (*>*) have "x \ \\" proof fix A assume "A \ \" - show "x \ A" sorry %noproof + show "x \ A" \ qed (*<*) end @@ -150,35 +192,30 @@ text_raw \\end{minipage}\begin{minipage}{0.4\textwidth}\ text \ - \infer{@{prop "x \ \\"}}{\infer*{@{prop "x \ A"}}{\[A][A \ \]\}} + \infer{\x \ \\\}{\infer*{\x \ A\}{\[A][A \ \]\}} \ text_raw \\end{minipage}\ text \ \<^medskip> - This Isar reasoning pattern again refers to the - primitive rule depicted above. The system determines it in the - ``@{command proof}'' step, which could have been spelled out more - explicitly as ``@{command proof}~\(rule InterI)\''. Note - that the rule involves both a local parameter @{term "A"} and an - assumption @{prop "A \ \"} in the nested reasoning. This kind of - compound rule typically demands a genuine sub-proof in Isar, working - backwards rather than forwards as seen before. In the proof body we - encounter the @{command fix}-@{command assume}-@{command show} - outline of nested sub-proofs that is typical for Isar. The final - @{command show} is like @{command have} followed by an additional - refinement of the enclosing claim, using the rule derived from the - proof body. + This Isar reasoning pattern again refers to the primitive rule depicted + above. The system determines it in the ``\<^theory_text>\proof\'' step, which could have + been spelled out more explicitly as ``\<^theory_text>\proof (rule InterI)\''. Note that + the rule involves both a local parameter \A\ and an assumption \A \ \\ in + the nested reasoning. Such compound rules typically demands a genuine + subproof in Isar, working backwards rather than forwards as seen before. In + the proof body we encounter the \<^theory_text>\fix\-\<^theory_text>\assume\-\<^theory_text>\show\ outline of nested + subproofs that is typical for Isar. The final \<^theory_text>\show\ is like \<^theory_text>\have\ + followed by an additional refinement of the enclosing claim, using the rule + derived from the proof body. \<^medskip> - The next example involves @{term "\\"}, which can be - characterized as the set of all @{term "x"} such that @{prop "\A. x - \ A \ A \ \"}. The elimination rule for @{prop "x \ \\"} does - not mention \\\ and \\\ at all, but admits to obtain - directly a local @{term "A"} such that @{prop "x \ A"} and @{prop "A - \ \"} hold. This corresponds to the following Isar proof and - inference rule, respectively: + The next example involves \\\\, which can be characterized as the set of + all \x\ such that \\A. x \ A \ A \ \\. The elimination rule for \x \ \\\ + does not mention \\\ and \\\ at all, but admits to obtain directly a local + \A\ such that \x \ A\ and \A \ \\ hold. This corresponds to the following + Isar proof and inference rule, respectively: \ text_raw \\medskip\begin{minipage}{0.6\textwidth}\ @@ -186,13 +223,14 @@ (*<*) notepad begin + fix x :: 'a and \ C (*>*) assume "x \ \\" then have C proof fix A assume "x \ A" and "A \ \" - show C sorry %noproof + show C \ qed (*<*) end @@ -201,26 +239,25 @@ text_raw \\end{minipage}\begin{minipage}{0.4\textwidth}\ text \ - \infer{@{prop "C"}}{@{prop "x \ \\"} & \infer*{@{prop "C"}~}{\[A][x \ A, A \ \]\}} + \infer{\C\}{\x \ \\\ & \infer*{\C\~}{\[A][x \ A, A \ \]\}} \ text_raw \\end{minipage}\ text \ \<^medskip> - Although the Isar proof follows the natural - deduction rule closely, the text reads not as natural as - anticipated. There is a double occurrence of an arbitrary - conclusion @{prop "C"}, which represents the final result, but is - irrelevant for now. This issue arises for any elimination rule - involving local parameters. Isar provides the derived language - element @{command obtain}, which is able to perform the same - elimination proof more conveniently: + Although the Isar proof follows the natural deduction rule closely, the text + reads not as natural as anticipated. There is a double occurrence of an + arbitrary conclusion \C\, which represents the final result, but is + irrelevant for now. This issue arises for any elimination rule involving + local parameters. Isar provides the derived language element \<^theory_text>\obtain\, + which is able to perform the same elimination proof more conveniently: \ (*<*) notepad begin + fix x :: 'a and \ (*>*) assume "x \ \\" then obtain A where "x \ A" and "A \ \" .. @@ -229,9 +266,9 @@ (*>*) text \ - Here we avoid to mention the final conclusion @{prop "C"} - and return to plain forward reasoning. The rule involved in the - ``@{command ".."}'' proof is the same as before. + Here we avoid to mention the final conclusion \C\ and return to plain + forward reasoning. The rule involved in the ``\<^theory_text>\..\'' proof is the same as + before. \ @@ -239,9 +276,9 @@ text \ The Pure logic @{cite "paulson-found" and "paulson700"} is an intuitionistic - fragment of higher-order logic @{cite "church40"}. In type-theoretic - parlance, there are three levels of \\\-calculus with - corresponding arrows \\\/\\\/\\\: + fragment of higher-order logic @{cite "church40"}. In type-theoretic + parlance, there are three levels of \\\-calculus with corresponding arrows + \\\/\\\/\\\: \<^medskip> \begin{tabular}{ll} @@ -251,39 +288,35 @@ \end{tabular} \<^medskip> - Here only the types of syntactic terms, and the - propositions of proof terms have been shown. The \\\-structure of proofs can be recorded as an optional feature of - the Pure inference kernel @{cite "Berghofer-Nipkow:2000:TPHOL"}, but - the formal system can never depend on them due to \<^emph>\proof - irrelevance\. + Here only the types of syntactic terms, and the propositions of proof terms + have been shown. The \\\-structure of proofs can be recorded as an optional + feature of the Pure inference kernel @{cite "Berghofer-Nipkow:2000:TPHOL"}, + but the formal system can never depend on them due to \<^emph>\proof irrelevance\. - On top of this most primitive layer of proofs, Pure implements a - generic calculus for nested natural deduction rules, similar to - @{cite "Schroeder-Heister:1984"}. Here object-logic inferences are - internalized as formulae over \\\ and \\\. - Combining such rule statements may involve higher-order unification - @{cite "paulson-natural"}. + On top of this most primitive layer of proofs, Pure implements a generic + calculus for nested natural deduction rules, similar to @{cite + "Schroeder-Heister:1984"}. Here object-logic inferences are internalized as + formulae over \\\ and \\\. Combining such rule statements may involve + higher-order unification @{cite "paulson-natural"}. \ subsection \Primitive inferences\ text \ - Term syntax provides explicit notation for abstraction \\x :: - \. b(x)\ and application \b a\, while types are usually - implicit thanks to type-inference; terms of type \prop\ are - called propositions. Logical statements are composed via \\x - :: \. B(x)\ and \A \ B\. Primitive reasoning operates on - judgments of the form \\ \ \\, with standard introduction - and elimination rules for \\\ and \\\ that refer to - fixed parameters \x\<^sub>1, \, x\<^sub>m\ and hypotheses - \A\<^sub>1, \, A\<^sub>n\ from the context \\\; - the corresponding proof terms are left implicit. The subsequent - inference rules define \\ \ \\ inductively, relative to a - collection of axioms: + Term syntax provides explicit notation for abstraction \\x :: \. b(x)\ and + application \b a\, while types are usually implicit thanks to + type-inference; terms of type \prop\ are called propositions. Logical + statements are composed via \\x :: \. B(x)\ and \A \ B\. Primitive reasoning + operates on judgments of the form \\ \ \\, with standard introduction and + elimination rules for \\\ and \\\ that refer to fixed parameters \x\<^sub>1, \, + x\<^sub>m\ and hypotheses \A\<^sub>1, \, A\<^sub>n\ from the context \\\; the corresponding + proof terms are left implicit. The subsequent inference rules define \\ \ \\ + inductively, relative to a collection of axioms from the implicit background + theory: \[ - \infer{\\ A\}{(\A\ \mbox{~axiom})} + \infer{\\ A\}{\A\ \mbox{~is axiom}} \qquad \infer{\A \ A\}{} \] @@ -300,68 +333,61 @@ \infer{\\\<^sub>1 \ \\<^sub>2 \ B\}{\\\<^sub>1 \ A \ B\ & \\\<^sub>2 \ A\} \] - Furthermore, Pure provides a built-in equality \\ :: \ \ \ \ - prop\ with axioms for reflexivity, substitution, extensionality, - and \\\\\-conversion on \\\-terms. + Furthermore, Pure provides a built-in equality \\ :: \ \ \ \ prop\ with + axioms for reflexivity, substitution, extensionality, and \\\\\-conversion + on \\\-terms. \<^medskip> - An object-logic introduces another layer on top of Pure, - e.g.\ with types \i\ for individuals and \o\ for - propositions, term constants \Trueprop :: o \ prop\ as - (implicit) derivability judgment and connectives like \\ :: o - \ o \ o\ or \\ :: (i \ o) \ o\, and axioms for object-level - rules such as \conjI: A \ B \ A \ B\ or \allI: (\x. B - x) \ \x. B x\. Derived object rules are represented as theorems of - Pure. After the initial object-logic setup, further axiomatizations - are usually avoided; plain definitions and derived principles are - used exclusively. + + An object-logic introduces another layer on top of Pure, e.g.\ with types + \i\ for individuals and \o\ for propositions, term constants \Trueprop :: o + \ prop\ as (implicit) derivability judgment and connectives like \\ :: o \ o + \ o\ or \\ :: (i \ o) \ o\, and axioms for object-level rules such as + \conjI: A \ B \ A \ B\ or \allI: (\x. B x) \ \x. B x\. Derived object rules + are represented as theorems of Pure. After the initial object-logic setup, + further axiomatizations are usually avoided: definitional principles are + used instead (e.g.\ \<^theory_text>\definition\, \<^theory_text>\inductive\, \<^theory_text>\fun\, \<^theory_text>\function\). \ subsection \Reasoning with rules \label{sec:framework-resolution}\ text \ - Primitive inferences mostly serve foundational purposes. The main - reasoning mechanisms of Pure operate on nested natural deduction - rules expressed as formulae, using \\\ to bind local - parameters and \\\ to express entailment. Multiple - parameters and premises are represented by repeating these + Primitive inferences mostly serve foundational purposes. The main reasoning + mechanisms of Pure operate on nested natural deduction rules expressed as + formulae, using \\\ to bind local parameters and \\\ to express entailment. + Multiple parameters and premises are represented by repeating these connectives in a right-associative manner. - Since \\\ and \\\ commute thanks to the theorem - @{prop "(A \ (\x. B x)) \ (\x. A \ B x)"}, we may assume w.l.o.g.\ - that rule statements always observe the normal form where - quantifiers are pulled in front of implications at each level of - nesting. This means that any Pure proposition may be presented as a - \<^emph>\Hereditary Harrop Formula\ @{cite "Miller:1991"} which is of the - form \\x\<^sub>1 \ x\<^sub>m. H\<^sub>1 \ \ H\<^sub>n \ - A\ for \m, n \ 0\, and \A\ atomic, and \H\<^sub>1, \, H\<^sub>n\ being recursively of the same format. - Following the convention that outermost quantifiers are implicit, - Horn clauses \A\<^sub>1 \ \ A\<^sub>n \ A\ are a special - case of this. + Thanks to the Pure theorem @{prop "(A \ (\x. B x)) \ (\x. A \ B x)"} the + connectives \\\ and \\\ commute. So we may assume w.l.o.g.\ that rule + statements always observe the normal form where quantifiers are pulled in + front of implications at each level of nesting. This means that any Pure + proposition may be presented as a \<^emph>\Hereditary Harrop Formula\ @{cite + "Miller:1991"} which is of the form \\x\<^sub>1 \ x\<^sub>m. H\<^sub>1 \ \ H\<^sub>n \ A\ for \m, n + \ 0\, and \A\ atomic, and \H\<^sub>1, \, H\<^sub>n\ being recursively of the same + format. Following the convention that outermost quantifiers are implicit, + Horn clauses \A\<^sub>1 \ \ A\<^sub>n \ A\ are a special case of this. - For example, \\\-introduction rule encountered before is - represented as a Pure theorem as follows: + For example, the \\\-introduction rule encountered before is represented as + a Pure theorem as follows: \[ \IntI:\~@{prop "x \ A \ x \ B \ x \ A \ B"} \] - This is a plain Horn clause, since no further nesting on - the left is involved. The general \\\-introduction - corresponds to a Hereditary Harrop Formula with one additional level - of nesting: + This is a plain Horn clause, since no further nesting on the left is + involved. The general \\\-introduction corresponds to a Hereditary Harrop + Formula with one additional level of nesting: \[ \InterI:\~@{prop "(\A. A \ \ \ x \ A) \ x \ \\"} \] \<^medskip> - Goals are also represented as rules: \A\<^sub>1 \ - \ A\<^sub>n \ C\ states that the sub-goals \A\<^sub>1, \, - A\<^sub>n\ entail the result \C\; for \n = 0\ the - goal is finished. To allow \C\ being a rule statement - itself, we introduce the protective marker \# :: prop \ - prop\, which is defined as identity and hidden from the user. We - initialize and finish goal states as follows: + Goals are also represented as rules: \A\<^sub>1 \ \ A\<^sub>n \ C\ states that the + subgoals \A\<^sub>1, \, A\<^sub>n\ entail the result \C\; for \n = 0\ the goal is + finished. To allow \C\ being a rule statement itself, there is an internal + protective marker \# :: prop \ prop\, which is defined as identity and + hidden from the user. We initialize and finish goal states as follows: \[ \begin{array}{c@ {\qquad}c} @@ -370,12 +396,12 @@ \end{array} \] - Goal states are refined in intermediate proof steps until - a finished form is achieved. Here the two main reasoning principles - are @{inference resolution}, for back-chaining a rule against a - sub-goal (replacing it by zero or more sub-goals), and @{inference - assumption}, for solving a sub-goal (finding a short-circuit with - local assumptions). Below \\<^vec>x\ stands for \x\<^sub>1, \, x\<^sub>n\ (\n \ 0\). + Goal states are refined in intermediate proof steps until a finished form is + achieved. Here the two main reasoning principles are @{inference + resolution}, for back-chaining a rule against a subgoal (replacing it by + zero or more subgoals), and @{inference assumption}, for solving a subgoal + (finding a short-circuit with local assumptions). Below \\<^vec>x\ stands + for \x\<^sub>1, \, x\<^sub>n\ (for \n \ 0\). \[ \infer[(@{inference_def resolution})] @@ -397,7 +423,7 @@ {\begin{tabular}{rl} \goal:\ & \(\\<^vec>x. \<^vec>H \<^vec>x \ A \<^vec>x) \ C\ \\ - \assm unifier:\ & \A\ = H\<^sub>i\\~~\mbox{(for some~\H\<^sub>i\)} \\ + \assm unifier:\ & \A\ = H\<^sub>i\\~~\mbox{for some~\H\<^sub>i\} \\ \end{tabular}} \] @@ -418,215 +444,166 @@ \<^medskip> } - Compositions of @{inference assumption} after @{inference - resolution} occurs quite often, typically in elimination steps. - Traditional Isabelle tactics accommodate this by a combined - @{inference_def elim_resolution} principle. In contrast, Isar uses - a slightly more refined combination, where the assumptions to be - closed are marked explicitly, using again the protective marker - \#\: + Compositions of @{inference assumption} after @{inference resolution} occurs + quite often, typically in elimination steps. Traditional Isabelle tactics + accommodate this by a combined @{inference_def elim_resolution} principle. + In contrast, Isar uses a combined refinement rule as follows:\footnote{For + simplicity and clarity, the presentation ignores \<^emph>\weak premises\ as + introduced via \<^theory_text>\presume\ or \<^theory_text>\show \ when\.} + {\small \[ \infer[(@{inference refinement})] - {\(\\<^vec>x. \<^vec>H \<^vec>x \ \<^vec>G' (\<^vec>a \<^vec>x))\ \ C\\} + {\C\\} {\begin{tabular}{rl} - \sub\proof:\ & - \\<^vec>G \<^vec>a \ B \<^vec>a\ \\ - \goal:\ & + \subgoal:\ & \(\\<^vec>x. \<^vec>H \<^vec>x \ B' \<^vec>x) \ C\ \\ - \goal unifier:\ & + \subproof:\ & + \\<^vec>G \<^vec>a \ B \<^vec>a\ \quad for schematic \\<^vec>a\ \\ + \concl unifier:\ & \(\\<^vec>x. B (\<^vec>a \<^vec>x))\ = B'\\ \\ \assm unifiers:\ & - \(\\<^vec>x. G\<^sub>j (\<^vec>a \<^vec>x))\ = #H\<^sub>i\\ \\ - & \quad (for each marked \G\<^sub>j\ some \#H\<^sub>i\) \\ + \(\\<^vec>x. G\<^sub>j (\<^vec>a \<^vec>x))\ = H\<^sub>i\\ \quad for each \G\<^sub>j\ some \H\<^sub>i\ \\ \end{tabular}} - \] + \]} - Here the \sub\proof\ rule stems from the - main @{command fix}-@{command assume}-@{command show} outline of - Isar (cf.\ \secref{sec:framework-subproof}): each assumption - indicated in the text results in a marked premise \G\ above. - The marking enforces resolution against one of the sub-goal's - premises. Consequently, @{command fix}-@{command assume}-@{command - show} enables to fit the result of a sub-proof quite robustly into a - pending sub-goal, while maintaining a good measure of flexibility. + Here the \subproof\ rule stems from the main \<^theory_text>\fix\-\<^theory_text>\assume\-\<^theory_text>\show\ + outline of Isar (cf.\ \secref{sec:framework-subproof}): each assumption + indicated in the text results in a marked premise \G\ above. Consequently, + \<^theory_text>\fix\-\<^theory_text>\assume\-\<^theory_text>\show\ enables to fit the result of a subproof quite + robustly into a pending subgoal, while maintaining a good measure of + flexibility: the subproof only needs to fit modulo unification, and its + assumptions may be a proper subset of the subgoal premises (see + \secref{sec:framework-subproof}). \ section \The Isar proof language \label{sec:framework-isar}\ text \ - Structured proofs are presented as high-level expressions for - composing entities of Pure (propositions, facts, and goals). The - Isar proof language allows to organize reasoning within the - underlying rule calculus of Pure, but Isar is not another logical - calculus! + Structured proofs are presented as high-level expressions for composing + entities of Pure (propositions, facts, and goals). The Isar proof language + allows to organize reasoning within the underlying rule calculus of Pure, + but Isar is not another logical calculus. Isar merely imposes certain + structure and policies on Pure inferences. + + Isar is intended as an exercise in minimalism. Approximately half of the + language is introduced as primitive, the rest defined as derived concepts. + The grammar in \appref{ap:main-grammar} describes the core language + (category \proof\), which is embedded into the main outer theory syntax via + elements that require a proof (e.g.\ \<^theory_text>\theorem\, \<^theory_text>\lemma\, \<^theory_text>\function\, + \<^theory_text>\termination\). - Isar is an exercise in sound minimalism. Approximately half of the - language is introduced as primitive, the rest defined as derived - concepts. The following grammar describes the core language - (category \proof\), which is embedded into theory - specification elements such as @{command theorem}; see also - \secref{sec:framework-stmt} for the separate category \statement\. + The syntax for terms and propositions is inherited from Pure (and the + object-logic). A \pattern\ is a \term\ with schematic variables, to be bound + by higher-order matching. Simultaneous propositions or facts may be + separated by the \<^theory_text>\and\ keyword. + + \<^medskip> + Facts may be referenced by name or proposition. For example, the result of + ``\<^theory_text>\have a: A \\'' becomes accessible both via the name \a\ and the + literal proposition \\A\\. Moreover, fact expressions may involve attributes + that modify either the theorem or the background context. For example, the + expression ``\a [OF b]\'' refers to the composition of two facts according + to the @{inference resolution} inference of + \secref{sec:framework-resolution}, while ``\a [intro]\'' declares a fact as + introduction rule in the context. + + The special fact called ``@{fact this}'' always refers to the last result, + as produced by \<^theory_text>\note\, \<^theory_text>\assume\, \<^theory_text>\have\, or \<^theory_text>\show\. Since \<^theory_text>\note\ occurs + frequently together with \<^theory_text>\then\, there are some abbreviations: \<^medskip> \begin{tabular}{rcl} - \theory\stmt\ & = & @{command "theorem"}~\statement proof |\~~@{command "definition"}~\\ | \\ \\[1ex] - - \proof\ & = & \prfx\<^sup>*\~@{command "proof"}~\method\<^sup>? stmt\<^sup>*\~@{command "qed"}~\method\<^sup>?\ \\[1ex] - - \prfx\ & = & @{command "using"}~\facts\ \\ - & \|\ & @{command "unfolding"}~\facts\ \\ - - \stmt\ & = & @{command "{"}~\stmt\<^sup>*\~@{command "}"} \\ - & \|\ & @{command "next"} \\ - & \|\ & @{command "note"}~\name = facts\ \\ - & \|\ & @{command "let"}~\term = term\ \\ - & \|\ & @{command "fix"}~\var\<^sup>+\ \\ - & \|\ & @{command assume}~\\inference\ name: props\ \\ - & \|\ & @{command "then"}\\<^sup>?\~\goal\ \\ - \goal\ & = & @{command "have"}~\name: props proof\ \\ - & \|\ & @{command "show"}~\name: props proof\ \\ - \end{tabular} - - \<^medskip> - Simultaneous propositions or facts may be separated by the - @{keyword "and"} keyword. - - \<^medskip> - The syntax for terms and propositions is inherited from - Pure (and the object-logic). A \pattern\ is a \term\ with schematic variables, to be bound by higher-order - matching. - - \<^medskip> - Facts may be referenced by name or proposition. For - example, the result of ``@{command have}~\a: A \proof\\'' - becomes available both as \a\ and - \isacharbackquoteopen\A\\isacharbackquoteclose. Moreover, - fact expressions may involve attributes that modify either the - theorem or the background context. For example, the expression - ``\a [OF b]\'' refers to the composition of two facts - according to the @{inference resolution} inference of - \secref{sec:framework-resolution}, while ``\a [intro]\'' - declares a fact as introduction rule in the context. - - The special fact called ``@{fact this}'' always refers to the last - result, as produced by @{command note}, @{command assume}, @{command - have}, or @{command show}. Since @{command note} occurs - frequently together with @{command then} we provide some - abbreviations: - - \<^medskip> - \begin{tabular}{rcl} - @{command from}~\a\ & \\\ & @{command note}~\a\~@{command then} \\ - @{command with}~\a\ & \\\ & @{command from}~\a \ this\ \\ + \<^theory_text>\from a\ & \\\ & \<^theory_text>\note a then\ \\ + \<^theory_text>\with a\ & \\\ & \<^theory_text>\from a and this\ \\ \end{tabular} \<^medskip> - The \method\ category is essentially a parameter and may be - populated later. Methods use the facts indicated by @{command - "then"} or @{command using}, and then operate on the goal state. - Some basic methods are predefined: ``@{method "-"}'' leaves the goal - unchanged, ``@{method this}'' applies the facts as rules to the - goal, ``@{method (Pure) "rule"}'' applies the facts to another rule and the - result to the goal (both ``@{method this}'' and ``@{method (Pure) rule}'' - refer to @{inference resolution} of - \secref{sec:framework-resolution}). The secondary arguments to - ``@{method (Pure) rule}'' may be specified explicitly as in ``\(rule - a)\'', or picked from the context. In the latter case, the system - first tries rules declared as @{attribute (Pure) elim} or - @{attribute (Pure) dest}, followed by those declared as @{attribute - (Pure) intro}. + The \method\ category is essentially a parameter of the Isar language and + may be populated later. The command \<^theory_text>\method_setup\ allows to define proof + methods semantically in Isabelle/ML. The Eisbach language allows to define + proof methods symbolically, as recursive expressions over existing methods + @{cite "Matichuk-et-al:2014"}; see also @{file "~~/src/HOL/Eisbach"}. - The default method for @{command proof} is ``@{method standard}'' - (arguments picked from the context), for @{command qed} it is - ``@{method "succeed"}''. Further abbreviations for terminal proof steps - are ``@{command "by"}~\method\<^sub>1 method\<^sub>2\'' for - ``@{command proof}~\method\<^sub>1\~@{command qed}~\method\<^sub>2\'', and ``@{command ".."}'' for ``@{command - "by"}~@{method standard}, and ``@{command "."}'' for ``@{command - "by"}~@{method this}''. The @{command unfolding} element operates - directly on the current facts and goal by applying equalities. + Methods use the facts indicated by \<^theory_text>\then\ or \<^theory_text>\using\, and then operate on + the goal state. Some basic methods are predefined in Pure: ``@{method "-"}'' + leaves the goal unchanged, ``@{method this}'' applies the facts as rules to + the goal, ``@{method (Pure) "rule"}'' applies the facts to another rule and + the result to the goal (both ``@{method this}'' and ``@{method (Pure) + rule}'' refer to @{inference resolution} of + \secref{sec:framework-resolution}). The secondary arguments to ``@{method + (Pure) rule}'' may be specified explicitly as in ``\(rule a)\'', or picked + from the context. In the latter case, the system first tries rules declared + as @{attribute (Pure) elim} or @{attribute (Pure) dest}, followed by those + declared as @{attribute (Pure) intro}. + + The default method for \<^theory_text>\proof\ is ``@{method standard}'' (which subsumes + @{method rule} with arguments picked from the context), for \<^theory_text>\qed\ it is + ``@{method "succeed"}''. Further abbreviations for terminal proof steps are + ``\<^theory_text>\by method\<^sub>1 method\<^sub>2\'' for ``\<^theory_text>\proof method\<^sub>1 qed method\<^sub>2\'', and + ``\<^theory_text>\..\'' for ``\<^theory_text>\by standard\, and ``\<^theory_text>\.\'' for ``\<^theory_text>\by this\''. The command + ``\<^theory_text>\unfolding facts\'' operates directly on the goal by applying equalities. \<^medskip> - Block structure can be indicated explicitly by ``@{command - "{"}~\\\~@{command "}"}'', although the body of a sub-proof - already involves implicit nesting. In any case, @{command next} - jumps into the next section of a block, i.e.\ it acts like closing - an implicit block scope and opening another one; there is no direct - correspondence to subgoals here. + Block structure can be indicated explicitly by ``\<^theory_text>\{ \ }\'', although the + body of a subproof ``\<^theory_text>\proof \ qed\'' already provides implicit nesting. In + both situations, \<^theory_text>\next\ jumps into the next section of a block, i.e.\ it + acts like closing an implicit block scope and opening another one. There is + no direct connection to subgoals here! - The remaining elements @{command fix} and @{command assume} build up - a local context (see \secref{sec:framework-context}), while - @{command show} refines a pending sub-goal by the rule resulting - from a nested sub-proof (see \secref{sec:framework-subproof}). - Further derived concepts will support calculational reasoning (see - \secref{sec:framework-calc}). + The commands \<^theory_text>\fix\ and \<^theory_text>\assume\ build up a local context (see + \secref{sec:framework-context}), while \<^theory_text>\show\ refines a pending subgoal by + the rule resulting from a nested subproof (see + \secref{sec:framework-subproof}). Further derived concepts will support + calculational reasoning (see \secref{sec:framework-calc}). \ subsection \Context elements \label{sec:framework-context}\ text \ - In judgments \\ \ \\ of the primitive framework, \\\ - essentially acts like a proof context. Isar elaborates this idea - towards a higher-level notion, with additional information for - type-inference, term abbreviations, local facts, hypotheses etc. + In judgments \\ \ \\ of the primitive framework, \\\ essentially acts like a + proof context. Isar elaborates this idea towards a more advanced concept, + with additional information for type-inference, term abbreviations, local + facts, hypotheses etc. - The element @{command fix}~\x :: \\ declares a local - parameter, i.e.\ an arbitrary-but-fixed entity of a given type; in - results exported from the context, \x\ may become anything. - The @{command assume}~\\inference\\ element provides a - general interface to hypotheses: ``@{command assume}~\\inference\ A\'' produces \A \ A\ locally, while the - included inference tells how to discharge \A\ from results - \A \ B\ later on. There is no user-syntax for \\inference\\, i.e.\ it may only occur internally when derived - commands are defined in ML. + The element \<^theory_text>\fix x :: \\ declares a local parameter, i.e.\ an + arbitrary-but-fixed entity of a given type; in results exported from the + context, \x\ may become anything. The \<^theory_text>\assume \inference\\ element provides + a general interface to hypotheses: \<^theory_text>\assume \inference\ A\ produces \A \ A\ + locally, while the included inference tells how to discharge \A\ from + results \A \ B\ later on. There is no surface syntax for \\inference\\, + i.e.\ it may only occur internally when derived commands are defined in ML. - At the user-level, the default inference for @{command assume} is - @{inference discharge} as given below. The additional variants - @{command presume} and @{command def} are defined as follows: - - \<^medskip> - \begin{tabular}{rcl} - @{command presume}~\A\ & \\\ & @{command assume}~\\weak\discharge\ A\ \\ - @{command def}~\x \ a\ & \\\ & @{command fix}~\x\~@{command assume}~\\expansion\ x \ a\ \\ - \end{tabular} - \<^medskip> + The default inference for \<^theory_text>\assume\ is @{inference export} as given below. + The derived element \<^theory_text>\def x \ a\ is defined as \<^theory_text>\fix x assume \expand\ x \ + a\, with the subsequent inference @{inference expand}. \[ - \infer[(@{inference_def discharge})]{\\\ - A \ #A \ B\}{\\\ \ B\} - \] - \[ - \infer[(@{inference_def "weak\discharge"})]{\\\ - A \ A \ B\}{\\\ \ B\} - \] - \[ - \infer[(@{inference_def expansion})]{\\\ - (x \ a) \ B a\}{\\\ \ B x\} + \infer[(@{inference_def export})]{\\\ - A \ A \ B\}{\\\ \ B\} + \qquad + \infer[(@{inference_def expand})]{\\\ - (x \ a) \ B a\}{\\\ \ B x\} \] \<^medskip> - Note that @{inference discharge} and @{inference - "weak\discharge"} differ in the marker for @{prop A}, which is - relevant when the result of a @{command fix}-@{command - assume}-@{command show} outline is composed with a pending goal, - cf.\ \secref{sec:framework-subproof}. - - The most interesting derived context element in Isar is @{command - obtain} @{cite \\S5.3\ "Wenzel-PhD"}, which supports generalized - elimination steps in a purely forward manner. The @{command obtain} - command takes a specification of parameters \\<^vec>x\ and - assumptions \\<^vec>A\ to be added to the context, together - with a proof of a case rule stating that this extension is + The most interesting derived context element in Isar is \<^theory_text>\obtain\ @{cite + \\S5.3\ "Wenzel-PhD"}, which supports generalized elimination steps in a + purely forward manner. The \<^theory_text>\obtain\ command takes a specification of + parameters \\<^vec>x\ and assumptions \\<^vec>A\ to be added to the context, + together with a proof of a case rule stating that this extension is conservative (i.e.\ may be removed from closed results later on): \<^medskip> \begin{tabular}{l} - \\facts\\~~@{command obtain}~\\<^vec>x \ \<^vec>A \<^vec>x \proof\ \\ \\[0.5ex] - \quad @{command have}~\case: \thesis. (\\<^vec>x. \<^vec>A \<^vec>x \ thesis) \ thesis\\ \\ - \quad @{command proof}~@{method "-"} \\ - \qquad @{command fix}~\thesis\ \\ - \qquad @{command assume}~\[intro]: \\<^vec>x. \<^vec>A \<^vec>x \ thesis\ \\ - \qquad @{command show}~\thesis\~@{command using}~\\facts\ \proof\\ \\ - \quad @{command qed} \\ - \quad @{command fix}~\\<^vec>x\~@{command assume}~\\elimination case\ \<^vec>A \<^vec>x\ \\ + \<^theory_text>\\facts\ obtain "\<^vec>x" where "\<^vec>A" "\<^vec>x" \ \\ \\[0.5ex] + \quad \<^theory_text>\have "case": "\thesis. (\\<^vec>x. \<^vec>A \<^vec>x \ thesis) \ thesis"\ \\ + \quad \<^theory_text>\proof -\ \\ + \qquad \<^theory_text>\fix thesis\ \\ + \qquad \<^theory_text>\assume [intro]: "\\<^vec>x. \<^vec>A \<^vec>x \ thesis"\ \\ + \qquad \<^theory_text>\show thesis using \facts\ \\ \\ + \quad \<^theory_text>\qed\ \\ + \quad \<^theory_text>\fix "\<^vec>x" assume \elimination "case"\ "\<^vec>A \<^vec>x"\ \\ \end{tabular} \<^medskip> @@ -640,21 +617,18 @@ \end{tabular}} \] - Here the name ``\thesis\'' is a specific convention - for an arbitrary-but-fixed proposition; in the primitive natural - deduction rules shown before we have occasionally used \C\. - The whole statement of ``@{command obtain}~\x\~@{keyword - "where"}~\A x\'' may be read as a claim that \A x\ - may be assumed for some arbitrary-but-fixed \x\. Also note - that ``@{command obtain}~\A \ B\'' without parameters - is similar to ``@{command have}~\A \ B\'', but the - latter involves multiple sub-goals. + Here the name ``\thesis\'' is a specific convention for an + arbitrary-but-fixed proposition; in the primitive natural deduction rules + shown before we have occasionally used \C\. The whole statement of + ``\<^theory_text>\obtain x where A x\'' can be read as a claim that \A x\ may be assumed + for some arbitrary-but-fixed \x\. Also note that ``\<^theory_text>\obtain A and B\'' + without parameters is similar to ``\<^theory_text>\have A and B\'', but the latter + involves multiple subgoals that need to be proven separately. \<^medskip> - The subsequent Isar proof texts explain all context - elements introduced above using the formal proof language itself. - After finishing a local proof within a block, we indicate the - exported result via @{command note}. + The subsequent Isar proof texts explain all context elements introduced + above using the formal proof language itself. After finishing a local proof + within a block, the exported result is indicated via \<^theory_text>\note\. \ (*<*) @@ -664,25 +638,25 @@ text_raw \\begin{minipage}[t]{0.45\textwidth}\ { fix x - have "B x" sorry %noproof + have "B x" \ } note \\x. B x\ text_raw \\end{minipage}\quad\begin{minipage}[t]{0.45\textwidth}\(*<*)next(*>*) { assume A - have B sorry %noproof + have B \ } note \A \ B\ text_raw \\end{minipage}\\[3ex]\begin{minipage}[t]{0.45\textwidth}\(*<*)next(*>*) { def x \ a - have "B x" sorry %noproof + have "B x" \ } note \B a\ text_raw \\end{minipage}\quad\begin{minipage}[t]{0.45\textwidth}\(*<*)next(*>*) { - obtain x where "A x" sorry %noproof - have B sorry %noproof + obtain x where "A x" \ + have B \ } note \B\ text_raw \\end{minipage}\ @@ -692,118 +666,110 @@ text \ \<^bigskip> - This illustrates the meaning of Isar context - elements without goals getting in between. + This explains the meaning of Isar context elements without, without goal + states getting in the way. \ subsection \Structured statements \label{sec:framework-stmt}\ text \ - The category \statement\ of top-level theorem specifications - is defined as follows: + The syntax of top-level theorem statements is defined as follows: \<^medskip> \begin{tabular}{rcl} - \statement\ & \\\ & \name: props \ \\ \\ + \statement\ & \\\ & \<^theory_text>\name: props and \\ \\ & \|\ & \context\<^sup>* conclusion\ \\[0.5ex] - \context\ & \\\ & \\ vars \ \\ \\ - & \|\ & \\ name: props \ \\ \\ + \context\ & \\\ & \<^theory_text>\fixes vars and \\ \\ + & \|\ & \<^theory_text>\assumes name: props and \\ \\ - \conclusion\ & \\\ & \\ name: props \ \\ \\ - & \|\ & \\ vars \ \ \ name: props \ \\ \\ + \conclusion\ & \\\ & \<^theory_text>\shows name: props and \\ \\ + & \|\ & \<^theory_text>\obtains vars and \ where name: props and \\ \\ & & \quad \\ \\ \\ \end{tabular} \<^medskip> - A simple \statement\ consists of named - propositions. The full form admits local context elements followed - by the actual conclusions, such as ``@{keyword "fixes"}~\x\~@{keyword "assumes"}~\A x\~@{keyword "shows"}~\B - x\''. The final result emerges as a Pure rule after discharging - the context: @{prop "\x. A x \ B x"}. + A simple statement consists of named propositions. The full form admits + local context elements followed by the actual conclusions, such as ``\<^theory_text>\fixes + x assumes A x shows B x\''. The final result emerges as a Pure rule after + discharging the context: @{prop "\x. A x \ B x"}. - The @{keyword "obtains"} variant is another abbreviation defined - below; unlike @{command obtain} (cf.\ - \secref{sec:framework-context}) there may be several ``cases'' - separated by ``\\\'', each consisting of several - parameters (\vars\) and several premises (\props\). - This specifies multi-branch elimination rules. + The \<^theory_text>\obtains\ variant is another abbreviation defined below; unlike + \<^theory_text>\obtain\ (cf.\ \secref{sec:framework-context}) there may be several + ``cases'' separated by ``\\\'', each consisting of several parameters + (\vars\) and several premises (\props\). This specifies multi-branch + elimination rules. \<^medskip> \begin{tabular}{l} - \\ \<^vec>x \ \<^vec>A \<^vec>x \ \ \\ \\[0.5ex] - \quad \\ thesis\ \\ - \quad \\ [intro]: \\<^vec>x. \<^vec>A \<^vec>x \ thesis \ \\ \\ - \quad \\ thesis\ \\ + \<^theory_text>\obtains "\<^vec>x" where "\<^vec>A" "\<^vec>x" "\" \ \\ \\[0.5ex] + \quad \<^theory_text>\fixes thesis\ \\ + \quad \<^theory_text>\assumes [intro]: "\\<^vec>x. \<^vec>A \<^vec>x \ thesis" and \\ \\ + \quad \<^theory_text>\shows thesis\ \\ \end{tabular} \<^medskip> Presenting structured statements in such an ``open'' format usually - simplifies the subsequent proof, because the outer structure of the - problem is already laid out directly. E.g.\ consider the following - canonical patterns for \\\ and \\\, - respectively: + simplifies the subsequent proof, because the outer structure of the problem + is already laid out directly. E.g.\ consider the following canonical + patterns for \<^theory_text>\shows\ and \<^theory_text>\obtains\, respectively: \ text_raw \\begin{minipage}{0.5\textwidth}\ -theorem - fixes x and y - assumes "A x" and "B y" - shows "C x y" -proof - - from \A x\ and \B y\ - show "C x y" sorry %noproof -qed + theorem + fixes x and y + assumes "A x" and "B y" + shows "C x y" + proof - + from \A x\ and \B y\ + show "C x y" \ + qed text_raw \\end{minipage}\begin{minipage}{0.5\textwidth}\ -theorem - obtains x and y - where "A x" and "B y" -proof - - have "A a" and "B b" sorry %noproof - then show thesis .. -qed + theorem + obtains x and y + where "A x" and "B y" + proof - + have "A a" and "B b" \ + then show thesis .. + qed text_raw \\end{minipage}\ text \ \<^medskip> - Here local facts \isacharbackquoteopen\A - x\\isacharbackquoteclose\ and \isacharbackquoteopen\B - y\\isacharbackquoteclose\ are referenced immediately; there is no - need to decompose the logical rule structure again. In the second - proof the final ``@{command then}~@{command show}~\thesis\~@{command ".."}'' involves the local rule case \\x - y. A x \ B y \ thesis\ for the particular instance of terms \a\ and \b\ produced in the body. + Here local facts \\A x\\ and \\B y\\ are referenced immediately; there is no + need to decompose the logical rule structure again. In the second proof the + final ``\<^theory_text>\then show thesis ..\'' involves the local rule case \\x y. A x \ B + y \ thesis\ for the particular instance of terms \a\ and \b\ produced in the + body. \ subsection \Structured proof refinement \label{sec:framework-subproof}\ text \ - By breaking up the grammar for the Isar proof language, we may - understand a proof text as a linear sequence of individual proof - commands. These are interpreted as transitions of the Isar virtual - machine (Isar/VM), which operates on a block-structured - configuration in single steps. This allows users to write proof - texts in an incremental manner, and inspect intermediate - configurations for debugging. + By breaking up the grammar for the Isar proof language, we may understand a + proof text as a linear sequence of individual proof commands. These are + interpreted as transitions of the Isar virtual machine (Isar/VM), which + operates on a block-structured configuration in single steps. This allows + users to write proof texts in an incremental manner, and inspect + intermediate configurations for debugging. - The basic idea is analogous to evaluating algebraic expressions on a - stack machine: \(a + b) \ c\ then corresponds to a sequence - of single transitions for each symbol \(, a, +, b, ), \, c\. - In Isar the algebraic values are facts or goals, and the operations - are inferences. + The basic idea is analogous to evaluating algebraic expressions on a stack + machine: \(a + b) \ c\ then corresponds to a sequence of single transitions + for each symbol \(, a, +, b, ), \, c\. In Isar the algebraic values are + facts or goals, and the operations are inferences. \<^medskip> - The Isar/VM state maintains a stack of nodes, each node - contains the local proof context, the linguistic mode, and a pending - goal (optional). The mode determines the type of transition that - may be performed next, it essentially alternates between forward and - backward reasoning, with an intermediate stage for chained facts - (see \figref{fig:isar-vm}). + The Isar/VM state maintains a stack of nodes, each node contains the local + proof context, the linguistic mode, and a pending goal (optional). The mode + determines the type of transition that may be performed next, it essentially + alternates between forward and backward reasoning, with an intermediate + stage for chained facts (see \figref{fig:isar-vm}). \begin{figure}[htb] \begin{center} @@ -812,17 +778,14 @@ \caption{Isar/VM modes}\label{fig:isar-vm} \end{figure} - For example, in \state\ mode Isar acts like a mathematical - scratch-pad, accepting declarations like @{command fix}, @{command - assume}, and claims like @{command have}, @{command show}. A goal - statement changes the mode to \prove\, which means that we - may now refine the problem via @{command unfolding} or @{command - proof}. Then we are again in \state\ mode of a proof body, - which may issue @{command show} statements to solve pending - sub-goals. A concluding @{command qed} will return to the original - \state\ mode one level upwards. The subsequent Isar/VM - trace indicates block structure, linguistic mode, goal state, and - inferences: + For example, in \state\ mode Isar acts like a mathematical scratch-pad, + accepting declarations like \<^theory_text>\fix\, \<^theory_text>\assume\, and claims like \<^theory_text>\have\, + \<^theory_text>\show\. A goal statement changes the mode to \prove\, which means that we + may now refine the problem via \<^theory_text>\unfolding\ or \<^theory_text>\proof\. Then we are again + in \state\ mode of a proof body, which may issue \<^theory_text>\show\ statements to solve + pending subgoals. A concluding \<^theory_text>\qed\ will return to the original \state\ + mode one level upwards. The subsequent Isar/VM trace indicates block + structure, linguistic mode, goal state, and inferences: \ text_raw \\begingroup\footnotesize\ @@ -833,7 +796,7 @@ proof assume A show B - sorry %noproof + \ qed text_raw \\end{minipage}\quad \begin{minipage}[t]{0.06\textwidth} @@ -873,13 +836,12 @@ text \ Here the @{inference refinement} inference from - \secref{sec:framework-resolution} mediates composition of Isar - sub-proofs nicely. Observe that this principle incorporates some - degree of freedom in proof composition. In particular, the proof - body allows parameters and assumptions to be re-ordered, or commuted - according to Hereditary Harrop Form. Moreover, context elements - that are not used in a sub-proof may be omitted altogether. For - example: + \secref{sec:framework-resolution} mediates composition of Isar subproofs + nicely. Observe that this principle incorporates some degree of freedom in + proof composition. In particular, the proof body allows parameters and + assumptions to be re-ordered, or commuted according to Hereditary Harrop + Form. Moreover, context elements that are not used in a subproof may be + omitted altogether. For example: \ text_raw \\begin{minipage}{0.5\textwidth}\ @@ -892,7 +854,7 @@ proof - fix x and y assume "A x" and "B y" - show "C x y" sorry %noproof + show "C x y" \ qed text_raw \\end{minipage}\begin{minipage}{0.5\textwidth}\ @@ -904,7 +866,7 @@ proof - fix x assume "A x" fix y assume "B y" - show "C x y" sorry %noproof + show "C x y" \ qed text_raw \\end{minipage}\\[3ex]\begin{minipage}{0.5\textwidth}\ @@ -916,7 +878,7 @@ proof - fix y assume "B y" fix x assume "A x" - show "C x y" sorry + show "C x y" \ qed text_raw \\end{minipage}\begin{minipage}{0.5\textwidth}\ @@ -927,7 +889,7 @@ proof - fix y assume "B y" fix x - show "C x y" sorry + show "C x y" \ qed (*<*) end @@ -937,17 +899,15 @@ text \ \<^medskip> - Such ``peephole optimizations'' of Isar texts are - practically important to improve readability, by rearranging - contexts elements according to the natural flow of reasoning in the - body, while still observing the overall scoping rules. + Such fine-tuning of Isar text is practically important to improve + readability. Contexts elements are rearranged according to the natural flow + of reasoning in the body, while still observing the overall scoping rules. \<^medskip> - This illustrates the basic idea of structured proof - processing in Isar. The main mechanisms are based on natural - deduction rule composition within the Pure framework. In - particular, there are no direct operations on goal states within the - proof body. Moreover, there is no hidden automated reasoning + This illustrates the basic idea of structured proof processing in Isar. The + main mechanisms are based on natural deduction rule composition within the + Pure framework. In particular, there are no direct operations on goal states + within the proof body. Moreover, there is no hidden automated reasoning involved, just plain unification. \ @@ -956,73 +916,69 @@ text \ The existing Isar infrastructure is sufficiently flexible to support - calculational reasoning (chains of transitivity steps) as derived - concept. The generic proof elements introduced below depend on - rules declared as @{attribute trans} in the context. It is left to - the object-logic to provide a suitable rule collection for mixed - relations of \=\, \<\, \\\, \\\, - \\\ etc. Due to the flexibility of rule composition - (\secref{sec:framework-resolution}), substitution of equals by - equals is covered as well, even substitution of inequalities - involving monotonicity conditions; see also @{cite \\S6\ "Wenzel-PhD"} - and @{cite "Bauer-Wenzel:2001"}. + calculational reasoning (chains of transitivity steps) as derived concept. + The generic proof elements introduced below depend on rules declared as + @{attribute trans} in the context. It is left to the object-logic to provide + a suitable rule collection for mixed relations of \=\, \<\, \\\, \\\, \\\ + etc. Due to the flexibility of rule composition + (\secref{sec:framework-resolution}), substitution of equals by equals is + covered as well, even substitution of inequalities involving monotonicity + conditions; see also @{cite \\S6\ "Wenzel-PhD"} and @{cite + "Bauer-Wenzel:2001"}. - The generic calculational mechanism is based on the observation that - rules such as \trans:\~@{prop "x = y \ y = z \ x = z"} - proceed from the premises towards the conclusion in a deterministic - fashion. Thus we may reason in forward mode, feeding intermediate - results into rules selected from the context. The course of - reasoning is organized by maintaining a secondary fact called - ``@{fact calculation}'', apart from the primary ``@{fact this}'' - already provided by the Isar primitives. In the definitions below, + The generic calculational mechanism is based on the observation that rules + such as \trans:\~@{prop "x = y \ y = z \ x = z"} proceed from the premises + towards the conclusion in a deterministic fashion. Thus we may reason in + forward mode, feeding intermediate results into rules selected from the + context. The course of reasoning is organized by maintaining a secondary + fact called ``@{fact calculation}'', apart from the primary ``@{fact this}'' + already provided by the Isar primitives. In the definitions below, @{attribute OF} refers to @{inference resolution} - (\secref{sec:framework-resolution}) with multiple rule arguments, - and \trans\ represents to a suitable rule from the context: + (\secref{sec:framework-resolution}) with multiple rule arguments, and + \trans\ represents to a suitable rule from the context: \begin{matharray}{rcl} - @{command "also"}\\<^sub>0\ & \equiv & @{command "note"}~\calculation = this\ \\ - @{command "also"}\\<^sub>n\<^sub>+\<^sub>1\ & \equiv & @{command "note"}~\calculation = trans [OF calculation this]\ \\[0.5ex] - @{command "finally"} & \equiv & @{command "also"}~@{command "from"}~\calculation\ \\ + \<^theory_text>\also"\<^sub>0"\ & \equiv & \<^theory_text>\note calculation = this\ \\ + \<^theory_text>\also"\<^sub>n\<^sub>+\<^sub>1"\ & \equiv & \<^theory_text>\note calculation = trans [OF calculation this]\ \\[0.5ex] + \<^theory_text>\finally\ & \equiv & \<^theory_text>\also from calculation\ \\ \end{matharray} - The start of a calculation is determined implicitly in the - text: here @{command also} sets @{fact calculation} to the current - result; any subsequent occurrence will update @{fact calculation} by - combination with the next result and a transitivity rule. The - calculational sequence is concluded via @{command finally}, where - the final result is exposed for use in a concluding claim. + The start of a calculation is determined implicitly in the text: here + \<^theory_text>\also\ sets @{fact calculation} to the current result; any subsequent + occurrence will update @{fact calculation} by combination with the next + result and a transitivity rule. The calculational sequence is concluded via + \<^theory_text>\finally\, where the final result is exposed for use in a concluding claim. - Here is a canonical proof pattern, using @{command have} to - establish the intermediate results: + Here is a canonical proof pattern, using \<^theory_text>\have\ to establish the + intermediate results: \ (*<*) notepad begin + fix a b c d :: 'a (*>*) - have "a = b" sorry - also have "\ = c" sorry - also have "\ = d" sorry + have "a = b" \ + also have "\ = c" \ + also have "\ = d" \ finally have "a = d" . (*<*) end (*>*) text \ - The term ``\\\'' above is a special abbreviation - provided by the Isabelle/Isar syntax layer: it statically refers to - the right-hand side argument of the previous statement given in the - text. Thus it happens to coincide with relevant sub-expressions in - the calculational chain, but the exact correspondence is dependent - on the transitivity rules being involved. + The term ``\\\'' (literal ellipsis) is a special abbreviation provided by + the Isabelle/Isar term syntax: it statically refers to the right-hand side + argument of the previous statement given in the text. Thus it happens to + coincide with relevant sub-expressions in the calculational chain, but the + exact correspondence is dependent on the transitivity rules being involved. \<^medskip> - Symmetry rules such as @{prop "x = y \ y = x"} are like - transitivities with only one premise. Isar maintains a separate - rule collection declared via the @{attribute sym} attribute, to be - used in fact expressions ``\a [symmetric]\'', or single-step - proofs ``@{command assume}~\x = y\~@{command then}~@{command - have}~\y = x\~@{command ".."}''. + Symmetry rules such as @{prop "x = y \ y = x"} are like transitivities with + only one premise. Isar maintains a separate rule collection declared via the + @{attribute sym} attribute, to be used in fact expressions ``\a + [symmetric]\'', or single-step proofs ``\<^theory_text>\assume "x = y" then have "y = x" + ..\''. \ end \ No newline at end of file diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/HOL_Specific.thy --- a/src/Doc/Isar_Ref/HOL_Specific.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/HOL_Specific.thy Fri Feb 12 22:36:48 2016 +0100 @@ -642,14 +642,15 @@ \} \<^descr> @{command (HOL) "recdef"} defines general well-founded - recursive functions (using the TFL package), see also - @{cite "isabelle-HOL"}. The ``\(permissive)\'' option tells - TFL to recover from failed proof attempts, returning unfinished - results. The \recdef_simp\, \recdef_cong\, and \recdef_wf\ hints refer to auxiliary rules to be used in the internal - automated proof process of TFL. Additional @{syntax clasimpmod} - declarations may be given to tune the context of the Simplifier - (cf.\ \secref{sec:simplifier}) and Classical reasoner (cf.\ - \secref{sec:classical}). + recursive functions (using the TFL package). The + ``\(permissive)\'' option tells TFL to recover from + failed proof attempts, returning unfinished results. The + \recdef_simp\, \recdef_cong\, and + \recdef_wf\ hints refer to auxiliary rules to be used + in the internal automated proof process of TFL. Additional + @{syntax clasimpmod} declarations may be given to tune the context + of the Simplifier (cf.\ \secref{sec:simplifier}) and Classical + reasoner (cf.\ \secref{sec:classical}). \<^medskip> @@ -763,9 +764,8 @@ These commands are mostly obsolete; @{command (HOL) "datatype"} should be used instead. - See @{cite "isabelle-HOL"} for more details on datatypes, but beware of - the old-style theory syntax being used there! Apart from proper - proof methods for case-analysis and induction, there are also + See @{cite "isabelle-datatypes"} for more details on datatypes. Apart from proper + proof methods for case analysis and induction, there are also emulations of ML tactics @{method (HOL) case_tac} and @{method (HOL) induct_tac} available, see \secref{sec:hol-induct-tac}; these admit to refer directly to the internal structure of subgoals (including diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/Proof.thy --- a/src/Doc/Isar_Ref/Proof.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/Proof.thy Fri Feb 12 22:36:48 2016 +0100 @@ -210,7 +210,7 @@ Abbreviations may be either bound by explicit @{command "let"}~\p \ t\ statements, or by annotating assumptions or goal statements with a list of - patterns ``\(\ p\<^sub>1 \ p\<^sub>n)\''. In both cases, higher-order matching is + patterns ``\<^theory_text>\(is p\<^sub>1 \ p\<^sub>n)\''. In both cases, higher-order matching is invoked to bind extra-logical term variables, which may be either named schematic variables of the form \?x\, or nameless dummies ``@{variable _}'' (underscore). Note that in the @{command "let"} form the patterns occur on @@ -239,13 +239,13 @@ The syntax of @{keyword "is"} patterns follows @{syntax term_pat} or @{syntax prop_pat} (see \secref{sec:term-decls}). - \<^descr> @{command "let"}~\p\<^sub>1 = t\<^sub>1 \ \ p\<^sub>n = t\<^sub>n\ binds any text variables - in patterns \p\<^sub>1, \, p\<^sub>n\ by simultaneous higher-order matching against - terms \t\<^sub>1, \, t\<^sub>n\. + \<^descr> \<^theory_text>\let p\<^sub>1 = t\<^sub>1 and \ p\<^sub>n = t\<^sub>n\ binds any text variables in patterns + \p\<^sub>1, \, p\<^sub>n\ by simultaneous higher-order matching against terms \t\<^sub>1, \, + t\<^sub>n\. - \<^descr> \(\ p\<^sub>1 \ p\<^sub>n)\ resembles @{command "let"}, but matches \p\<^sub>1, \, - p\<^sub>n\ against the preceding statement. Also note that @{keyword "is"} is - not a separate command, but part of others (such as @{command "assume"}, + \<^descr> \<^theory_text>\(is p\<^sub>1 \ p\<^sub>n)\ resembles @{command "let"}, but matches \p\<^sub>1, \, p\<^sub>n\ + against the preceding statement. Also note that @{keyword "is"} is not a + separate command, but part of others (such as @{command "assume"}, @{command "have"} etc.). Some \<^emph>\implicit\ term abbreviations\index{term abbreviations} for goals and @@ -441,14 +441,10 @@ warning beforehand. Watch out for the following message: @{verbatim [display] \Local statement fails to refine any pending goal\} - \<^descr> @{command "hence"} abbreviates ``@{command "then"}~@{command "have"}'', - i.e.\ claims a local goal to be proven by forward chaining the current - facts. Note that @{command "hence"} is also equivalent to ``@{command - "from"}~\this\~@{command "have"}''. - - \<^descr> @{command "thus"} abbreviates ``@{command "then"}~@{command "show"}''. - Note that @{command "thus"} is also equivalent to ``@{command - "from"}~\this\~@{command "show"}''. + \<^descr> @{command "hence"} expands to ``@{command "then"}~@{command "have"}'' and + @{command "thus"} expands to ``@{command "then"}~@{command "show"}''. These + conflations are left-over from early history of Isar. The expanded syntax is + more orthogonal and improves readability and maintainability of proofs. \<^descr> @{command "print_statement"}~\a\ prints facts from the current theory or proof context in long statement form, according to the syntax for @{command @@ -682,11 +678,11 @@ forward chaining are passed if so indicated by \proof(chain)\ mode. \<^descr> @{command "qed"}~\m\<^sub>2\ refines any remaining goals by proof method \m\<^sub>2\ - and concludes the sub-proof by assumption. If the goal had been \show\ (or - \thus\), some pending sub-goal is solved as well by the rule resulting from - the result \<^emph>\exported\ into the enclosing goal context. Thus \qed\ may fail - for two reasons: either \m\<^sub>2\ fails, or the resulting rule does not fit to - any pending goal\<^footnote>\This includes any additional ``strong'' assumptions as + and concludes the sub-proof by assumption. If the goal had been \show\, some + pending sub-goal is solved as well by the rule resulting from the result + \<^emph>\exported\ into the enclosing goal context. Thus \qed\ may fail for two + reasons: either \m\<^sub>2\ fails, or the resulting rule does not fit to any + pending goal\<^footnote>\This includes any additional ``strong'' assumptions as introduced by @{command "assume"}.\ of the enclosing context. Debugging such a situation might involve temporarily changing @{command "show"} into @{command "have"}, or weakening the local context by replacing occurrences diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/Proof_Script.thy --- a/src/Doc/Isar_Ref/Proof_Script.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/Proof_Script.thy Fri Feb 12 22:36:48 2016 +0100 @@ -13,10 +13,13 @@ Nonetheless, it is possible to emulate proof scripts by sequential refinements of a proof state in backwards mode, notably with the @{command - apply} command (see \secref{sec:tactic-commands}). There are also various - proof methods that allow to refer to implicit goal state information that is - normally not accessible to structured Isar proofs (see - \secref{sec:tactics}). + apply} command (see \secref{sec:tactic-commands}). + + There are also various proof methods that allow to refer to implicit goal + state information that is not accessible to structured Isar proofs (see + \secref{sec:tactics}). Note that the @{command subgoal} + (\secref{sec:subgoal}) command usually eliminates the need for implicit goal + state references. \ @@ -82,7 +85,7 @@ \ -section \Explicit subgoal structure\ +section \Explicit subgoal structure \label{sec:subgoal}\ text \ \begin{matharray}{rcl} @@ -130,24 +133,24 @@ lemma "\x y z. A x \ B y \ C z" and "\u v. X u \ Y v" - subgoal sorry - subgoal sorry + subgoal \ + subgoal \ done lemma "\x y z. A x \ B y \ C z" and "\u v. X u \ Y v" - subgoal for x y z sorry - subgoal for u v sorry + subgoal for x y z \ + subgoal for u v \ done lemma "\x y z. A x \ B y \ C z" and "\u v. X u \ Y v" subgoal premises for x y z using \A x\ \B y\ - sorry + \ subgoal premises for u v using \X u\ - sorry + \ done lemma "\x y z. A x \ B y \ C z" @@ -156,21 +159,21 @@ proof - have "A x" by (fact prems) moreover have "B y" by (fact prems) - ultimately show ?thesis sorry + ultimately show ?thesis \ qed subgoal premises prems for u v proof - have "\x y z. A x \ B y \ C z" by (fact r) moreover have "X u" by (fact prems) - ultimately show ?thesis sorry + ultimately show ?thesis \ qed done lemma "\x y z. A x \ B y \ C z" subgoal premises prems for \ z proof - - from prems show "C z" sorry + from prems show "C z" \ qed done diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/Quick_Reference.thy --- a/src/Doc/Isar_Ref/Quick_Reference.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/Quick_Reference.thy Fri Feb 12 22:36:48 2016 +0100 @@ -8,43 +8,58 @@ section \Proof commands\ -subsection \Primitives and basic syntax\ +subsection \Main grammar \label{ap:main-grammar}\ + +text \ + \begin{tabular}{rcl} + \main\ & = & \<^theory_text>\notepad begin "statement\<^sup>*" end\ \\ + & \|\ & \<^theory_text>\theorem name: props "proof"\ \\ + & \|\ & \<^theory_text>\theorem name:\ \\ + & & \quad\<^theory_text>\fixes "var\<^sup>+"\ \\ + & & \quad\<^theory_text>\assumes name: props\ \\ + & & \quad\<^theory_text>\shows name: props "proof"\ \\ + \proof\ & = & \<^theory_text>\"refinement\<^sup>*" proof "method\<^sup>?" "statement\<^sup>*" qed "method\<^sup>?"\ \\ + & \|\ & \<^theory_text>\"refinement\<^sup>*" done\ \\ + \refinement\ & = & \<^theory_text>\apply method\ \\ + & \|\ & \<^theory_text>\supply facts\ \\ + & \|\ & \<^theory_text>\subgoal "proof"\ \\ + & \|\ & \<^theory_text>\subgoal for "var\<^sup>+" "proof"\ \\ + & \|\ & \<^theory_text>\using facts\ \\ + & \|\ & \<^theory_text>\unfolding facts\ \\ + \statement\ & = & \<^theory_text>\{ "statement\<^sup>*" }\ \\ + & \|\ & \<^theory_text>\next\ \\ + & \|\ & \<^theory_text>\note name = facts\ \\ + & \|\ & \<^theory_text>\let "term" = "term"\ \\ + & \|\ & \<^theory_text>\write name (mixfix)\ \\ + & \|\ & \<^theory_text>\fix "var\<^sup>+"\ \\ + & \|\ & \<^theory_text>\assume name: props\ \\ + & \|\ & \<^theory_text>\assume name: props if name: props for "var\<^sup>+"\ \\ + & \|\ & \<^theory_text>\then"\<^sup>?" goal\ \\ + \goal\ & = & \<^theory_text>\have name: props "proof"\ \\ + & \|\ & \<^theory_text>\have name: props if name: props for "var\<^sup>+" "proof"\ \\ + & \|\ & \<^theory_text>\show name: props "proof"\ \\ + & \|\ & \<^theory_text>\show name: props if name: props for "var\<^sup>+" "proof"\ \\ + \end{tabular} +\ + + +subsection \Primitives\ text \ \begin{tabular}{ll} - @{command "fix"}~\x\ & augment context by \\x. \\ \\ - @{command "assume"}~\a: \\ & augment context by \\ \ \\ \\ - @{command "then"} & indicate forward chaining of facts \\ - @{command "have"}~\a: \\ & prove local result \\ - @{command "show"}~\a: \\ & prove local result, refining some goal \\ - @{command "using"}~\a\ & indicate use of additional facts \\ - @{command "unfolding"}~\a\ & unfold definitional equations \\ - @{command "proof"}~\m\<^sub>1\~\dots~@{command "qed"}~\m\<^sub>2\ & indicate proof structure and refinements \\ - @{command "{"}~\\\~@{command "}"} & indicate explicit blocks \\ - @{command "next"} & switch blocks \\ - @{command "note"}~\a = b\ & reconsider facts \\ - @{command "let"}~\p = t\ & abbreviate terms by higher-order matching \\ - @{command "write"}~\c (mx)\ & declare local mixfix syntax \\ - \end{tabular} - - \<^medskip> - - \begin{tabular}{rcl} - \proof\ & = & \prfx\<^sup>*\~@{command "proof"}~\method\<^sup>? stmt\<^sup>*\~@{command "qed"}~\method\<^sup>?\ \\ - & \|\ & \prfx\<^sup>*\~@{command "done"} \\ - \prfx\ & = & @{command "apply"}~\method\ \\ - & \|\ & @{command "using"}~\facts\ \\ - & \|\ & @{command "unfolding"}~\facts\ \\ - \stmt\ & = & @{command "{"}~\stmt\<^sup>*\~@{command "}"} \\ - & \|\ & @{command "next"} \\ - & \|\ & @{command "note"}~\name = facts\ \\ - & \|\ & @{command "let"}~\term = term\ \\ - & \|\ & @{command "write"}~\name (mixfix)\ \\ - & \|\ & @{command "fix"}~\var\<^sup>+\ \\ - & \|\ & @{command "assume"}~\name: props\ \\ - & \|\ & @{command "then"}\\<^sup>?\~\goal\ \\ - \goal\ & = & @{command "have"}~\name: props proof\ \\ - & \|\ & @{command "show"}~\name: props proof\ \\ + \<^theory_text>\fix x\ & augment context by \\x. \\ \\ + \<^theory_text>\assume a: A\ & augment context by \A \ \\ \\ + \<^theory_text>\then\ & indicate forward chaining of facts \\ + \<^theory_text>\have a: A\ & prove local result \\ + \<^theory_text>\show a: A\ & prove local result, refining some goal \\ + \<^theory_text>\using a\ & indicate use of additional facts \\ + \<^theory_text>\unfolding a\ & unfold definitional equations \\ + \<^theory_text>\proof m\<^sub>1 \ qed m\<^sub>2\ & indicate proof structure and refinements \\ + \<^theory_text>\{ \ }\ & indicate explicit blocks \\ + \<^theory_text>\next\ & switch proof blocks \\ + \<^theory_text>\note a = b\ & reconsider and declare facts \\ + \<^theory_text>\let p = t\ & abbreviate terms by higher-order matching \\ + \<^theory_text>\write c (mx)\ & declare local mixfix syntax \\ \end{tabular} \ @@ -53,17 +68,12 @@ text \ \begin{tabular}{rcl} - @{command "by"}~\m\<^sub>1 m\<^sub>2\ & \\\ & - @{command "proof"}~\m\<^sub>1\~@{command "qed"}~\m\<^sub>2\ \\ - @{command ".."} & \\\ & @{command "by"}~\standard\ \\ - @{command "."} & \\\ & @{command "by"}~\this\ \\ - @{command "hence"} & \\\ & @{command "then"}~@{command "have"} \\ - @{command "thus"} & \\\ & @{command "then"}~@{command "show"} \\ - @{command "from"}~\a\ & \\\ & @{command "note"}~\a\~@{command "then"} \\ - @{command "with"}~\a\ & \\\ & @{command "from"}~\a \ this\ \\ - @{command "from"}~\this\ & \\\ & @{command "then"} \\ - @{command "from"}~\this\~@{command "have"} & \\\ & @{command "hence"} \\ - @{command "from"}~\this\~@{command "show"} & \\\ & @{command "thus"} \\ + \<^theory_text>\by m\<^sub>1 m\<^sub>2\ & \\\ & \<^theory_text>\proof m\<^sub>1 qed m\<^sub>2\ \\ + \<^theory_text>\..\ & \\\ & \<^theory_text>\by standard\ \\ + \<^theory_text>\.\ & \\\ & \<^theory_text>\by this\ \\ + \<^theory_text>\from a\ & \\\ & \<^theory_text>\note a then\ \\ + \<^theory_text>\with a\ & \\\ & \<^theory_text>\from a and this\ \\ + \<^theory_text>\from this\ & \\\ & \<^theory_text>\then\ \\ \end{tabular} \ @@ -72,26 +82,19 @@ text \ \begin{tabular}{rcl} - @{command "also"}\\<^sub>0\ & \\\ & - @{command "note"}~\calculation = this\ \\ - @{command "also"}\\<^sub>n\<^sub>+\<^sub>1\ & \\\ & - @{command "note"}~\calculation = trans [OF calculation this]\ \\ - @{command "finally"} & \\\ & - @{command "also"}~@{command "from"}~\calculation\ \\[0.5ex] - @{command "moreover"} & \\\ & - @{command "note"}~\calculation = calculation this\ \\ - @{command "ultimately"} & \\\ & - @{command "moreover"}~@{command "from"}~\calculation\ \\[0.5ex] - @{command "presume"}~\a: \\ & \\\ & - @{command "assume"}~\a: \\ \\ - @{command "def"}~\a: x \ t\ & \\\ & - @{command "fix"}~\x\~@{command "assume"}~\a: x \ t\ \\ - @{command "obtain"}~\x \ a: \\ & \\\ & - \\\~@{command "fix"}~\x\~@{command "assume"}~\a: \\ \\ - @{command "case"}~\c\ & \\\ & - @{command "fix"}~\x\~@{command "assume"}~\c: \\ \\ - @{command "sorry"} & \\\ & - @{command "by"}~\cheating\ \\ + \<^theory_text>\also"\<^sub>0"\ & \\\ & \<^theory_text>\note calculation = this\ \\ + \<^theory_text>\also"\<^sub>n\<^sub>+\<^sub>1"\ & \\\ & \<^theory_text>\note calculation = trans [OF calculation this]\ \\ + \<^theory_text>\finally\ & \\\ & \<^theory_text>\also from calculation\ \\[0.5ex] + \<^theory_text>\moreover\ & \\\ & \<^theory_text>\note calculation = calculation this\ \\ + \<^theory_text>\ultimately\ & \\\ & \<^theory_text>\moreover from calculation\ \\[0.5ex] + \<^theory_text>\presume a: A\ & \\\ & \<^theory_text>\assume a: A\ \\ + \<^theory_text>\def "x \ t"\ & \\\ & \<^theory_text>\fix x assume x_def: "x \ t"\ \\ + \<^theory_text>\consider x where A | \\ & \\\ & \<^theory_text>\have thesis\ \\ + & & \quad \<^theory_text>\if "\x. A \ thesis" and \ for thesis\ \\ + \<^theory_text>\obtain x where a: A \\ & \\\ & \<^theory_text>\consider x where A \\ \\ + & & \<^theory_text>\fix x assume a: A\ \\ + \<^theory_text>\case c\ & \\\ & \<^theory_text>\fix x assume c: A\ \\ + \<^theory_text>\sorry\ & \\\ & \<^theory_text>\by cheating\ \\ \end{tabular} \ @@ -100,12 +103,11 @@ text \ \begin{tabular}{ll} - @{command "print_state"} & print proof state \\ - @{command "print_statement"} & print fact in long statement form \\ - @{command "thm"}~\a\ & print fact \\ - @{command "prop"}~\\\ & print proposition \\ - @{command "term"}~\t\ & print term \\ - @{command "typ"}~\\\ & print type \\ + \<^theory_text>\typ \\ & print type \\ + \<^theory_text>\term t\ & print term \\ + \<^theory_text>\prop \\ & print proposition \\ + \<^theory_text>\thm a\ & print fact \\ + \<^theory_text>\print_statement a\ & print fact in long statement form \\ \end{tabular} \ @@ -115,7 +117,7 @@ text \ \begin{tabular}{ll} \multicolumn{2}{l}{\<^bold>\Single steps (forward-chaining facts)\} \\[0.5ex] - @{method assumption} & apply some assumption \\ + @{method assumption} & apply some goal assumption \\ @{method this} & apply current facts \\ @{method rule}~\a\ & apply some rule \\ @{method standard} & apply standard rule (default for @{command "proof"}) \\ @@ -127,6 +129,8 @@ @{method "-"} & no rules \\ @{method intro}~\a\ & introduction rules \\ @{method intro_classes} & class introduction rules \\ + @{method intro_locales} & locale introduction rules (without body) \\ + @{method unfold_locales} & locale introduction rules (with body) \\ @{method elim}~\a\ & elimination rules \\ @{method unfold}~\a\ & definitional rewrite rules \\[2ex] @@ -195,18 +199,20 @@ \ -section \Emulating tactic scripts\ +section \Proof scripts\ subsection \Commands\ text \ \begin{tabular}{ll} - @{command "apply"}~\m\ & apply proof method at initial position \\ - @{command "apply_end"}~\m\ & apply proof method near terminal position \\ - @{command "done"} & complete proof \\ - @{command "defer"}~\n\ & move subgoal to end \\ - @{command "prefer"}~\n\ & move subgoal to beginning \\ - @{command "back"} & backtrack last command \\ + \<^theory_text>\apply m\ & apply proof method during backwards refinement \\ + \<^theory_text>\apply_end m\ & apply proof method (as if in terminal position) \\ + \<^theory_text>\supply a\ & supply facts during backwards refinement \\ + \<^theory_text>\subgoal\ & nested proof during backwards refinement \\ + \<^theory_text>\defer n\ & move subgoal to end \\ + \<^theory_text>\prefer n\ & move subgoal to start \\ + \<^theory_text>\back\ & backtrack last command \\ + \<^theory_text>\done\ & complete proof \\ \end{tabular} \ diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/Synopsis.thy --- a/src/Doc/Isar_Ref/Synopsis.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/Synopsis.thy Fri Feb 12 22:36:48 2016 +0100 @@ -53,7 +53,7 @@ assume a: A txt \Via proof (``let''):\ - have b: B sorry + have b: B \ txt \Via abbreviation (``let''):\ note c = a b @@ -156,8 +156,8 @@ notepad begin { - have a: A sorry - have b: B sorry + have a: A \ + have b: B \ note a b } note this @@ -174,15 +174,15 @@ begin { - have a: A sorry + have a: A \ next have b: B proof - - show B sorry + show B \ next - have c: C sorry + have c: C \ next - have d: D sorry + have d: D \ qed } @@ -190,19 +190,19 @@ { { - have a: A sorry + have a: A \ } { have b: B proof - { - show B sorry + show B \ } { - have c: C sorry + have c: C \ } { - have d: D sorry + have d: D \ } qed } @@ -235,7 +235,7 @@ have "x = y" proof - term ?thesis - show ?thesis sorry + show ?thesis \ term ?thesis \ \static!\ qed term "\" @@ -260,31 +260,31 @@ notepad begin txt \Plain bottom-up calculation:\ - have "a = b" sorry + have "a = b" \ also - have "b = c" sorry + have "b = c" \ also - have "c = d" sorry + have "c = d" \ finally have "a = d" . txt \Variant using the \\\ abbreviation:\ - have "a = b" sorry + have "a = b" \ also - have "\ = c" sorry + have "\ = c" \ also - have "\ = d" sorry + have "\ = d" \ finally have "a = d" . txt \Top-down version with explicit claim at the head:\ have "a = d" proof - - have "a = b" sorry + have "a = b" \ also - have "\ = c" sorry + have "\ = c" \ also - have "\ = d" sorry + have "\ = d" \ finally show ?thesis . qed @@ -292,11 +292,11 @@ txt \Mixed inequalities (require suitable base type):\ fix a b c d :: nat - have "a < b" sorry + have "a < b" \ also - have "b \ c" sorry + have "b \ c" \ also - have "c = d" sorry + have "c = d" \ finally have "a < d" . end @@ -313,43 +313,35 @@ \ -subsection \Degenerate calculations and bigstep reasoning\ +subsection \Degenerate calculations\ -text \The Idea is to append \this\ to \calculation\, - without rule composition.\ +text \The Idea is to append \this\ to \calculation\, without rule composition. + This is occasionally useful to avoid naming intermediate facts.\ notepad begin txt \A vacuous proof:\ - have A sorry + have A \ moreover - have B sorry + have B \ moreover - have C sorry + have C \ ultimately have A and B and C . next txt \Slightly more content (trivial bigstep reasoning):\ - have A sorry + have A \ moreover - have B sorry + have B \ moreover - have C sorry + have C \ ultimately have "A \ B \ C" by blast -next - txt \More ambitious bigstep reasoning involving structured results:\ - have "A \ B \ C" sorry - moreover - { assume A have R sorry } - moreover - { assume B have R sorry } - moreover - { assume C have R sorry } - ultimately - have R by blast \ \``big-bang integration'' of proof blocks (occasionally fragile)\ end +text \Note that For multi-branch case splitting, it is better to use @{command + consider}.\ + section \Induction\ @@ -367,11 +359,11 @@ fix n :: nat have "P n" proof (rule nat.induct) \ \fragile rule application!\ - show "P 0" sorry + show "P 0" \ next fix n :: nat assume "P n" - show "P (Suc n)" sorry + show "P (Suc n)" \ qed end @@ -394,10 +386,10 @@ have "P n" proof (induct n) case 0 - show ?case sorry + show ?case \ next case (Suc n) - from Suc.hyps show ?case sorry + from Suc.hyps show ?case \ qed end @@ -456,29 +448,29 @@ have "P n" proof (induct n) case 0 - show "P 0" sorry + show "P 0" \ next case (Suc n) - from \P n\ show "P (Suc n)" sorry + from \P n\ show "P (Suc n)" \ qed have "A n \ P n" proof (induct n) case 0 - from \A 0\ show "P 0" sorry + from \A 0\ show "P 0" \ next case (Suc n) from \A n \ P n\ - and \A (Suc n)\ show "P (Suc n)" sorry + and \A (Suc n)\ show "P (Suc n)" \ qed have "\x. Q x n" proof (induct n) case 0 - show "Q x 0" sorry + show "Q x 0" \ next case (Suc n) - from \\x. Q x n\ show "Q x (Suc n)" sorry + from \\x. Q x n\ show "Q x (Suc n)" \ txt \Local quantification admits arbitrary instances:\ note \Q a n\ and \Q b n\ qed @@ -502,11 +494,11 @@ then have "Q x n" proof (induct n arbitrary: x) case 0 - from \A x 0\ show "Q x 0" sorry + from \A x 0\ show "Q x 0" \ next case (Suc n) from \\x. A x n \ Q x n\ \ \arbitrary instances can be produced here\ - and \A x (Suc n)\ show "Q x (Suc n)" sorry + and \A x (Suc n)\ show "Q x (Suc n)" \ qed end @@ -532,13 +524,13 @@ case 0 note prem = \A (a x)\ and defn = \0 = a x\ - show "P (a x)" sorry + show "P (a x)" \ next case (Suc n) note hyp = \\x. n = a x \ A (a x) \ P (a x)\ and prem = \A (a x)\ and defn = \Suc n = a x\ - show "P (a x)" sorry + show "P (a x)" \ qed end @@ -628,7 +620,7 @@ begin { fix x - have "B x" sorry + have "B x" \ } have "\x. B x" by fact @@ -636,7 +628,7 @@ { assume A - have B sorry + have B \ } have "A \ B" by fact @@ -644,15 +636,15 @@ { def x \ t - have "B x" sorry + have "B x" \ } have "B t" by fact next { - obtain x :: 'a where "B x" sorry - have C sorry + obtain x :: 'a where "B x" \ + have C \ } have C by fact @@ -703,7 +695,7 @@ proof - fix x assume "A x" - show "B x" sorry + show "B x" \ qed have "\x. A x \ B x" @@ -711,7 +703,7 @@ { fix x assume "A x" - show "B x" sorry + show "B x" \ } \ "implicit block structure made explicit" note \\x. A x \ B x\ \ "side exit for the resulting rule" @@ -728,41 +720,41 @@ notepad begin - assume r1: "A \ B \ C" \ \simple rule (Horn clause)\ + assume r\<^sub>1: "A \ B \ C" \ \simple rule (Horn clause)\ - have A sorry \ "prefix of facts via outer sub-proof" + have A \ \ "prefix of facts via outer sub-proof" then have C - proof (rule r1) - show B sorry \ "remaining rule premises via inner sub-proof" + proof (rule r\<^sub>1) + show B \ \ "remaining rule premises via inner sub-proof" qed have C - proof (rule r1) - show A sorry - show B sorry + proof (rule r\<^sub>1) + show A \ + show B \ qed - have A and B sorry + have A and B \ then have C - proof (rule r1) + proof (rule r\<^sub>1) qed - have A and B sorry - then have C by (rule r1) + have A and B \ + then have C by (rule r\<^sub>1) next - assume r2: "A \ (\x. B1 x \ B2 x) \ C" \ \nested rule\ + assume r\<^sub>2: "A \ (\x. B\<^sub>1 x \ B\<^sub>2 x) \ C" \ \nested rule\ - have A sorry + have A \ then have C - proof (rule r2) + proof (rule r\<^sub>2) fix x - assume "B1 x" - show "B2 x" sorry + assume "B\<^sub>1 x" + show "B\<^sub>2 x" \ qed - txt \The compound rule premise @{prop "\x. B1 x \ B2 x"} is better + txt \The compound rule premise @{prop "\x. B\<^sub>1 x \ B\<^sub>2 x"} is better addressed via @{command fix}~/ @{command assume}~/ @{command show} in the nested proof body.\ end @@ -777,35 +769,35 @@ notepad begin - have "A \ B" and A sorry + have "A \ B" and A \ then have B .. - have A sorry + have A \ then have "A \ B" .. - have B sorry + have B \ then have "A \ B" .. - have "A \ B" sorry + have "A \ B" \ then have C proof assume A - then show C sorry + then show C \ next assume B - then show C sorry + then show C \ qed - have A and B sorry + have A and B \ then have "A \ B" .. - have "A \ B" sorry + have "A \ B" \ then have A .. - have "A \ B" sorry + have "A \ B" \ then have B .. - have False sorry + have False \ then have A .. have True .. @@ -813,36 +805,36 @@ have "\ A" proof assume A - then show False sorry + then show False \ qed - have "\ A" and A sorry + have "\ A" and A \ then have B .. have "\x. P x" proof fix x - show "P x" sorry + show "P x" \ qed - have "\x. P x" sorry + have "\x. P x" \ then have "P a" .. have "\x. P x" proof - show "P a" sorry + show "P a" \ qed - have "\x. P x" sorry + have "\x. P x" \ then have C proof fix a assume "P a" - show C sorry + show C \ qed txt \Less awkward version using @{command obtain}:\ - have "\x. P x" sorry + have "\x. P x" \ then obtain a where "P a" .. end @@ -853,32 +845,32 @@ begin have "A \ B" proof \ \two strictly isolated subproofs\ - show A sorry + show A \ next - show B sorry + show B \ qed have "A \ B" proof \ \one simultaneous sub-proof\ - show A and B sorry + show A and B \ qed have "A \ B" proof \ \two subproofs in the same context\ - show A sorry - show B sorry + show A \ + show B \ qed have "A \ B" proof \ \swapped order\ - show B sorry - show A sorry + show B \ + show A \ qed have "A \ B" proof \ \sequential subproofs\ - show A sorry - show B using \A\ sorry + show A \ + show B using \A\ \ qed end @@ -893,23 +885,23 @@ notepad begin - have "x \ A" and "x \ B" sorry + have "x \ A" and "x \ B" \ then have "x \ A \ B" .. - have "x \ A" sorry + have "x \ A" \ then have "x \ A \ B" .. - have "x \ B" sorry + have "x \ B" \ then have "x \ A \ B" .. - have "x \ A \ B" sorry + have "x \ A \ B" \ then have C proof assume "x \ A" - then show C sorry + then show C \ next assume "x \ B" - then show C sorry + then show C \ qed next @@ -917,19 +909,19 @@ proof fix a assume "a \ A" - show "x \ a" sorry + show "x \ a" \ qed - have "x \ \A" sorry + have "x \ \A" \ then have "x \ a" proof - show "a \ A" sorry + show "a \ A" \ qed - have "a \ A" and "x \ a" sorry + have "a \ A" and "x \ a" \ then have "x \ \A" .. - have "x \ \A" sorry + have "x \ \A" \ then obtain a where "a \ A" and "x \ a" .. end @@ -960,21 +952,21 @@ notepad begin assume r: - "A1 \ A2 \ (* assumptions *) - (\x y. B1 x y \ C1 x y \ R) \ (* case 1 *) - (\x y. B2 x y \ C2 x y \ R) \ (* case 2 *) + "A\<^sub>1 \ A\<^sub>2 \ (* assumptions *) + (\x y. B\<^sub>1 x y \ C\<^sub>1 x y \ R) \ (* case 1 *) + (\x y. B\<^sub>2 x y \ C\<^sub>2 x y \ R) \ (* case 2 *) R (* main conclusion *)" - have A1 and A2 sorry + have A\<^sub>1 and A\<^sub>2 \ then have R proof (rule r) fix x y - assume "B1 x y" and "C1 x y" - show ?thesis sorry + assume "B\<^sub>1 x y" and "C\<^sub>1 x y" + show ?thesis \ next fix x y - assume "B2 x y" and "C2 x y" - show ?thesis sorry + assume "B\<^sub>2 x y" and "C\<^sub>2 x y" + show ?thesis \ qed end @@ -1003,11 +995,11 @@ print_statement disjE lemma - assumes A1 and A2 \ \assumptions\ + assumes A\<^sub>1 and A\<^sub>2 \ \assumptions\ obtains - (case1) x y where "B1 x y" and "C1 x y" - | (case2) x y where "B2 x y" and "C2 x y" - sorry + (case\<^sub>1) x y where "B\<^sub>1 x y" and "C\<^sub>1 x y" + | (case\<^sub>2) x y where "B\<^sub>2 x y" and "C\<^sub>2 x y" + \ subsubsection \Example\ @@ -1024,10 +1016,10 @@ have C proof (cases "x = y" rule: tertium_non_datur) case T - from \x = y\ show ?thesis sorry + from \x = y\ show ?thesis \ next case F - from \x \ y\ show ?thesis sorry + from \x \ y\ show ?thesis \ qed end @@ -1047,14 +1039,44 @@ have C proof (cases x) case Foo - from \x = Foo\ show ?thesis sorry + from \x = Foo\ show ?thesis \ next case (Bar a) - from \x = Bar a\ show ?thesis sorry + from \x = Bar a\ show ?thesis \ qed end +subsection \Elimination statements and case-splitting\ + +text \ + The @{command consider} states rules for generalized elimination and case + splitting. This is like a toplevel statement \<^theory_text>\theorem obtains\ used within + a proof body; or like a multi-branch \<^theory_text>\obtain\ without activation of the + local context elements yet. + + The proof method @{method cases} is able to use such rules with + forward-chaining (e.g.\ via \<^theory_text>\then\). This leads to the subsequent pattern + for case-splitting in a particular situation within a proof. +\ + +notepad +begin + consider (a) A | (b) B | (c) C + \ \ \typically \<^theory_text>\by auto\, \<^theory_text>\by blast\ etc.\ + then have something + proof cases + case a + then show ?thesis \ + next + case b + then show ?thesis \ + next + case c + then show ?thesis \ + qed +end + subsection \Obtaining local contexts\ text \A single ``case'' branch may be inlined into Isar proof text @@ -1065,13 +1087,13 @@ begin fix B :: "'a \ bool" - obtain x where "B x" sorry + obtain x where "B x" \ note \B x\ txt \Conclusions from this context may not mention @{term x} again!\ { - obtain x where "B x" sorry - from \B x\ have C sorry + obtain x where "B x" \ + from \B x\ have C \ } note \C\ end diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/Isar_Ref/document/style.sty --- a/src/Doc/Isar_Ref/document/style.sty Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/Isar_Ref/document/style.sty Fri Feb 12 22:36:48 2016 +0100 @@ -16,9 +16,11 @@ %% Isar \newcommand{\isasymBBAR}{{\,\newdimen{\tmpheight}\settoheight\tmpheight{\isacharbar}\rule{1pt}{\tmpheight}\,}} -\isafoldtag{noproof}\def\isafoldnoproof{~\isafold{proof}} \renewcommand{\isacommand}[1]{\isakeyword{\isadigitreset#1}} +\newcommand{\isasymproof}{\isamath{\,\langle\mathit{proof}\rangle}} + + %% ML \newenvironment{mldecls}{\par\noindent\begingroup\def\isanewline{\\}\begin{tabular}{ll}}{\end{tabular}\medskip\endgroup} diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/JEdit/JEdit.thy --- a/src/Doc/JEdit/JEdit.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/JEdit/JEdit.thy Fri Feb 12 22:36:48 2016 +0100 @@ -1016,16 +1016,15 @@ text \ The \<^emph>\Query\ panel provides various GUI forms to request extra information - from the prover. In old times the user would have issued some diagnostic - command like @{command find_theorems} and inspected its output, but this is - now integrated into the Prover IDE. + from the prover, as a replacement of old-style diagnostic commands like + @{command find_theorems}. There are input fields and buttons for a + particular query command, with output in a dedicated text area. - A \<^emph>\Query\ window provides some input fields and buttons for a particular - query command, with output in a dedicated text area. There are various query - modes: \<^emph>\Find Theorems\, \<^emph>\Find Constants\, \<^emph>\Print Context\, e.g.\ see - \figref{fig:query}. As usual in jEdit, multiple \<^emph>\Query\ windows may be - active at the same time: any number of floating instances, but at most one - docked instance (which is used by default). + The main query modes are presented as separate tabs: \<^emph>\Find Theorems\, + \<^emph>\Find Constants\, \<^emph>\Print Context\, e.g.\ see \figref{fig:query}. As usual + in jEdit, multiple \<^emph>\Query\ windows may be active at the same time: any + number of floating instances, but at most one docked instance (which is used + by default). \begin{figure}[!htb] \begin{center} @@ -1101,20 +1100,20 @@ The \<^emph>\Query\ panel in \<^emph>\Print Context\ mode prints information from the theory or proof context, or proof state. See also the Isar commands @{command_ref print_context}, @{command_ref print_cases}, @{command_ref - print_term_bindings}, @{command_ref print_theorems}, @{command_ref - print_state} described in @{cite "isabelle-isar-ref"}. + print_term_bindings}, @{command_ref print_theorems}, described in @{cite + "isabelle-isar-ref"}. \ section \Tooltips and hyperlinks \label{sec:tooltips-hyperlinks}\ text \ - Formally processed text (prover input or output) contains rich markup - information that can be explored further by using the \<^verbatim>\CONTROL\ modifier - key on Linux and Windows, or \<^verbatim>\COMMAND\ on Mac OS X. Hovering with the mouse - while the modifier is pressed reveals a \<^emph>\tooltip\ (grey box over the text - with a yellow popup) and/or a \<^emph>\hyperlink\ (black rectangle over the text - with change of mouse pointer); see also \figref{fig:tooltip}. + Formally processed text (prover input or output) contains rich markup that + can be explored by using the \<^verbatim>\CONTROL\ modifier key on Linux and Windows, + or \<^verbatim>\COMMAND\ on Mac OS X. Hovering with the mouse while the modifier is + pressed reveals a \<^emph>\tooltip\ (grey box over the text with a yellow popup) + and/or a \<^emph>\hyperlink\ (black rectangle over the text with change of mouse + pointer); see also \figref{fig:tooltip}. \begin{figure}[!htb] \begin{center} @@ -1124,7 +1123,7 @@ \label{fig:tooltip} \end{figure} - Tooltip popups use the same rendering mechanisms as the main text area, and + Tooltip popups use the same rendering technology as the main text area, and further tooltips and/or hyperlinks may be exposed recursively by the same mechanism; see \figref{fig:nested-tooltips}. @@ -1146,13 +1145,12 @@ a mouse click (while the \<^verbatim>\CONTROL\ or \<^verbatim>\COMMAND\ modifier key is still pressed). Such jumps to other text locations are recorded by the \<^emph>\Navigator\ plugin, which is bundled with Isabelle/jEdit and enabled by - default, including navigation arrows in the main jEdit toolbar. + default. There are usually navigation arrows in the main jEdit toolbar. - Also note that the link target may be a file that is itself not subject to - formal document processing of the editor session and thus prevents further + Note that the link target may be a file that is itself not subject to formal + document processing of the editor session and thus prevents further exploration: the chain of hyperlinks may end in some source file of the - underlying logic image, or within the ML bootstrap sources of - Isabelle/Pure. + underlying logic image, or within the ML bootstrap sources of Isabelle/Pure. \ @@ -1263,6 +1261,17 @@ syntax keyword. Non-word abbreviations like \<^verbatim>\-->\ are inserted more aggressively, except for single-character abbreviations like \<^verbatim>\!\ above. + Completion via abbreviations like \<^verbatim>\ALL\ or \<^verbatim>\-->\ depends on the semantic + language context (\secref{sec:completion-context}). In contrast, backslash + sequences like \<^verbatim>\\forall\ \<^verbatim>\\\ are always possible, but require + additional interaction to confirm (via popup). + + The latter is important in ambiguous situations, e.g.\ for Isabelle document + source, which may contain formal symbols or informal {\LaTeX} macros. + Backslash sequences also help when input is broken, and thus escapes its + normal semantic context: e.g.\ antiquotations or string literals in ML, + which do not allow arbitrary backslash sequences. + \<^medskip> Additional abbreviations may be specified in @{file "$ISABELLE_HOME/etc/abbrevs"} and @{file_unchecked @@ -1272,13 +1281,6 @@ than just one symbol; otherwise the meaning is the same as a symbol specification ``\sym\~\<^verbatim>\abbrev:\~\abbrev\'' within @{file_unchecked "etc/symbols"}. - - \<^medskip> - Symbol completion depends on the semantic language context - (\secref{sec:completion-context}), to enable or disable that aspect for a - particular sub-language of Isabelle. For example, symbol completion is - suppressed within document source to avoid confusion with {\LaTeX} macros - that use similar notation. \ @@ -1310,13 +1312,12 @@ subsubsection \File-system paths\ text \ - Depending on prover markup about file-system path specifications in the - source text, e.g.\ for the argument of a load command - (\secref{sec:aux-files}), the completion mechanism explores the directory - content and offers the result as completion popup. Relative path - specifications are understood wrt.\ the \<^emph>\master directory\ of the document - node (\secref{sec:buffer-node}) of the enclosing editor buffer; this - requires a proper theory, not an auxiliary file. + Depending on prover markup about file-system paths in the source text, e.g.\ + for the argument of a load command (\secref{sec:aux-files}), the completion + mechanism explores the directory content and offers the result as completion + popup. Relative path specifications are understood wrt.\ the \<^emph>\master + directory\ of the document node (\secref{sec:buffer-node}) of the enclosing + editor buffer; this requires a proper theory, not an auxiliary file. A suffix of slashes may be used to continue the exploration of an already recognized directory name. @@ -1351,8 +1352,8 @@ \<^medskip> Dictionary lookup uses some educated guesses about lower-case, upper-case, and capitalized words. This is oriented on common use in English, where this - aspect is not decisive for proper spelling, in contrast to German, for - example. + aspect is not decisive for proper spelling (in contrast to German, for + example). \ @@ -1366,22 +1367,17 @@ editor mode (see also \secref{sec:buffer-node}). The semantic \<^emph>\language context\ provides information about nested - sub-languages of Isabelle: keywords are only completed for outer syntax, - symbols or antiquotations for languages that support them. E.g.\ there is no - symbol completion for ML source, but within ML strings, comments, - antiquotations. + sub-languages of Isabelle: keywords are only completed for outer syntax, and + antiquotations for languages that support them. Symbol abbreviations only + work for specific sub-languages: e.g.\ ``\<^verbatim>\=>\'' is \<^emph>\not\ completed in + regular ML source, but is completed within ML strings, comments, + antiquotations. Backslash representations of symbols like ``\<^verbatim>\\foobar\'' or + ``\<^verbatim>\\\'' work in any context --- after additional confirmation. The prover may produce \<^emph>\no completion\ markup in exceptional situations, to tell that some language keywords should be excluded from further completion - attempts. For example, \<^verbatim>\:\ within accepted Isar syntax looses its meaning - as abbreviation for symbol \\\. - - \<^medskip> - The completion context is \<^emph>\ignored\ for built-in templates and symbols in - their explicit form ``\<^verbatim>\\\''; see also - \secref{sec:completion-varieties}. This allows to complete within broken - input that escapes its normal semantic context, e.g.\ antiquotations or - string literals in ML, which do not allow arbitrary backslash sequences. + attempts. For example, ``\<^verbatim>\:\'' within accepted Isar syntax looses its + meaning as abbreviation for symbol ``\\\''. \ @@ -1420,7 +1416,7 @@ (enabled by default) controls whether replacement text should be inserted immediately without popup, regardless of @{system_option jedit_completion_delay}. This aggressive mode of completion is restricted - to Isabelle symbols and their abbreviations (\secref{sec:symbols}). + to symbol abbreviations that are not plain words (\secref{sec:symbols}). \<^enum> Completion of symbol abbreviations with only one relevant character in the text always enforces an explicit popup, regardless of @@ -1439,7 +1435,7 @@ \<^verbatim>\PAGE_DOWN\, but all other key events are passed to the underlying text area. This allows to ignore unwanted completions most of the time and continue typing quickly. Thus the popup serves as a mechanism of - confirmation of proposed items, but the default is to continue without + confirmation of proposed items, while the default is to continue without completion. The meaning of special keys is as follows: @@ -1534,7 +1530,7 @@ A @{system_option jedit_completion_delay}~\<^verbatim>\> 0\ postpones the processing of key events, until after the user has stopped typing for the given time span, - but @{system_option jedit_completion_immediate}~\<^verbatim>\"= true\ means that + but @{system_option jedit_completion_immediate}~\<^verbatim>\= true\ means that abbreviations of Isabelle symbols are handled nonetheless. \<^item> @{system_option_def jedit_completion_path_ignore} specifies ``glob'' @@ -1562,10 +1558,10 @@ text \ Continuous document processing works asynchronously in the background. Visible document source that has been evaluated may get augmented by - additional results of \<^emph>\asynchronous print functions\. The canonical example - is proof state output, which is always enabled. More heavy-weight print - functions may be applied, in order to prove or disprove parts of the formal - text by other means. + additional results of \<^emph>\asynchronous print functions\. An example for that + is proof state output, if that is enabled in the Output panel + (\secref{sec:output}). More heavy-weight print functions may be applied as + well, e.g.\ to prove or disprove parts of the formal text by other means. Isabelle/HOL provides various automatically tried tools that operate on outermost goal statements (e.g.\ @{command lemma}, @{command theorem}), @@ -1575,8 +1571,8 @@ information sign in the gutter (see \figref{fig:auto-tools}). The message content may be shown as for other output (see also \secref{sec:output}). Some tools produce output with \<^emph>\sendback\ markup, which means that clicking - on certain parts of the output inserts that text into the source in the - proper place. + on certain parts of the text inserts that into the source in the proper + place. \begin{figure}[!htb] \begin{center} @@ -1722,8 +1718,11 @@ section \Markdown structure\ text \ - FIXME - \figref{fig:markdown-document} + Document text is internally structured in paragraphs and nested lists, using + notation that is similar to Markdown\<^footnote>\@{url "http://commonmark.org"}\. There + are special control symbols for items of different kinds of lists, + corresponding to \<^verbatim>\itemize\, \<^verbatim>\enumerate\, \<^verbatim>\description\ in {\LaTeX}. This + is illustrated in for \<^verbatim>\itemize\ in \figref{fig:markdown-document}. \begin{figure}[!htb] \begin{center} @@ -1732,6 +1731,12 @@ \caption{Markdown structure within document text} \label{fig:markdown-document} \end{figure} + + Items take colour according to the depth of nested lists. This helps to + explore the implicit rules for list structure interactively. There is also + markup for individual paragraphs in the text: it may be explored via mouse + hovering with \<^verbatim>\CONTROL\ / \<^verbatim>\COMMAND\ as usual + (\secref{sec:tooltips-hyperlinks}). \ @@ -1774,19 +1779,95 @@ \ -chapter \ML debugger\ +chapter \ML debugging within the Prover IDE\ text \ - FIXME - \figref{fig:ml-debugger} + Isabelle/ML is based on Poly/ML\<^footnote>\@{url "http://www.polyml.org"}\ and thus + benefits from the source-level debugger of that implementation of Standard + ML. The Prover IDE provides the \<^emph>\Debugger\ dockable to connect to running + ML threads, inspect the stack frame with local ML bindings, and evaluate ML + expressions in a particular run-time context. A typical debugger session is + shown in \figref{fig:ml-debugger}. + + ML debugging depends on the following pre-requisites. + + \<^enum> ML source needs to be compiled with debugging enabled. This may be + controlled for particular chunks of ML sources using any of the subsequent + facilities. + + \<^enum> The system option @{system_option_ref ML_debugger} as implicit state + of the Isabelle process. It may be changed in the menu \<^emph>\Plugins / + Plugin Options / Isabelle / General\. ML modules need to be reloaded and + recompiled to pick up that option as intended. + + \<^enum> The configuration option @{attribute_ref ML_debugger}, with an + attribute of the same name, to update a global or local context (e.g.\ + with the @{command declare} command). + + \<^enum> Commands that modify @{attribute ML_debugger} state for individual + files: @{command_ref ML_file_debug}, @{command_ref ML_file_no_debug}, + @{command_ref SML_file_debug}, @{command_ref SML_file_no_debug}. + + The instrumentation of ML code for debugging causes minor run-time + overhead. ML modules that implement critical system infrastructure may + lead to deadlocks or other undefined behaviour, when put under debugger + control! + + \<^enum> The \<^emph>\Debugger\ panel needs to be active, otherwise the program ignores + debugger instrumentation of the compiler and runs unmanaged. It is also + possible to start debugging with the panel open, and later undock it, to + let the program continue unhindered. + + \<^enum> The ML program needs to be stopped at a suitable breakpoint, which may + be activated individually or globally as follows. + + For ML sources that have been compiled with debugger support, the IDE + visualizes possible breakpoints in the text. A breakpoint may be toggled + by pointing accurately with the mouse, with a right-click to activate + jEdit's context menu and its \<^emph>\Toggle Breakpoint\ item. Alternatively, the + \<^emph>\Break\ checkbox in the \<^emph>\Debugger\ panel may be enabled to stop ML + threads always at the next possible breakpoint. + + Note that the state of individual breakpoints \<^emph>\gets lost\ when the + coresponding ML source is re-compiled! This may happen unintentionally, + e.g.\ when following hyperlinks into ML modules that have not been loaded + into the IDE before. \begin{figure}[!htb] \begin{center} \includegraphics[scale=0.333]{ml-debugger} \end{center} - \caption{ML debugger} + \caption{ML debugger session} \label{fig:ml-debugger} \end{figure} + + The debugger panel (\figref{fig:ml-debugger}) shows a list of all threads + that are presently stopped. Each thread shows a stack of all function + invocations that lead to the current breakpoint at the top. + + It is possible to jump between stack positions freely, by clicking on this + list. The current situation is displayed in the big output window, as a + local ML environment with names and printed values. + + ML expressions may be evaluated in the current context by entering snippets + of source into the text fields labeled \Context\ and \ML\, and pushing the + \Eval\ button. By default, the source is interpreted as Isabelle/ML with the + usual support for antiquotations (like @{command ML}, @{command ML_file}). + Alternatively, strict Standard ML may be enforced via the \<^emph>\SML\ checkbox + (like @{command SML_file}). + + The context for Isabelle/ML is optional, it may evaluate to a value of type + @{ML_type theory}, @{ML_type Proof.context}, or @{ML_type Context.generic}. + Thus the given ML expression (with its antiquotations) may be subject to the + intended dynamic run-time context, instead of the static compile-time + context. + + \<^medskip> + The buttons labeled \<^emph>\Continue\, \<^emph>\Step\, \<^emph>\Step over\, \<^emph>\Step out\ + recommence execution of the program, with different policies concerning + nested function invocations. The debugger always moves the cursor within the + ML source to the next breakpoint position, and offers new stack frames as + before. \ @@ -1812,10 +1893,10 @@ It is also possible to reveal individual timing information via some tooltip for the corresponding command keyword, using the technique of mouse hovering - with \<^verbatim>\CONTROL\~/ \<^verbatim>\COMMAND\ modifier key as explained in - \secref{sec:tooltips-hyperlinks}. Actual display of timing depends on the - global option @{system_option_ref jedit_timing_threshold}, which can be - configured in \<^emph>\Plugin Options~/ Isabelle~/ General\. + with \<^verbatim>\CONTROL\~/ \<^verbatim>\COMMAND\ modifier (\secref{sec:tooltips-hyperlinks}). + Actual display of timing depends on the global option @{system_option_ref + jedit_timing_threshold}, which can be configured in \<^emph>\Plugin Options~/ + Isabelle~/ General\. \<^medskip> The \<^emph>\Monitor\ panel visualizes various data collections about recent @@ -1831,11 +1912,11 @@ section \Low-level output\ text \ - Prover output is normally shown directly in the main text area or secondary - \<^emph>\Output\ panels, as explained in \secref{sec:output}. - - Beyond this, it is occasionally useful to inspect low-level output channels - via some of the following additional panels: + Prover output is normally shown directly in the main text area or specific + panels like \<^emph>\Output\ (\secref{sec:output}) or \<^emph>\State\ + (\secref{sec:state-output}). Beyond this, it is occasionally useful to + inspect low-level output channels via some of the following additional + panels: \<^item> \<^emph>\Protocol\ shows internal messages between the Isabelle/Scala and Isabelle/ML side of the PIDE document editing protocol. Recording of @@ -1914,8 +1995,16 @@ \<^item> \<^bold>\Problem:\ Mac OS X system fonts sometimes lead to character drop-outs in the main text area. - \<^bold>\Workaround:\ Use the default \<^verbatim>\IsabelleText\ font. (Do not install that - font on the system.) + \<^bold>\Workaround:\ Use the default \<^verbatim>\IsabelleText\ font. + + \<^item> \<^bold>\Problem:\ Mac OS X with Retina display has problems to determine the + font metrics of \<^verbatim>\IsabelleText\ accurately, notably in plain Swing text + fields (e.g.\ in the \<^emph>\Search and Replace\ dialog). + + \<^bold>\Workaround:\ Install \<^verbatim>\IsabelleText\ and \<^verbatim>\IsabelleTextBold\ on the system + with \<^emph>\Font Book\, despite the warnings in \secref{sec:symbols} against + that! The \<^verbatim>\.ttf\ font files reside in some directory @{file_unchecked + "$ISABELLE_HOME/contrib/isabelle_fonts-XYZ"}. \<^item> \<^bold>\Problem:\ Some Linux/X11 input methods such as IBus tend to disrupt key event handling of Java/AWT/Swing. diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/ROOT --- a/src/Doc/ROOT Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/ROOT Fri Feb 12 22:36:48 2016 +0100 @@ -126,7 +126,7 @@ "root.tex" session Implementation (doc) in "Implementation" = "HOL-Proofs" + - options [document_variants = "implementation", quick_and_dirty] + options [condition = ML_SYSTEM_POLYML, document_variants = "implementation", quick_and_dirty] theories Eq Integration diff -r 9343649abb09 -r 1fd4831e9f93 src/Doc/manual.bib --- a/src/Doc/manual.bib Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Doc/manual.bib Fri Feb 12 22:36:48 2016 +0100 @@ -306,6 +306,12 @@ series = LNCS, publisher = Springer} +@manual{isabelle-datatypes, + author = {Julian Biendarra and Jasmin Christian Blanchette and Martin Desharnais and Lorenz Panny and Andrei Popescu and Dmitriy Traytel}, + title = {Defining (Co)datatypes and Primitively (Co)recursive Functions in {Isabelle\slash HOL}}, + institution = {TU Munich}, + note = {\url{http://isabelle.in.tum.de/doc/datatypes.pdf}}} + @book{Bird-Wadler,author="Richard Bird and Philip Wadler", title="Introduction to Functional Programming",publisher=PH,year=1988} @@ -373,12 +379,6 @@ pages = "93--110" } -@manual{isabelle-datatypes, - author = {Jasmin Christian Blanchette and Martin Desharnais and Lorenz Panny and Andrei Popescu and Dmitriy Traytel}, - title = {Defining (Co)datatypes in Isabelle/HOL}, - institution = {TU Munich}, - note = {\url{http://isabelle.in.tum.de/doc/datatypes.pdf}}} - @inproceedings{why3, author = {Fran\c{c}ois Bobot and Jean-Christophe Filli\^atre and Claude March\'e and Andrei Paskevich}, title = {{Why3}: Shepherd Your Herd of Provers}, @@ -1121,6 +1121,22 @@ year = 1984, publisher = {Bibliopolis}} +@inproceedings{Matichuk-et-al:2014, + author = {Daniel Matichuk and Makarius Wenzel and Toby C. Murray}, + title = {An {Isabelle} Proof Method Language}, + editor = {Gerwin Klein and Ruben Gamboa}, + booktitle = {Interactive Theorem Proving - 5th International Conference, {ITP} + 2014, Held as Part of the Vienna Summer of Logic, {VSL} 2014, Vienna, + Austria}, + year = {2014}, + url = {http://dx.doi.org/10.1007/978-3-319-08970-6_25}, + doi = {10.1007/978-3-319-08970-6_25}, + series = LNCS, + volume = {8558}, + publisher = {Springer}, + year = {2014}, +} + @incollection{melham89, author = {Thomas F. Melham}, title = {Automating Recursive Type Definitions in Higher Order diff -r 9343649abb09 -r 1fd4831e9f93 src/HOL/Isar_Examples/Cantor.thy --- a/src/HOL/Isar_Examples/Cantor.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/HOL/Isar_Examples/Cantor.thy Fri Feb 12 22:36:48 2016 +0100 @@ -71,6 +71,7 @@ from * have "\x. ?D = f x" .. then obtain a where "?D = f a" .. then have "?D a \ f a a" by (rule arg_cong) + then have "\ f a a \ f a a" . then show False by (rule iff_contradiction) qed diff -r 9343649abb09 -r 1fd4831e9f93 src/HOL/Isar_Examples/Higher_Order_Logic.thy --- a/src/HOL/Isar_Examples/Higher_Order_Logic.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/HOL/Isar_Examples/Higher_Order_Logic.thy Fri Feb 12 22:36:48 2016 +0100 @@ -282,6 +282,7 @@ from * have "\x. ?D = f x" .. 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) qed diff -r 9343649abb09 -r 1fd4831e9f93 src/HOL/Mirabelle/lib/scripts/mirabelle.pl --- a/src/HOL/Mirabelle/lib/scripts/mirabelle.pl Wed Feb 10 15:49:05 2016 +0100 +++ b/src/HOL/Mirabelle/lib/scripts/mirabelle.pl Fri Feb 12 22:36:48 2016 +0100 @@ -157,8 +157,11 @@ if ($output_log) { print "Mirabelle: $thy_file\n"; } -my $result = system "\"$ENV{'ISABELLE_PROCESS'}\" " . - "-o quick_and_dirty -e 'Multithreading.max_threads_setmp 1 use_thy \"$path/$new_thy_name\" handle _ => exit 1;\n' -q $mirabelle_logic" . $quiet; +my $cmd = + "\"$ENV{'ISABELLE_PROCESS'}\" " . + "-o quick_and_dirty -e 'Multithreading.max_threads_setmp 1 use_thy \"$path/$new_thy_name\" handle _ => exit 1;\n' -q $mirabelle_logic" . + $quiet; +my $result = system "bash", "-c", $cmd; if ($output_log) { my $outcome = ($result ? "failure" : "success"); diff -r 9343649abb09 -r 1fd4831e9f93 src/HOL/ROOT --- a/src/HOL/ROOT Wed Feb 10 15:49:05 2016 +0100 +++ b/src/HOL/ROOT Fri Feb 12 22:36:48 2016 +0100 @@ -18,7 +18,7 @@ description {* HOL-Main with explicit proof terms. *} - options [document = false, quick_and_dirty = false] + options [condition = ML_SYSTEM_POLYML, document = false, quick_and_dirty = false] theories Proofs (*sequential change of global flag!*) theories "~~/src/HOL/Library/Old_Datatype" files @@ -252,17 +252,17 @@ Generate_Target_Nat Generate_Efficient_Datastructures Generate_Pretty_Char - theories [condition = ISABELLE_GHC] + theories [condition = "ML_SYSTEM_POLYML,ISABELLE_GHC"] Code_Test_GHC - theories [condition = ISABELLE_MLTON] + theories [condition = "ML_SYSTEM_POLYML,ISABELLE_MLTON"] Code_Test_MLton - theories [condition = ISABELLE_OCAMLC] + theories [condition = "ML_SYSTEM_POLYML,ISABELLE_OCAMLC"] Code_Test_OCaml - theories [condition = ISABELLE_POLYML] + theories [condition = "ML_SYSTEM_POLYML,ISABELLE_POLYML"] Code_Test_PolyML - theories [condition = ISABELLE_SCALA] + theories [condition = "ML_SYSTEM_POLYML,ISABELLE_SCALA"] Code_Test_Scala - theories [condition = ISABELLE_SMLNJ] + theories [condition = "ML_SYSTEM_POLYML,ISABELLE_SMLNJ"] Code_Test_SMLNJ session "HOL-Metis_Examples" in Metis_Examples = HOL + @@ -398,7 +398,7 @@ theories Decision_Procs session "HOL-Proofs-ex" in "Proofs/ex" = "HOL-Proofs" + - options [document = false, parallel_proofs = 0] + options [condition = ML_SYSTEM_POLYML, document = false, parallel_proofs = 0] theories Hilbert_Classical XML_Data @@ -432,7 +432,8 @@ The paper "More Church-Rosser Proofs (in Isabelle/HOL)" describes the whole theory (see http://www.in.tum.de/~nipkow/pubs/jar2001.html). *} - options [print_mode = "no_brackets", parallel_proofs = 0, quick_and_dirty = false] + options [condition = ML_SYSTEM_POLYML, print_mode = "no_brackets", + parallel_proofs = 0, quick_and_dirty = false] theories [document = false] "~~/src/HOL/Library/Code_Target_Int" theories @@ -845,7 +846,7 @@ theories Ex session "HOL-Word-SMT_Examples" in SMT_Examples = "HOL-Word" + - options [document = false, quick_and_dirty] + options [condition = ML_SYSTEM_POLYML, document = false, quick_and_dirty] theories Boogie SMT_Examples @@ -992,7 +993,7 @@ session "HOL-Predicate_Compile_Examples" in Predicate_Compile_Examples = HOL + options [document = false] - theories + theories [condition = ML_SYSTEM_POLYML] Examples Predicate_Compile_Tests Predicate_Compile_Quickcheck_Examples @@ -1003,13 +1004,13 @@ Hotel_Example_Small_Generator *) IMP_3 IMP_4 - theories [condition = "ISABELLE_SWIPL"] + theories [condition = ISABELLE_SWIPL] Code_Prolog_Examples Context_Free_Grammar_Example Hotel_Example_Prolog Lambda_Example List_Examples - theories [condition = "ISABELLE_SWIPL", quick_and_dirty] + theories [condition = ISABELLE_SWIPL, quick_and_dirty] Reg_Exp_Example session HOLCF (main) in HOLCF = HOL + diff -r 9343649abb09 -r 1fd4831e9f93 src/HOL/TPTP/TPTP_Parser/tptp_reconstruct.ML --- a/src/HOL/TPTP/TPTP_Parser/tptp_reconstruct.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/HOL/TPTP/TPTP_Parser/tptp_reconstruct.ML Fri Feb 12 22:36:48 2016 +0100 @@ -1070,9 +1070,7 @@ rec_inf_tac) end) fun ignore_interpretation_exn f x = SOME (f x) - handle - INTERPRET_INFERENCE => NONE - | exn => reraise exn + handle INTERPRET_INFERENCE => NONE in if List.null skel then raise SKELETON diff -r 9343649abb09 -r 1fd4831e9f93 src/HOL/TPTP/TPTP_Proof_Reconstruction.thy --- a/src/HOL/TPTP/TPTP_Proof_Reconstruction.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/HOL/TPTP/TPTP_Proof_Reconstruction.thy Fri Feb 12 22:36:48 2016 +0100 @@ -875,8 +875,8 @@ in use_candidate target_ty params' (candidate_param :: acc) val_ty end - handle TYPE ("dest_funT", _, _) => NONE - | DEST_LIST => NONE + handle TYPE ("dest_funT", _, _) => NONE (* FIXME fragile *) + | _ => NONE (* FIXME avoid catch-all handler *) val (skolem_const_ty, params') = skolem_const_info_of conclusion diff -r 9343649abb09 -r 1fd4831e9f93 src/HOL/ex/Cubic_Quartic.thy --- a/src/HOL/ex/Cubic_Quartic.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/HOL/ex/Cubic_Quartic.thy Fri Feb 12 22:36:48 2016 +0100 @@ -2,7 +2,7 @@ Author: Amine Chaieb *) -header "The Cubic and Quartic Root Formulas" +section "The Cubic and Quartic Root Formulas" theory Cubic_Quartic imports Complex_Main diff -r 9343649abb09 -r 1fd4831e9f93 src/HOL/ex/Pythagoras.thy --- a/src/HOL/ex/Pythagoras.thy Wed Feb 10 15:49:05 2016 +0100 +++ b/src/HOL/ex/Pythagoras.thy Fri Feb 12 22:36:48 2016 +0100 @@ -2,7 +2,7 @@ Author: Amine Chaieb *) -header "The Pythagorean Theorem" +section "The Pythagorean Theorem" theory Pythagoras imports Complex_Main diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Concurrent/event_timer.ML --- a/src/Pure/Concurrent/event_timer.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Concurrent/event_timer.ML Fri Feb 12 22:36:48 2016 +0100 @@ -110,7 +110,7 @@ fun shutdown () = uninterruptible (fn restore_attributes => fn () => - if Synchronized.change_result state (fn st as State {requests, status, manager} => + if Synchronized.change_result state (fn st as State {requests, manager, ...} => if is_shutdown Normal st then (false, st) else if is_shutdown Shutdown_Ack st orelse is_shutdown_req st then raise Fail "Concurrent attempt to shutdown event timer" diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Concurrent/future.scala --- a/src/Pure/Concurrent/future.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Concurrent/future.scala Fri Feb 12 22:36:48 2016 +0100 @@ -88,7 +88,7 @@ status.change(_ => Finished(if (Thread.interrupted) Exn.Exn(Exn.Interrupt()) else result)) } } - private val task = Standard_Thread.pool.submit(new Callable[A] { def call = body }) + private val task = Standard_Thread.pool.submit(new Callable[Unit] { def call = try_run() }) def join_result: Exn.Result[A] = { diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Concurrent/standard_thread.scala --- a/src/Pure/Concurrent/standard_thread.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Concurrent/standard_thread.scala Fri Feb 12 22:36:48 2016 +0100 @@ -56,8 +56,7 @@ /* delayed events */ - final class Delay private [Standard_Thread]( - first: Boolean, delay: => Time, cancel: () => Unit, event: => Unit) + final class Delay private [Standard_Thread](first: Boolean, delay: => Time, event: => Unit) { private var running: Option[Event_Timer.Request] = None @@ -73,8 +72,8 @@ { val new_run = running match { - case Some(request) => if (first) false else { request.cancel; cancel(); true } - case None => cancel(); true + case Some(request) => if (first) false else { request.cancel; true } + case None => true } if (new_run) running = Some(Event_Timer.request(Time.now() + delay)(run)) @@ -83,8 +82,8 @@ def revoke(): Unit = synchronized { running match { - case Some(request) => request.cancel; cancel(); running = None - case None => cancel() + case Some(request) => request.cancel; running = None + case None => } } @@ -94,20 +93,16 @@ case Some(request) => val alt_time = Time.now() + alt_delay if (request.time < alt_time && request.cancel) { - cancel() running = Some(Event_Timer.request(alt_time)(run)) } - else cancel() - case None => cancel() + case None => } } } // delayed event after first invocation - def delay_first(delay: => Time, cancel: () => Unit = () => ())(event: => Unit): Delay = - new Delay(true, delay, cancel, event) + def delay_first(delay: => Time)(event: => Unit): Delay = new Delay(true, delay, event) // delayed event after last invocation - def delay_last(delay: => Time, cancel: () => Unit = () => ())(event: => Unit): Delay = - new Delay(false, delay, cancel, event) + def delay_last(delay: => Time)(event: => Unit): Delay = new Delay(false, delay, event) } diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/GUI/gui_thread.scala --- a/src/Pure/GUI/gui_thread.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/GUI/gui_thread.scala Fri Feb 12 22:36:48 2016 +0100 @@ -49,9 +49,9 @@ /* delayed events */ - def delay_first(delay: => Time, cancel: () => Unit = () => ())(event: => Unit) - : Standard_Thread.Delay = Standard_Thread.delay_first(delay, cancel) { later { event } } + def delay_first(delay: => Time)(event: => Unit): Standard_Thread.Delay = + Standard_Thread.delay_first(delay) { later { event } } - def delay_last(delay: => Time, cancel: () => Unit = () => ())(event: => Unit) - : Standard_Thread.Delay = Standard_Thread.delay_last(delay, cancel) { later { event } } + def delay_last(delay: => Time)(event: => Unit): Standard_Thread.Delay = + Standard_Thread.delay_last(delay) { later { event } } } diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/General/binding.ML --- a/src/Pure/General/binding.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/General/binding.ML Fri Feb 12 22:36:48 2016 +0100 @@ -31,7 +31,7 @@ val prefix_of: binding -> (string * bool) list val map_prefix: ((string * bool) list -> (string * bool) list) -> binding -> binding val prefix: bool -> string -> binding -> binding - val restricted_default: (bool * scope) option -> binding -> binding + val restricted: (bool * scope) option -> binding -> binding val concealed: binding -> binding val pretty: binding -> Pretty.T val print: binding -> string @@ -135,14 +135,9 @@ (* visibility flags *) -fun restricted strict scope = - map_binding (fn (_, concealed, prefix, qualifier, name, pos) => - (SOME (strict, scope), concealed, prefix, qualifier, name, pos)); - -fun restricted_default restricted' = +fun restricted default = map_binding (fn (restricted, concealed, prefix, qualifier, name, pos) => - (if is_some restricted then restricted else restricted', - concealed, prefix, qualifier, name, pos)); + (if is_some restricted then restricted else default, concealed, prefix, qualifier, name, pos)); val concealed = map_binding (fn (restricted, _, prefix, qualifier, name, pos) => diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/General/completion.scala --- a/src/Pure/General/completion.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/General/completion.scala Fri Feb 12 22:36:48 2016 +0100 @@ -322,7 +322,9 @@ if path.is_file entry <- Abbrevs_Parser.parse_file(path) } yield entry - symbol_abbrevs ::: more_abbrevs + val remove_abbrevs = (for { (a, b) <- more_abbrevs if b == "" } yield a).toSet + + (symbol_abbrevs ::: more_abbrevs).filterNot({ case (a, _) => remove_abbrevs.contains(a) }) } private val caret_indicator = '\u0007' diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/General/name_space.ML --- a/src/Pure/General/name_space.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/General/name_space.ML Fri Feb 12 22:36:48 2016 +0100 @@ -389,7 +389,7 @@ concealed' ? concealed; fun transform_binding (Naming {restricted, concealed, ...}) = - Binding.restricted_default restricted #> + Binding.restricted restricted #> concealed ? Binding.concealed; diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/General/symbol.scala --- a/src/Pure/General/symbol.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/General/symbol.scala Fri Feb 12 22:36:48 2016 +0100 @@ -255,7 +255,7 @@ tab.get(x) match { case None => tab += (x -> y) case Some(z) => - error("Duplicate mapping of " + quote(x) + " to " + quote(y) + " vs. " + quote(z)) + error("Duplicate symbol mapping of " + quote(x) + " to " + quote(y) + " vs. " + quote(z)) } } tab diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/General/symbol_pos.ML --- a/src/Pure/General/symbol_pos.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/General/symbol_pos.ML Fri Feb 12 22:36:48 2016 +0100 @@ -71,7 +71,7 @@ fun split syms = (case take_prefix (fn (s, _) => s <> "\n") syms of (line, []) => [line] - | (line, nl :: rest) => line :: split rest); + | (line, _ :: rest) => line :: split rest); in split list end; val trim_blanks = trim (Symbol.is_blank o symbol); diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/General/url.scala --- a/src/Pure/General/url.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/General/url.scala Fri Feb 12 22:36:48 2016 +0100 @@ -12,6 +12,9 @@ object Url { + def escape(name: String): String = + (for (c <- name.iterator) yield if (c == '\'') "%27" else new String(Array(c))).mkString + def apply(name: String): URL = { try { new URL(name) } diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Isar/named_target.ML --- a/src/Pure/Isar/named_target.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Isar/named_target.ML Fri Feb 12 22:36:48 2016 +0100 @@ -86,7 +86,7 @@ | abbrev (locale, false) = Generic_Target.locale_abbrev locale | abbrev (class, true) = Class.abbrev class; -fun declaration ("", _) flags decl = Generic_Target.theory_declaration decl +fun declaration ("", _) _ decl = Generic_Target.theory_declaration decl | declaration (locale, _) flags decl = Generic_Target.locale_declaration locale flags decl; fun theory_registration ("", _) = Generic_Target.theory_registration diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Isar/outer_syntax.scala --- a/src/Pure/Isar/outer_syntax.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Isar/outer_syntax.scala Fri Feb 12 22:36:48 2016 +0100 @@ -166,9 +166,9 @@ if (tok.is_command) { if (tok.is_command_kind(keywords, Keyword.theory_goal)) (2, 1) else if (tok.is_command_kind(keywords, Keyword.theory)) (1, 0) + else if (tok.is_command_kind(keywords, Keyword.proof_open)) (y + 2, y + 1) else if (tok.is_command_kind(keywords, Keyword.PRF_BLOCK == _)) (y + 2, y + 1) - else if (tok.is_command_kind(keywords, Keyword.QED_BLOCK == _)) (y + 1, y - 3) - else if (tok.is_command_kind(keywords, Keyword.proof_open)) (y + 2, y + 1) + else if (tok.is_command_kind(keywords, Keyword.QED_BLOCK == _)) (y + 1, y - 2) else if (tok.is_command_kind(keywords, Keyword.proof_close)) (y + 1, y - 1) else if (tok.is_command_kind(keywords, Keyword.qed_global)) (1, 0) else (x, y) diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Isar/toplevel.ML --- a/src/Pure/Isar/toplevel.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Isar/toplevel.ML Fri Feb 12 22:36:48 2016 +0100 @@ -212,10 +212,6 @@ fun reset_presentation (Theory (gthy, _)) = Theory (gthy, NONE) | reset_presentation node = node; -fun map_theory f (Theory (gthy, ctxt)) = - Theory (Context.mapping f (Local_Theory.raw_theory f) gthy, ctxt) - | map_theory _ node = node; - in fun apply_transaction f g node = diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/ML/ml_antiquotations.ML --- a/src/Pure/ML/ml_antiquotations.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/ML/ml_antiquotations.ML Fri Feb 12 22:36:48 2016 +0100 @@ -11,7 +11,7 @@ val _ = Theory.setup (ML_Antiquotation.value @{binding cartouche} - (Args.context -- Scan.lift (Parse.position Args.cartouche_input) >> (fn (ctxt, (source, pos)) => + (Scan.lift Args.cartouche_input >> (fn source => "Input.source true " ^ ML_Syntax.print_string (Input.text_of source) ^ " " ^ ML_Syntax.atomic (ML_Syntax.print_range (Input.range_of source)))) #> diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/PIDE/markup.ML --- a/src/Pure/PIDE/markup.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/PIDE/markup.ML Fri Feb 12 22:36:48 2016 +0100 @@ -28,7 +28,7 @@ val is_delimited: Properties.T -> bool val language: {name: string, symbols: bool, antiquotes: bool, delimited: bool} -> T val language': {name: string, symbols: bool, antiquotes: bool} -> bool -> T - val language_outer: bool -> T + val language_Isar: bool -> T val language_method: T val language_attribute: T val language_sort: bool -> T @@ -301,7 +301,7 @@ fun language' {name, symbols, antiquotes} delimited = language {name = name, symbols = symbols, antiquotes = antiquotes, delimited = delimited}; -val language_outer = language' {name = "", symbols = true, antiquotes = false}; +val language_Isar = language' {name = "Isar", symbols = true, antiquotes = false}; val language_method = language {name = "method", symbols = true, antiquotes = false, delimited = false}; val language_attribute = diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Syntax/syntax_phases.ML --- a/src/Pure/Syntax/syntax_phases.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Syntax/syntax_phases.ML Fri Feb 12 22:36:48 2016 +0100 @@ -581,7 +581,7 @@ (mark Ts t1 $ mark Ts t2); in mark [] tm end; -fun prune_types ctxt tm = +fun prune_types tm = let fun regard t t' seen = if Type_Annotation.is_omitted (Type_Annotation.fastype_of [] t) then (t, seen) @@ -651,7 +651,7 @@ in Ast.mk_appl (constrain (c $ Syntax.free x) X) (map ast_of ts) end | (Const ("_idtdummy", T), ts) => Ast.mk_appl (constrain (Syntax.const "_idtdummy") T) (map ast_of ts) - | (const as Const (c, T), ts) => trans c (Type_Annotation.smash T) ts + | (Const (c, T), ts) => trans c (Type_Annotation.smash T) ts | (t, ts) => Ast.mk_appl (simple_ast_of ctxt t) (map ast_of ts)) and trans a T args = ast_of (trf a ctxt T args) @@ -672,7 +672,7 @@ in tm |> mark_aprop - |> show_types ? prune_types ctxt + |> show_types ? prune_types |> Variable.revert_bounds ctxt |> mark_atoms is_syntax_const ctxt |> ast_of diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/System/options.scala --- a/src/Pure/System/options.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/System/options.scala Fri Feb 12 22:36:48 2016 +0100 @@ -387,48 +387,52 @@ class Options_Variable { - private var options = Options.empty + private var options: Option[Options] = None + + def store(new_options: Options): Unit = synchronized { options = Some(new_options) } - def value: Options = synchronized { options } - def update(new_options: Options): Unit = synchronized { options = new_options } + def value: Options = synchronized { + options match { + case Some(opts) => opts + case None => error("Uninitialized Isabelle system options") + } + } - def + (name: String, x: String): Unit = synchronized { options = options + (name, x) } + private def upd(f: Options => Options): Unit = synchronized { options = Some(f(value)) } + + def + (name: String, x: String): Unit = upd(opts => opts + (name, x)) class Bool_Access { - def apply(name: String): Boolean = synchronized { options.bool(name) } - def update(name: String, x: Boolean): Unit = - synchronized { options = options.bool.update(name, x) } + def apply(name: String): Boolean = value.bool(name) + def update(name: String, x: Boolean): Unit = upd(opts => opts.bool.update(name, x)) } val bool = new Bool_Access class Int_Access { - def apply(name: String): Int = synchronized { options.int(name) } - def update(name: String, x: Int): Unit = - synchronized { options = options.int.update(name, x) } + def apply(name: String): Int = value.int(name) + def update(name: String, x: Int): Unit = upd(opts => opts.int.update(name, x)) } val int = new Int_Access class Real_Access { - def apply(name: String): Double = synchronized { options.real(name) } - def update(name: String, x: Double): Unit = - synchronized { options = options.real.update(name, x) } + def apply(name: String): Double = value.real(name) + def update(name: String, x: Double): Unit = upd(opts => opts.real.update(name, x)) } val real = new Real_Access class String_Access { - def apply(name: String): String = synchronized { options.string(name) } - def update(name: String, x: String): Unit = - synchronized { options = options.string.update(name, x) } + def apply(name: String): String = value.string(name) + def update(name: String, x: String): Unit = upd(opts => opts.string.update(name, x)) } val string = new String_Access class Seconds_Access { - def apply(name: String): Time = synchronized { options.seconds(name) } + def apply(name: String): Time = value.seconds(name) } val seconds = new Seconds_Access } diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Thy/document_antiquotations.ML --- a/src/Pure/Thy/document_antiquotations.ML Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Thy/document_antiquotations.ML Fri Feb 12 22:36:48 2016 +0100 @@ -87,7 +87,7 @@ let val _ = Context_Position.report ctxt (Input.pos_of source) - (Markup.language_outer (Input.is_delimited source)); + (Markup.language_Isar (Input.is_delimited source)); val keywords = Thy_Header.get_keywords' ctxt; val toks = @@ -217,7 +217,9 @@ Theory.setup (entity_antiquotation @{binding command} Outer_Syntax.check_command (enclose "\\isacommand{" "}" o Output.output) #> - entity_antiquotation @{binding method} Method.check_name Output.output #> - entity_antiquotation @{binding attribute} Attrib.check_name Output.output); + entity_antiquotation @{binding method} Method.check_name + (enclose "\\isa{" "}" o Output.output) #> + entity_antiquotation @{binding attribute} Attrib.check_name + (enclose "\\isa{" "}" o Output.output)); end; diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Tools/check_source.scala --- a/src/Pure/Tools/check_source.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Tools/check_source.scala Fri Feb 12 22:36:48 2016 +0100 @@ -44,7 +44,7 @@ Isabelle_System.hg("--repository " + File.shell_path(root) + " root").check_error for { file <- Isabelle_System.hg("manifest", root).check_error.out_lines - if file.endsWith(".thy") || file.endsWith(".ML") + if file.endsWith(".thy") || file.endsWith(".ML") || file.endsWith("/ROOT") } check_file(root + Path.explode(file)) } diff -r 9343649abb09 -r 1fd4831e9f93 src/Pure/Tools/main.scala --- a/src/Pure/Tools/main.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Pure/Tools/main.scala Fri Feb 12 22:36:48 2016 +0100 @@ -105,6 +105,7 @@ val env = env0.asInstanceOf[java.util.Map[String, String]] env.put("ISABELLE_HOME", File.platform_path(isabelle_home)) env.put("ISABELLE_HOME_USER", File.platform_path(isabelle_home_user)) + env.remove("ISABELLE_ROOT") } } diff -r 9343649abb09 -r 1fd4831e9f93 src/Tools/jEdit/src/context_menu.scala --- a/src/Tools/jEdit/src/context_menu.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Tools/jEdit/src/context_menu.scala Fri Feb 12 22:36:48 2016 +0100 @@ -21,22 +21,23 @@ class Context_Menu extends DynamicContextMenuService { def createMenu(text_area: JEditTextArea, evt: MouseEvent): Array[JMenuItem] = - { - PIDE.dismissed_popups(text_area.getView) + if (evt == null) null + else { + PIDE.dismissed_popups(text_area.getView) - val items1 = - if (evt != null && evt.getSource == text_area.getPainter) { - val offset = text_area.xyToOffset(evt.getX, evt.getY) - if (offset >= 0) - Spell_Checker.context_menu(text_area, offset) ::: - Debugger_Dockable.context_menu(text_area, offset) + val items1 = + if (evt != null && evt.getSource == text_area.getPainter) { + val offset = text_area.xyToOffset(evt.getX, evt.getY) + if (offset >= 0) + Spell_Checker.context_menu(text_area, offset) ::: + Debugger_Dockable.context_menu(text_area, offset) + else Nil + } else Nil - } - else Nil + + val items2 = Bibtex_JEdit.context_menu(text_area) - val items2 = Bibtex_JEdit.context_menu(text_area) - - val items = items1 ::: items2 - if (items.isEmpty) null else items.toArray + val items = items1 ::: items2 + if (items.isEmpty) null else items.toArray } } diff -r 9343649abb09 -r 1fd4831e9f93 src/Tools/jEdit/src/document_model.scala --- a/src/Tools/jEdit/src/document_model.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Tools/jEdit/src/document_model.scala Fri Feb 12 22:36:48 2016 +0100 @@ -309,6 +309,7 @@ for (text_area <- JEdit_Lib.jedit_text_areas(buffer)) Untyped.method(Class.forName("org.gjt.sp.jedit.textarea.TextArea"), "foldStructureChanged"). invoke(text_area) + buffer.invalidateCachedFoldLevels } private def init_token_marker() diff -r 9343649abb09 -r 1fd4831e9f93 src/Tools/jEdit/src/jedit_editor.scala --- a/src/Tools/jEdit/src/jedit_editor.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Tools/jEdit/src/jedit_editor.scala Fri Feb 12 22:36:48 2016 +0100 @@ -223,7 +223,7 @@ val external = true def follow(view: View): Unit = Standard_Thread.fork("hyperlink_url") { - try { Isabelle_System.open(name) } + try { Isabelle_System.open(Url.escape(name)) } catch { case exn: Throwable => GUI_Thread.later { diff -r 9343649abb09 -r 1fd4831e9f93 src/Tools/jEdit/src/jedit_lib.scala --- a/src/Tools/jEdit/src/jedit_lib.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Tools/jEdit/src/jedit_lib.scala Fri Feb 12 22:36:48 2016 +0100 @@ -16,7 +16,7 @@ import scala.annotation.tailrec import scala.util.parsing.input.CharSequenceReader -import org.gjt.sp.jedit.{jEdit, Buffer, View, GUIUtilities, Debug} +import org.gjt.sp.jedit.{jEdit, Buffer, View, GUIUtilities, Debug, EditPane} import org.gjt.sp.jedit.gui.KeyEventWorkaround import org.gjt.sp.jedit.buffer.{JEditBuffer, LineManager} import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea, TextAreaPainter} @@ -130,6 +130,10 @@ def jedit_views(): Iterator[View] = jEdit.getViews().iterator + def jedit_edit_panes(view: View): Iterator[EditPane] = + if (view == null) Iterator.empty + else view.getEditPanes().iterator.filter(_ != null) + def jedit_text_areas(view: View): Iterator[JEditTextArea] = if (view == null) Iterator.empty else view.getEditPanes().iterator.filter(_ != null).map(_.getTextArea).filter(_ != null) diff -r 9343649abb09 -r 1fd4831e9f93 src/Tools/jEdit/src/jedit_options.scala --- a/src/Tools/jEdit/src/jedit_options.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Tools/jEdit/src/jedit_options.scala Fri Feb 12 22:36:48 2016 +0100 @@ -96,7 +96,7 @@ val title = opt_title def load = text = value.check_name(opt_name).value def save = - try { update(value + (opt_name, text)) } + try { store(value + (opt_name, text)) } catch { case ERROR(msg) => GUI.error_dialog(this.peer, "Failed to update options", diff -r 9343649abb09 -r 1fd4831e9f93 src/Tools/jEdit/src/output_dockable.scala --- a/src/Tools/jEdit/src/output_dockable.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Tools/jEdit/src/output_dockable.scala Fri Feb 12 22:36:48 2016 +0100 @@ -129,6 +129,7 @@ Session.Consumer[Any](getClass.getName) { case _: Session.Global_Options => GUI_Thread.later { + handle_resize() output_state_button.selected = output_state handle_update(do_update, None) } diff -r 9343649abb09 -r 1fd4831e9f93 src/Tools/jEdit/src/plugin.scala --- a/src/Tools/jEdit/src/plugin.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Tools/jEdit/src/plugin.scala Fri Feb 12 22:36:48 2016 +0100 @@ -19,8 +19,8 @@ import org.gjt.sp.jedit.buffer.JEditBuffer import org.gjt.sp.jedit.syntax.ModeProvider import org.gjt.sp.jedit.msg.{EditorStarted, BufferUpdate, EditPaneUpdate, PropertiesChanged} - import org.gjt.sp.util.SyntaxUtilities +import org.gjt.sp.util.Log object PIDE @@ -377,6 +377,15 @@ } case msg: PropertiesChanged => + for { + view <- JEdit_Lib.jedit_views + edit_pane <- JEdit_Lib.jedit_edit_panes(view) + } { + val buffer = edit_pane.getBuffer + val text_area = edit_pane.getTextArea + if (buffer != null && text_area != null) PIDE.init_view(buffer, text_area) + } + PIDE.spell_checker.update(PIDE.options.value) PIDE.session.update_options(PIDE.options.value) @@ -391,7 +400,7 @@ Debug.DISABLE_SEARCH_DIALOG_POOL = true PIDE.plugin = this - PIDE.options.update(Options.init()) + PIDE.options.store(Options.init()) PIDE.completion_history.load() PIDE.spell_checker.update(PIDE.options.value) @@ -420,6 +429,7 @@ case exn: Throwable => PIDE.startup_failure = Some(exn) PIDE.startup_notified = false + Log.log(Log.ERROR, this, exn) } } diff -r 9343649abb09 -r 1fd4831e9f93 src/Tools/jEdit/src/text_overview.scala --- a/src/Tools/jEdit/src/text_overview.scala Wed Feb 10 15:49:05 2016 +0100 +++ b/src/Tools/jEdit/src/text_overview.scala Fri Feb 12 22:36:48 2016 +0100 @@ -72,6 +72,9 @@ private var current_overview = Overview() private var current_colors: List[(Color, Int, Int)] = Nil + private val delay_repaint = + GUI_Thread.delay_first(PIDE.options.seconds("editor_update_delay")) { repaint() } + override def paintComponent(gfx: Graphics) { super.paintComponent(gfx) @@ -83,7 +86,7 @@ val overview = get_overview() if (rendering.snapshot.is_outdated || overview != current_overview) { - invoke() + delay_repaint.invoke() gfx.setColor(rendering.outdated_color) gfx.asInstanceOf[Graphics2D].fill(gfx.getClipBounds) @@ -103,23 +106,21 @@ /* asynchronous refresh */ - private var future_refresh: Option[Future[Unit]] = None - private def cancel(): Unit = future_refresh.map(_.cancel) + private val future_refresh = Synchronized(Future.value(())) + private def is_running(): Boolean = !future_refresh.value.is_finished def invoke(): Unit = delay_refresh.invoke() - def revoke(): Unit = delay_refresh.revoke() + def revoke(): Unit = { delay_refresh.revoke(); future_refresh.change(x => { x.cancel; x }) } private val delay_refresh = - GUI_Thread.delay_first(PIDE.options.seconds("editor_update_delay"), cancel _) { + GUI_Thread.delay_first(PIDE.options.seconds("editor_update_delay")) { doc_view.rich_text_area.robust_body(()) { JEdit_Lib.buffer_lock(buffer) { val rendering = doc_view.get_rendering() val overview = get_overview() - if (rendering.snapshot.is_outdated) invoke() + if (rendering.snapshot.is_outdated || is_running()) invoke() else { - cancel() - val line_offsets = { val line_manager = JEdit_Lib.buffer_line_manager(buffer) @@ -128,8 +129,8 @@ a } - future_refresh = - Some(Future.fork { + future_refresh.change(_ => + Future.fork { val line_count = overview.line_count val char_count = overview.char_count val L = overview.L @@ -170,7 +171,8 @@ current_colors = new_colors repaint() } - }) + } + ) } } }