src/HOL/Tools/function_package/fundef_common.ML
author krauss
Wed, 13 Sep 2006 12:05:50 +0200
changeset 20523 36a59e5d0039
parent 20289 ba7a7c56bed5
child 20654 d80502f0d701
permissions -rw-r--r--
Major update to function package, including new syntax and the (only theoretical) ability to handle local contexts.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     1
(*  Title:      HOL/Tools/function_package/fundef_common.ML
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     2
    ID:         $Id$
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     3
    Author:     Alexander Krauss, TU Muenchen
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     4
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     5
A package for general recursive function definitions. 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     6
Common type definitions and other infrastructure.
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     7
*)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     8
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     9
structure FundefCommon =
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    10
struct
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    11
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    12
(* Theory Dependencies *)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    13
val acc_const_name = "Accessible_Part.acc"
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    14
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    15
fun mk_acc domT R =
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    16
    Const (acc_const_name, (fastype_of R) --> HOLogic.mk_setT domT) $ R 
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    17
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    18
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    19
type depgraph = int IntGraph.T
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    20
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    21
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    22
datatype ctx_tree 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    23
  = Leaf of term
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    24
  | Cong of (term * thm * depgraph * ((string * typ) list * thm list * ctx_tree) list)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    25
  | RCall of (term * ctx_tree)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    26
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
    27
type glrs = (term list * term list * term * term) list
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    28
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    29
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    30
datatype globals =
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    31
   Globals of { 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    32
         fvar: term, 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    33
         domT: typ, 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    34
         ranT: typ,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    35
         h: term, 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    36
         y: term, 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    37
         x: term, 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    38
         z: term, 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    39
         a:term, 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    40
         P: term, 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    41
         D: term, 
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    42
         Pbool:term
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    43
}
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    44
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    45
19583
c5fa77b03442 function-package: Changed record usage to make sml/nj happy...
krauss
parents: 19564
diff changeset
    46
datatype rec_call_info = 
19781
c62720b20e9a HOL/Tools/function_package: More cleanup
krauss
parents: 19770
diff changeset
    47
  RCInfo of
c62720b20e9a HOL/Tools/function_package: More cleanup
krauss
parents: 19770
diff changeset
    48
  {
19922
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
    49
   RIvs: (string * typ) list,  (* Call context: fixes and assumes *)
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
    50
   CCas: thm list,
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
    51
   rcarg: term,                 (* The recursive argument *)
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
    52
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
    53
   llRI: thm,
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    54
   h_assum: term
19781
c62720b20e9a HOL/Tools/function_package: More cleanup
krauss
parents: 19770
diff changeset
    55
  } 
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    56
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    57
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    58
datatype clause_context =
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    59
  ClauseContext of
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    60
  {
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    61
    ctxt : Proof.context,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    62
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    63
    qs : term list,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    64
    gs : term list,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    65
    lhs: term,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    66
    rhs: term,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    67
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    68
    cqs: cterm list,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    69
    ags: thm list,     
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    70
    case_hyp : thm
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    71
  }
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    72
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    73
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    74
fun transfer_clause_ctx thy (ClauseContext { ctxt, qs, gs, lhs, rhs, cqs, ags, case_hyp }) =
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    75
    ClauseContext { ctxt = ProofContext.transfer thy ctxt,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    76
                    qs = qs, gs = gs, lhs = lhs, rhs = rhs, cqs = cqs, ags = ags, case_hyp = case_hyp }
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    77
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    78
19583
c5fa77b03442 function-package: Changed record usage to make sml/nj happy...
krauss
parents: 19564
diff changeset
    79
datatype clause_info =
c5fa77b03442 function-package: Changed record usage to make sml/nj happy...
krauss
parents: 19564
diff changeset
    80
  ClauseInfo of 
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    81
     {
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    82
      no: int,
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    83
      qglr : ((string * typ) list * term list * term * term),
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    84
      cdata : clause_context,
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    85
19922
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
    86
      tree: ctx_tree,
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    87
      lGI: thm,
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    88
      RCs: rec_call_info list
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    89
     }
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    90
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    91
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    92
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    93
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    94
type qgar = string * (string * typ) list * term list * term list * term
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    95
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
    96
fun name_of_fqgar (f, _, _, _, _) = f
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
    97
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
    98
datatype mutual_part =
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
    99
  MutualPart of 
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   100
	 {
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   101
          fvar : string * typ,
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   102
	  cargTs: typ list,
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   103
	  pthA: SumTools.sum_path,
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   104
	  pthR: SumTools.sum_path,
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   105
	  f_def: term,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   106
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   107
	  f: term option,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   108
          f_defthm : thm option
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   109
	 }
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   110
	 
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   111
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   112
datatype mutual_info =
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   113
  Mutual of 
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   114
	 { 
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   115
	  defname: string,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   116
          fsum_var : string * typ,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   117
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   118
	  ST: typ,
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   119
	  RST: typ,
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   120
	  streeA: SumTools.sum_tree,
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   121
	  streeR: SumTools.sum_tree,
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   122
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   123
	  parts: mutual_part list,
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   124
	  fqgars: qgar list,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   125
	  qglrs: ((string * typ) list * term list * term * term) list,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   126
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   127
          fsum : term option
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   128
	 }
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   129
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   130
19583
c5fa77b03442 function-package: Changed record usage to make sml/nj happy...
krauss
parents: 19564
diff changeset
   131
datatype prep_result =
c5fa77b03442 function-package: Changed record usage to make sml/nj happy...
krauss
parents: 19564
diff changeset
   132
  Prep of
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   133
     {
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   134
      globals: globals,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   135
      f: term,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   136
      G: term,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   137
      R: term,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   138
 
19922
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
   139
      goal: term,
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
   140
      goalI: thm,
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
   141
      values: thm list,
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
   142
      clauses: clause_info list,
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
   143
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
   144
      R_cases: thm,
984ae977f7aa Fixed name clash.
krauss
parents: 19781
diff changeset
   145
      ex1_iff: thm
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   146
     }
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   147
19583
c5fa77b03442 function-package: Changed record usage to make sml/nj happy...
krauss
parents: 19564
diff changeset
   148
datatype fundef_result =
c5fa77b03442 function-package: Changed record usage to make sml/nj happy...
krauss
parents: 19564
diff changeset
   149
  FundefResult of
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   150
     {
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   151
      f: term,
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   152
      G : term,
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   153
      R : term,
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   154
      completeness : thm,
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   155
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   156
      psimps : thm list, 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   157
      subset_pinduct : thm, 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   158
      simple_pinduct : thm, 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   159
      total_intro : thm,
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   160
      dom_intros : thm list
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   161
     }
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   162
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   163
datatype fundef_mresult =
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   164
  FundefMResult of
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   165
     {
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   166
      f: term,
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   167
      G: term,
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   168
      R: term,
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   169
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   170
      psimps : thm list, 
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   171
      subset_pinducts : thm list, 
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   172
      simple_pinducts : thm list, 
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   173
      cases : thm,
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   174
      termination : thm,
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   175
      domintros : thm list
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   176
     }
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   177
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   178
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   179
type fundef_spec = ((string * typ) * mixfix) list *((string * Attrib.src list) * term list) list list
20270
3abe7dae681e Function package can now do automatic splits of overlapping datatype patterns
krauss
parents: 19922
diff changeset
   180
type result_with_names = fundef_mresult * mutual_info * fundef_spec
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   181
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   182
structure FundefData = GenericDataFun
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   183
(struct
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   184
  val name = "HOL/function_def/data";
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19617
diff changeset
   185
  type T = string * result_with_names Symtab.table
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   186
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   187
  val empty = ("", Symtab.empty);
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   188
  val copy = I;
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   189
  val extend = I;
19617
7cb4b67d4b97 avoid raw equality on type thm;
wenzelm
parents: 19612
diff changeset
   190
  fun merge _ ((l1,tab1),(l2,tab2)) = (l1, Symtab.merge (K true) (tab1, tab2))
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   191
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   192
  fun print _ _ = ();
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   193
end);
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   194
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   195
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   196
structure FundefCongs = GenericDataFun
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   197
(struct
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   198
    val name = "HOL/function_def/congs"
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   199
    type T = thm list
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   200
    val empty = []
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   201
    val extend = I
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   202
    fun merge _ (l1, l2) = l1 @ l2
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   203
    fun print  _ _ = ()
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   204
end);
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   205
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   206
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   207
fun add_fundef_data name fundef_data =
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   208
    FundefData.map (fn (_,tab) => (name, Symtab.update_new (name, fundef_data) tab))
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   209
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   210
fun get_fundef_data name thy = Symtab.lookup (snd (FundefData.get thy)) name
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   211
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   212
fun get_last_fundef thy = fst (FundefData.get thy)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   213
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   214
val map_fundef_congs = FundefCongs.map 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   215
val get_fundef_congs = FundefCongs.get
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   216
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   217
end
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   218
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   219
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   220
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   221
(* Common Abbreviations *)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   222
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   223
structure FundefAbbrev =
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   224
struct
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   225
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   226
fun implies_elim_swp x y = implies_elim y x
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   227
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   228
(* Some HOL things frequently used *)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   229
val boolT = HOLogic.boolT
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   230
val mk_prod = HOLogic.mk_prod
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   231
val mk_mem = HOLogic.mk_mem
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   232
val mk_eq = HOLogic.mk_eq
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20289
diff changeset
   233
val eq_const = HOLogic.eq_const
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   234
val Trueprop = HOLogic.mk_Trueprop
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   235
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   236
val mk_relT = HOLogic.mk_setT o HOLogic.mk_prodT
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   237
fun mk_relmem (x,y) R = Trueprop (mk_mem (mk_prod (x, y), R))
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   238
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   239
fun mk_subset T A B = 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   240
    let val sT = HOLogic.mk_setT T
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   241
    in Const ("Orderings.less_eq", sT --> sT --> boolT) $ A $ B end
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   242
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   243
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   244
(* with explicit types: Needed with loose bounds *)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   245
fun mk_relmemT xT yT (x,y) R = 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   246
    let 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   247
	val pT = HOLogic.mk_prodT (xT, yT)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   248
	val RT = HOLogic.mk_setT pT
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   249
    in
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   250
	Const ("op :", [pT, RT] ---> boolT)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   251
	      $ (HOLogic.pair_const xT yT $ x $ y)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   252
	      $ R
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   253
    end
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   254
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   255
fun free_to_var (Free (v,T)) = Var ((v,0),T)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   256
  | free_to_var _ = raise Match
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   257
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   258
fun var_to_free (Var ((v,_),T)) = Free (v,T)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   259
  | var_to_free _ = raise Match
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   260
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   261
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
   262
end