src/Pure/more_thm.ML
author blanchet
Mon, 20 Dec 2010 14:17:49 +0100
changeset 41317 fc48faccd77b
parent 40238 edcdecd55655
child 42375 774df7c59508
permissions -rw-r--r--
disable feature that was enabled by mistake
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/more_thm.ML
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
     3
22907
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
     4
Further operations on type ctyp/cterm/thm, outside the inference kernel.
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
     5
*)
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
     6
23169
37091da05d8e moved aconvc to more_thm.ML;
wenzelm
parents: 22907
diff changeset
     7
infix aconvc;
37091da05d8e moved aconvc to more_thm.ML;
wenzelm
parents: 22907
diff changeset
     8
32842
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
     9
signature BASIC_THM =
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    10
sig
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    11
  include BASIC_THM
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    12
  structure Ctermtab: TABLE
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    13
  structure Thmtab: TABLE
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    14
  val aconvc: cterm * cterm -> bool
40238
edcdecd55655 type attribute is derived concept outside the kernel;
wenzelm
parents: 39133
diff changeset
    15
  type attribute = Context.generic * thm -> Context.generic * thm
32842
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    16
end;
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    17
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    18
signature THM =
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    19
sig
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    20
  include THM
32842
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    21
  structure Ctermtab: TABLE
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    22
  structure Thmtab: TABLE
24948
wenzelm
parents: 24775
diff changeset
    23
  val aconvc: cterm * cterm -> bool
23491
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
    24
  val add_cterm_frees: cterm -> cterm list -> cterm list
32198
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
    25
  val all_name: string * cterm -> cterm -> cterm
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
    26
  val all: cterm -> cterm -> cterm
22907
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
    27
  val mk_binop: cterm -> cterm -> cterm -> cterm
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
    28
  val dest_binop: cterm -> cterm * cterm
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
    29
  val dest_implies: cterm -> cterm * cterm
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
    30
  val dest_equals: cterm -> cterm * cterm
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
    31
  val dest_equals_lhs: cterm -> cterm
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
    32
  val dest_equals_rhs: cterm -> cterm
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
    33
  val lhs_of: thm -> cterm
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
    34
  val rhs_of: thm -> cterm
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    35
  val thm_ord: thm * thm -> order
32842
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    36
  val cterm_cache: (cterm -> 'a) -> cterm -> 'a
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
    37
  val thm_cache: (thm -> 'a) -> thm -> 'a
23599
d889725b0d8a added is_reflexive;
wenzelm
parents: 23491
diff changeset
    38
  val is_reflexive: thm -> bool
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    39
  val eq_thm: thm * thm -> bool
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    40
  val eq_thms: thm list * thm list -> bool
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    41
  val eq_thm_thy: thm * thm -> bool
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    42
  val eq_thm_prop: thm * thm -> bool
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    43
  val equiv_thm: thm * thm -> bool
31944
c8a35979a5bc clarified Thm.of_class/of_sort/class_triv;
wenzelm
parents: 31904
diff changeset
    44
  val class_triv: theory -> class -> thm
c8a35979a5bc clarified Thm.of_class/of_sort/class_triv;
wenzelm
parents: 31904
diff changeset
    45
  val of_sort: ctyp * sort -> thm list
28621
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
    46
  val check_shyps: sort list -> thm -> thm
24048
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
    47
  val is_dummy: thm -> bool
22695
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
    48
  val plain_prop_of: thm -> term
24048
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
    49
  val add_thm: thm -> thm list -> thm list
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
    50
  val del_thm: thm -> thm list -> thm list
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
    51
  val merge_thms: thm list * thm list -> thm list
33453
fe551dc9d4bd scalable version of Named_Thms, using Item_Net;
wenzelm
parents: 33373
diff changeset
    52
  val full_rules: thm Item_Net.T
30560
0cc3b7f03ade adapted to general Item_Net;
wenzelm
parents: 30433
diff changeset
    53
  val intro_rules: thm Item_Net.T
0cc3b7f03ade adapted to general Item_Net;
wenzelm
parents: 30433
diff changeset
    54
  val elim_rules: thm Item_Net.T
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    55
  val elim_implies: thm -> thm -> thm
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    56
  val forall_elim_var: int -> thm -> thm
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    57
  val forall_elim_vars: int -> thm -> thm
32279
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
    58
  val certify_inst: theory ->
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
    59
    ((indexname * sort) * typ) list * ((indexname * typ) * term) list ->
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
    60
    (ctyp * ctyp) list * (cterm * cterm) list
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
    61
  val certify_instantiate:
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
    62
    ((indexname * sort) * typ) list * ((indexname * typ) * term) list -> thm -> thm
35985
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
    63
  val forall_intr_frees: thm -> thm
35845
e5980f0ad025 renamed varify/unvarify operations to varify_global/unvarify_global to emphasize that these only work in a global situation;
wenzelm
parents: 35715
diff changeset
    64
  val unvarify_global: thm -> thm
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    65
  val close_derivation: thm -> thm
36106
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
    66
  val add_axiom: binding * term -> theory -> (string * thm) * theory
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
    67
  val add_def: bool -> bool -> binding * term -> theory -> (string * thm) * theory
40238
edcdecd55655 type attribute is derived concept outside the kernel;
wenzelm
parents: 39133
diff changeset
    68
  type attribute = Context.generic * thm -> Context.generic * thm
30210
225fa48756b2 added type binding and val empty_binding;
wenzelm
parents: 29579
diff changeset
    69
  type binding = binding * attribute list
225fa48756b2 added type binding and val empty_binding;
wenzelm
parents: 29579
diff changeset
    70
  val empty_binding: binding
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    71
  val rule_attribute: (Context.generic -> thm -> thm) -> attribute
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    72
  val declaration_attribute: (thm -> Context.generic -> Context.generic) -> attribute
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    73
  val theory_attributes: attribute list -> theory * thm -> theory * thm
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    74
  val proof_attributes: attribute list -> Proof.context * thm -> Proof.context * thm
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    75
  val no_attributes: 'a -> 'a * 'b list
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    76
  val simple_fact: 'a -> ('a * 'b list) list
28017
4919bd124a58 type Properties.T;
wenzelm
parents: 27866
diff changeset
    77
  val tag_rule: Properties.property -> thm -> thm
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    78
  val untag_rule: string -> thm -> thm
28017
4919bd124a58 type Properties.T;
wenzelm
parents: 27866
diff changeset
    79
  val tag: Properties.property -> attribute
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    80
  val untag: string -> attribute
30342
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
    81
  val def_name: string -> string
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
    82
  val def_name_optional: string -> string -> string
35238
18ae6ef02fe0 Thm.def_binding;
wenzelm
parents: 33713
diff changeset
    83
  val def_binding: Binding.binding -> Binding.binding
30433
ce5138c92ca7 added def_binding_optional -- robust version of def_name_optional for bindings;
wenzelm
parents: 30342
diff changeset
    84
  val def_binding_optional: Binding.binding -> Binding.binding -> Binding.binding
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    85
  val has_name_hint: thm -> bool
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    86
  val get_name_hint: thm -> string
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    87
  val put_name_hint: string -> thm -> thm
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    88
  val definitionK: string
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    89
  val theoremK: string
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    90
  val lemmaK: string
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    91
  val corollaryK: string
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    92
  val get_kind: thm -> string
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    93
  val kind_rule: string -> thm -> thm
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
    94
  val kind: string -> attribute
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    95
end;
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    96
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    97
structure Thm: THM =
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    98
struct
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
    99
22695
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   100
(** basic operations **)
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   101
23491
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   102
(* collecting cterms *)
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   103
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   104
val op aconvc = op aconv o pairself Thm.term_of;
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   105
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   106
fun add_cterm_frees ct =
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   107
  let
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   108
    val cert = Thm.cterm_of (Thm.theory_of_cterm ct);
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   109
    val t = Thm.term_of ct;
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   110
  in Term.fold_aterms (fn v as Free _ => insert (op aconvc) (cert v) | _ => I) t end;
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   111
c13ca04303de added reasonably efficient add_cterm_frees;
wenzelm
parents: 23170
diff changeset
   112
22907
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   113
(* cterm constructors and destructors *)
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   114
32198
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
   115
fun all_name (x, t) A =
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
   116
  let
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
   117
    val cert = Thm.cterm_of (Thm.theory_of_cterm t);
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
   118
    val T = #T (Thm.rep_cterm t);
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
   119
  in Thm.capply (cert (Const ("all", (T --> propT) --> propT))) (Thm.cabs_name (x, t) A) end;
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
   120
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
   121
fun all t A = all_name ("", t) A;
9bdd47909ea8 lambda/cabs/all: named variants;
wenzelm
parents: 31977
diff changeset
   122
22907
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   123
fun mk_binop c a b = Thm.capply (Thm.capply c a) b;
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   124
fun dest_binop ct = (Thm.dest_arg1 ct, Thm.dest_arg ct);
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   125
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   126
fun dest_implies ct =
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   127
  (case Thm.term_of ct of
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   128
    Const ("==>", _) $ _ $ _ => dest_binop ct
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   129
  | _ => raise TERM ("dest_implies", [Thm.term_of ct]));
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   130
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   131
fun dest_equals ct =
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   132
  (case Thm.term_of ct of
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   133
    Const ("==", _) $ _ $ _ => dest_binop ct
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   134
  | _ => raise TERM ("dest_equals", [Thm.term_of ct]));
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   135
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   136
fun dest_equals_lhs ct =
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   137
  (case Thm.term_of ct of
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   138
    Const ("==", _) $ _ $ _ => Thm.dest_arg1 ct
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   139
  | _ => raise TERM ("dest_equals_lhs", [Thm.term_of ct]));
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   140
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   141
fun dest_equals_rhs ct =
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   142
  (case Thm.term_of ct of
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   143
    Const ("==", _) $ _ $ _ => Thm.dest_arg ct
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   144
  | _ => raise TERM ("dest_equals_rhs", [Thm.term_of ct]));
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   145
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   146
val lhs_of = dest_equals_lhs o Thm.cprop_of;
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   147
val rhs_of = dest_equals_rhs o Thm.cprop_of;
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   148
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   149
dccd0763ae37 added destructors from drule.ML;
wenzelm
parents: 22695
diff changeset
   150
(* thm order: ignores theory context! *)
22682
92448396c9d9 added read_def_cterms, read_cterm (from thm.ML);
wenzelm
parents: 22378
diff changeset
   151
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   152
fun thm_ord (th1, th2) =
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   153
  let
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   154
    val {shyps = shyps1, hyps = hyps1, tpairs = tpairs1, prop = prop1, ...} = Thm.rep_thm th1;
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   155
    val {shyps = shyps2, hyps = hyps2, tpairs = tpairs2, prop = prop2, ...} = Thm.rep_thm th2;
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   156
  in
35408
b48ab741683b modernized structure Term_Ord;
wenzelm
parents: 35238
diff changeset
   157
    (case Term_Ord.fast_term_ord (prop1, prop2) of
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   158
      EQUAL =>
35408
b48ab741683b modernized structure Term_Ord;
wenzelm
parents: 35238
diff changeset
   159
        (case list_ord (prod_ord Term_Ord.fast_term_ord Term_Ord.fast_term_ord) (tpairs1, tpairs2) of
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   160
          EQUAL =>
35408
b48ab741683b modernized structure Term_Ord;
wenzelm
parents: 35238
diff changeset
   161
            (case list_ord Term_Ord.fast_term_ord (hyps1, hyps2) of
b48ab741683b modernized structure Term_Ord;
wenzelm
parents: 35238
diff changeset
   162
              EQUAL => list_ord Term_Ord.sort_ord (shyps1, shyps2)
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   163
            | ord => ord)
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   164
        | ord => ord)
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   165
    | ord => ord)
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   166
  end;
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   167
22682
92448396c9d9 added read_def_cterms, read_cterm (from thm.ML);
wenzelm
parents: 22378
diff changeset
   168
32842
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   169
(* tables and caches *)
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   170
35408
b48ab741683b modernized structure Term_Ord;
wenzelm
parents: 35238
diff changeset
   171
structure Ctermtab = Table(type key = cterm val ord = Term_Ord.fast_term_ord o pairself Thm.term_of);
32842
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   172
structure Thmtab = Table(type key = thm val ord = thm_ord);
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   173
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   174
fun cterm_cache f = Cache.create Ctermtab.empty Ctermtab.lookup Ctermtab.update f;
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   175
fun thm_cache f = Cache.create Thmtab.empty Thmtab.lookup Thmtab.update f;
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   176
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   177
22682
92448396c9d9 added read_def_cterms, read_cterm (from thm.ML);
wenzelm
parents: 22378
diff changeset
   178
(* equality *)
92448396c9d9 added read_def_cterms, read_cterm (from thm.ML);
wenzelm
parents: 22378
diff changeset
   179
23599
d889725b0d8a added is_reflexive;
wenzelm
parents: 23491
diff changeset
   180
fun is_reflexive th = op aconv (Logic.dest_equals (Thm.prop_of th))
d889725b0d8a added is_reflexive;
wenzelm
parents: 23491
diff changeset
   181
  handle TERM _ => false;
d889725b0d8a added is_reflexive;
wenzelm
parents: 23491
diff changeset
   182
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   183
fun eq_thm ths =
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   184
  Context.joinable (pairself Thm.theory_of_thm ths) andalso
26653
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   185
  is_equal (thm_ord ths);
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   186
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   187
val eq_thms = eq_list eq_thm;
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   188
26665
2e363edf7578 Theory.eq_thy;
wenzelm
parents: 26653
diff changeset
   189
val eq_thm_thy = Theory.eq_thy o pairself Thm.theory_of_thm;
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   190
val eq_thm_prop = op aconv o pairself Thm.full_prop_of;
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   191
22682
92448396c9d9 added read_def_cterms, read_cterm (from thm.ML);
wenzelm
parents: 22378
diff changeset
   192
92448396c9d9 added read_def_cterms, read_cterm (from thm.ML);
wenzelm
parents: 22378
diff changeset
   193
(* pattern equivalence *)
92448396c9d9 added read_def_cterms, read_cterm (from thm.ML);
wenzelm
parents: 22378
diff changeset
   194
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   195
fun equiv_thm ths =
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   196
  Pattern.equiv (Theory.merge (pairself Thm.theory_of_thm ths)) (pairself Thm.full_prop_of ths);
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   197
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   198
31904
a86896359ca4 renamed Drule.sort_triv to Thm.sort_triv (cf. more_thm.ML);
wenzelm
parents: 31177
diff changeset
   199
(* type classes and sorts *)
a86896359ca4 renamed Drule.sort_triv to Thm.sort_triv (cf. more_thm.ML);
wenzelm
parents: 31177
diff changeset
   200
31944
c8a35979a5bc clarified Thm.of_class/of_sort/class_triv;
wenzelm
parents: 31904
diff changeset
   201
fun class_triv thy c =
c8a35979a5bc clarified Thm.of_class/of_sort/class_triv;
wenzelm
parents: 31904
diff changeset
   202
  Thm.of_class (Thm.ctyp_of thy (TVar ((Name.aT, 0), [c])), c);
c8a35979a5bc clarified Thm.of_class/of_sort/class_triv;
wenzelm
parents: 31904
diff changeset
   203
c8a35979a5bc clarified Thm.of_class/of_sort/class_triv;
wenzelm
parents: 31904
diff changeset
   204
fun of_sort (T, S) = map (fn c => Thm.of_class (T, c)) S;
28621
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   205
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   206
fun check_shyps sorts raw_th =
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   207
  let
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   208
    val th = Thm.strip_shyps raw_th;
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   209
    val prt_sort = Syntax.pretty_sort_global (Thm.theory_of_thm th);
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   210
    val pending = Sorts.subtract sorts (Thm.extra_shyps th);
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   211
  in
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   212
    if null pending then th
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   213
    else error (Pretty.string_of (Pretty.block (Pretty.str "Pending sort hypotheses:" ::
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   214
      Pretty.brk 1 :: Pretty.commas (map prt_sort pending))))
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   215
  end;
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   216
a60164e8fff0 added check_shyps, which reject pending sort hypotheses;
wenzelm
parents: 28116
diff changeset
   217
22695
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   218
(* misc operations *)
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   219
24048
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   220
fun is_dummy thm =
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   221
  (case try Logic.dest_term (Thm.concl_of thm) of
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   222
    NONE => false
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   223
  | SOME t => Term.is_dummy_pattern t);
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   224
22695
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   225
fun plain_prop_of raw_thm =
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   226
  let
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   227
    val thm = Thm.strip_shyps raw_thm;
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   228
    fun err msg = raise THM ("plain_prop_of: " ^ msg, 0, [thm]);
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   229
    val {hyps, prop, tpairs, ...} = Thm.rep_thm thm;
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   230
  in
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   231
    if not (null hyps) then
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   232
      err "theorem may not contain hypotheses"
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   233
    else if not (null (Thm.extra_shyps thm)) then
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   234
      err "theorem may not contain sort hypotheses"
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   235
    else if not (null tpairs) then
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   236
      err "theorem may not contain flex-flex pairs"
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   237
    else prop
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   238
  end;
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   239
17073e9b94f2 moved Drule.plain_prop_of, Drule.fold_terms to more_thm.ML;
wenzelm
parents: 22682
diff changeset
   240
30564
deddb8a1516f tuned comment;
wenzelm
parents: 30560
diff changeset
   241
(* collections of theorems in canonical order *)
24048
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   242
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   243
val add_thm = update eq_thm_prop;
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   244
val del_thm = remove eq_thm_prop;
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   245
val merge_thms = merge eq_thm_prop;
a12b4faff474 moved Drule.add/del/merge_rules to Thm.add/del/merge_thms;
wenzelm
parents: 23599
diff changeset
   246
33453
fe551dc9d4bd scalable version of Named_Thms, using Item_Net;
wenzelm
parents: 33373
diff changeset
   247
val full_rules = Item_Net.init eq_thm_prop (single o Thm.full_prop_of);
33373
674df68d4df0 adapted Item_Net;
wenzelm
parents: 33315
diff changeset
   248
val intro_rules = Item_Net.init eq_thm_prop (single o Thm.concl_of);
674df68d4df0 adapted Item_Net;
wenzelm
parents: 33315
diff changeset
   249
val elim_rules = Item_Net.init eq_thm_prop (single o Thm.major_prem_of);
30560
0cc3b7f03ade adapted to general Item_Net;
wenzelm
parents: 30433
diff changeset
   250
0cc3b7f03ade adapted to general Item_Net;
wenzelm
parents: 30433
diff changeset
   251
22682
92448396c9d9 added read_def_cterms, read_cterm (from thm.ML);
wenzelm
parents: 22378
diff changeset
   252
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   253
(** basic derived rules **)
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   254
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   255
(*Elimination of implication
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   256
  A    A ==> B
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   257
  ------------
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   258
        B
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   259
*)
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   260
fun elim_implies thA thAB = Thm.implies_elim thAB thA;
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   261
26653
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   262
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   263
(* forall_elim_var(s) *)
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   264
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   265
local
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   266
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   267
fun forall_elim_vars_aux strip_vars i th =
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   268
  let
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   269
    val thy = Thm.theory_of_thm th;
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   270
    val {tpairs, prop, ...} = Thm.rep_thm th;
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   271
    val add_used = Term.fold_aterms
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   272
      (fn Var ((x, j), _) => if i = j then insert (op =) x else I | _ => I);
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   273
    val used = fold (fn (t, u) => add_used t o add_used u) tpairs (add_used prop []);
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   274
    val vars = strip_vars prop;
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   275
    val cvars = (Name.variant_list used (map #1 vars), vars)
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   276
      |> ListPair.map (fn (x, (_, T)) => Thm.cterm_of thy (Var ((x, i), T)));
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   277
  in fold Thm.forall_elim cvars th end;
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   278
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   279
in
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   280
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   281
val forall_elim_vars = forall_elim_vars_aux Term.strip_all_vars;
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   282
33697
wenzelm
parents: 33666
diff changeset
   283
fun forall_elim_var i th =
wenzelm
parents: 33666
diff changeset
   284
  forall_elim_vars_aux
wenzelm
parents: 33666
diff changeset
   285
    (fn Const ("all", _) $ Abs (a, T, _) => [(a, T)]
wenzelm
parents: 33666
diff changeset
   286
      | _ => raise THM ("forall_elim_vars", i, [th])) i th;
26653
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   287
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   288
end;
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   289
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   290
32279
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   291
(* certify_instantiate *)
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   292
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   293
fun certify_inst thy (instT, inst) =
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   294
  (map (fn (v, T) => (Thm.ctyp_of thy (TVar v), Thm.ctyp_of thy T)) instT,
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   295
    map (fn (v, t) => (Thm.cterm_of thy (Var v), Thm.cterm_of thy t)) inst);
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   296
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   297
fun certify_instantiate insts th =
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   298
  Thm.instantiate (certify_inst (Thm.theory_of_thm th) insts) th;
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   299
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   300
35985
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   301
(* forall_intr_frees: generalization over all suitable Free variables *)
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   302
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   303
fun forall_intr_frees th =
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   304
  let
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   305
    val thy = Thm.theory_of_thm th;
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   306
    val {prop, hyps, tpairs, ...} = Thm.rep_thm th;
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   307
    val fixed = fold Term.add_frees (Thm.terms_of_tpairs tpairs @ hyps) [];
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   308
    val frees = Term.fold_aterms (fn Free v =>
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   309
      if member (op =) fixed v then I else insert (op =) v | _ => I) prop [];
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   310
  in fold (Thm.forall_intr o Thm.cterm_of thy o Free) frees th end;
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   311
0bbf0d2348f9 moved Drule.forall_intr_frees to Thm.forall_intr_frees (in more_thm.ML, which is loaded before pure_thy.ML);
wenzelm
parents: 35857
diff changeset
   312
35845
e5980f0ad025 renamed varify/unvarify operations to varify_global/unvarify_global to emphasize that these only work in a global situation;
wenzelm
parents: 35715
diff changeset
   313
(* unvarify_global: global schematic variables *)
26653
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   314
35845
e5980f0ad025 renamed varify/unvarify operations to varify_global/unvarify_global to emphasize that these only work in a global situation;
wenzelm
parents: 35715
diff changeset
   315
fun unvarify_global th =
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   316
  let
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   317
    val prop = Thm.full_prop_of th;
35845
e5980f0ad025 renamed varify/unvarify operations to varify_global/unvarify_global to emphasize that these only work in a global situation;
wenzelm
parents: 35715
diff changeset
   318
    val _ = map Logic.unvarify_global (prop :: Thm.hyps_of th)
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   319
      handle TERM (msg, _) => raise THM (msg, 0, [th]);
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   320
32279
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   321
    val instT = rev (Term.add_tvars prop []) |> map (fn v as ((a, _), S) => (v, TFree (a, S)));
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   322
    val inst = rev (Term.add_vars prop []) |> map (fn ((a, i), T) =>
32279
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   323
      let val T' = Term_Subst.instantiateT instT T
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   324
      in (((a, i), T'), Free ((a, T'))) end);
e40563627419 added certify_inst, certify_instantiate;
wenzelm
parents: 32198
diff changeset
   325
  in certify_instantiate (instT, inst) th end;
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   326
26653
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   327
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   328
(* close_derivation *)
60e0cf6bef89 Thm.forall_elim_var(s);
wenzelm
parents: 26628
diff changeset
   329
26628
63306cb94313 replaced Drule.close_derivation/Goal.close_result by Thm.close_derivation (removed obsolete compression);
wenzelm
parents: 25518
diff changeset
   330
fun close_derivation thm =
36744
6e1f3d609a68 renamed Thm.get_name -> Thm.derivation_name and Thm.put_name -> Thm.name_derivation, to emphasize the true nature of these operations;
wenzelm
parents: 36106
diff changeset
   331
  if Thm.derivation_name thm = "" then Thm.name_derivation "" thm
26628
63306cb94313 replaced Drule.close_derivation/Goal.close_result by Thm.close_derivation (removed obsolete compression);
wenzelm
parents: 25518
diff changeset
   332
  else thm;
63306cb94313 replaced Drule.close_derivation/Goal.close_result by Thm.close_derivation (removed obsolete compression);
wenzelm
parents: 25518
diff changeset
   333
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   334
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   335
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   336
(** specification primitives **)
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   337
30342
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   338
(* rules *)
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   339
35855
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   340
fun stripped_sorts thy t =
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   341
  let
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   342
    val tfrees = rev (map TFree (Term.add_tfrees t []));
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   343
    val tfrees' = map (fn a => TFree (a, [])) (Name.invents Name.context Name.aT (length tfrees));
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   344
    val strip = tfrees ~~ tfrees';
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   345
    val recover = map (pairself (Thm.ctyp_of thy o Logic.varifyT_global) o swap) strip;
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   346
    val t' = Term.map_types (Term.map_atyps (perhaps (AList.lookup (op =) strip))) t;
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   347
  in (strip, recover, t') end;
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   348
29579
cb520b766e00 binding replaces bstring
haftmann
parents: 29269
diff changeset
   349
fun add_axiom (b, prop) thy =
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   350
  let
35853
f2126d4d0486 more explicit invented name;
wenzelm
parents: 35845
diff changeset
   351
    val b' = if Binding.is_empty b then Binding.name ("unnamed_axiom_" ^ serial_string ()) else b;
36106
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
   352
39133
70d3915c92f0 pretty printing: prefer regular Proof.context over Pretty.pp, which is mostly for special bootstrap purposes involving theory merge, for example;
wenzelm
parents: 36744
diff changeset
   353
    val _ = Sign.no_vars (Syntax.init_pretty_global thy) prop;
35855
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   354
    val (strip, recover, prop') = stripped_sorts thy prop;
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   355
    val constraints = map (fn (TFree (_, S), T) => (T, S)) strip;
e7d004b89ca8 add_axiom: axiomatize "unconstrained" version, with explicit of_class premises;
wenzelm
parents: 35853
diff changeset
   356
    val of_sorts = maps (fn (T as TFree (_, S), _) => of_sort (Thm.ctyp_of thy T, S)) strip;
36106
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
   357
35857
28e73b3e7b6c replaced Theory.add_axioms(_i) by more primitive Theory.add_axiom;
wenzelm
parents: 35855
diff changeset
   358
    val thy' =
28e73b3e7b6c replaced Theory.add_axioms(_i) by more primitive Theory.add_axiom;
wenzelm
parents: 35855
diff changeset
   359
      Theory.add_axiom (b', Logic.list_implies (maps Logic.mk_of_sort constraints, prop')) thy;
36106
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
   360
    val axm_name = Sign.full_name thy' b';
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
   361
    val axm' = Thm.axiom thy' axm_name;
35988
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   362
    val thm =
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   363
      Thm.instantiate (recover, []) axm'
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   364
      |> unvarify_global
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   365
      |> fold elim_implies of_sorts;
36106
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
   366
  in ((axm_name, thm), thy') end;
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   367
29579
cb520b766e00 binding replaces bstring
haftmann
parents: 29269
diff changeset
   368
fun add_def unchecked overloaded (b, prop) thy =
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   369
  let
39133
70d3915c92f0 pretty printing: prefer regular Proof.context over Pretty.pp, which is mostly for special bootstrap purposes involving theory merge, for example;
wenzelm
parents: 36744
diff changeset
   370
    val _ = Sign.no_vars (Syntax.init_pretty_global thy) prop;
35988
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   371
    val prems = map (Thm.cterm_of thy) (Logic.strip_imp_prems prop);
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   372
    val (_, recover, concl') = stripped_sorts thy (Logic.strip_imp_concl prop);
36106
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
   373
35988
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   374
    val thy' = Theory.add_def unchecked overloaded (b, concl') thy;
36106
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
   375
    val axm_name = Sign.full_name thy' b;
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
   376
    val axm' = Thm.axiom thy' axm_name;
35988
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   377
    val thm =
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   378
      Thm.instantiate (recover, []) axm'
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   379
      |> unvarify_global
76ca601c941e disallow premises in primitive Theory.add_def -- handle in Thm.add_def;
wenzelm
parents: 35985
diff changeset
   380
      |> fold_rev Thm.implies_intr prems;
36106
19deea200358 Thm.add_axiom/add_def: return internal name of foundational axiom;
wenzelm
parents: 35988
diff changeset
   381
  in ((axm_name, thm), thy') end;
24980
16a74cfca971 added elim_implies (more convenient argument order);
wenzelm
parents: 24948
diff changeset
   382
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   383
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   384
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   385
(** attributes **)
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   386
40238
edcdecd55655 type attribute is derived concept outside the kernel;
wenzelm
parents: 39133
diff changeset
   387
(*attributes subsume any kind of rules or context modifiers*)
edcdecd55655 type attribute is derived concept outside the kernel;
wenzelm
parents: 39133
diff changeset
   388
type attribute = Context.generic * thm -> Context.generic * thm;
edcdecd55655 type attribute is derived concept outside the kernel;
wenzelm
parents: 39133
diff changeset
   389
30210
225fa48756b2 added type binding and val empty_binding;
wenzelm
parents: 29579
diff changeset
   390
type binding = binding * attribute list;
225fa48756b2 added type binding and val empty_binding;
wenzelm
parents: 29579
diff changeset
   391
val empty_binding: binding = (Binding.empty, []);
225fa48756b2 added type binding and val empty_binding;
wenzelm
parents: 29579
diff changeset
   392
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   393
fun rule_attribute f (x, th) = (x, f x th);
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   394
fun declaration_attribute f (x, th) = (f th x, th);
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   395
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   396
fun apply_attributes mk dest =
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   397
  let
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   398
    fun app [] = I
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   399
      | app ((f: attribute) :: fs) = fn (x, th) => f (mk x, th) |>> dest |> app fs;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   400
  in app end;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   401
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   402
val theory_attributes = apply_attributes Context.Theory Context.the_theory;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   403
val proof_attributes = apply_attributes Context.Proof Context.the_proof;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   404
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   405
fun no_attributes x = (x, []);
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   406
fun simple_fact x = [(x, [])];
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   407
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   408
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   409
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   410
(*** theorem tags ***)
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   411
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   412
(* add / delete tags *)
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   413
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   414
fun tag_rule tg = Thm.map_tags (insert (op =) tg);
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   415
fun untag_rule s = Thm.map_tags (filter_out (fn (s', _) => s = s'));
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   416
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   417
fun tag tg x = rule_attribute (K (tag_rule tg)) x;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   418
fun untag s x = rule_attribute (K (untag_rule s)) x;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   419
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   420
30342
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   421
(* def_name *)
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   422
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   423
fun def_name c = c ^ "_def";
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   424
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   425
fun def_name_optional c "" = def_name c
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   426
  | def_name_optional _ name = name;
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   427
35238
18ae6ef02fe0 Thm.def_binding;
wenzelm
parents: 33713
diff changeset
   428
val def_binding = Binding.map_name def_name;
18ae6ef02fe0 Thm.def_binding;
wenzelm
parents: 33713
diff changeset
   429
30433
ce5138c92ca7 added def_binding_optional -- robust version of def_name_optional for bindings;
wenzelm
parents: 30342
diff changeset
   430
fun def_binding_optional b name =
35238
18ae6ef02fe0 Thm.def_binding;
wenzelm
parents: 33713
diff changeset
   431
  if Binding.is_empty name then def_binding b else name;
30433
ce5138c92ca7 added def_binding_optional -- robust version of def_name_optional for bindings;
wenzelm
parents: 30342
diff changeset
   432
30342
d32daa6aba3c moved Thm.def_name(_optional) to more_thm.ML;
wenzelm
parents: 30210
diff changeset
   433
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   434
(* unofficial theorem names *)
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   435
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   436
fun the_name_hint thm = the (AList.lookup (op =) (Thm.get_tags thm) Markup.nameN);
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   437
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   438
val has_name_hint = can the_name_hint;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   439
val get_name_hint = the_default "??.unknown" o try the_name_hint;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   440
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   441
fun put_name_hint name = untag_rule Markup.nameN #> tag_rule (Markup.nameN, name);
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   442
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   443
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   444
(* theorem kinds *)
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   445
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   446
val definitionK = "definition";
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   447
val theoremK = "theorem";
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   448
val lemmaK = "lemma";
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   449
val corollaryK = "corollary";
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   450
33315
784c1b09d485 eliminated obsolete/unused Thm.kind_internal/is_internal etc.;
wenzelm
parents: 33167
diff changeset
   451
fun get_kind thm = the_default "" (Properties.get (Thm.get_tags thm) Markup.kindN);
27866
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   452
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   453
fun kind_rule k = tag_rule (Markup.kindN, k) o untag_rule Markup.kindN;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   454
fun kind k x = if k = "" then x else rule_attribute (K (kind_rule k)) x;
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   455
c721ea6e0eb4 moved basic thm operations from structure PureThy to Thm;
wenzelm
parents: 27255
diff changeset
   456
22362
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   457
open Thm;
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   458
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   459
end;
6470ce514b6e Further operations on type thm, outside the inference kernel.
wenzelm
parents:
diff changeset
   460
32842
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   461
structure Basic_Thm: BASIC_THM = Thm;
98702c579ad0 added Ctermtab, cterm_cache, thm_cache;
wenzelm
parents: 32279
diff changeset
   462
open Basic_Thm;
23170
94e9413bd7fc made aconvc pervasive;
wenzelm
parents: 23169
diff changeset
   463