src/Pure/Isar/rule_context.ML
author wenzelm
Mon, 26 Nov 2001 23:24:27 +0100
changeset 12301 adf0eff5ea62
child 12311 ce5f9e61c037
permissions -rw-r--r--
added Pure/Isar/rule_context.ML;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12301
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/rule_context.ML
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
     3
    Author:     Stefan Berghofer and Markus Wenzel, TU Muenchen
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
     5
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
     6
Declarations of intro/elim/dest rules in Pure; see
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
     7
Provers/classical.ML for a more specialized version.
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
     8
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
     9
TODO:
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    10
  - del rules;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    11
  - tactics;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    12
  - add/del ML interface (?);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    13
*)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    14
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    15
signature RULE_CONTEXT =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    16
sig
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    17
  type T
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    18
  val empty_rules: T
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    19
  val print_global_rules: theory -> unit
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    20
  val print_local_rules: Proof.context -> unit
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    21
  val intro_bang_global: int option -> theory attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    22
  val elim_bang_global: int option -> theory attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    23
  val dest_bang_global: int option -> theory attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    24
  val intro_global: int option -> theory attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    25
  val elim_global: int option -> theory attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    26
  val dest_global: int option -> theory attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    27
  val intro_query_global: int option -> theory attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    28
  val elim_query_global: int option -> theory attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    29
  val dest_query_global: int option -> theory attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    30
  val intro_bang_local: int option -> Proof.context attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    31
  val elim_bang_local: int option -> Proof.context attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    32
  val dest_bang_local: int option -> Proof.context attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    33
  val intro_local: int option -> Proof.context attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    34
  val elim_local: int option -> Proof.context attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    35
  val dest_local: int option -> Proof.context attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    36
  val intro_query_local: int option -> Proof.context attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    37
  val elim_query_local: int option -> Proof.context attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    38
  val dest_query_local: int option -> Proof.context attribute
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    39
  val setup: (theory -> theory) list
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    40
end;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    41
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    42
structure RuleContext: RULE_CONTEXT =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    43
struct
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    44
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    45
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    46
(** rule declaration contexts **)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    47
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    48
(* rule kinds *)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    49
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    50
val intro_bangK = (0, false);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    51
val elim_bangK = (0, true);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    52
val introK = (1, false);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    53
val elimK = (1, true);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    54
val intro_queryK = (2, false);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    55
val elim_queryK = (2, true);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    56
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    57
val kind_names =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    58
 [(intro_bangK, "safe introduction rules (intro!)"),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    59
  (elim_bangK, "safe elimination rules (elim!)"),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    60
  (introK, "introduction rules (intro)"),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    61
  (elimK, "elimination rules (elim)"),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    62
  (intro_queryK, "extra introduction rules (intro?)"),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    63
  (elim_queryK, "extra elimination rules (elim?)")];
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    64
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    65
val rule_kinds = map #1 kind_names;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    66
val rule_indexes = distinct (map #1 rule_kinds);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    67
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    68
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    69
(* netpairs *)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    70
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    71
type net = ((int * int) * (bool * thm)) Net.net;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    72
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    73
val empty_netpairs = replicate (length rule_indexes) (Net.empty: net, Net.empty: net);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    74
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    75
fun make_netpairs rules =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    76
  let
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    77
    fun add (netpairs, (n, (w, ((i, b), th)))) =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    78
      map_nth_elem i (curry insert_tagged_brl ((w, n), (b, th))) netpairs;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    79
    val next = ~ (length rules);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    80
  in (next - 1, foldl add (empty_netpairs, next upto ~1 ~~ rules)) end;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    81
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    82
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    83
(* rules *)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    84
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    85
datatype T = Rules of
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    86
 {next: int,
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    87
  rules: (int * ((int * bool) * thm)) list,
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    88
  netpairs: (net * net) list,
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    89
  wrappers: ((bool * ((int -> tactic) -> int -> tactic)) * stamp) list};
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    90
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    91
val empty_rules = Rules {next = ~1, rules = [], netpairs = empty_netpairs, wrappers = []};
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    92
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    93
fun add_rule (i, b) opt_w th (Rules {next, rules, netpairs, wrappers}) =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    94
  let val w = (case opt_w of Some w => w | None => Tactic.subgoals_of_brl (b, th)) in
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    95
    Rules {next = next - 1,
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    96
      rules = (w, ((i, b), th)) :: rules,
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    97
      netpairs = map_nth_elem i (curry insert_tagged_brl ((w, next), (b, th))) netpairs,
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    98
      wrappers = wrappers}
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
    99
  end;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   100
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   101
fun print_rules prt x (Rules {rules, ...}) =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   102
  let
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   103
    fun prt_kind (i, b) =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   104
      Pretty.big_list (the (assoc (kind_names, (i, b))) ^ ":")
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   105
        (mapfilter (fn (_, (k, th)) => if k = (i, b) then Some (prt x th) else None) rules);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   106
  in Pretty.writeln (Pretty.chunks (map prt_kind rule_kinds)) end;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   107
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   108
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   109
(* theory and proof data *)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   110
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   111
structure GlobalRulesArgs =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   112
struct
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   113
  val name = "Isar/rule_context";
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   114
  type T = T;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   115
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   116
  val empty = empty_rules;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   117
  val copy = I;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   118
  val finish = I;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   119
  val prep_ext = I;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   120
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   121
  fun merge (Rules {rules = rules1, wrappers = wrappers1, ...},
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   122
      Rules {rules = rules2, wrappers = wrappers2, ...}) =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   123
    let
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   124
      val wrappers = gen_merge_lists' eq_snd wrappers1 wrappers2;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   125
      val rules = gen_merge_lists' (fn ((_, (k1, th1)), (_, (k2, th2))) =>
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   126
          k1 = k2 andalso Thm.eq_thm (th1, th2)) rules1 rules2;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   127
      val next = ~ (length rules);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   128
      val netpairs = foldl (fn (nps, (n, (w, ((i, b), th)))) =>
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   129
          map_nth_elem i (curry insert_tagged_brl ((w, n), (b, th))) nps)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   130
        (empty_netpairs, next upto ~1 ~~ rules);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   131
    in Rules {next = next - 1, rules = rules, netpairs = netpairs, wrappers = wrappers} end;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   132
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   133
  val print = print_rules Display.pretty_thm_sg;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   134
end;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   135
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   136
structure GlobalRules = TheoryDataFun(GlobalRulesArgs);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   137
val print_global_rules = GlobalRules.print;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   138
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   139
structure LocalRulesArgs =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   140
struct
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   141
  val name = GlobalRulesArgs.name;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   142
  type T = GlobalRulesArgs.T;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   143
  val init = GlobalRules.get;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   144
  val print = print_rules ProofContext.pretty_thm;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   145
end;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   146
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   147
structure LocalRules = ProofDataFun(LocalRulesArgs);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   148
val print_local_rules = LocalRules.print;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   149
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   150
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   151
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   152
(** attributes **)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   153
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   154
(* add rules *)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   155
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   156
local
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   157
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   158
fun mk_att k view map_data opt_w (x, th) = (map_data (add_rule k opt_w th) x, th);
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   159
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   160
in
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   161
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   162
val intro_bang_global  = mk_att intro_bangK I GlobalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   163
val elim_bang_global   = mk_att elim_bangK I GlobalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   164
val dest_bang_global   = mk_att elim_bangK Tactic.make_elim GlobalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   165
val intro_global       = mk_att introK I GlobalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   166
val elim_global        = mk_att elimK I GlobalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   167
val dest_global        = mk_att elimK Tactic.make_elim GlobalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   168
val intro_query_global = mk_att intro_queryK I GlobalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   169
val elim_query_global  = mk_att elim_queryK I GlobalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   170
val dest_query_global  = mk_att elim_queryK Tactic.make_elim GlobalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   171
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   172
val intro_bang_local   = mk_att intro_bangK I LocalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   173
val elim_bang_local    = mk_att elim_bangK I LocalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   174
val dest_bang_local    = mk_att elim_bangK Tactic.make_elim LocalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   175
val intro_local        = mk_att introK I LocalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   176
val elim_local         = mk_att elimK I LocalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   177
val dest_local         = mk_att elimK Tactic.make_elim LocalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   178
val intro_query_local  = mk_att intro_queryK I LocalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   179
val elim_query_local   = mk_att elim_queryK I LocalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   180
val dest_query_local   = mk_att elim_queryK Tactic.make_elim LocalRules.map;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   181
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   182
end;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   183
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   184
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   185
(* concrete syntax *)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   186
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   187
fun add_args a b c x = Attrib.syntax
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   188
  (Scan.lift (Scan.option (Args.bracks Args.nat) --
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   189
    (Args.bang >> K a || Args.query >> K c || Scan.succeed b) >> op |>)) x;
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   190
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   191
val rule_atts =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   192
 [("intro",
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   193
   (add_args intro_bang_global intro_global intro_query_global,
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   194
    add_args intro_bang_local intro_local intro_query_local),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   195
    "declaration of introduction rule"),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   196
  ("elim",
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   197
   (add_args elim_bang_global elim_global elim_query_global,
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   198
    add_args elim_bang_local elim_local elim_query_local),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   199
    "declaration of elimination rule"),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   200
  ("dest",
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   201
   (add_args dest_bang_global dest_global dest_query_global,
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   202
    add_args dest_bang_local dest_local dest_query_local),
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   203
    "declaration of destruction rule")];
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   204
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   205
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   206
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   207
(** theory setup **)
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   208
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   209
val setup =
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   210
 [GlobalRules.init, LocalRules.init
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   211
  (*FIXME Attrib.add_attributes rule_atts*)];
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   212
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   213
adf0eff5ea62 added Pure/Isar/rule_context.ML;
wenzelm
parents:
diff changeset
   214
end;