Nominal/nominal_dt_rawfuns.ML
author Christian Urban <urbanc@in.tum.de>
Wed, 29 Feb 2012 16:57:25 +0000
changeset 3130 8fc6b801985b
parent 3065 51ef8a3cb6ef
child 3218 89158f401b07
permissions -rw-r--r--
final changes to the lmcs paper
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2297
Christian Urban <urbanc@in.tum.de>
parents: 2296
diff changeset
     1
(*  Title:      nominal_dt_rawfuns.ML
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
    Author:     Cezary Kaliszyk
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
    Author:     Christian Urban
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
     5
  Definitions of the raw fv, fv_bn and permute functions.
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
*)
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
signature NOMINAL_DT_RAWFUNS =
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
sig
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    10
  val get_all_binders: bclause list -> (term option * int) list
2616
dd7490fdd998 all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
    11
  val is_recursive_binder: bclause -> bool
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    12
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
    13
  val define_raw_bns: raw_dt_info -> (binding * typ option * mixfix) list -> 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
    14
    (Attrib.binding * term) list -> local_theory ->
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
    15
    (term list * thm list * bn_info list * thm list * local_theory) 
2601
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    16
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
    17
  val define_raw_fvs: raw_dt_info -> bn_info list -> bclause list list list -> 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
    18
    Proof.context -> term list * term list * thm list * thm list * local_theory
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
    19
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
    20
  val define_raw_bn_perms: raw_dt_info -> bn_info list -> local_theory -> 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
    21
    (term list * thm list * local_theory)
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
    22
 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
    23
  val define_raw_perms: raw_dt_info -> local_theory -> (term list * thm list * thm list) * local_theory
2305
93ab397f5980 smaller code for raw-eqvt proofs
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
    24
 
93ab397f5980 smaller code for raw-eqvt proofs
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
    25
  val raw_prove_eqvt: term list -> thm list -> thm list -> Proof.context -> thm list
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
    26
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
end
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
structure Nominal_Dt_RawFuns: NOMINAL_DT_RAWFUNS =
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
struct
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
    33
open Nominal_Permeq 
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    35
fun get_all_binders bclauses = 
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    36
  bclauses
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2608
diff changeset
    37
  |> map (fn (BC (_, binders, _)) => binders) 
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    38
  |> flat
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    39
  |> remove_dups (op =)
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    40
2616
dd7490fdd998 all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
    41
fun is_recursive_binder (BC (_, binders, bodies)) =
dd7490fdd998 all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
    42
  case (inter (op =) (map snd binders) bodies) of
dd7490fdd998 all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
    43
    nil => false
dd7490fdd998 all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
    44
  | _ => true
dd7490fdd998 all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
    45
  
dd7490fdd998 all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
    46
2438
abafea9b39bb corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents: 2431
diff changeset
    47
fun lookup xs x = the (AList.lookup (op=) xs x)
abafea9b39bb corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents: 2431
diff changeset
    48
abafea9b39bb corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents: 2431
diff changeset
    49
2601
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    50
(** functions that define the raw binding functions **)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    51
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    52
(* strip_bn_fun takes a rhs of a bn function: this can only contain unions or
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    53
   appends of elements; in case of recursive calls it returns also the applied
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    54
   bn function *)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    55
fun strip_bn_fun lthy args t =
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    56
let 
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    57
  fun aux t =
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    58
    case t of
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    59
      Const (@{const_name sup}, _) $ l $ r => aux l @ aux r
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    60
    | Const (@{const_name append}, _) $ l $ r => aux l @ aux r
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    61
    | Const (@{const_name insert}, _) $ (Const (@{const_name atom}, _) $ (x as Var _)) $ y =>
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    62
        (find_index (equal x) args, NONE) :: aux y
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    63
    | Const (@{const_name Cons}, _) $ (Const (@{const_name atom}, _) $ (x as Var _)) $ y =>
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    64
        (find_index (equal x) args, NONE) :: aux y
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    65
    | Const (@{const_name bot}, _) => []
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    66
    | Const (@{const_name Nil}, _) => []
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    67
    | (f as Const _) $ (x as Var _) => [(find_index (equal x) args, SOME f)]
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    68
    | _ => error ("Unsupported binding function: " ^ (Syntax.string_of_term lthy t))
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    69
in
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    70
  aux t
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    71
end  
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    72
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    73
(** definition of the raw binding functions **)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    74
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    75
fun prep_bn_info lthy dt_names dts bn_funs eqs = 
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    76
let
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    77
  fun process_eq eq = 
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    78
  let
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    79
    val (lhs, rhs) = eq
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    80
      |> HOLogic.dest_Trueprop
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    81
      |> HOLogic.dest_eq
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    82
    val (bn_fun, [cnstr]) = strip_comb lhs
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    83
    val (_, ty) = dest_Const bn_fun
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    84
    val (ty_name, _) = dest_Type (domain_type ty)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    85
    val dt_index = find_index (fn x => x = ty_name) dt_names
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    86
    val (cnstr_head, cnstr_args) = strip_comb cnstr    
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    87
    val cnstr_name = Long_Name.base_name (fst (dest_Const cnstr_head))
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    88
    val rhs_elements = strip_bn_fun lthy cnstr_args rhs
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    89
  in
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    90
    ((bn_fun, dt_index), (cnstr_name, rhs_elements))
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    91
  end
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    92
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    93
  (* order according to constructor names *)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    94
  fun cntrs_order ((bn, dt_index), data) = 
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    95
  let
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    96
    val dt = nth dts dt_index                      
3065
51ef8a3cb6ef updated to lates changes in the datatype package
Christian Urban <urbanc@in.tum.de>
parents: 3061
diff changeset
    97
    val cts = snd dt     
2601
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    98
    val ct_names = map (Binding.name_of o (fn (x, _, _) => x)) cts  
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
    99
  in
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   100
    (bn, (bn, dt_index, order (op=) ct_names data))
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   101
  end 
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   102
in
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   103
  eqs
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   104
  |> map process_eq 
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   105
  |> AList.group (op=)      (* eqs grouped according to bn_functions *)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   106
  |> map cntrs_order        (* inner data ordered according to constructors *)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   107
  |> order (op=) bn_funs    (* ordered according to bn_functions *)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   108
end
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   109
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   110
fun define_raw_bns raw_dt_info raw_bn_funs raw_bn_eqs lthy =
2601
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   111
  if null raw_bn_funs 
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   112
  then ([], [], [], [], lthy)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   113
  else 
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   114
    let
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   115
      val RawDtInfo 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   116
        {raw_dt_names, raw_dts, raw_inject_thms, raw_distinct_thms, raw_size_thms, ...} = raw_dt_info 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   117
2601
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   118
      val (_, lthy1) = Function.add_function raw_bn_funs raw_bn_eqs
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   119
        Function_Common.default_config (pat_completeness_simp (raw_inject_thms @ raw_distinct_thms)) lthy
2601
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   120
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   121
      val (info, lthy2) = prove_termination_fun raw_size_thms (Local_Theory.restore lthy1)
2601
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   122
      val {fs, simps, inducts, ...} = info
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   123
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   124
      val raw_bn_induct = (the inducts)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   125
      val raw_bn_eqs = the simps
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   126
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   127
      val raw_bn_info = 
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   128
        prep_bn_info lthy raw_dt_names raw_dts fs (map prop_of raw_bn_eqs)
2601
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   129
    in
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   130
      (fs, raw_bn_eqs, raw_bn_info, raw_bn_induct, lthy2)
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   131
    end
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   132
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   133
89c55d36980f moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents: 2598
diff changeset
   134
2295
8aff3f3ce47f started to work on alpha
Christian Urban <urbanc@in.tum.de>
parents: 2294
diff changeset
   135
(** functions that construct the equations for fv and fv_bn **)
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   136
2464
f4eba60cbd69 made the fv-definition aggree more with alpha (needed in the support proofs)
Christian Urban <urbanc@in.tum.de>
parents: 2438
diff changeset
   137
fun mk_fv_rhs lthy fv_map fv_bn_map args (BC (bmode, binders, bodies)) =
2295
8aff3f3ce47f started to work on alpha
Christian Urban <urbanc@in.tum.de>
parents: 2294
diff changeset
   138
  let
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   139
    fun mk_fv_body fv_map args i = 
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   140
      let
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   141
        val arg = nth args i
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   142
        val ty = fastype_of arg
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   143
      in
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   144
        case AList.lookup (op=) fv_map ty of
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   145
          NONE => mk_supp arg
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   146
        | SOME fv => fv $ arg
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   147
      end  
2295
8aff3f3ce47f started to work on alpha
Christian Urban <urbanc@in.tum.de>
parents: 2294
diff changeset
   148
2464
f4eba60cbd69 made the fv-definition aggree more with alpha (needed in the support proofs)
Christian Urban <urbanc@in.tum.de>
parents: 2438
diff changeset
   149
  fun mk_fv_binder lthy fv_bn_map args binders = 
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   150
    let
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   151
      fun bind_set lthy args (NONE, i) = (setify lthy (nth args i), @{term "{}::atom set"})
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   152
        | bind_set _ args (SOME bn, i) = (bn $ (nth args i), 
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   153
            if  member (op=) bodies i then @{term "{}::atom set"}  
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   154
            else lookup fv_bn_map bn $ (nth args i))
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   155
      fun bind_lst lthy args (NONE, i) = (listify lthy (nth args i), @{term "[]::atom list"})
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   156
        | bind_lst _ args (SOME bn, i) = (bn $ (nth args i),
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   157
            if  member (op=) bodies i then @{term "[]::atom list"}  
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   158
            else lookup fv_bn_map bn $ (nth args i)) 
2464
f4eba60cbd69 made the fv-definition aggree more with alpha (needed in the support proofs)
Christian Urban <urbanc@in.tum.de>
parents: 2438
diff changeset
   159
  
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   160
      val (combine_fn, bind_fn) =
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   161
        case bmode of
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   162
          Lst => (fold_append, bind_lst) 
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   163
        | Set => (fold_union, bind_set)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   164
        | Res => (fold_union, bind_set)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   165
    in
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   166
      binders
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   167
      |> map (bind_fn lthy args)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   168
      |> split_list
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   169
      |> pairself combine_fn
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   170
    end  
2295
8aff3f3ce47f started to work on alpha
Christian Urban <urbanc@in.tum.de>
parents: 2294
diff changeset
   171
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   172
    val t1 = map (mk_fv_body fv_map args) bodies
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   173
    val (t2, t3) = mk_fv_binder lthy fv_bn_map args binders
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   174
  in 
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   175
    mk_union (mk_diff (fold_union t1, to_set t2), to_set t3)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   176
  end
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   177
2293
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   178
(* in case of fv_bn we have to treat the case special, where an
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   179
   "empty" binding clause is given *)
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   180
fun mk_fv_bn_rhs lthy fv_map fv_bn_map bn_args args bclause =
2295
8aff3f3ce47f started to work on alpha
Christian Urban <urbanc@in.tum.de>
parents: 2294
diff changeset
   181
  let
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   182
    fun mk_fv_bn_body i = 
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   183
    let
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   184
      val arg = nth args i
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   185
      val ty = fastype_of arg
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   186
    in
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   187
      case AList.lookup (op=) bn_args i of
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   188
        NONE => (case (AList.lookup (op=) fv_map ty) of
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   189
                   NONE => mk_supp arg
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   190
                 | SOME fv => fv $ arg)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   191
      | SOME (NONE) => @{term "{}::atom set"}
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   192
      | SOME (SOME bn) => lookup fv_bn_map bn $ arg
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   193
    end  
2295
8aff3f3ce47f started to work on alpha
Christian Urban <urbanc@in.tum.de>
parents: 2294
diff changeset
   194
  in
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   195
    case bclause of
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   196
      BC (_, [], bodies) => fold_union (map mk_fv_bn_body bodies)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   197
    | _ => mk_fv_rhs lthy fv_map fv_bn_map args bclause
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   198
  end
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2295
diff changeset
   200
fun mk_fv_eq lthy fv_map fv_bn_map (constr, ty, arg_tys, _) bclauses = 
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   201
  let
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   202
    val arg_names = Datatype_Prop.make_tnames arg_tys
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   203
    val args = map Free (arg_names ~~ arg_tys)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   204
    val fv = lookup fv_map ty
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   205
    val lhs = fv $ list_comb (constr, args)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   206
    val rhs_trms = map (mk_fv_rhs lthy fv_map fv_bn_map args) bclauses
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   207
    val rhs = fold_union rhs_trms
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   208
  in
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   209
    HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, rhs))
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   210
  end
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   211
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2295
diff changeset
   212
fun mk_fv_bn_eq lthy bn_trm fv_map fv_bn_map (bn_args, (constr, _, arg_tys, _)) bclauses =
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   213
  let
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   214
    val arg_names = Datatype_Prop.make_tnames arg_tys
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   215
    val args = map Free (arg_names ~~ arg_tys)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   216
    val fv_bn = lookup fv_bn_map bn_trm
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   217
    val lhs = fv_bn $ list_comb (constr, args)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   218
    val rhs_trms = map (mk_fv_bn_rhs lthy fv_map fv_bn_map bn_args args) bclauses
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   219
    val rhs = fold_union rhs_trms
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   220
  in
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   221
    HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, rhs))
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   222
  end
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   224
fun mk_fv_bn_eqs lthy fv_map fv_bn_map constrs_info bclausesss (bn_trm, bn_n, bn_argss) = 
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   225
  let
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   226
    val nth_constrs_info = nth constrs_info bn_n
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   227
    val nth_bclausess = nth bclausesss bn_n
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   228
  in
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   229
    map2 (mk_fv_bn_eq lthy bn_trm fv_map fv_bn_map) (bn_argss ~~ nth_constrs_info) nth_bclausess
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   230
  end
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   231
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   232
fun define_raw_fvs raw_dt_info bn_info bclausesss lthy =
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   233
  let
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   234
    val RawDtInfo 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   235
      {raw_dt_names, raw_tys, raw_cns_info, raw_inject_thms, raw_distinct_thms, raw_size_thms, ...} = 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   236
        raw_dt_info
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   237
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   238
    val fv_names = map (prefix "fv_" o Long_Name.base_name) raw_dt_names
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   239
    val fv_tys = map (fn ty => ty --> @{typ "atom set"}) raw_tys
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   240
    val fv_frees = map Free (fv_names ~~ fv_tys);
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   241
    val fv_map = raw_tys ~~ fv_frees
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   242
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   243
    val (bns, bn_tys) = split_list (map (fn (bn, i, _) => (bn, i)) bn_info)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   244
    val bn_names = map (fn bn => Long_Name.base_name (fst (dest_Const bn))) bns
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   245
    val fv_bn_names = map (prefix "fv_") bn_names
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   246
    val fv_bn_arg_tys = map (nth raw_tys) bn_tys
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   247
    val fv_bn_tys = map (fn ty => ty --> @{typ "atom set"}) fv_bn_arg_tys
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   248
    val fv_bn_frees = map Free (fv_bn_names ~~ fv_bn_tys)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   249
    val fv_bn_map = bns ~~ fv_bn_frees
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   250
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   251
    val fv_eqs = map2 (map2 (mk_fv_eq lthy fv_map fv_bn_map)) raw_cns_info bclausesss 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   252
    val fv_bn_eqs = map (mk_fv_bn_eqs lthy fv_map fv_bn_map raw_cns_info bclausesss) bn_info
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   253
  
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   254
    val all_fun_names = map (fn s => (Binding.name s, NONE, NoSyn)) (fv_names @ fv_bn_names)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   255
    val all_fun_eqs = map (pair Attrib.empty_binding) (flat fv_eqs @ flat fv_bn_eqs)
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   256
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   257
    val (_, lthy') = Function.add_function all_fun_names all_fun_eqs
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   258
      Function_Common.default_config (pat_completeness_simp (raw_inject_thms @ raw_distinct_thms)) lthy
2569
94750b31a97d fixed bug in fv function where a shallow binder binds lists of names
Christian Urban <urbanc@in.tum.de>
parents: 2560
diff changeset
   259
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   260
    val (info, lthy'') = prove_termination_fun raw_size_thms (Local_Theory.restore lthy')
2410
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2409
diff changeset
   261
 
2888
eda5aeb056a6 fixed nasty bug with type variables in nominal_datatypes; this included to be careful with the output of the inductive and function package
Christian Urban <urbanc@in.tum.de>
parents: 2765
diff changeset
   262
    val {fs, simps, inducts, ...} = info; 
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   263
3045
d0ad264f8c4f updated to Isabelle 3 Nov; it includes a hack to work around a bug in the localised version of the quotient package
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   264
    val morphism = Proof_Context.export_morphism lthy'' lthy
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   265
    val simps_exp = map (Morphism.thm morphism) (the simps)
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   266
    val inducts_exp = map (Morphism.thm morphism) (the inducts)
2888
eda5aeb056a6 fixed nasty bug with type variables in nominal_datatypes; this included to be careful with the output of the inductive and function package
Christian Urban <urbanc@in.tum.de>
parents: 2765
diff changeset
   267
    
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   268
    val (fvs', fv_bns') = chop (length fv_frees) fs
2888
eda5aeb056a6 fixed nasty bug with type variables in nominal_datatypes; this included to be careful with the output of the inductive and function package
Christian Urban <urbanc@in.tum.de>
parents: 2765
diff changeset
   269
eda5aeb056a6 fixed nasty bug with type variables in nominal_datatypes; this included to be careful with the output of the inductive and function package
Christian Urban <urbanc@in.tum.de>
parents: 2765
diff changeset
   270
    (* grafting the types so that they coincide with the input into the function package *)
eda5aeb056a6 fixed nasty bug with type variables in nominal_datatypes; this included to be careful with the output of the inductive and function package
Christian Urban <urbanc@in.tum.de>
parents: 2765
diff changeset
   271
    val fvs'' = map2 (fn t => fn ty => Const (fst (dest_Const t), ty) ) fvs' fv_tys
eda5aeb056a6 fixed nasty bug with type variables in nominal_datatypes; this included to be careful with the output of the inductive and function package
Christian Urban <urbanc@in.tum.de>
parents: 2765
diff changeset
   272
    val fv_bns'' = map2 (fn t => fn ty => Const (fst (dest_Const t), ty) ) fv_bns' fv_bn_tys
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   273
  in
2888
eda5aeb056a6 fixed nasty bug with type variables in nominal_datatypes; this included to be careful with the output of the inductive and function package
Christian Urban <urbanc@in.tum.de>
parents: 2765
diff changeset
   274
    (fvs'', fv_bns'', simps_exp, inducts_exp, lthy'')
2476
8f8652a8107f tuned (to conform with indentation policy of Markus)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   275
  end
2305
93ab397f5980 smaller code for raw-eqvt proofs
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   276
93ab397f5980 smaller code for raw-eqvt proofs
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   277
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   278
(** definition of raw permute_bn functions **)
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   279
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   280
fun mk_perm_bn_eq_rhs p perm_bn_map bn_args (i, arg) = 
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   281
  case AList.lookup (op=) bn_args i of
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   282
    NONE => arg
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   283
  | SOME (NONE) => mk_perm p arg
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   284
  | SOME (SOME bn) => (lookup perm_bn_map bn) $ p $ arg   
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   285
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   286
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   287
fun mk_perm_bn_eq lthy bn_trm perm_bn_map bn_args (constr, _, arg_tys, _) =
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   288
  let
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   289
    val p = Free ("p", @{typ perm})
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   290
    val arg_names = Datatype_Prop.make_tnames arg_tys
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   291
    val args = map Free (arg_names ~~ arg_tys)
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   292
    val perm_bn = lookup perm_bn_map bn_trm
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   293
    val lhs = perm_bn $ p $ list_comb (constr, args)
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   294
    val rhs = list_comb (constr, map_index (mk_perm_bn_eq_rhs p perm_bn_map bn_args) args)
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   295
  in
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   296
    HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, rhs))
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   297
  end
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   298
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   299
fun mk_perm_bn_eqs lthy perm_bn_map cns_info (bn_trm, bn_n, bn_argss) = 
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   300
  let
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   301
    val nth_cns_info = nth cns_info bn_n
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   302
  in
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   303
    map2 (mk_perm_bn_eq lthy bn_trm perm_bn_map) bn_argss nth_cns_info
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   304
  end
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   305
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   306
fun define_raw_bn_perms raw_dt_info bn_info lthy =
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   307
  if null bn_info
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   308
  then ([], [], lthy)
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   309
  else
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   310
    let
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   311
      val RawDtInfo
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   312
        {raw_tys, raw_cns_info, raw_inject_thms, raw_distinct_thms, raw_size_thms, ...} = raw_dt_info
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   313
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   314
      val (bns, bn_tys) = split_list (map (fn (bn, i, _) => (bn, i)) bn_info)
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   315
      val bn_names = map (fn bn => Long_Name.base_name (fst (dest_Const bn))) bns
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   316
      val perm_bn_names = map (prefix "permute_") bn_names
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   317
      val perm_bn_arg_tys = map (nth raw_tys) bn_tys
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   318
      val perm_bn_tys = map (fn ty => @{typ "perm"} --> ty --> ty) perm_bn_arg_tys
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   319
      val perm_bn_frees = map Free (perm_bn_names ~~ perm_bn_tys)
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   320
      val perm_bn_map = bns ~~ perm_bn_frees
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   321
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   322
      val perm_bn_eqs = map (mk_perm_bn_eqs lthy perm_bn_map raw_cns_info) bn_info
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   323
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   324
      val all_fun_names = map (fn s => (Binding.name s, NONE, NoSyn)) perm_bn_names
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   325
      val all_fun_eqs = map (pair Attrib.empty_binding) (flat perm_bn_eqs)
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   326
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   327
      val prod_simps = @{thms prod.inject HOL.simp_thms}
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   328
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   329
      val (_, lthy') = Function.add_function all_fun_names all_fun_eqs
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   330
        Function_Common.default_config 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   331
          (pat_completeness_simp (prod_simps @ raw_inject_thms @ raw_distinct_thms)) lthy
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   332
    
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   333
      val (info, lthy'') = prove_termination_fun raw_size_thms (Local_Theory.restore lthy')
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   334
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   335
      val {fs, simps, ...} = info;
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   336
3045
d0ad264f8c4f updated to Isabelle 3 Nov; it includes a hack to work around a bug in the localised version of the quotient package
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   337
      val morphism = Proof_Context.export_morphism lthy'' lthy
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   338
      val simps_exp = map (Morphism.thm morphism) (the simps)
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   339
    in
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   340
      (fs, simps_exp, lthy'')
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   341
    end
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   342
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   343
(*** raw permutation functions ***)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   344
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   345
(** proves the two pt-type class properties **)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   346
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   347
fun prove_permute_zero induct perm_defs perm_fns lthy =
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   348
  let
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   349
    val perm_types = map (body_type o fastype_of) perm_fns
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   350
    val perm_indnames = Datatype_Prop.make_tnames perm_types
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   351
  
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   352
    fun single_goal ((perm_fn, T), x) =
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   353
      HOLogic.mk_eq (perm_fn $ @{term "0::perm"} $ Free (x, T), Free (x, T))
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   354
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   355
    val goals =
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   356
      HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   357
        (map single_goal (perm_fns ~~ perm_types ~~ perm_indnames)))
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   358
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   359
    val simps = HOL_basic_ss addsimps (@{thm permute_zero} :: perm_defs)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   360
3061
cfc795473656 updated to Isabelle 6 Dec (thanks to Odrej Kuncar)
Christian Urban <urbanc@in.tum.de>
parents: 3045
diff changeset
   361
    val tac = (Datatype_Aux.ind_tac induct perm_indnames 
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   362
               THEN_ALL_NEW asm_simp_tac simps) 1
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   363
  in
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   364
    Goal.prove lthy perm_indnames [] goals (K tac)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   365
    |> Datatype_Aux.split_conj_thm
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   366
  end
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   367
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   368
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   369
fun prove_permute_plus induct perm_defs perm_fns lthy =
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   370
  let
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   371
    val p = Free ("p", @{typ perm})
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   372
    val q = Free ("q", @{typ perm})
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   373
    val perm_types = map (body_type o fastype_of) perm_fns
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   374
    val perm_indnames = Datatype_Prop.make_tnames perm_types
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   375
  
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   376
    fun single_goal ((perm_fn, T), x) = HOLogic.mk_eq 
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   377
      (perm_fn $ (mk_plus p q) $ Free (x, T), perm_fn $ p $ (perm_fn $ q $ Free (x, T)))
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   378
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   379
    val goals =
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   380
      HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   381
        (map single_goal (perm_fns ~~ perm_types ~~ perm_indnames)))
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   382
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   383
    val simps = HOL_basic_ss addsimps (@{thm permute_plus} :: perm_defs)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   384
3061
cfc795473656 updated to Isabelle 6 Dec (thanks to Odrej Kuncar)
Christian Urban <urbanc@in.tum.de>
parents: 3045
diff changeset
   385
    val tac = (Datatype_Aux.ind_tac induct perm_indnames
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   386
               THEN_ALL_NEW asm_simp_tac simps) 1
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   387
  in
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   388
    Goal.prove lthy ("p" :: "q" :: perm_indnames) [] goals (K tac)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   389
    |> Datatype_Aux.split_conj_thm 
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   390
  end
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   391
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   392
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   393
fun mk_perm_eq ty_perm_assoc cnstr = 
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   394
  let
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   395
    fun lookup_perm p (ty, arg) = 
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   396
      case (AList.lookup (op=) ty_perm_assoc ty) of
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   397
        SOME perm => perm $ p $ arg
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   398
      | NONE => Const (@{const_name permute}, perm_ty ty) $ p $ arg
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   399
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   400
    val p = Free ("p", @{typ perm})
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   401
    val (arg_tys, ty) =
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   402
      fastype_of cnstr
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   403
      |> strip_type
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   404
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   405
    val arg_names = Name.variant_list ["p"] (Datatype_Prop.make_tnames arg_tys)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   406
    val args = map Free (arg_names ~~ arg_tys)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   407
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   408
    val lhs = lookup_perm p (ty, list_comb (cnstr, args))
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   409
    val rhs = list_comb (cnstr, map (lookup_perm p) (arg_tys ~~ args))
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   410
  
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   411
    val eq = HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, rhs))  
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   412
  in
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   413
    (Attrib.empty_binding, eq)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   414
  end
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   415
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   416
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   417
fun define_raw_perms raw_dt_info lthy =
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   418
  let
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   419
    val RawDtInfo 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   420
      {raw_dt_names, raw_tys, raw_ty_args, raw_all_cns, raw_induct_thm, ...} = raw_dt_info
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   421
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   422
    val perm_fn_names = raw_dt_names
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   423
      |> map Long_Name.base_name
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   424
      |> map (prefix "permute_")
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   425
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   426
    val perm_fn_types = map perm_ty raw_tys
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   427
    val perm_fn_frees = map Free (perm_fn_names ~~ perm_fn_types)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   428
    val perm_fn_binds = map (fn s => (Binding.name s, NONE, NoSyn)) perm_fn_names
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   429
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   430
    val perm_eqs = map (mk_perm_eq (raw_tys ~~ perm_fn_frees)) (flat raw_all_cns)
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   431
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   432
    fun tac _ (_, _, simps) =
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   433
      Class.intro_classes_tac [] THEN ALLGOALS (resolve_tac simps)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   434
  
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   435
    fun morphism phi (fvs, dfs, simps) =
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   436
      (map (Morphism.term phi) fvs, 
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   437
       map (Morphism.thm phi) dfs, 
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   438
       map (Morphism.thm phi) simps);
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   439
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   440
    val ((perm_funs, perm_eq_thms), lthy') =
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   441
      lthy
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   442
      |> Local_Theory.exit_global
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   443
      |> Class.instantiation (raw_dt_names, raw_ty_args, @{sort pt}) 
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   444
      |> Primrec.add_primrec perm_fn_binds perm_eqs
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   445
    
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   446
    val perm_zero_thms = prove_permute_zero raw_induct_thm perm_eq_thms perm_funs lthy'
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   447
    val perm_plus_thms = prove_permute_plus raw_induct_thm perm_eq_thms perm_funs lthy'  
2598
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   448
  in
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   449
    lthy'
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   450
    |> Class.prove_instantiation_exit_result morphism tac 
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   451
         (perm_funs, perm_eq_thms, perm_zero_thms @ perm_plus_thms)
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   452
    ||> Named_Target.theory_init
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   453
  end
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   454
b136721eedb2 automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   455
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   456
(** equivarance proofs **)
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   457
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   458
val eqvt_apply_sym = @{thm eqvt_apply[symmetric]}
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   459
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   460
fun subproof_tac const_names simps = 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   461
  SUBPROOF (fn {prems, context, ...} => 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   462
    HEADGOAL 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   463
      (simp_tac (HOL_basic_ss addsimps simps)
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   464
       THEN' eqvt_tac context (eqvt_relaxed_config addexcls const_names)
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   465
       THEN' simp_tac (HOL_basic_ss addsimps (prems @ [eqvt_apply_sym]))))
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   466
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   467
fun prove_eqvt_tac insts ind_thms const_names simps ctxt = 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   468
  HEADGOAL
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   469
    (Object_Logic.full_atomize_tac
3045
d0ad264f8c4f updated to Isabelle 3 Nov; it includes a hack to work around a bug in the localised version of the quotient package
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   470
     THEN' (DETERM o (Induct_Tacs.induct_rules_tac ctxt insts ind_thms))  
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   471
     THEN_ALL_NEW  subproof_tac const_names simps ctxt)
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   472
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   473
fun mk_eqvt_goal pi const arg =
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   474
  let
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   475
    val lhs = mk_perm pi (const $ arg)
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   476
    val rhs = const $ (mk_perm pi arg)  
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   477
  in
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   478
    HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, rhs))
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   479
  end
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   480
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   481
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   482
fun raw_prove_eqvt consts ind_thms simps ctxt =
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   483
  if null consts then []
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   484
  else
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   485
    let 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   486
      val ([p], ctxt') = Variable.variant_fixes ["p"] ctxt
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   487
      val p = Free (p, @{typ perm})
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   488
      val arg_tys = 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   489
        consts
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   490
        |> map fastype_of
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   491
        |> map domain_type 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   492
      val (arg_names, ctxt'') = 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   493
        Variable.variant_fixes (Datatype_Prop.make_tnames arg_tys) ctxt'
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   494
      val args = map Free (arg_names ~~ arg_tys)
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   495
      val goals = map2 (mk_eqvt_goal p) consts args
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   496
      val insts = map (single o SOME) arg_names
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   497
      val const_names = map (fst o dest_Const) consts      
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   498
    in
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   499
      Goal.prove_multi ctxt'' [] [] goals (fn {context, ...} => 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   500
        prove_eqvt_tac insts ind_thms const_names simps context)
3045
d0ad264f8c4f updated to Isabelle 3 Nov; it includes a hack to work around a bug in the localised version of the quotient package
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   501
      |> Proof_Context.export ctxt'' ctxt
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   502
    end
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   503
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2888
diff changeset
   504
2288
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   505
end (* structure *)
3b83960f9544 new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   506