62 @{syntax_def modes}: '(' (@{syntax name} + ) ')' |
62 @{syntax_def modes}: '(' (@{syntax name} + ) ')' |
63 \<close>} |
63 \<close>} |
64 |
64 |
65 \begin{description} |
65 \begin{description} |
66 |
66 |
67 \item @{command "typ"}~@{text \<tau>} reads and prints a type expression |
67 \<^descr> @{command "typ"}~@{text \<tau>} reads and prints a type expression |
68 according to the current context. |
68 according to the current context. |
69 |
69 |
70 \item @{command "typ"}~@{text "\<tau> :: s"} uses type-inference to |
70 \<^descr> @{command "typ"}~@{text "\<tau> :: s"} uses type-inference to |
71 determine the most general way to make @{text "\<tau>"} conform to sort |
71 determine the most general way to make @{text "\<tau>"} conform to sort |
72 @{text "s"}. For concrete @{text "\<tau>"} this checks if the type |
72 @{text "s"}. For concrete @{text "\<tau>"} this checks if the type |
73 belongs to that sort. Dummy type parameters ``@{text "_"}'' |
73 belongs to that sort. Dummy type parameters ``@{text "_"}'' |
74 (underscore) are assigned to fresh type variables with most general |
74 (underscore) are assigned to fresh type variables with most general |
75 sorts, according the the principles of type-inference. |
75 sorts, according the the principles of type-inference. |
76 |
76 |
77 \item @{command "term"}~@{text t} and @{command "prop"}~@{text \<phi>} |
77 \<^descr> @{command "term"}~@{text t} and @{command "prop"}~@{text \<phi>} |
78 read, type-check and print terms or propositions according to the |
78 read, type-check and print terms or propositions according to the |
79 current theory or proof context; the inferred type of @{text t} is |
79 current theory or proof context; the inferred type of @{text t} is |
80 output as well. Note that these commands are also useful in |
80 output as well. Note that these commands are also useful in |
81 inspecting the current environment of term abbreviations. |
81 inspecting the current environment of term abbreviations. |
82 |
82 |
83 \item @{command "thm"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} retrieves |
83 \<^descr> @{command "thm"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} retrieves |
84 theorems from the current theory or proof context. Note that any |
84 theorems from the current theory or proof context. Note that any |
85 attributes included in the theorem specifications are applied to a |
85 attributes included in the theorem specifications are applied to a |
86 temporary context derived from the current theory or proof; the |
86 temporary context derived from the current theory or proof; the |
87 result is discarded, i.e.\ attributes involved in @{text "a\<^sub>1, |
87 result is discarded, i.e.\ attributes involved in @{text "a\<^sub>1, |
88 \<dots>, a\<^sub>n"} do not have any permanent effect. |
88 \<dots>, a\<^sub>n"} do not have any permanent effect. |
89 |
89 |
90 \item @{command "prf"} displays the (compact) proof term of the |
90 \<^descr> @{command "prf"} displays the (compact) proof term of the |
91 current proof state (if present), or of the given theorems. Note |
91 current proof state (if present), or of the given theorems. Note |
92 that this requires proof terms to be switched on for the current |
92 that this requires proof terms to be switched on for the current |
93 object logic (see the ``Proof terms'' section of the Isabelle |
93 object logic (see the ``Proof terms'' section of the Isabelle |
94 reference manual for information on how to do this). |
94 reference manual for information on how to do this). |
95 |
95 |
96 \item @{command "full_prf"} is like @{command "prf"}, but displays |
96 \<^descr> @{command "full_prf"} is like @{command "prf"}, but displays |
97 the full proof term, i.e.\ also displays information omitted in the |
97 the full proof term, i.e.\ also displays information omitted in the |
98 compact proof term, which is denoted by ``@{text _}'' placeholders |
98 compact proof term, which is denoted by ``@{text _}'' placeholders |
99 there. |
99 there. |
100 |
100 |
101 \item @{command "print_state"} prints the current proof state (if |
101 \<^descr> @{command "print_state"} prints the current proof state (if |
102 present), including current facts and goals. |
102 present), including current facts and goals. |
103 |
103 |
104 \end{description} |
104 \end{description} |
105 |
105 |
106 All of the diagnostic commands above admit a list of @{text modes} |
106 All of the diagnostic commands above admit a list of @{text modes} |
144 is displayed for types, terms, theorems, goals etc. See also |
144 is displayed for types, terms, theorems, goals etc. See also |
145 \secref{sec:config}. |
145 \secref{sec:config}. |
146 |
146 |
147 \begin{description} |
147 \begin{description} |
148 |
148 |
149 \item @{attribute show_markup} controls direct inlining of markup |
149 \<^descr> @{attribute show_markup} controls direct inlining of markup |
150 into the printed representation of formal entities --- notably type |
150 into the printed representation of formal entities --- notably type |
151 and sort constraints. This enables Prover IDE users to retrieve |
151 and sort constraints. This enables Prover IDE users to retrieve |
152 that information via tooltips or popups while hovering with the |
152 that information via tooltips or popups while hovering with the |
153 mouse over the output window, for example. Consequently, this |
153 mouse over the output window, for example. Consequently, this |
154 option is enabled by default for Isabelle/jEdit. |
154 option is enabled by default for Isabelle/jEdit. |
155 |
155 |
156 \item @{attribute show_types} and @{attribute show_sorts} control |
156 \<^descr> @{attribute show_types} and @{attribute show_sorts} control |
157 printing of type constraints for term variables, and sort |
157 printing of type constraints for term variables, and sort |
158 constraints for type variables. By default, neither of these are |
158 constraints for type variables. By default, neither of these are |
159 shown in output. If @{attribute show_sorts} is enabled, types are |
159 shown in output. If @{attribute show_sorts} is enabled, types are |
160 always shown as well. In Isabelle/jEdit, manual setting of these |
160 always shown as well. In Isabelle/jEdit, manual setting of these |
161 options is normally not required thanks to @{attribute show_markup} |
161 options is normally not required thanks to @{attribute show_markup} |
163 |
163 |
164 Note that displaying types and sorts may explain why a polymorphic |
164 Note that displaying types and sorts may explain why a polymorphic |
165 inference rule fails to resolve with some goal, or why a rewrite |
165 inference rule fails to resolve with some goal, or why a rewrite |
166 rule does not apply as expected. |
166 rule does not apply as expected. |
167 |
167 |
168 \item @{attribute show_consts} controls printing of types of |
168 \<^descr> @{attribute show_consts} controls printing of types of |
169 constants when displaying a goal state. |
169 constants when displaying a goal state. |
170 |
170 |
171 Note that the output can be enormous, because polymorphic constants |
171 Note that the output can be enormous, because polymorphic constants |
172 often occur at several different type instances. |
172 often occur at several different type instances. |
173 |
173 |
174 \item @{attribute show_abbrevs} controls folding of constant |
174 \<^descr> @{attribute show_abbrevs} controls folding of constant |
175 abbreviations. |
175 abbreviations. |
176 |
176 |
177 \item @{attribute show_brackets} controls bracketing in pretty |
177 \<^descr> @{attribute show_brackets} controls bracketing in pretty |
178 printed output. If enabled, all sub-expressions of the pretty |
178 printed output. If enabled, all sub-expressions of the pretty |
179 printing tree will be parenthesized, even if this produces malformed |
179 printing tree will be parenthesized, even if this produces malformed |
180 term syntax! This crude way of showing the internal structure of |
180 term syntax! This crude way of showing the internal structure of |
181 pretty printed entities may occasionally help to diagnose problems |
181 pretty printed entities may occasionally help to diagnose problems |
182 with operator priorities, for example. |
182 with operator priorities, for example. |
183 |
183 |
184 \item @{attribute names_long}, @{attribute names_short}, and |
184 \<^descr> @{attribute names_long}, @{attribute names_short}, and |
185 @{attribute names_unique} control the way of printing fully |
185 @{attribute names_unique} control the way of printing fully |
186 qualified internal names in external form. See also |
186 qualified internal names in external form. See also |
187 \secref{sec:antiq} for the document antiquotation options of the |
187 \secref{sec:antiq} for the document antiquotation options of the |
188 same names. |
188 same names. |
189 |
189 |
190 \item @{attribute eta_contract} controls @{text "\<eta>"}-contracted |
190 \<^descr> @{attribute eta_contract} controls @{text "\<eta>"}-contracted |
191 printing of terms. |
191 printing of terms. |
192 |
192 |
193 The @{text \<eta>}-contraction law asserts @{prop "(\<lambda>x. f x) \<equiv> f"}, |
193 The @{text \<eta>}-contraction law asserts @{prop "(\<lambda>x. f x) \<equiv> f"}, |
194 provided @{text x} is not free in @{text f}. It asserts |
194 provided @{text x} is not free in @{text f}. It asserts |
195 \emph{extensionality} of functions: @{prop "f \<equiv> g"} if @{prop "f x \<equiv> |
195 \emph{extensionality} of functions: @{prop "f \<equiv> g"} if @{prop "f x \<equiv> |
205 Note that the distinction between a term and its @{text \<eta>}-expanded |
205 Note that the distinction between a term and its @{text \<eta>}-expanded |
206 form occasionally matters. While higher-order resolution and |
206 form occasionally matters. While higher-order resolution and |
207 rewriting operate modulo @{text "\<alpha>\<beta>\<eta>"}-conversion, some other tools |
207 rewriting operate modulo @{text "\<alpha>\<beta>\<eta>"}-conversion, some other tools |
208 might look at terms more discretely. |
208 might look at terms more discretely. |
209 |
209 |
210 \item @{attribute goals_limit} controls the maximum number of |
210 \<^descr> @{attribute goals_limit} controls the maximum number of |
211 subgoals to be printed. |
211 subgoals to be printed. |
212 |
212 |
213 \item @{attribute show_main_goal} controls whether the main result |
213 \<^descr> @{attribute show_main_goal} controls whether the main result |
214 to be proven should be displayed. This information might be |
214 to be proven should be displayed. This information might be |
215 relevant for schematic goals, to inspect the current claim that has |
215 relevant for schematic goals, to inspect the current claim that has |
216 been synthesized so far. |
216 been synthesized so far. |
217 |
217 |
218 \item @{attribute show_hyps} controls printing of implicit |
218 \<^descr> @{attribute show_hyps} controls printing of implicit |
219 hypotheses of local facts. Normally, only those hypotheses are |
219 hypotheses of local facts. Normally, only those hypotheses are |
220 displayed that are \emph{not} covered by the assumptions of the |
220 displayed that are \emph{not} covered by the assumptions of the |
221 current context: this situation indicates a fault in some tool being |
221 current context: this situation indicates a fault in some tool being |
222 used. |
222 used. |
223 |
223 |
224 By enabling @{attribute show_hyps}, output of \emph{all} hypotheses |
224 By enabling @{attribute show_hyps}, output of \emph{all} hypotheses |
225 can be enforced, which is occasionally useful for diagnostic |
225 can be enforced, which is occasionally useful for diagnostic |
226 purposes. |
226 purposes. |
227 |
227 |
228 \item @{attribute show_tags} controls printing of extra annotations |
228 \<^descr> @{attribute show_tags} controls printing of extra annotations |
229 within theorems, such as internal position information, or the case |
229 within theorems, such as internal position information, or the case |
230 names being attached by the attribute @{attribute case_names}. |
230 names being attached by the attribute @{attribute case_names}. |
231 |
231 |
232 Note that the @{attribute tagged} and @{attribute untagged} |
232 Note that the @{attribute tagged} and @{attribute untagged} |
233 attributes provide low-level access to the collection of tags |
233 attributes provide low-level access to the collection of tags |
234 associated with a theorem. |
234 associated with a theorem. |
235 |
235 |
236 \item @{attribute show_question_marks} controls printing of question |
236 \<^descr> @{attribute show_question_marks} controls printing of question |
237 marks for schematic variables, such as @{text ?x}. Only the leading |
237 marks for schematic variables, such as @{text ?x}. Only the leading |
238 question mark is affected, the remaining text is unchanged |
238 question mark is affected, the remaining text is unchanged |
239 (including proper markup for schematic variables that might be |
239 (including proper markup for schematic variables that might be |
240 relevant for user interfaces). |
240 relevant for user interfaces). |
241 |
241 |
257 modes as optional argument. The underlying ML operations are as |
257 modes as optional argument. The underlying ML operations are as |
258 follows. |
258 follows. |
259 |
259 |
260 \begin{description} |
260 \begin{description} |
261 |
261 |
262 \item @{ML "print_mode_value ()"} yields the list of currently |
262 \<^descr> @{ML "print_mode_value ()"} yields the list of currently |
263 active print mode names. This should be understood as symbolic |
263 active print mode names. This should be understood as symbolic |
264 representation of certain individual features for printing (with |
264 representation of certain individual features for printing (with |
265 precedence from left to right). |
265 precedence from left to right). |
266 |
266 |
267 \item @{ML Print_Mode.with_modes}~@{text "modes f x"} evaluates |
267 \<^descr> @{ML Print_Mode.with_modes}~@{text "modes f x"} evaluates |
268 @{text "f x"} in an execution context where the print mode is |
268 @{text "f x"} in an execution context where the print mode is |
269 prepended by the given @{text "modes"}. This provides a thread-safe |
269 prepended by the given @{text "modes"}. This provides a thread-safe |
270 way to augment print modes. It is also monotonic in the set of mode |
270 way to augment print modes. It is also monotonic in the set of mode |
271 names: it retains the default print mode that certain |
271 names: it retains the default print mode that certain |
272 user-interfaces might have installed for their proper functioning! |
272 user-interfaces might have installed for their proper functioning! |
391 @{verbatim ")"} & close parenthesis \\ |
391 @{verbatim ")"} & close parenthesis \\ |
392 @{verbatim "/"} & slash \\ |
392 @{verbatim "/"} & slash \\ |
393 \end{tabular} |
393 \end{tabular} |
394 \<^medskip> |
394 \<^medskip> |
395 |
395 |
396 \item @{verbatim "'"} escapes the special meaning of these |
396 \<^descr> @{verbatim "'"} escapes the special meaning of these |
397 meta-characters, producing a literal version of the following |
397 meta-characters, producing a literal version of the following |
398 character, unless that is a blank. |
398 character, unless that is a blank. |
399 |
399 |
400 A single quote followed by a blank separates delimiters, without |
400 A single quote followed by a blank separates delimiters, without |
401 affecting printing, but input tokens may have additional white space |
401 affecting printing, but input tokens may have additional white space |
402 here. |
402 here. |
403 |
403 |
404 \item @{verbatim "_"} is an argument position, which stands for a |
404 \<^descr> @{verbatim "_"} is an argument position, which stands for a |
405 certain syntactic category in the underlying grammar. |
405 certain syntactic category in the underlying grammar. |
406 |
406 |
407 \item @{text "\<index>"} is an indexed argument position; this is the place |
407 \<^descr> @{text "\<index>"} is an indexed argument position; this is the place |
408 where implicit structure arguments can be attached. |
408 where implicit structure arguments can be attached. |
409 |
409 |
410 \item @{text "s"} is a non-empty sequence of spaces for printing. |
410 \<^descr> @{text "s"} is a non-empty sequence of spaces for printing. |
411 This and the following specifications do not affect parsing at all. |
411 This and the following specifications do not affect parsing at all. |
412 |
412 |
413 \item @{verbatim "("}@{text n} opens a pretty printing block. The |
413 \<^descr> @{verbatim "("}@{text n} opens a pretty printing block. The |
414 optional number specifies how much indentation to add when a line |
414 optional number specifies how much indentation to add when a line |
415 break occurs within the block. If the parenthesis is not followed |
415 break occurs within the block. If the parenthesis is not followed |
416 by digits, the indentation defaults to 0. A block specified via |
416 by digits, the indentation defaults to 0. A block specified via |
417 @{verbatim "(00"} is unbreakable. |
417 @{verbatim "(00"} is unbreakable. |
418 |
418 |
419 \item @{verbatim ")"} closes a pretty printing block. |
419 \<^descr> @{verbatim ")"} closes a pretty printing block. |
420 |
420 |
421 \item @{verbatim "//"} forces a line break. |
421 \<^descr> @{verbatim "//"} forces a line break. |
422 |
422 |
423 \item @{verbatim "/"}@{text s} allows a line break. Here @{text s} |
423 \<^descr> @{verbatim "/"}@{text s} allows a line break. Here @{text s} |
424 stands for the string of spaces (zero or more) right after the |
424 stands for the string of spaces (zero or more) right after the |
425 slash. These spaces are printed if the break is \emph{not} taken. |
425 slash. These spaces are printed if the break is \emph{not} taken. |
426 |
426 |
427 \end{description} |
427 \end{description} |
428 |
428 |
532 @@{command write} @{syntax mode}? (@{syntax nameref} @{syntax mixfix} + @'and') |
532 @@{command write} @{syntax mode}? (@{syntax nameref} @{syntax mixfix} + @'and') |
533 \<close>} |
533 \<close>} |
534 |
534 |
535 \begin{description} |
535 \begin{description} |
536 |
536 |
537 \item @{command "type_notation"}~@{text "c (mx)"} associates mixfix |
537 \<^descr> @{command "type_notation"}~@{text "c (mx)"} associates mixfix |
538 syntax with an existing type constructor. The arity of the |
538 syntax with an existing type constructor. The arity of the |
539 constructor is retrieved from the context. |
539 constructor is retrieved from the context. |
540 |
540 |
541 \item @{command "no_type_notation"} is similar to @{command |
541 \<^descr> @{command "no_type_notation"} is similar to @{command |
542 "type_notation"}, but removes the specified syntax annotation from |
542 "type_notation"}, but removes the specified syntax annotation from |
543 the present context. |
543 the present context. |
544 |
544 |
545 \item @{command "notation"}~@{text "c (mx)"} associates mixfix |
545 \<^descr> @{command "notation"}~@{text "c (mx)"} associates mixfix |
546 syntax with an existing constant or fixed variable. The type |
546 syntax with an existing constant or fixed variable. The type |
547 declaration of the given entity is retrieved from the context. |
547 declaration of the given entity is retrieved from the context. |
548 |
548 |
549 \item @{command "no_notation"} is similar to @{command "notation"}, |
549 \<^descr> @{command "no_notation"} is similar to @{command "notation"}, |
550 but removes the specified syntax annotation from the present |
550 but removes the specified syntax annotation from the present |
551 context. |
551 context. |
552 |
552 |
553 \item @{command "write"} is similar to @{command "notation"}, but |
553 \<^descr> @{command "write"} is similar to @{command "notation"}, but |
554 works within an Isar proof body. |
554 works within an Isar proof body. |
555 |
555 |
556 \end{description} |
556 \end{description} |
557 \<close> |
557 \<close> |
558 |
558 |
771 inner syntax. The meaning of the nonterminals defined by the above |
771 inner syntax. The meaning of the nonterminals defined by the above |
772 grammar is as follows: |
772 grammar is as follows: |
773 |
773 |
774 \begin{description} |
774 \begin{description} |
775 |
775 |
776 \item @{syntax_ref (inner) any} denotes any term. |
776 \<^descr> @{syntax_ref (inner) any} denotes any term. |
777 |
777 |
778 \item @{syntax_ref (inner) prop} denotes meta-level propositions, |
778 \<^descr> @{syntax_ref (inner) prop} denotes meta-level propositions, |
779 which are terms of type @{typ prop}. The syntax of such formulae of |
779 which are terms of type @{typ prop}. The syntax of such formulae of |
780 the meta-logic is carefully distinguished from usual conventions for |
780 the meta-logic is carefully distinguished from usual conventions for |
781 object-logics. In particular, plain @{text "\<lambda>"}-term notation is |
781 object-logics. In particular, plain @{text "\<lambda>"}-term notation is |
782 \emph{not} recognized as @{syntax (inner) prop}. |
782 \emph{not} recognized as @{syntax (inner) prop}. |
783 |
783 |
784 \item @{syntax_ref (inner) aprop} denotes atomic propositions, which |
784 \<^descr> @{syntax_ref (inner) aprop} denotes atomic propositions, which |
785 are embedded into regular @{syntax (inner) prop} by means of an |
785 are embedded into regular @{syntax (inner) prop} by means of an |
786 explicit @{verbatim PROP} token. |
786 explicit @{verbatim PROP} token. |
787 |
787 |
788 Terms of type @{typ prop} with non-constant head, e.g.\ a plain |
788 Terms of type @{typ prop} with non-constant head, e.g.\ a plain |
789 variable, are printed in this form. Constants that yield type @{typ |
789 variable, are printed in this form. Constants that yield type @{typ |
790 prop} are expected to provide their own concrete syntax; otherwise |
790 prop} are expected to provide their own concrete syntax; otherwise |
791 the printed version will appear like @{syntax (inner) logic} and |
791 the printed version will appear like @{syntax (inner) logic} and |
792 cannot be parsed again as @{syntax (inner) prop}. |
792 cannot be parsed again as @{syntax (inner) prop}. |
793 |
793 |
794 \item @{syntax_ref (inner) logic} denotes arbitrary terms of a |
794 \<^descr> @{syntax_ref (inner) logic} denotes arbitrary terms of a |
795 logical type, excluding type @{typ prop}. This is the main |
795 logical type, excluding type @{typ prop}. This is the main |
796 syntactic category of object-logic entities, covering plain @{text |
796 syntactic category of object-logic entities, covering plain @{text |
797 \<lambda>}-term notation (variables, abstraction, application), plus |
797 \<lambda>}-term notation (variables, abstraction, application), plus |
798 anything defined by the user. |
798 anything defined by the user. |
799 |
799 |
800 When specifying notation for logical entities, all logical types |
800 When specifying notation for logical entities, all logical types |
801 (excluding @{typ prop}) are \emph{collapsed} to this single category |
801 (excluding @{typ prop}) are \emph{collapsed} to this single category |
802 of @{syntax (inner) logic}. |
802 of @{syntax (inner) logic}. |
803 |
803 |
804 \item @{syntax_ref (inner) index} denotes an optional index term for |
804 \<^descr> @{syntax_ref (inner) index} denotes an optional index term for |
805 indexed syntax. If omitted, it refers to the first @{keyword_ref |
805 indexed syntax. If omitted, it refers to the first @{keyword_ref |
806 "structure"} variable in the context. The special dummy ``@{text |
806 "structure"} variable in the context. The special dummy ``@{text |
807 "\<index>"}'' serves as pattern variable in mixfix annotations that |
807 "\<index>"}'' serves as pattern variable in mixfix annotations that |
808 introduce indexed notation. |
808 introduce indexed notation. |
809 |
809 |
810 \item @{syntax_ref (inner) idt} denotes identifiers, possibly |
810 \<^descr> @{syntax_ref (inner) idt} denotes identifiers, possibly |
811 constrained by types. |
811 constrained by types. |
812 |
812 |
813 \item @{syntax_ref (inner) idts} denotes a sequence of @{syntax_ref |
813 \<^descr> @{syntax_ref (inner) idts} denotes a sequence of @{syntax_ref |
814 (inner) idt}. This is the most basic category for variables in |
814 (inner) idt}. This is the most basic category for variables in |
815 iterated binders, such as @{text "\<lambda>"} or @{text "\<And>"}. |
815 iterated binders, such as @{text "\<lambda>"} or @{text "\<And>"}. |
816 |
816 |
817 \item @{syntax_ref (inner) pttrn} and @{syntax_ref (inner) pttrns} |
817 \<^descr> @{syntax_ref (inner) pttrn} and @{syntax_ref (inner) pttrns} |
818 denote patterns for abstraction, cases bindings etc. In Pure, these |
818 denote patterns for abstraction, cases bindings etc. In Pure, these |
819 categories start as a merely copy of @{syntax (inner) idt} and |
819 categories start as a merely copy of @{syntax (inner) idt} and |
820 @{syntax (inner) idts}, respectively. Object-logics may add |
820 @{syntax (inner) idts}, respectively. Object-logics may add |
821 additional productions for binding forms. |
821 additional productions for binding forms. |
822 |
822 |
823 \item @{syntax_ref (inner) type} denotes types of the meta-logic. |
823 \<^descr> @{syntax_ref (inner) type} denotes types of the meta-logic. |
824 |
824 |
825 \item @{syntax_ref (inner) sort} denotes meta-level sorts. |
825 \<^descr> @{syntax_ref (inner) sort} denotes meta-level sorts. |
826 |
826 |
827 \end{description} |
827 \end{description} |
828 |
828 |
829 Here are some further explanations of certain syntax features. |
829 Here are some further explanations of certain syntax features. |
830 |
830 |
849 \<^item> Dummy variables (written as underscore) may occur in different |
849 \<^item> Dummy variables (written as underscore) may occur in different |
850 roles. |
850 roles. |
851 |
851 |
852 \begin{description} |
852 \begin{description} |
853 |
853 |
854 \item A type ``@{text "_"}'' or ``@{text "_ :: sort"}'' acts like an |
854 \<^descr> A type ``@{text "_"}'' or ``@{text "_ :: sort"}'' acts like an |
855 anonymous inference parameter, which is filled-in according to the |
855 anonymous inference parameter, which is filled-in according to the |
856 most general type produced by the type-checking phase. |
856 most general type produced by the type-checking phase. |
857 |
857 |
858 \item A bound ``@{text "_"}'' refers to a vacuous abstraction, where |
858 \<^descr> A bound ``@{text "_"}'' refers to a vacuous abstraction, where |
859 the body does not refer to the binding introduced here. As in the |
859 the body does not refer to the binding introduced here. As in the |
860 term @{term "\<lambda>x _. x"}, which is @{text "\<alpha>"}-equivalent to @{text |
860 term @{term "\<lambda>x _. x"}, which is @{text "\<alpha>"}-equivalent to @{text |
861 "\<lambda>x y. x"}. |
861 "\<lambda>x y. x"}. |
862 |
862 |
863 \item A free ``@{text "_"}'' refers to an implicit outer binding. |
863 \<^descr> A free ``@{text "_"}'' refers to an implicit outer binding. |
864 Higher definitional packages usually allow forms like @{text "f x _ |
864 Higher definitional packages usually allow forms like @{text "f x _ |
865 = x"}. |
865 = x"}. |
866 |
866 |
867 \item A schematic ``@{text "_"}'' (within a term pattern, see |
867 \<^descr> A schematic ``@{text "_"}'' (within a term pattern, see |
868 \secref{sec:term-decls}) refers to an anonymous variable that is |
868 \secref{sec:term-decls}) refers to an anonymous variable that is |
869 implicitly abstracted over its context of locally bound variables. |
869 implicitly abstracted over its context of locally bound variables. |
870 For example, this allows pattern matching of @{text "{x. f x = g |
870 For example, this allows pattern matching of @{text "{x. f x = g |
871 x}"} against @{text "{x. _ = _}"}, or even @{text "{_. _ = _}"} by |
871 x}"} against @{text "{x. _ = _}"}, or even @{text "{_. _ = _}"} by |
872 using both bound and schematic dummies. |
872 using both bound and schematic dummies. |
873 |
873 |
874 \end{description} |
874 \end{description} |
875 |
875 |
876 \item The three literal dots ``@{verbatim "..."}'' may be also |
876 \<^descr> The three literal dots ``@{verbatim "..."}'' may be also |
877 written as ellipsis symbol @{verbatim "\<dots>"}. In both cases this |
877 written as ellipsis symbol @{verbatim "\<dots>"}. In both cases this |
878 refers to a special schematic variable, which is bound in the |
878 refers to a special schematic variable, which is bound in the |
879 context. This special term abbreviation works nicely with |
879 context. This special term abbreviation works nicely with |
880 calculational reasoning (\secref{sec:calculation}). |
880 calculational reasoning (\secref{sec:calculation}). |
881 |
881 |
882 \item @{verbatim CONST} ensures that the given identifier is treated |
882 \<^descr> @{verbatim CONST} ensures that the given identifier is treated |
883 as constant term, and passed through the parse tree in fully |
883 as constant term, and passed through the parse tree in fully |
884 internalized form. This is particularly relevant for translation |
884 internalized form. This is particularly relevant for translation |
885 rules (\secref{sec:syn-trans}), notably on the RHS. |
885 rules (\secref{sec:syn-trans}), notably on the RHS. |
886 |
886 |
887 \item @{verbatim XCONST} is similar to @{verbatim CONST}, but |
887 \<^descr> @{verbatim XCONST} is similar to @{verbatim CONST}, but |
888 retains the constant name as given. This is only relevant to |
888 retains the constant name as given. This is only relevant to |
889 translation rules (\secref{sec:syn-trans}), notably on the LHS. |
889 translation rules (\secref{sec:syn-trans}), notably on the LHS. |
890 |
890 |
891 \end{itemize} |
891 \end{itemize} |
892 \<close> |
892 \<close> |
899 @{command_def "print_syntax"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
899 @{command_def "print_syntax"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
900 \end{matharray} |
900 \end{matharray} |
901 |
901 |
902 \begin{description} |
902 \begin{description} |
903 |
903 |
904 \item @{command "print_syntax"} prints the inner syntax of the |
904 \<^descr> @{command "print_syntax"} prints the inner syntax of the |
905 current context. The output can be quite large; the most important |
905 current context. The output can be quite large; the most important |
906 sections are explained below. |
906 sections are explained below. |
907 |
907 |
908 \begin{description} |
908 \begin{description} |
909 |
909 |
910 \item @{text "lexicon"} lists the delimiters of the inner token |
910 \<^descr> @{text "lexicon"} lists the delimiters of the inner token |
911 language; see \secref{sec:inner-lex}. |
911 language; see \secref{sec:inner-lex}. |
912 |
912 |
913 \item @{text "prods"} lists the productions of the underlying |
913 \<^descr> @{text "prods"} lists the productions of the underlying |
914 priority grammar; see \secref{sec:priority-grammar}. |
914 priority grammar; see \secref{sec:priority-grammar}. |
915 |
915 |
916 The nonterminal @{text "A\<^sup>(\<^sup>p\<^sup>)"} is rendered in plain text as @{text |
916 The nonterminal @{text "A\<^sup>(\<^sup>p\<^sup>)"} is rendered in plain text as @{text |
917 "A[p]"}; delimiters are quoted. Many productions have an extra |
917 "A[p]"}; delimiters are quoted. Many productions have an extra |
918 @{text "\<dots> => name"}. These names later become the heads of parse |
918 @{text "\<dots> => name"}. These names later become the heads of parse |
929 production}. Chain productions act as abbreviations: conceptually, |
929 production}. Chain productions act as abbreviations: conceptually, |
930 they are removed from the grammar by adding new productions. |
930 they are removed from the grammar by adding new productions. |
931 Priority information attached to chain productions is ignored; only |
931 Priority information attached to chain productions is ignored; only |
932 the dummy value @{text "-1"} is displayed. |
932 the dummy value @{text "-1"} is displayed. |
933 |
933 |
934 \item @{text "print modes"} lists the alternative print modes |
934 \<^descr> @{text "print modes"} lists the alternative print modes |
935 provided by this grammar; see \secref{sec:print-modes}. |
935 provided by this grammar; see \secref{sec:print-modes}. |
936 |
936 |
937 \item @{text "parse_rules"} and @{text "print_rules"} relate to |
937 \<^descr> @{text "parse_rules"} and @{text "print_rules"} relate to |
938 syntax translations (macros); see \secref{sec:syn-trans}. |
938 syntax translations (macros); see \secref{sec:syn-trans}. |
939 |
939 |
940 \item @{text "parse_ast_translation"} and @{text |
940 \<^descr> @{text "parse_ast_translation"} and @{text |
941 "print_ast_translation"} list sets of constants that invoke |
941 "print_ast_translation"} list sets of constants that invoke |
942 translation functions for abstract syntax trees, which are only |
942 translation functions for abstract syntax trees, which are only |
943 required in very special situations; see \secref{sec:tr-funs}. |
943 required in very special situations; see \secref{sec:tr-funs}. |
944 |
944 |
945 \item @{text "parse_translation"} and @{text "print_translation"} |
945 \<^descr> @{text "parse_translation"} and @{text "print_translation"} |
946 list the sets of constants that invoke regular translation |
946 list the sets of constants that invoke regular translation |
947 functions; see \secref{sec:tr-funs}. |
947 functions; see \secref{sec:tr-funs}. |
948 |
948 |
949 \end{description} |
949 \end{description} |
950 |
950 |
1249 The special case of copy production is specified by @{text |
1249 The special case of copy production is specified by @{text |
1250 "c = "}@{verbatim \<open>""\<close>} (empty string). It means that the |
1250 "c = "}@{verbatim \<open>""\<close>} (empty string). It means that the |
1251 resulting parse tree @{text "t"} is copied directly, without any |
1251 resulting parse tree @{text "t"} is copied directly, without any |
1252 further decoration. |
1252 further decoration. |
1253 |
1253 |
1254 \item @{command "no_syntax"}~@{text "(mode) decls"} removes grammar |
1254 \<^descr> @{command "no_syntax"}~@{text "(mode) decls"} removes grammar |
1255 declarations (and translations) resulting from @{text decls}, which |
1255 declarations (and translations) resulting from @{text decls}, which |
1256 are interpreted in the same manner as for @{command "syntax"} above. |
1256 are interpreted in the same manner as for @{command "syntax"} above. |
1257 |
1257 |
1258 \item @{command "translations"}~@{text rules} specifies syntactic |
1258 \<^descr> @{command "translations"}~@{text rules} specifies syntactic |
1259 translation rules (i.e.\ macros) as first-order rewrite rules on |
1259 translation rules (i.e.\ macros) as first-order rewrite rules on |
1260 ASTs (\secref{sec:ast}). The theory context maintains two |
1260 ASTs (\secref{sec:ast}). The theory context maintains two |
1261 independent lists translation rules: parse rules (@{verbatim "=>"} |
1261 independent lists translation rules: parse rules (@{verbatim "=>"} |
1262 or @{text "\<rightharpoonup>"}) and print rules (@{verbatim "<="} or @{text "\<leftharpoondown>"}). |
1262 or @{text "\<rightharpoonup>"}) and print rules (@{verbatim "<="} or @{text "\<leftharpoondown>"}). |
1263 For convenience, both can be specified simultaneously as parse~/ |
1263 For convenience, both can be specified simultaneously as parse~/ |
1471 |
1471 |
1472 The @{command_ref print_syntax} command displays the sets of names |
1472 The @{command_ref print_syntax} command displays the sets of names |
1473 associated with the translation functions of a theory under @{text |
1473 associated with the translation functions of a theory under @{text |
1474 "parse_ast_translation"} etc. |
1474 "parse_ast_translation"} etc. |
1475 |
1475 |
1476 \item @{text "@{class_syntax c}"}, @{text "@{type_syntax c}"}, |
1476 \<^descr> @{text "@{class_syntax c}"}, @{text "@{type_syntax c}"}, |
1477 @{text "@{const_syntax c}"} inline the authentic syntax name of the |
1477 @{text "@{const_syntax c}"} inline the authentic syntax name of the |
1478 given formal entities into the ML source. This is the |
1478 given formal entities into the ML source. This is the |
1479 fully-qualified logical name prefixed by a special marker to |
1479 fully-qualified logical name prefixed by a special marker to |
1480 indicate its kind: thus different logical name spaces are properly |
1480 indicate its kind: thus different logical name spaces are properly |
1481 distinguished within parse trees. |
1481 distinguished within parse trees. |
1482 |
1482 |
1483 \item @{text "@{const_syntax c}"} inlines the name @{text "c"} of |
1483 \<^descr> @{text "@{const_syntax c}"} inlines the name @{text "c"} of |
1484 the given syntax constant, having checked that it has been declared |
1484 the given syntax constant, having checked that it has been declared |
1485 via some @{command syntax} commands within the theory context. Note |
1485 via some @{command syntax} commands within the theory context. Note |
1486 that the usual naming convention makes syntax constants start with |
1486 that the usual naming convention makes syntax constants start with |
1487 underscore, to reduce the chance of accidental clashes with other |
1487 underscore, to reduce the chance of accidental clashes with other |
1488 names occurring in parse trees (unqualified constants etc.). |
1488 names occurring in parse trees (unqualified constants etc.). |
1515 functions called during the parsing process differ from those for |
1515 functions called during the parsing process differ from those for |
1516 printing in their overall behaviour: |
1516 printing in their overall behaviour: |
1517 |
1517 |
1518 \begin{description} |
1518 \begin{description} |
1519 |
1519 |
1520 \item [Parse translations] are applied bottom-up. The arguments are |
1520 \<^descr>[Parse translations] are applied bottom-up. The arguments are |
1521 already in translated form. The translations must not fail; |
1521 already in translated form. The translations must not fail; |
1522 exceptions trigger an error message. There may be at most one |
1522 exceptions trigger an error message. There may be at most one |
1523 function associated with any syntactic name. |
1523 function associated with any syntactic name. |
1524 |
1524 |
1525 \item [Print translations] are applied top-down. They are supplied |
1525 \<^descr>[Print translations] are applied top-down. They are supplied |
1526 with arguments that are partly still in internal form. The result |
1526 with arguments that are partly still in internal form. The result |
1527 again undergoes translation; therefore a print translation should |
1527 again undergoes translation; therefore a print translation should |
1528 not introduce as head the very constant that invoked it. The |
1528 not introduce as head the very constant that invoked it. The |
1529 function may raise exception @{ML Match} to indicate failure; in |
1529 function may raise exception @{ML Match} to indicate failure; in |
1530 this event it has no effect. Multiple functions associated with |
1530 this event it has no effect. Multiple functions associated with |