# HG changeset patch # User wenzelm # Date 1292605837 -3600 # Node ID 26f12f98f50addefa6254a479d2d3dc66996f46b # Parent 7cf837f1a8dfaba9338967856947f897fdf2e9a9 Command 'type_synonym' (with single argument) supersedes 'types' (legacy feature); diff -r 7cf837f1a8df -r 26f12f98f50a NEWS --- a/NEWS Fri Dec 17 17:48:05 2010 +0100 +++ b/NEWS Fri Dec 17 18:10:37 2010 +0100 @@ -83,9 +83,12 @@ *** Pure *** -* Replaced command 'nonterminals' by slightly modernized version -'nonterminal' (with 'and' separated list of arguments). -INCOMPATIBILITY. +* Command 'type_synonym' (with single argument) replaces somewhat +outdated 'types', which is still available as legacy feature for some +time. + +* Command 'nonterminal' (with 'and' separated list of arguments) +replaces somewhat outdated 'nonterminals'. INCOMPATIBILITY. * Command 'notepad' replaces former 'example_proof' for experimentation in Isar without any result. INCOMPATIBILITY. diff -r 7cf837f1a8df -r 26f12f98f50a doc-src/IsarRef/Thy/Spec.thy --- a/doc-src/IsarRef/Thy/Spec.thy Fri Dec 17 17:48:05 2010 +0100 +++ b/doc-src/IsarRef/Thy/Spec.thy Fri Dec 17 18:10:37 2010 +0100 @@ -973,13 +973,13 @@ text {* \begin{matharray}{rcll} - @{command_def "types"} & : & @{text "local_theory \ local_theory"} \\ + @{command_def "type_synonym"} & : & @{text "local_theory \ local_theory"} \\ @{command_def "typedecl"} & : & @{text "local_theory \ local_theory"} \\ @{command_def "arities"} & : & @{text "theory \ theory"} & (axiomatic!) \\ \end{matharray} \begin{rail} - 'types' (typespec '=' type mixfix? +) + 'type_synonym' (typespec '=' type mixfix?) ; 'typedecl' typespec mixfix? ; @@ -989,12 +989,12 @@ \begin{description} - \item @{command "types"}~@{text "(\\<^sub>1, \, \\<^sub>n) t = \"} introduces a - \emph{type synonym} @{text "(\\<^sub>1, \, \\<^sub>n) t"} for the existing type - @{text "\"}. Unlike actual type definitions, as are available in - Isabelle/HOL for example, type synonyms are merely syntactic - abbreviations without any logical significance. Internally, type - synonyms are fully expanded. + \item @{command "type_synonym"}~@{text "(\\<^sub>1, \, \\<^sub>n) t = \"} + introduces a \emph{type synonym} @{text "(\\<^sub>1, \, \\<^sub>n) t"} for the + existing type @{text "\"}. Unlike actual type definitions, as are + available in Isabelle/HOL for example, type synonyms are merely + syntactic abbreviations without any logical significance. + Internally, type synonyms are fully expanded. \item @{command "typedecl"}~@{text "(\\<^sub>1, \, \\<^sub>n) t"} declares a new type constructor @{text t}. If the object-logic defines a base sort diff -r 7cf837f1a8df -r 26f12f98f50a doc-src/IsarRef/Thy/document/Spec.tex --- a/doc-src/IsarRef/Thy/document/Spec.tex Fri Dec 17 17:48:05 2010 +0100 +++ b/doc-src/IsarRef/Thy/document/Spec.tex Fri Dec 17 18:10:37 2010 +0100 @@ -1010,13 +1010,13 @@ % \begin{isamarkuptext}% \begin{matharray}{rcll} - \indexdef{}{command}{types}\hypertarget{command.types}{\hyperlink{command.types}{\mbox{\isa{\isacommand{types}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\ + \indexdef{}{command}{type\_synonym}\hypertarget{command.type-synonym}{\hyperlink{command.type-synonym}{\mbox{\isa{\isacommand{type{\isaliteral{5F}{\isacharunderscore}}synonym}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\ \indexdef{}{command}{typedecl}\hypertarget{command.typedecl}{\hyperlink{command.typedecl}{\mbox{\isa{\isacommand{typedecl}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\ \indexdef{}{command}{arities}\hypertarget{command.arities}{\hyperlink{command.arities}{\mbox{\isa{\isacommand{arities}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} & (axiomatic!) \\ \end{matharray} \begin{rail} - 'types' (typespec '=' type mixfix? +) + 'type_synonym' (typespec '=' type mixfix?) ; 'typedecl' typespec mixfix? ; @@ -1026,12 +1026,12 @@ \begin{description} - \item \hyperlink{command.types}{\mbox{\isa{\isacommand{types}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}} introduces a - \emph{type synonym} \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}} for the existing type - \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}}. Unlike actual type definitions, as are available in - Isabelle/HOL for example, type synonyms are merely syntactic - abbreviations without any logical significance. Internally, type - synonyms are fully expanded. + \item \hyperlink{command.type-synonym}{\mbox{\isa{\isacommand{type{\isaliteral{5F}{\isacharunderscore}}synonym}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}} + introduces a \emph{type synonym} \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}} for the + existing type \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}}. Unlike actual type definitions, as are + available in Isabelle/HOL for example, type synonyms are merely + syntactic abbreviations without any logical significance. + Internally, type synonyms are fully expanded. \item \hyperlink{command.typedecl}{\mbox{\isa{\isacommand{typedecl}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}} declares a new type constructor \isa{t}. If the object-logic defines a base sort diff -r 7cf837f1a8df -r 26f12f98f50a etc/isar-keywords-ZF.el --- a/etc/isar-keywords-ZF.el Fri Dec 17 17:48:05 2010 +0100 +++ b/etc/isar-keywords-ZF.el Fri Dec 17 18:10:37 2010 +0100 @@ -189,6 +189,7 @@ "txt_raw" "typ" "type_notation" + "type_synonym" "typed_print_translation" "typedecl" "types" @@ -403,6 +404,7 @@ "theorems" "translations" "type_notation" + "type_synonym" "typed_print_translation" "typedecl" "types" diff -r 7cf837f1a8df -r 26f12f98f50a etc/isar-keywords.el --- a/etc/isar-keywords.el Fri Dec 17 17:48:05 2010 +0100 +++ b/etc/isar-keywords.el Fri Dec 17 18:10:37 2010 +0100 @@ -250,6 +250,7 @@ "typ" "type_lifting" "type_notation" + "type_synonym" "typed_print_translation" "typedecl" "typedef" @@ -516,6 +517,7 @@ "theorems" "translations" "type_notation" + "type_synonym" "typed_print_translation" "typedecl" "types" diff -r 7cf837f1a8df -r 26f12f98f50a src/Pure/Isar/isar_syn.ML --- a/src/Pure/Isar/isar_syn.ML Fri Dec 17 17:48:05 2010 +0100 +++ b/src/Pure/Isar/isar_syn.ML Fri Dec 17 18:10:37 2010 +0100 @@ -111,12 +111,19 @@ (Parse.type_args -- Parse.binding -- Parse.opt_mixfix >> (fn ((args, a), mx) => Typedecl.typedecl (a, map (rpair dummyS) args, mx) #> snd)); +val type_abbrev = + Parse.type_args -- Parse.binding -- + (Parse.$$$ "=" |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix')); + val _ = Outer_Syntax.local_theory "types" "declare type abbreviations" Keyword.thy_decl - (Scan.repeat1 - (Parse.type_args -- Parse.binding -- - (Parse.$$$ "=" |-- Parse.!!! (Parse.typ -- Parse.opt_mixfix'))) - >> (fold (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs))); + (Scan.repeat1 type_abbrev >> (fn specs => fn lthy => + (legacy_feature "Old 'types' commands -- use 'type_synonym' instead"; + fold (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs) specs lthy))); + +val _ = + Outer_Syntax.local_theory "type_synonym" "declare type abbreviation" Keyword.thy_decl + (type_abbrev >> (fn ((args, a), (rhs, mx)) => snd o Typedecl.abbrev_cmd (a, args, mx) rhs)); val _ = Outer_Syntax.command "nonterminal"