Nominal/nominal_dt_rawfuns.ML
author Christian Urban <urbanc@in.tum.de>
Fri, 21 May 2010 11:40:18 +0100
changeset 2293 aecebd5ed424
parent 2292 d134bd4f6d1b
child 2294 72ad4e766acf
permissions -rw-r--r--
hving a working fv-definition without the export
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
     1
(*  Title:      nominal_dt_rawperm.ML
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
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
     5
  Definitions of the raw bn, fv and fv_bn
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
  functions
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
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
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
    10
sig
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
    11
  (* binding modes and binding clauses *)
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
    12
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
    13
  datatype bmode = Lst | Res | Set
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
    14
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
    15
  datatype bclause = BC of bmode * (term option * int) list * int list
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
    16
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
    17
  val setify: Proof.context -> term -> term
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
    18
  val listify: Proof.context -> term -> term
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
    19
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    20
  val define_raw_fvs: 
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    21
     string list -> term list -> 
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    22
     Datatype_Aux.descr ->
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    23
     (string * sort) list ->
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    24
     (term * int * (int * term option) list list) list ->
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    25
     (term * int * (int * term option) list list) list ->
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    26
     bclause list list list -> Proof.context -> term list * term list * thm list * local_theory
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
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
    33
datatype bmode = Lst | Res | Set
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
datatype bclause = BC of bmode * (term option * int) list * int list
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
    35
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    36
(* testing for concrete atom types *)
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
    37
fun is_atom ctxt ty =
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
    38
  Sign.of_sort (ProofContext.theory_of ctxt) (ty, @{sort at_base})
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
    39
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
    40
fun is_atom_set ctxt (Type ("fun", [t, @{typ bool}])) = is_atom ctxt t
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
    41
  | is_atom_set _ _ = false;
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
    42
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
    43
fun is_atom_fset ctxt (Type (@{type_name "fset"}, [t])) = is_atom ctxt t
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
    44
  | is_atom_fset _ _ = false;
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
    45
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
    46
fun is_atom_list ctxt (Type (@{type_name "list"}, [t])) = is_atom ctxt t
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
    47
  | is_atom_list _ _ = false
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
    48
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
    49
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    50
(* functions for producing sets, fsets and lists of general atom type
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    51
   out from concrete atom types *)
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
    52
fun mk_atom_set t =
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
    53
let
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
    54
  val ty = fastype_of t;
2290
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
    55
  val atom_ty = HOLogic.dest_setT ty --> @{typ "atom"};
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
    56
  val img_ty = atom_ty --> ty --> @{typ "atom set"};
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
    57
in
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    58
  Const (@{const_name image}, img_ty) $ mk_atom_ty atom_ty t
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    59
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
    60
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
    61
fun mk_atom_fset t =
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
    62
let
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
    63
  val ty = fastype_of t;
2290
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
    64
  val atom_ty = dest_fsetT ty --> @{typ "atom"};
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
    65
  val fmap_ty = atom_ty --> ty --> @{typ "atom fset"};
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
    66
  val fset_to_set = @{term "fset_to_set :: atom fset => atom set"}
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
    67
in
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
    68
  fset_to_set $ (Const (@{const_name fmap}, fmap_ty) $ Const (@{const_name atom}, atom_ty) $ t)
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    69
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
    70
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
    71
fun mk_atom_list t =
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
    72
let
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
    73
  val ty = fastype_of t;
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
    74
  val atom_ty = dest_listT ty --> @{typ atom};
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
    75
  val map_ty = atom_ty --> ty --> @{typ "atom list"};
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
    76
in
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    77
  Const (@{const_name map}, map_ty) $ mk_atom_ty atom_ty t
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    78
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
    79
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    80
(* functions that coerces concrete atoms, sets and fsets into sets
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    81
   of general atoms *)
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
    82
fun setify ctxt t =
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
    83
let
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
    84
  val ty = fastype_of t;
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
    85
in
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
    86
  if is_atom ctxt ty
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
    87
    then  HOLogic.mk_set @{typ atom} [mk_atom t]
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
    88
  else if is_atom_set ctxt ty
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
    89
    then mk_atom_set t
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
    90
  else if is_atom_fset ctxt ty
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
    91
    then mk_atom_fset t
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
    92
  else raise TERM ("setify", [t])
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
    93
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
    94
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    95
(* functions that coerces concrete atoms and lists into lists of 
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
    96
   general atoms  *)
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
    97
fun listify ctxt t =
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
    98
let
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
    99
  val ty = fastype_of t;
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
   100
in
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
   101
  if is_atom ctxt ty
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
   102
    then HOLogic.mk_list @{typ atom} [mk_atom t]
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
   103
  else if is_atom_list ctxt ty
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
   104
    then mk_atom_set t
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
   105
  else raise TERM ("listify", [t])
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
   106
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
   107
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
   108
(* coerces a list into a set *)
2290
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   109
fun to_set t =
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   110
  if fastype_of t = @{typ "atom list"}
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   111
  then @{term "set::atom list => atom set"} $ t
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   112
  else t
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
   113
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
   114
2290
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   115
(* functions that construct the equations for fv and fv_bn *)
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
   116
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   117
fun mk_fv_body fv_map args i = 
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
   118
let
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
   119
  val arg = nth args i
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
   120
  val ty = fastype_of arg
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
   121
in
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
   122
  case (AList.lookup (op=) fv_map ty) of
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
   123
    NONE => mk_supp arg
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
   124
  | SOME fv => fv $ arg
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
   125
end  
2293
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   126
handle Option  => error "fv_map lookup "
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   127
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   128
fun mk_fv_binder lthy fv_bn_map args (bn_option, i) = 
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   129
let
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   130
  val arg = nth args i
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   131
in
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   132
  case bn_option of
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   133
    NONE => (setify lthy arg, @{term "{}::atom set"})
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   134
  | SOME bn => (to_set (bn $ arg), the (AList.lookup (op=) fv_bn_map bn) $ arg)
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   135
end  
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   136
handle Option  => error "fv_bn_map lookup "
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
   137
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   138
fun mk_fv_bn_body fv_map fv_bn_map bn_args args i = 
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
   139
let
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
   140
  val arg = nth args i
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
   141
  val ty = fastype_of arg
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
   142
in
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
   143
  case AList.lookup (op=) bn_args i of
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
   144
    NONE => (case (AList.lookup (op=) fv_map ty) of
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
   145
              NONE => mk_supp arg
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
   146
            | SOME fv => fv $ arg)
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
   147
  | SOME (NONE) => @{term "{}::atom set"}
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
   148
  | SOME (SOME bn) => the (AList.lookup (op=) fv_bn_map bn) $ arg
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
   149
end  
2293
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   150
handle Option  => error "fv_map/fv_bn_map lookup "
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   151
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   152
fun mk_fv_rhs lthy fv_map fv_bn_map args (BC (_, binders, bodies)) =
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   153
let
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   154
  val t1 = map (mk_fv_body fv_map args) bodies
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   155
  val (t2, t3) = split_list (map (mk_fv_binder lthy fv_bn_map args) binders)
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   156
in 
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   157
  fold_union (mk_diff (fold_union t1, fold_union t2)::t3)
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   158
end
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   159
2293
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   160
(* 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
   161
   "empty" binding clause is given *)
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   162
fun mk_fv_bn_rhs lthy fv_map fv_bn_map bn_args args bclause =
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
   163
  case bclause of
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   164
    BC (_, [], bodies) => fold_union (map (mk_fv_bn_body fv_map fv_bn_map bn_args args) bodies)
2293
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   165
  | _ => mk_fv_rhs lthy fv_map fv_bn_map args bclause
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   166
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
   167
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   168
fun mk_fv_eq lthy fv_map fv_bn_map (constr, ty, arg_tys) bclauses = 
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   169
let
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   170
  val arg_names = Datatype_Prop.make_tnames arg_tys
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   171
  val args = map Free (arg_names ~~ arg_tys)
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   172
  val fv = the (AList.lookup (op=) fv_map ty)
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   173
  val lhs = fv $ list_comb (constr, args)
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   174
  val rhs_trms = map (mk_fv_rhs lthy fv_map fv_bn_map args) bclauses
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   175
  val rhs = fold_union rhs_trms
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   176
in
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   177
  HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, rhs))
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   178
end
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   179
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   180
fun mk_fv_bn_eq lthy bn_trm fv_map fv_bn_map (bn_args, (constr, _, arg_tys)) bclauses =
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
   181
let
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
   182
  val arg_names = Datatype_Prop.make_tnames arg_tys
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
   183
  val args = map Free (arg_names ~~ arg_tys)
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
   184
  val fv_bn = the (AList.lookup (op=) fv_bn_map bn_trm)
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
   185
  val lhs = fv_bn $ list_comb (constr, args)
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   186
  val rhs_trms = map (mk_fv_bn_rhs lthy fv_map fv_bn_map bn_args args) bclauses
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
   187
  val rhs = fold_union rhs_trms
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
   188
in
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
   189
  HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, rhs))
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
   190
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
   191
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   192
fun mk_fv_bn_eqs lthy fv_map fv_bn_map constrs_info bclausesss (bn_trm, bn_n, bn_argss) = 
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
   193
let
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
   194
  val nth_constrs_info = nth constrs_info bn_n
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
   195
  val nth_bclausess = nth bclausesss bn_n
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
   196
in
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   197
  map2 (mk_fv_bn_eq lthy bn_trm fv_map fv_bn_map) (bn_argss ~~ nth_constrs_info) nth_bclausess
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
   198
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
   199
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   200
fun define_raw_fvs t1 t2 dt_descr sorts bn_funs bn_funs2 bclausesss lthy =
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
   201
let
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   202
  val _ = tracing ("bn-functions to be defined\n " ^ commas t1)
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   203
  val _ = tracing ("bn-equations\n " ^ cat_lines (map (Syntax.string_of_term lthy) t2))
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
   204
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
   205
  val fv_names = prefix_dt_names dt_descr sorts "fv_"
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
   206
  val fv_arg_tys = map (fn (i, _) => nth_dtyp dt_descr sorts i) dt_descr;
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
   207
  val fv_tys = map (fn ty => ty --> @{typ "atom set"}) fv_arg_tys;
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
   208
  val fv_frees = map Free (fv_names ~~ fv_tys);
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
   209
  val fv_map = fv_arg_tys ~~ fv_frees
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
   210
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
   211
  val (bns, bn_tys) = split_list (map (fn (bn, i, _) => (bn, i)) bn_funs)
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
   212
  val (bns2, bn_tys2) = split_list (map (fn (bn, i, _) => (bn, i)) bn_funs2)
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
   213
  val bn_args2 = map (fn (_, _, arg) => arg) bn_funs2
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
   214
  val fv_bn_names2 = map (fn bn => "fv_" ^ (fst (dest_Free bn))) bns2
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
   215
  val fv_bn_arg_tys2 = map (fn i => nth_dtyp dt_descr sorts i) bn_tys2
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
   216
  val fv_bn_tys2 = map (fn ty => ty --> @{typ "atom set"}) fv_bn_arg_tys2
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
   217
  val fv_bn_frees2 = map Free (fv_bn_names2 ~~ fv_bn_tys2)
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
   218
  val fv_bn_map2 = bns ~~ fv_bn_frees2
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
   219
  val fv_bn_map3 = bns2 ~~ fv_bn_frees2
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
   220
 
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   221
  val _ = tracing ("fn_bn_map2 " ^ @{make_string} fv_bn_map2)
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   222
  val _ = tracing ("fn_bn_map3 " ^ @{make_string} fv_bn_map3)
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   223
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
   224
  val constrs_info = all_dtyp_constrs_types dt_descr sorts
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
   225
2293
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   226
  val fv_eqs2 = map2 (map2 (mk_fv_eq lthy fv_map fv_bn_map3)) constrs_info bclausesss 
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   227
  val fv_bn_eqs2 = map (mk_fv_bn_eqs lthy fv_map fv_bn_map3 constrs_info bclausesss) bn_funs2
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
   228
  
2293
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   229
  val _ = tracing ("functions to be defined\n " ^ @{make_string} (t1 @ fv_names @ fv_bn_names2))
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   230
  val _ = tracing ("equations\n " ^ 
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   231
    cat_lines (map (Syntax.string_of_term lthy) (t2 @ flat fv_eqs2 @ flat fv_bn_eqs2)))
2292
Christian Urban <urbanc@in.tum.de>
parents: 2290
diff changeset
   232
2293
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   233
  val all_fv_names = map (fn s => (Binding.name s, NONE, NoSyn)) (t1 @ fv_names @ fv_bn_names2)
aecebd5ed424 hving a working fv-definition without the export
Christian Urban <urbanc@in.tum.de>
parents: 2292
diff changeset
   234
  val all_fv_eqs = map (pair Attrib.empty_binding) (t2 @ flat fv_eqs2 @ flat fv_bn_eqs2)
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
   235
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
   236
  fun pat_completeness_auto lthy =
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
   237
    Pat_Completeness.pat_completeness_tac lthy 1
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
   238
      THEN auto_tac (clasimpset_of lthy)
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
   239
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
   240
  fun prove_termination lthy =
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
   241
    Function.prove_termination NONE
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
      (Lexicographic_Order.lexicographic_order_tac true lthy) lthy
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
   243
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
   244
  val (_, lthy') = Function.add_function all_fv_names all_fv_eqs
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
   245
    Function_Common.default_config pat_completeness_auto lthy
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
   246
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
   247
  val (info, lthy'') = prove_termination (Local_Theory.restore lthy')
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
   248
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
   249
  val {fs, simps, ...} = info;
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
   250
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
   251
  val morphism = ProofContext.export_morphism lthy'' lthy
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
   252
  val fs_exp = map (Morphism.term morphism) fs
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
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
   254
  val (fv_frees_exp, fv_bns_exp) = chop (length fv_frees) fs_exp
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
   255
  val simps_exp = Morphism.fact morphism (the simps)
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
in
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
   257
  (fv_frees_exp, fv_bns_exp, simps_exp, lthy'')
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
   258
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
   259
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
   260
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
   261