src/Pure/Isar/specification.ML
author wenzelm
Fri, 29 Apr 2016 01:21:44 +0200
changeset 63069 f009347b9072
parent 63065 3cb7b06d0a9f
child 63094 056ea294c256
permissions -rw-r--r--
re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/specification.ML
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
     3
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
     4
Derived local theory specifications --- with type-inference and
18810
6dc5416368e9 swapped Toplevel.theory_context;
wenzelm
parents: 18786
diff changeset
     5
toplevel polymorphism.
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
     6
*)
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
     7
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
     8
signature SPECIFICATION =
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
     9
sig
59844
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    10
  val read_props: string list -> (binding * string option * mixfix) list -> Proof.context ->
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    11
    term list * Proof.context
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    12
  val read_prop: string -> (binding * string option * mixfix) list -> Proof.context ->
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    13
    term * Proof.context
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    14
  val check_spec: (binding * typ option * mixfix) list ->
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    15
    term list -> Attrib.binding * term -> Proof.context ->
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    16
    ((((binding * typ) * mixfix) list * (Attrib.binding * term)) * (string -> Position.T))
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
    17
      * Proof.context
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    18
  val read_spec: (binding * string option * mixfix) list ->
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    19
    string list -> Attrib.binding * string -> Proof.context ->
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    20
    ((((binding * typ) * mixfix) list * (Attrib.binding * term)) * (string -> Position.T))
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
    21
      * Proof.context
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    22
  type multi_specs = ((Attrib.binding * term) * term list) list
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    23
  type multi_specs_cmd = ((Attrib.binding * string) * string list) list
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    24
  val check_multi_specs: (binding * typ option * mixfix) list -> multi_specs -> Proof.context ->
30482
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
    25
    (((binding * typ) * mixfix) list * (Attrib.binding * term) list) * Proof.context
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    26
  val read_multi_specs: (binding * string option * mixfix) list -> multi_specs_cmd -> Proof.context ->
30482
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
    27
    (((binding * typ) * mixfix) list * (Attrib.binding * term) list) * Proof.context
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    28
  val check_specification: (binding * typ option * mixfix) list -> term list ->
30482
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
    29
    (Attrib.binding * term list) list -> Proof.context ->
29581
b3b33e0298eb binding is alias for Binding.T
haftmann
parents: 29249
diff changeset
    30
    (((binding * typ) * mixfix) list * (Attrib.binding * term list) list) * Proof.context
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    31
  val read_specification: (binding * string option * mixfix) list -> string list ->
28084
a05ca48ef263 type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents: 28080
diff changeset
    32
    (Attrib.binding * string list) list -> Proof.context ->
29581
b3b33e0298eb binding is alias for Binding.T
haftmann
parents: 29249
diff changeset
    33
    (((binding * typ) * mixfix) list * (Attrib.binding * term list) list) * Proof.context
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    34
  val axiomatization: (binding * typ option * mixfix) list -> term list ->
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    35
    (Attrib.binding * term list) list -> theory -> (term list * thm list list) * theory
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    36
  val axiomatization_cmd: (binding * string option * mixfix) list -> string list ->
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    37
    (Attrib.binding * string list) list -> theory -> (term list * thm list list) * theory
35894
ab6dc4d86ea1 added Specification.axiom convenience;
wenzelm
parents: 35625
diff changeset
    38
  val axiom: Attrib.binding * term -> theory -> thm * theory
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    39
  val definition: (binding * typ option * mixfix) option -> term list ->
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    40
    Attrib.binding * term -> local_theory -> (term * (string * thm)) * local_theory
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    41
  val definition': (binding * typ option * mixfix) option -> term list ->
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    42
    Attrib.binding * term -> bool -> local_theory -> (term * (string * thm)) * local_theory
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    43
  val definition_cmd: (binding * string option * mixfix) option -> string list ->
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    44
    Attrib.binding * string -> bool -> local_theory -> (term * (string * thm)) * local_theory
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    45
  val abbreviation: Syntax.mode -> (binding * typ option * mixfix) option -> term ->
44192
a32ca9165928 less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents: 43329
diff changeset
    46
    bool -> local_theory -> local_theory
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
    47
  val abbreviation_cmd: Syntax.mode -> (binding * string option * mixfix) option -> string ->
44192
a32ca9165928 less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents: 43329
diff changeset
    48
    bool -> local_theory -> local_theory
35413
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
    49
  val type_notation: bool -> Syntax.mode -> (typ * mixfix) list -> local_theory -> local_theory
55639
e4e8cbd9d780 tuned whitespace;
wenzelm
parents: 55119
diff changeset
    50
  val type_notation_cmd: bool -> Syntax.mode -> (string * mixfix) list ->
e4e8cbd9d780 tuned whitespace;
wenzelm
parents: 55119
diff changeset
    51
    local_theory -> local_theory
24949
5f00e3532418 generalized notation interface (add or del);
wenzelm
parents: 24927
diff changeset
    52
  val notation: bool -> Syntax.mode -> (term * mixfix) list -> local_theory -> local_theory
5f00e3532418 generalized notation interface (add or del);
wenzelm
parents: 24927
diff changeset
    53
  val notation_cmd: bool -> Syntax.mode -> (string * mixfix) list -> local_theory -> local_theory
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
    54
  val theorems: string ->
58011
bc6bced136e5 tuned signature -- moved type src to Token, without aliases;
wenzelm
parents: 56932
diff changeset
    55
    (Attrib.binding * (thm list * Token.src list) list) list ->
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
    56
    (binding * typ option * mixfix) list ->
44192
a32ca9165928 less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents: 43329
diff changeset
    57
    bool -> local_theory -> (string * thm list) list * local_theory
26336
a0e2b706ce73 renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents: 25371
diff changeset
    58
  val theorems_cmd: string ->
58011
bc6bced136e5 tuned signature -- moved type src to Token, without aliases;
wenzelm
parents: 56932
diff changeset
    59
    (Attrib.binding * (Facts.ref * Token.src list) list) list ->
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
    60
    (binding * string option * mixfix) list ->
44192
a32ca9165928 less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents: 43329
diff changeset
    61
    bool -> local_theory -> (string * thm list) list * local_theory
24986
1f902ded7f70 removed unused/impure quiet_mode;
wenzelm
parents: 24949
diff changeset
    62
  val theorem: string -> Method.text option ->
28084
a05ca48ef263 type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents: 28080
diff changeset
    63
    (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
    64
    string list -> Element.context_i list -> Element.statement_i ->
24452
93b113c5ac33 - theorem(_i) now also takes "interactive" flag as argument
berghofe
parents: 24219
diff changeset
    65
    bool -> local_theory -> Proof.state
24986
1f902ded7f70 removed unused/impure quiet_mode;
wenzelm
parents: 24949
diff changeset
    66
  val theorem_cmd: string -> Method.text option ->
28084
a05ca48ef263 type Attrib.binding abbreviates Name.binding without attributes;
wenzelm
parents: 28080
diff changeset
    67
    (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
    68
    (xstring * Position.T) list -> Element.context list -> Element.statement ->
24452
93b113c5ac33 - theorem(_i) now also takes "interactive" flag as argument
berghofe
parents: 24219
diff changeset
    69
    bool -> local_theory -> Proof.state
36317
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36106
diff changeset
    70
  val schematic_theorem: string -> Method.text option ->
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36106
diff changeset
    71
    (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
    72
    string list -> Element.context_i list -> Element.statement_i ->
36317
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36106
diff changeset
    73
    bool -> local_theory -> Proof.state
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36106
diff changeset
    74
  val schematic_theorem_cmd: string -> Method.text option ->
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36106
diff changeset
    75
    (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
    76
    (xstring * Position.T) list -> Element.context list -> Element.statement ->
36317
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36106
diff changeset
    77
    bool -> local_theory -> Proof.state
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
    78
end;
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
    79
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
    80
structure Specification: SPECIFICATION =
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
    81
struct
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
    82
59844
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    83
(* prepare propositions *)
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    84
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    85
fun read_props raw_props raw_fixes ctxt =
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    86
  let
60469
d1ea37df7358 tuned signature;
wenzelm
parents: 60454
diff changeset
    87
    val (_, ctxt1) = ctxt |> Proof_Context.add_fixes_cmd raw_fixes;
59844
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    88
    val props1 = map (Syntax.parse_prop ctxt1) raw_props;
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    89
    val (props2, ctxt2) = ctxt1 |> fold_map Variable.fix_dummy_patterns props1;
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    90
    val props3 = Syntax.check_props ctxt2 props2;
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    91
    val ctxt3 = ctxt2 |> fold Variable.declare_term props3;
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    92
  in (props3, ctxt3) end;
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    93
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    94
fun read_prop raw_prop raw_fixes ctxt =
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    95
  let val ([prop], ctxt') = read_props [raw_prop] raw_fixes ctxt
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    96
  in (prop, ctxt') end;
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    97
c648efffea73 support for minimal specifications, with usual treatment of fixes and dummies;
wenzelm
parents: 58993
diff changeset
    98
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
    99
(* prepare specification *)
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
   100
24724
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   101
local
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   102
63063
wenzelm
parents: 63041
diff changeset
   103
fun close_forms ctxt auto_close i prems concls =
63069
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   104
  if not auto_close andalso null prems then concls
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   105
  else
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   106
    let
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   107
      val xs =
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   108
        if auto_close then rev (fold (Variable.add_free_names ctxt) (prems @ concls) [])
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   109
        else [];
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   110
      val types =
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   111
        map (Type_Infer.param i o rpair []) (Name.invent Name.context Name.aT (length xs));
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   112
      val uniform_typing = AList.lookup (op =) (xs ~~ types);
f009347b9072 re-tuned c9605a284fba, which impacts performance significantly (for unclear reasons) -- make AFP/Collections build again;
wenzelm
parents: 63065
diff changeset
   113
    in map (Logic.close_prop_constraint uniform_typing (xs ~~ xs) prems) concls end;
24724
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   114
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   115
fun get_positions ctxt x =
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   116
  let
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   117
    fun get Cs (Const ("_type_constraint_", C) $ t) = get (C :: Cs) t
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   118
      | get _ (t $ u) = get [] t @ get [] u
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   119
      | get _ (Abs (_, _, t)) = get [] t
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   120
      | get Cs (Free (y, T)) =
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   121
          if x = y then
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   122
            map_filter Term_Position.decode_positionT
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   123
              (T :: map (Type.constraint_type ctxt) Cs)
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   124
          else []
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   125
      | get _ _ = [];
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   126
  in get [] end;
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   127
63063
wenzelm
parents: 63041
diff changeset
   128
fun prepare prep_var parse_prop prep_att auto_close raw_vars raw_specss ctxt =
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
   129
  let
60379
51d9dcd71ad7 tuned signature;
wenzelm
parents: 60377
diff changeset
   130
    val (vars, vars_ctxt) = ctxt |> fold_map prep_var raw_vars;
62992
d2e3b3b159d7 clarified PIDE reports;
wenzelm
parents: 62770
diff changeset
   131
    val (xs, params_ctxt) = vars_ctxt
d2e3b3b159d7 clarified PIDE reports;
wenzelm
parents: 62770
diff changeset
   132
      |> Context_Position.set_visible false
d2e3b3b159d7 clarified PIDE reports;
wenzelm
parents: 62770
diff changeset
   133
      |> Proof_Context.add_fixes vars
d2e3b3b159d7 clarified PIDE reports;
wenzelm
parents: 62770
diff changeset
   134
      ||> Context_Position.restore_visible vars_ctxt;
d2e3b3b159d7 clarified PIDE reports;
wenzelm
parents: 62770
diff changeset
   135
    val _ =
d2e3b3b159d7 clarified PIDE reports;
wenzelm
parents: 62770
diff changeset
   136
      Context_Position.reports params_ctxt
d2e3b3b159d7 clarified PIDE reports;
wenzelm
parents: 62770
diff changeset
   137
        (map (Binding.pos_of o #1) vars ~~
d2e3b3b159d7 clarified PIDE reports;
wenzelm
parents: 62770
diff changeset
   138
          map (Variable.markup_entity_def params_ctxt ##> Properties.remove Markup.kindN) xs);
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
   139
63063
wenzelm
parents: 63041
diff changeset
   140
    val Asss0 =
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   141
      map (fn (raw_concls, raw_prems) => raw_prems :: map snd raw_concls) raw_specss
58993
302104d8366b prefer independent parallel map where user input is processed -- avoid non-deterministic feedback in error situations;
wenzelm
parents: 58848
diff changeset
   142
      |> (burrow o burrow) (grouped 10 Par_List.map_independent (parse_prop params_ctxt));
63063
wenzelm
parents: 63041
diff changeset
   143
    val names =
wenzelm
parents: 63041
diff changeset
   144
      Variable.names_of (params_ctxt |> (fold o fold o fold) Variable.declare_term Asss0)
24734
ff617b6711f4 read/check_specification: free_dummy_patterns;
wenzelm
parents: 24724
diff changeset
   145
      |> fold Name.declare xs;
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   146
63063
wenzelm
parents: 63041
diff changeset
   147
    val (Asss1, _) = (fold_map o fold_map o fold_map) Term.free_dummy_patterns Asss0 names;
wenzelm
parents: 63041
diff changeset
   148
    val idx = (fold o fold o fold) Term.maxidx_term Asss1 ~1 + 1;
wenzelm
parents: 63041
diff changeset
   149
wenzelm
parents: 63041
diff changeset
   150
    val (Asss2, _) =
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   151
      fold_map (fn prems :: conclss => fn i =>
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   152
        (burrow (close_forms params_ctxt auto_close i prems) conclss, i + 1)) Asss1 idx;
63063
wenzelm
parents: 63041
diff changeset
   153
wenzelm
parents: 63041
diff changeset
   154
    val specs = burrow (Syntax.check_props params_ctxt) (flat Asss2);
24724
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   155
    val specs_ctxt = params_ctxt |> (fold o fold) Variable.declare_term specs;
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   156
60407
53ef7b78e78a tuned signature;
wenzelm
parents: 60379
diff changeset
   157
    val ps = specs_ctxt |> fold_map Proof_Context.inferred_param xs |> fst;
53ef7b78e78a tuned signature;
wenzelm
parents: 60379
diff changeset
   158
    val params = map2 (fn (b, _, mx) => fn (_, T) => ((b, T), mx)) vars ps;
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   159
    val name_atts: Attrib.binding list =
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   160
      map (fn ((name, atts), _) => (name, map (prep_att ctxt) atts)) (maps #1 raw_specss);
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   161
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   162
    fun get_pos x =
63063
wenzelm
parents: 63041
diff changeset
   163
      (case (maps o maps o maps) (get_positions specs_ctxt x) Asss2 of
wenzelm
parents: 63041
diff changeset
   164
        [] => Position.none
wenzelm
parents: 63041
diff changeset
   165
      | pos :: _ => pos);
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   166
  in (((params, name_atts ~~ specs), get_pos), specs_ctxt) end;
24724
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   167
30482
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
   168
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   169
fun single_spec ((a, B), As) = ([(a, [B])], As);
30482
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
   170
fun the_spec (a, [prop]) = (a, prop);
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
   171
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   172
fun prep_specs prep_var parse_prop prep_att auto_close vars specs =
63063
wenzelm
parents: 63041
diff changeset
   173
  prepare prep_var parse_prop prep_att auto_close
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   174
    vars (map single_spec specs) #>> (apfst o apsnd) (map the_spec);
30482
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
   175
24724
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   176
in
21370
d9dd7b4e5e69 replaced Variable.fix_frees by Variable.auto_fixes (depends on body mode);
wenzelm
parents: 21359
diff changeset
   177
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   178
fun check_spec xs As B =
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   179
  prep_specs Proof_Context.cert_var (K I) (K I) false xs [(B, As)] #>
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   180
  (apfst o apfst o apsnd) the_single;
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   181
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   182
fun read_spec xs As B =
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   183
  prep_specs Proof_Context.read_var Syntax.parse_prop Attrib.check_src false xs [(B, As)] #>
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   184
  (apfst o apfst o apsnd) the_single;
30482
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
   185
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   186
type multi_specs = ((Attrib.binding * term) * term list) list;
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   187
type multi_specs_cmd = ((Attrib.binding * string) * string list) list;
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   188
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   189
fun check_multi_specs xs specs =
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   190
  prep_specs Proof_Context.cert_var (K I) (K I) true xs specs #>> #1;
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   191
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   192
fun read_multi_specs xs specs =
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   193
  prep_specs Proof_Context.read_var Syntax.parse_prop Attrib.check_src true xs specs #>> #1;
30482
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
   194
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   195
fun check_specification xs As Bs =
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   196
  prepare Proof_Context.cert_var (K I) (K I) true xs [(Bs, As)] #>> #1;
30482
6e3c92de4a7d simplified versions check_spec, read_spec, check_free_spec, read_free_spec: operate on list of singleton statements;
wenzelm
parents: 30472
diff changeset
   197
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   198
fun read_specification xs As Bs =
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   199
  prepare Proof_Context.read_var Syntax.parse_prop Attrib.check_src true xs [(Bs, As)] #>> #1;
24724
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   200
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   201
end;
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
   202
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
   203
28114
2637fb838f74 axiomatization is now global-only;
wenzelm
parents: 28093
diff changeset
   204
(* axiomatization -- within global theory *)
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
   205
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   206
fun gen_axioms prep raw_decls raw_prems raw_concls thy =
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
   207
  let
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   208
    val ((decls, specs), _) = prep raw_decls raw_prems raw_concls (Proof_Context.init_global thy);
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   209
    val xs = map (fn ((b, T), _) => (Variable.check_name b, T)) decls;
28114
2637fb838f74 axiomatization is now global-only;
wenzelm
parents: 28093
diff changeset
   210
2637fb838f74 axiomatization is now global-only;
wenzelm
parents: 28093
diff changeset
   211
    (*consts*)
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   212
    val (consts, consts_thy) = thy |> fold_map Theory.specify_const decls;
28114
2637fb838f74 axiomatization is now global-only;
wenzelm
parents: 28093
diff changeset
   213
    val subst = Term.subst_atomic (map Free xs ~~ consts);
2637fb838f74 axiomatization is now global-only;
wenzelm
parents: 28093
diff changeset
   214
2637fb838f74 axiomatization is now global-only;
wenzelm
parents: 28093
diff changeset
   215
    (*axioms*)
30470
9ae8f9d78cd3 axiomatization: more precise treatment of binding;
wenzelm
parents: 30434
diff changeset
   216
    val (axioms, axioms_thy) = (specs, consts_thy) |-> fold_map (fn ((b, atts), props) =>
42375
774df7c59508 report Name_Space.declare/define, relatively to context;
wenzelm
parents: 42360
diff changeset
   217
        fold_map Thm.add_axiom_global
30470
9ae8f9d78cd3 axiomatization: more precise treatment of binding;
wenzelm
parents: 30434
diff changeset
   218
          (map (apfst (fn a => Binding.map_name (K a) b))
47021
f35f654f297d clarified Binding.name_of vs Name_Space.base_name vs Variable.check_name (see also 9bd8d4addd6e, 3305f573294e);
wenzelm
parents: 46992
diff changeset
   219
            (Global_Theory.name_multi (Binding.name_of b) (map subst props)))
36106
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35894
diff changeset
   220
        #>> (fn ths => ((b, atts), [(map #2 ths, [])])));
30470
9ae8f9d78cd3 axiomatization: more precise treatment of binding;
wenzelm
parents: 30434
diff changeset
   221
9ae8f9d78cd3 axiomatization: more precise treatment of binding;
wenzelm
parents: 30434
diff changeset
   222
    (*facts*)
33703
50b6c07c0dd4 axiomatization: declare Spec_Rules, direct result;
wenzelm
parents: 33671
diff changeset
   223
    val (facts, facts_lthy) = axioms_thy
38388
94d5624dd1f7 Named_Target.theory_init
haftmann
parents: 38350
diff changeset
   224
      |> Named_Target.theory_init
33703
50b6c07c0dd4 axiomatization: declare Spec_Rules, direct result;
wenzelm
parents: 33671
diff changeset
   225
      |> Spec_Rules.add Spec_Rules.Unknown (consts, maps (maps #1 o #2) axioms)
50b6c07c0dd4 axiomatization: declare Spec_Rules, direct result;
wenzelm
parents: 33671
diff changeset
   226
      |> Local_Theory.notes axioms;
30470
9ae8f9d78cd3 axiomatization: more precise treatment of binding;
wenzelm
parents: 30434
diff changeset
   227
33703
50b6c07c0dd4 axiomatization: declare Spec_Rules, direct result;
wenzelm
parents: 33671
diff changeset
   228
  in ((consts, map #2 facts), Local_Theory.exit_global facts_lthy) end;
18786
591a37d48794 added definition(_i);
wenzelm
parents: 18771
diff changeset
   229
44192
a32ca9165928 less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents: 43329
diff changeset
   230
val axiomatization = gen_axioms check_specification;
a32ca9165928 less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents: 43329
diff changeset
   231
val axiomatization_cmd = gen_axioms read_specification;
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
   232
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   233
fun axiom (b, ax) = axiomatization [] [] [(b, [ax])] #>> (hd o hd o snd);
35894
ab6dc4d86ea1 added Specification.axiom convenience;
wenzelm
parents: 35625
diff changeset
   234
18786
591a37d48794 added definition(_i);
wenzelm
parents: 18771
diff changeset
   235
591a37d48794 added definition(_i);
wenzelm
parents: 18771
diff changeset
   236
(* definition *)
591a37d48794 added definition(_i);
wenzelm
parents: 18771
diff changeset
   237
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   238
fun gen_def prep raw_var raw_prems raw_spec int lthy =
18786
591a37d48794 added definition(_i);
wenzelm
parents: 18771
diff changeset
   239
  let
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   240
    val ((vars, ((raw_name, atts), prop)), get_pos) =
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   241
      fst (prep (the_list raw_var) raw_prems raw_spec lthy);
63038
1fbad761c1ba within a proof body context, undeclared frees are like global constants;
wenzelm
parents: 63019
diff changeset
   242
    val (((x, T), rhs), prove) = Local_Defs.derived_def lthy {conditional = true} prop;
56169
9b0dc5c704c9 reject internal names, notably from Term.free_dummy_patterns;
wenzelm
parents: 56026
diff changeset
   243
    val _ = Name.reject_internal (x, []);
62770
wenzelm
parents: 61950
diff changeset
   244
    val (b, mx) =
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   245
      (case vars of
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   246
        [] => (Binding.make (x, get_pos x), NoSyn)
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   247
      | [((b, _), mx)] =>
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   248
          let
42494
eef1a23c9077 tuned signature -- eliminated odd comment;
wenzelm
parents: 42482
diff changeset
   249
            val y = Variable.check_name b;
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   250
            val _ = x = y orelse
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   251
              error ("Head of definition " ^ quote x ^ " differs from declaration " ^ quote y ^
48992
0518bf89c777 renamed Position.str_of to Position.here;
wenzelm
parents: 47080
diff changeset
   252
                Position.here (Binding.pos_of b));
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   253
          in (b, mx) end);
63041
cb495c4807b3 clarified def binding position: reset for implicit/derived binding, keep for explicit binding;
wenzelm
parents: 63038
diff changeset
   254
    val name = Thm.def_binding_optional b raw_name;
33455
4da71b27b3fe declare Spec_Rules for most basic definitional packages;
wenzelm
parents: 33389
diff changeset
   255
    val ((lhs, (_, raw_th)), lthy2) = lthy
62770
wenzelm
parents: 61950
diff changeset
   256
      |> Local_Theory.define_internal ((b, mx), ((Binding.suffix_name "_raw" name, []), rhs));
33455
4da71b27b3fe declare Spec_Rules for most basic definitional packages;
wenzelm
parents: 33389
diff changeset
   257
4da71b27b3fe declare Spec_Rules for most basic definitional packages;
wenzelm
parents: 33389
diff changeset
   258
    val th = prove lthy2 raw_th;
4da71b27b3fe declare Spec_Rules for most basic definitional packages;
wenzelm
parents: 33389
diff changeset
   259
    val lthy3 = lthy2 |> Spec_Rules.add Spec_Rules.Equational ([lhs], [th]);
4da71b27b3fe declare Spec_Rules for most basic definitional packages;
wenzelm
parents: 33389
diff changeset
   260
33670
02b7738aef6a eliminated slightly odd kind argument of LocalTheory.note(s);
wenzelm
parents: 33644
diff changeset
   261
    val ([(def_name, [th'])], lthy4) = lthy3
47080
wenzelm
parents: 47067
diff changeset
   262
      |> Local_Theory.notes [((name, Code.add_default_eqn_attrib :: atts), [([th], [])])];
18786
591a37d48794 added definition(_i);
wenzelm
parents: 18771
diff changeset
   263
33671
4b0f2599ed48 modernized structure Local_Theory;
wenzelm
parents: 33670
diff changeset
   264
    val lhs' = Morphism.term (Local_Theory.target_morphism lthy4) lhs;
44192
a32ca9165928 less verbosity in batch mode -- spam reduction and notable performance improvement;
wenzelm
parents: 43329
diff changeset
   265
56932
11a4001b06c6 more position markup to help locating the query context, e.g. from "Info" dockable;
wenzelm
parents: 56897
diff changeset
   266
    val _ =
11a4001b06c6 more position markup to help locating the query context, e.g. from "Info" dockable;
wenzelm
parents: 56897
diff changeset
   267
      Proof_Display.print_consts int (Position.thread_data ()) lthy4
11a4001b06c6 more position markup to help locating the query context, e.g. from "Info" dockable;
wenzelm
parents: 56897
diff changeset
   268
        (member (op =) (Term.add_frees lhs' [])) [(x, T)];
33455
4da71b27b3fe declare Spec_Rules for most basic definitional packages;
wenzelm
parents: 33389
diff changeset
   269
  in ((lhs, (def_name, th')), lthy4) end;
18786
591a37d48794 added definition(_i);
wenzelm
parents: 18771
diff changeset
   270
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   271
val definition' = gen_def check_spec;
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   272
fun definition xs As B = definition' xs As B false;
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   273
val definition_cmd = gen_def read_spec;
18786
591a37d48794 added definition(_i);
wenzelm
parents: 18771
diff changeset
   274
19080
46ba991e27d5 added abbreviation(_i);
wenzelm
parents: 18954
diff changeset
   275
46ba991e27d5 added abbreviation(_i);
wenzelm
parents: 18954
diff changeset
   276
(* abbreviation *)
46ba991e27d5 added abbreviation(_i);
wenzelm
parents: 18954
diff changeset
   277
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   278
fun gen_abbrev prep mode raw_var raw_prop int lthy =
19080
46ba991e27d5 added abbreviation(_i);
wenzelm
parents: 18954
diff changeset
   279
  let
55119
9ca72949ebac observe local syntax mode (according to e3a39dae2004, which was lost in 0f3ad56548bc), e.g. relevant for "abbreviation (output)" with non-terminating syntax;
wenzelm
parents: 54883
diff changeset
   280
    val lthy1 = lthy
9ca72949ebac observe local syntax mode (according to e3a39dae2004, which was lost in 0f3ad56548bc), e.g. relevant for "abbreviation (output)" with non-terminating syntax;
wenzelm
parents: 54883
diff changeset
   281
      |> Proof_Context.set_syntax_mode mode;
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   282
    val (((vars, (_, prop)), get_pos), _) =
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   283
      prep (the_list raw_var) [] (Attrib.empty_binding, raw_prop)
55119
9ca72949ebac observe local syntax mode (according to e3a39dae2004, which was lost in 0f3ad56548bc), e.g. relevant for "abbreviation (output)" with non-terminating syntax;
wenzelm
parents: 54883
diff changeset
   284
        (lthy1 |> Proof_Context.set_mode Proof_Context.mode_abbrev);
9ca72949ebac observe local syntax mode (according to e3a39dae2004, which was lost in 0f3ad56548bc), e.g. relevant for "abbreviation (output)" with non-terminating syntax;
wenzelm
parents: 54883
diff changeset
   285
    val ((x, T), rhs) = Local_Defs.abs_def (#2 (Local_Defs.cert_def lthy1 prop));
56169
9b0dc5c704c9 reject internal names, notably from Term.free_dummy_patterns;
wenzelm
parents: 56026
diff changeset
   286
    val _ = Name.reject_internal (x, []);
62770
wenzelm
parents: 61950
diff changeset
   287
    val (b, mx) =
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   288
      (case vars of
61947
8d996ee7e986 more position information;
wenzelm
parents: 60477
diff changeset
   289
        [] => (Binding.make (x, get_pos x), NoSyn)
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   290
      | [((b, _), mx)] =>
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   291
          let
42494
eef1a23c9077 tuned signature -- eliminated odd comment;
wenzelm
parents: 42482
diff changeset
   292
            val y = Variable.check_name b;
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   293
            val _ = x = y orelse
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   294
              error ("Head of abbreviation " ^ quote x ^ " differs from declaration " ^ quote y ^
48992
0518bf89c777 renamed Position.str_of to Position.here;
wenzelm
parents: 47080
diff changeset
   295
                Position.here (Binding.pos_of b));
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   296
          in (b, mx) end);
55119
9ca72949ebac observe local syntax mode (according to e3a39dae2004, which was lost in 0f3ad56548bc), e.g. relevant for "abbreviation (output)" with non-terminating syntax;
wenzelm
parents: 54883
diff changeset
   297
    val lthy2 = lthy1
62770
wenzelm
parents: 61950
diff changeset
   298
      |> Local_Theory.abbrev mode ((b, mx), rhs) |> snd
42360
da8817d01e7c modernized structure Proof_Context;
wenzelm
parents: 42357
diff changeset
   299
      |> Proof_Context.restore_syntax_mode lthy;
24724
0df74bb87a13 read/check_specification: proper type inference across multiple sections, result is in closed form;
wenzelm
parents: 24676
diff changeset
   300
56932
11a4001b06c6 more position markup to help locating the query context, e.g. from "Info" dockable;
wenzelm
parents: 56897
diff changeset
   301
    val _ = Proof_Display.print_consts int (Position.thread_data ()) lthy2 (K false) [(x, T)];
55119
9ca72949ebac observe local syntax mode (according to e3a39dae2004, which was lost in 0f3ad56548bc), e.g. relevant for "abbreviation (output)" with non-terminating syntax;
wenzelm
parents: 54883
diff changeset
   302
  in lthy2 end;
19080
46ba991e27d5 added abbreviation(_i);
wenzelm
parents: 18954
diff changeset
   303
63064
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   304
val abbreviation = gen_abbrev check_spec;
2f18172214c8 support 'assumes' in specifications, e.g. 'definition', 'inductive';
wenzelm
parents: 63063
diff changeset
   305
val abbreviation_cmd = gen_abbrev read_spec;
19080
46ba991e27d5 added abbreviation(_i);
wenzelm
parents: 18954
diff changeset
   306
19664
e1dc01a48a52 added const_syntax(_i);
wenzelm
parents: 19585
diff changeset
   307
21230
abfdce60b371 theorem statements: incorporate Obtain.statement, tuned;
wenzelm
parents: 21206
diff changeset
   308
(* notation *)
19664
e1dc01a48a52 added const_syntax(_i);
wenzelm
parents: 19585
diff changeset
   309
35413
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   310
local
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   311
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   312
fun gen_type_notation prep_type add mode args lthy =
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   313
  lthy |> Local_Theory.type_notation add mode (map (apfst (prep_type lthy)) args);
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   314
24949
5f00e3532418 generalized notation interface (add or del);
wenzelm
parents: 24927
diff changeset
   315
fun gen_notation prep_const add mode args lthy =
33671
4b0f2599ed48 modernized structure Local_Theory;
wenzelm
parents: 33670
diff changeset
   316
  lthy |> Local_Theory.notation add mode (map (apfst (prep_const lthy)) args);
19664
e1dc01a48a52 added const_syntax(_i);
wenzelm
parents: 19585
diff changeset
   317
35413
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   318
in
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   319
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   320
val type_notation = gen_type_notation (K I);
55951
c07d184aebe9 tuned signature -- more uniform check_type_name/read_type_name;
wenzelm
parents: 55639
diff changeset
   321
val type_notation_cmd =
56002
2028467b4df4 tuned signature;
wenzelm
parents: 55997
diff changeset
   322
  gen_type_notation (Proof_Context.read_type_name {proper = true, strict = false});
35413
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   323
24927
48e08f37ce92 Specification: renamed XXX_i to XXX, and XXX to XXX_cmd;
wenzelm
parents: 24848
diff changeset
   324
val notation = gen_notation (K I);
56002
2028467b4df4 tuned signature;
wenzelm
parents: 55997
diff changeset
   325
val notation_cmd = gen_notation (Proof_Context.read_const {proper = false, strict = false});
19664
e1dc01a48a52 added const_syntax(_i);
wenzelm
parents: 19585
diff changeset
   326
35413
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   327
end;
4c7cba1f7ce9 added type_notation command;
wenzelm
parents: 35399
diff changeset
   328
20914
3f065aa89792 added theorems(_i) -- with present_results;
wenzelm
parents: 20890
diff changeset
   329
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   330
(* fact statements *)
20914
3f065aa89792 added theorems(_i) -- with present_results;
wenzelm
parents: 20890
diff changeset
   331
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   332
local
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   333
60469
d1ea37df7358 tuned signature;
wenzelm
parents: 60454
diff changeset
   334
fun gen_theorems prep_fact prep_att add_fixes
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   335
    kind raw_facts raw_fixes int lthy =
20914
3f065aa89792 added theorems(_i) -- with present_results;
wenzelm
parents: 20890
diff changeset
   336
  let
3f065aa89792 added theorems(_i) -- with present_results;
wenzelm
parents: 20890
diff changeset
   337
    val facts = raw_facts |> map (fn ((name, atts), bs) =>
55997
9dc5ce83202c modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
wenzelm
parents: 55955
diff changeset
   338
      ((name, map (prep_att lthy) atts),
9dc5ce83202c modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
wenzelm
parents: 55955
diff changeset
   339
        bs |> map (fn (b, more_atts) => (prep_fact lthy b, map (prep_att lthy) more_atts))));
60469
d1ea37df7358 tuned signature;
wenzelm
parents: 60454
diff changeset
   340
    val (_, ctxt') = add_fixes raw_fixes lthy;
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   341
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   342
    val facts' = facts
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   343
      |> Attrib.partial_evaluation ctxt'
58028
e4250d370657 tuned signature -- define some elementary operations earlier;
wenzelm
parents: 58011
diff changeset
   344
      |> Attrib.transform_facts (Proof_Context.export_morphism ctxt' lthy);
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   345
    val (res, lthy') = lthy |> Local_Theory.notes_kind kind facts';
56932
11a4001b06c6 more position markup to help locating the query context, e.g. from "Info" dockable;
wenzelm
parents: 56897
diff changeset
   346
    val _ = Proof_Display.print_results int (Position.thread_data ()) lthy' ((kind, ""), res);
20914
3f065aa89792 added theorems(_i) -- with present_results;
wenzelm
parents: 20890
diff changeset
   347
  in (res, lthy') end;
3f065aa89792 added theorems(_i) -- with present_results;
wenzelm
parents: 20890
diff changeset
   348
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   349
in
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   350
60469
d1ea37df7358 tuned signature;
wenzelm
parents: 60454
diff changeset
   351
val theorems = gen_theorems (K I) (K I) Proof_Context.add_fixes;
d1ea37df7358 tuned signature;
wenzelm
parents: 60454
diff changeset
   352
val theorems_cmd = gen_theorems Proof_Context.get_fact Attrib.check_src Proof_Context.add_fixes_cmd;
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   353
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 45584
diff changeset
   354
end;
20914
3f065aa89792 added theorems(_i) -- with present_results;
wenzelm
parents: 20890
diff changeset
   355
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   356
21230
abfdce60b371 theorem statements: incorporate Obtain.statement, tuned;
wenzelm
parents: 21206
diff changeset
   357
(* complex goal statements *)
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   358
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   359
local
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   360
60477
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   361
fun prep_statement prep_att prep_stmt raw_elems raw_stmt ctxt =
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   362
  let
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   363
    val (stmt, elems_ctxt) = prep_stmt raw_elems raw_stmt ctxt;
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   364
    val prems = Assumption.local_prems_of elems_ctxt ctxt;
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   365
    val stmt_ctxt = fold (fold (Variable.auto_fixes o fst) o snd) stmt elems_ctxt;
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   366
  in
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   367
    (case raw_stmt of
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   368
      Element.Shows _ =>
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   369
        let val stmt' = Attrib.map_specs (map prep_att) stmt
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   370
        in (([], prems, stmt', NONE), stmt_ctxt) end
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   371
    | Element.Obtains raw_obtains =>
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   372
        let
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   373
          val asms_ctxt = stmt_ctxt
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   374
            |> fold (fn ((name, _), asm) =>
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   375
                snd o Proof_Context.add_assms Assumption.assume_export
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   376
                  [((name, [Context_Rules.intro_query NONE]), asm)]) stmt;
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   377
          val that = Assumption.local_prems_of asms_ctxt stmt_ctxt;
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   378
          val ([(_, that')], that_ctxt) = asms_ctxt
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   379
            |> Proof_Context.note_thmss "" [((Binding.name Auto_Bind.thatN, []), [(that, [])])];
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   380
60477
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   381
          val stmt' = [((Binding.empty, []), [(#2 (#1 (Obtain.obtain_thesis ctxt)), [])])];
63019
80ef19b51493 prefer internal attribute source;
wenzelm
parents: 62992
diff changeset
   382
        in ((Obtain.obtains_attribs raw_obtains, prems, stmt', SOME that'), that_ctxt) end)
60477
051b200f7578 improved treatment of Element.Obtains via Expression.prepare_stmt;
wenzelm
parents: 60469
diff changeset
   383
  end;
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   384
56026
893fe12639bc tuned signature -- prefer Name_Space.get with its builtin error;
wenzelm
parents: 56002
diff changeset
   385
fun gen_theorem schematic bundle_includes prep_att prep_stmt
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   386
    kind before_qed after_qed (name, raw_atts) raw_includes raw_elems raw_concl int lthy =
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   387
  let
47066
8a6124d09ff5 basic support for nested contexts including bundles;
wenzelm
parents: 47021
diff changeset
   388
    val _ = Local_Theory.assert lthy;
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   389
55997
9dc5ce83202c modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
wenzelm
parents: 55955
diff changeset
   390
    val elems = raw_elems |> map (Element.map_ctxt_attrib (prep_att lthy));
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   391
    val ((more_atts, prems, stmt, facts), goal_ctxt) = lthy
56026
893fe12639bc tuned signature -- prefer Name_Space.get with its builtin error;
wenzelm
parents: 56002
diff changeset
   392
      |> bundle_includes raw_includes
55997
9dc5ce83202c modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
wenzelm
parents: 55955
diff changeset
   393
      |> prep_statement (prep_att lthy) prep_stmt elems raw_concl;
9dc5ce83202c modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
wenzelm
parents: 55955
diff changeset
   394
    val atts = more_atts @ map (prep_att lthy) raw_atts;
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   395
56932
11a4001b06c6 more position markup to help locating the query context, e.g. from "Info" dockable;
wenzelm
parents: 56897
diff changeset
   396
    val pos = Position.thread_data ();
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   397
    fun after_qed' results goal_ctxt' =
45584
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   398
      let
54883
dd04a8b654fc proper context for norm_hhf and derived operations;
wenzelm
parents: 51313
diff changeset
   399
        val results' =
dd04a8b654fc proper context for norm_hhf and derived operations;
wenzelm
parents: 51313
diff changeset
   400
          burrow (map (Goal.norm_result lthy) o Proof_Context.export goal_ctxt' lthy) results;
45584
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   401
        val (res, lthy') =
49062
7e31dfd99ce7 discontinued complicated/unreliable notion of recent proofs within context;
wenzelm
parents: 49059
diff changeset
   402
          if forall (Attrib.is_empty_binding o fst) stmt then (map (pair "") results', lthy)
45584
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   403
          else
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   404
            Local_Theory.notes_kind kind
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   405
              (map2 (fn (b, _) => fn ths => (b, [(ths, [])])) stmt results') lthy;
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   406
        val lthy'' =
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   407
          if Attrib.is_empty_binding (name, atts) then
56932
11a4001b06c6 more position markup to help locating the query context, e.g. from "Info" dockable;
wenzelm
parents: 56897
diff changeset
   408
            (Proof_Display.print_results int pos lthy' ((kind, ""), res); lthy')
28080
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   409
          else
4723eb2456ce explicit type Name.binding for higher-specification elements;
wenzelm
parents: 27858
diff changeset
   410
            let
45584
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   411
              val ([(res_name, _)], lthy'') =
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   412
                Local_Theory.notes_kind kind [((name, atts), [(maps #2 res, [])])] lthy';
56932
11a4001b06c6 more position markup to help locating the query context, e.g. from "Info" dockable;
wenzelm
parents: 56897
diff changeset
   413
              val _ = Proof_Display.print_results int pos lthy' ((kind, res_name), res);
45584
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   414
            in lthy'' end;
41a768a431a6 do not store vacuous theorem specifications -- relevant for frugal local theory content;
wenzelm
parents: 45583
diff changeset
   415
      in after_qed results' lthy'' end;
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   416
  in
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   417
    goal_ctxt
42360
da8817d01e7c modernized structure Proof_Context;
wenzelm
parents: 42357
diff changeset
   418
    |> Proof_Context.note_thmss "" [((Binding.name Auto_Bind.assmsN, []), [(prems, [])])]
21450
f16c9e6401d1 theorem(_i): note assms of statement;
wenzelm
parents: 21435
diff changeset
   419
    |> snd
36323
655e2d74de3a modernized naming conventions of main Isar proof elements;
wenzelm
parents: 36317
diff changeset
   420
    |> Proof.theorem before_qed after_qed' (map snd stmt)
32856
92d9555ac790 clarified Proof.refine_insert -- always "refine" to apply standard method treatment (of conjunctions);
wenzelm
parents: 32786
diff changeset
   421
    |> (case facts of NONE => I | SOME ths => Proof.refine_insert ths)
36317
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36106
diff changeset
   422
    |> tap (fn state => not schematic andalso Proof.schematic_goal state andalso
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36106
diff changeset
   423
        error "Illegal schematic goal statement")
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   424
  end;
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   425
21230
abfdce60b371 theorem statements: incorporate Obtain.statement, tuned;
wenzelm
parents: 21206
diff changeset
   426
in
abfdce60b371 theorem statements: incorporate Obtain.statement, tuned;
wenzelm
parents: 21206
diff changeset
   427
56026
893fe12639bc tuned signature -- prefer Name_Space.get with its builtin error;
wenzelm
parents: 56002
diff changeset
   428
val theorem =
893fe12639bc tuned signature -- prefer Name_Space.get with its builtin error;
wenzelm
parents: 56002
diff changeset
   429
  gen_theorem false Bundle.includes (K I) Expression.cert_statement;
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   430
val theorem_cmd =
56026
893fe12639bc tuned signature -- prefer Name_Space.get with its builtin error;
wenzelm
parents: 56002
diff changeset
   431
  gen_theorem false Bundle.includes_cmd Attrib.check_src Expression.read_statement;
36317
506d732cb522 explicit 'schematic_theorem' etc. for schematic theorem statements;
wenzelm
parents: 36106
diff changeset
   432
56026
893fe12639bc tuned signature -- prefer Name_Space.get with its builtin error;
wenzelm
parents: 56002
diff changeset
   433
val schematic_theorem =
893fe12639bc tuned signature -- prefer Name_Space.get with its builtin error;
wenzelm
parents: 56002
diff changeset
   434
  gen_theorem true Bundle.includes (K I) Expression.cert_statement;
47067
4ef29b0c568f optional 'includes' element for long theorem statements;
wenzelm
parents: 47066
diff changeset
   435
val schematic_theorem_cmd =
56026
893fe12639bc tuned signature -- prefer Name_Space.get with its builtin error;
wenzelm
parents: 56002
diff changeset
   436
  gen_theorem true Bundle.includes_cmd Attrib.check_src Expression.read_statement;
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   437
18620
fc8b5f275359 Theory specifications --- with type-inference, but no internal polymorphism.
wenzelm
parents:
diff changeset
   438
end;
21036
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   439
0eed532acfca added theorem(_i);
wenzelm
parents: 20914
diff changeset
   440
end;