Nominal/nominal_library.ML
author Christian Urban <urbanc@in.tum.de>
Thu, 06 Jan 2011 19:57:57 +0000
changeset 2647 5e95387bef45
parent 2637 3890483c674f
child 2733 5f6fefdbf055
permissions -rw-r--r--
removed debugging code abd introduced a guarded tracing function
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
(*  Title:      nominal_library.ML
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
    Author:     Christian Urban
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
1979
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
     4
  Basic functions for nominal.
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
*)
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
signature NOMINAL_LIBRARY =
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
sig
2647
5e95387bef45 removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
parents: 2637
diff changeset
     9
  val trace: bool Unsynchronized.ref
5e95387bef45 removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
parents: 2637
diff changeset
    10
  val trace_msg: (unit -> string) -> unit
5e95387bef45 removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
parents: 2637
diff changeset
    11
2593
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
    12
  val last2: 'a list -> 'a * 'a
2635
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
    13
  val split_last2: 'a list -> 'a list * 'a * 'a
2593
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
    14
  val order: ('a * 'a -> bool) -> 'a list -> ('a * 'b) list -> 'b list
2635
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
    15
  val order_default: ('a * 'a -> bool) -> 'b -> 'a list -> ('a * 'b) list -> 'b list
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    16
  val remove_dups: ('a * 'a -> bool) -> 'a list -> 'a list
2619
25fb0dbe9f13 a bit tuning
Christian Urban <urbanc@in.tum.de>
parents: 2616
diff changeset
    17
  val map4: ('a -> 'b -> 'c -> 'd -> 'e) -> 'a list -> 'b list -> 'c list -> 'd list -> 'e 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: 2613
diff changeset
    18
  val split_filter: ('a -> bool) -> 'a list -> 'a list * 'a list
2625
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
    19
  val fold_left: ('a * 'a -> 'a) -> 'a list -> 'a -> 'a
2619
25fb0dbe9f13 a bit tuning
Christian Urban <urbanc@in.tum.de>
parents: 2616
diff changeset
    20
  
2593
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
    21
  val is_true: term -> bool
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
    22
 
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
    23
  val dest_listT: typ -> typ
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    24
  val dest_fsetT: typ -> typ
2313
25d2cdf7d7e4 transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    25
2593
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
    26
  val mk_id: term -> term
2609
666ffc8a92a9 freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents: 2608
diff changeset
    27
  val mk_all: (string * typ) -> term -> term
2635
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
    28
  val mk_All: (string * typ) -> term -> term
2637
3890483c674f final version of the ESOP paper; used set+ instead of res as requested by one reviewer
Christian Urban <urbanc@in.tum.de>
parents: 2635
diff changeset
    29
  val mk_exists: (string * typ) -> term -> term
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: 1979
diff changeset
    30
2410
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
    31
  val sum_case_const: typ -> typ -> typ -> term
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
    32
  val mk_sum_case: term -> term -> term
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
    33
 
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
  val mk_minus: term -> term
1896
996d4411e95e tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents: 1871
diff changeset
    35
  val mk_plus: term -> term -> term
996d4411e95e tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents: 1871
diff changeset
    36
1899
8e0bfb14f6bf optimised the code of define_raw_perm
Christian Urban <urbanc@in.tum.de>
parents: 1896
diff changeset
    37
  val perm_ty: typ -> typ 
2635
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
    38
  val perm_const: typ -> term
1871
c704d129862b moved some general function into nominal_library.ML
Christian Urban <urbanc@in.tum.de>
parents: 1834
diff changeset
    39
  val mk_perm_ty: typ -> term -> term -> term
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  val mk_perm: term -> term -> term
1834
9909cc3566c5 moved a couple of more functions to the library
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    41
  val dest_perm: term -> term * term
9909cc3566c5 moved a couple of more functions to the library
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    42
1962
84a13d1e2511 moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents: 1899
diff changeset
    43
  val mk_sort_of: term -> term
1979
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
    44
  val atom_ty: typ -> typ
2569
94750b31a97d fixed bug in fv function where a shallow binder binds lists of names
Christian Urban <urbanc@in.tum.de>
parents: 2568
diff changeset
    45
  val atom_const: typ -> term
1962
84a13d1e2511 moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents: 1899
diff changeset
    46
  val mk_atom_ty: typ -> term -> term
84a13d1e2511 moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents: 1899
diff changeset
    47
  val mk_atom: term -> term
84a13d1e2511 moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents: 1899
diff changeset
    48
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    49
  val mk_atom_set_ty: typ -> term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    50
  val mk_atom_set: term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    51
  val mk_atom_fset_ty: typ -> term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    52
  val mk_atom_fset: term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    53
  val mk_atom_list_ty: typ -> term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    54
  val mk_atom_list: term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    55
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    56
  val is_atom: Proof.context -> typ -> bool
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    57
  val is_atom_set: Proof.context -> typ -> bool
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    58
  val is_atom_fset: Proof.context -> typ -> bool
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    59
  val is_atom_list: Proof.context -> typ -> bool
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    60
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    61
  val to_set_ty: typ -> term -> term
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    62
  val to_set: term -> term
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    63
  
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
    64
  val atomify_ty: Proof.context -> typ -> term -> term
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
    65
  val atomify: Proof.context -> term -> term
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    66
  val setify_ty: Proof.context -> typ -> term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    67
  val setify: Proof.context -> term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    68
  val listify_ty: Proof.context -> typ -> term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    69
  val listify: Proof.context -> term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    70
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    71
  val fresh_star_ty: typ -> typ
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    72
  val fresh_star_const: typ -> term
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
    73
  val mk_fresh_star_ty: typ -> term -> term -> term
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    74
  val mk_fresh_star: term -> term -> term
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
    75
1979
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
    76
  val supp_ty: typ -> typ
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
    77
  val supp_const: typ -> term
1979
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
    78
  val mk_supp_ty: typ -> term -> term
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
    79
  val mk_supp: term -> term
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
    80
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
    81
  val supp_rel_ty: typ -> typ
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
    82
  val supp_rel_const: typ -> term
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
    83
  val mk_supp_rel_ty: typ -> term -> term -> term
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
    84
  val mk_supp_rel: term -> term -> term		       
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
    85
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
    86
  val supports_const: typ -> term
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
    87
  val mk_supports_ty: typ -> term -> term -> term
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
    88
  val mk_supports: term -> term -> term
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
    89
2450
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
    90
  val finite_const: typ -> term
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
    91
  val mk_finite_ty: typ -> term -> term
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
    92
  val mk_finite: term -> term
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
    93
1834
9909cc3566c5 moved a couple of more functions to the library
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    94
  val mk_equiv: thm -> thm
9909cc3566c5 moved a couple of more functions to the library
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    95
  val safe_mk_equiv: thm -> thm
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: 1979
diff changeset
    96
2289
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
    97
  val mk_diff: term * term -> term
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
    98
  val mk_append: term * term -> term
2289
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
    99
  val mk_union: term * term -> term
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   100
  val fold_union: term list -> term
2464
f4eba60cbd69 made the fv-definition aggree more with alpha (needed in the support proofs)
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
   101
  val fold_append: term list -> term
2389
0f24c961b5f6 introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents: 2384
diff changeset
   102
  val mk_conj: term * term -> term
0f24c961b5f6 introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents: 2384
diff changeset
   103
  val fold_conj: term list -> term
2289
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   104
2625
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   105
  (* functions for de-Bruijn open terms *)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   106
  val mk_binop_env: typ list -> string -> term * term -> term
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   107
  val mk_union_env: typ list -> term * term -> term
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   108
  val fold_union_env: typ list -> term list -> term
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   109
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   110
  (* fresh arguments for a term *)
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   111
  val fresh_args: Proof.context -> term -> term list
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   112
2625
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   113
  (* some logic operations *)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   114
  val strip_full_horn: term -> (string * typ) list * term list * term
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   115
  val mk_full_horn: (string * typ) list -> term list -> term -> term
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   116
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: 1979
diff changeset
   117
  (* datatype operations *)
2407
49ab06c0ca64 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2399
diff changeset
   118
  type cns_info = (term * typ * typ list * bool list) list
49ab06c0ca64 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2399
diff changeset
   119
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   120
  val all_dtyps: Datatype_Aux.descr -> (string * sort) list -> typ list
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: 1979
diff changeset
   121
  val nth_dtyp: Datatype_Aux.descr -> (string * sort) list -> int -> typ
2407
49ab06c0ca64 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2399
diff changeset
   122
  val all_dtyp_constrs_types: Datatype_Aux.descr -> (string * sort) list -> cns_info list
49ab06c0ca64 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2399
diff changeset
   123
  val nth_dtyp_constrs_types: Datatype_Aux.descr -> (string * sort) list -> int -> cns_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: 1979
diff changeset
   124
  val prefix_dt_names: Datatype_Aux.descr -> (string * sort) list -> string -> string 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: 1979
diff changeset
   125
2304
8a98171ba1fc all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents: 2296
diff changeset
   126
  (* tactics for function package *)
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   127
  val size_simpset: simpset
2304
8a98171ba1fc all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents: 2296
diff changeset
   128
  val pat_completeness_simp: thm list -> Proof.context -> tactic
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   129
  val prove_termination_ind: Proof.context -> int -> tactic
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   130
  val prove_termination_fun: thm list -> Proof.context -> Function.info * local_theory
2304
8a98171ba1fc all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents: 2296
diff changeset
   131
2311
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   132
  (* transformations of premises in inductions *)
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   133
  val transform_prem1: Proof.context -> string list -> thm -> thm
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   134
  val transform_prem2: Proof.context -> string list -> thm -> thm
2397
c670a849af65 more experiments with lifting
Christian Urban <urbanc@in.tum.de>
parents: 2389
diff changeset
   135
c670a849af65 more experiments with lifting
Christian Urban <urbanc@in.tum.de>
parents: 2389
diff changeset
   136
  (* transformation into the object logic *)
c670a849af65 more experiments with lifting
Christian Urban <urbanc@in.tum.de>
parents: 2389
diff changeset
   137
  val atomize: thm -> thm
2398
1e6160690546 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2397
diff changeset
   138
2625
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   139
  (* applies a tactic to a formula composed of conjunctions *)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   140
  val conj_tac: (int -> tactic) -> int -> tactic
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
end
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
structure Nominal_Library: NOMINAL_LIBRARY =
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
struct
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
2647
5e95387bef45 removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
parents: 2637
diff changeset
   147
val trace = Unsynchronized.ref false
5e95387bef45 removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
parents: 2637
diff changeset
   148
fun trace_msg msg = if ! trace then tracing (msg ()) else ()
5e95387bef45 removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
parents: 2637
diff changeset
   149
5e95387bef45 removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
parents: 2637
diff changeset
   150
2635
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   151
(* orders an AList according to keys - every key needs to be there *)
2593
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   152
fun order eq keys list = 
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   153
  map (the o AList.lookup eq list) keys
2480
ac7dff1194e8 introduced a general procedure for structural inductions; simplified reflexivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2477
diff changeset
   154
2635
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   155
(* orders an AList according to keys - returns default for non-existing keys *)
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   156
fun order_default eq default keys list = 
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   157
  map (the_default default o AList.lookup eq list) keys
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   158
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   159
(* remove duplicates *)
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   160
fun remove_dups eq [] = []
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   161
  | remove_dups eq (x :: xs) = 
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   162
      if member eq xs x 
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   163
      then remove_dups eq xs 
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   164
      else x :: remove_dups eq xs
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   165
2313
25d2cdf7d7e4 transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   166
fun last2 [] = raise Empty
25d2cdf7d7e4 transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   167
  | last2 [_] = raise Empty
2375
e163fd99de44 minor polishing
Christian Urban <urbanc@in.tum.de>
parents: 2313
diff changeset
   168
  | last2 [x, y] = (x, y)
2313
25d2cdf7d7e4 transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   169
  | last2 (_ :: xs) = last2 xs
25d2cdf7d7e4 transitivity proofs done
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   170
2635
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   171
fun split_last2 xs = 
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   172
  let
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   173
    val (xs', x) = split_last xs
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   174
    val (xs'', y) = split_last xs'
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   175
  in
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   176
    (xs'', y, x)
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   177
  end
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   178
2619
25fb0dbe9f13 a bit tuning
Christian Urban <urbanc@in.tum.de>
parents: 2616
diff changeset
   179
fun map4 _ [] [] [] [] = []
25fb0dbe9f13 a bit tuning
Christian Urban <urbanc@in.tum.de>
parents: 2616
diff changeset
   180
  | map4 f (x :: xs) (y :: ys) (z :: zs) (u :: us) = f x y z u :: map4 f xs ys zs us
2613
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
   181
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: 2613
diff changeset
   182
fun split_filter f [] = ([], [])
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: 2613
diff changeset
   183
  | split_filter f (x :: xs) =
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: 2613
diff changeset
   184
      let 
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: 2613
diff changeset
   185
        val (r, l) = split_filter f xs 
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: 2613
diff changeset
   186
      in 
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: 2613
diff changeset
   187
        if f x 
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: 2613
diff changeset
   188
        then (x :: r, l) 
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: 2613
diff changeset
   189
        else (r, x :: l) 
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: 2613
diff changeset
   190
      end
2613
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
   191
2625
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   192
(* to be used with left-infix binop-operations *)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   193
fun fold_left f [] z = z
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   194
  | fold_left f [x] z = x
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   195
  | fold_left f (x :: y :: xs) z = fold_left f (f (x, y) :: xs) z
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   196
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   197
2613
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
   198
2593
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   199
fun is_true @{term "Trueprop True"} = true
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   200
  | is_true _ = false 
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   201
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: 1979
diff changeset
   202
fun dest_listT (Type (@{type_name list}, [T])) = 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: 1979
diff changeset
   203
  | dest_listT T = raise TYPE ("dest_listT: list type expected", [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: 1979
diff changeset
   204
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   205
fun dest_fsetT (Type (@{type_name fset}, [T])) = T
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   206
  | dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []);
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   207
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   208
2620
81921f8ad245 updated to Isabelle 22 December
Christian Urban <urbanc@in.tum.de>
parents: 2619
diff changeset
   209
fun mk_id trm = HOLogic.id_const (fastype_of trm) $ trm
2593
25dcb2b1329e ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents: 2571
diff changeset
   210
2609
666ffc8a92a9 freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents: 2608
diff changeset
   211
fun mk_all (a, T) t =  Term.all T $ Abs (a, T, t)
666ffc8a92a9 freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents: 2608
diff changeset
   212
2635
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   213
fun mk_All (a, T) t =  HOLogic.all_const T $ Abs (a, T, t)
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   214
2637
3890483c674f final version of the ESOP paper; used set+ instead of res as requested by one reviewer
Christian Urban <urbanc@in.tum.de>
parents: 2635
diff changeset
   215
fun mk_exists (a, T) t =  HOLogic.exists_const T $ Abs (a, T, t)
3890483c674f final version of the ESOP paper; used set+ instead of res as requested by one reviewer
Christian Urban <urbanc@in.tum.de>
parents: 2635
diff changeset
   216
2410
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
   217
fun sum_case_const ty1 ty2 ty3 = 
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
   218
  Const (@{const_name sum_case}, [ty1 --> ty3, ty2 --> ty3, Type (@{type_name sum}, [ty1, ty2])] ---> ty3)
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   219
2410
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
   220
fun mk_sum_case trm1 trm2 =
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   221
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   222
    val ([ty1], ty3) = strip_type (fastype_of trm1)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   223
    val ty2 = domain_type (fastype_of trm2)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   224
  in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   225
    sum_case_const ty1 ty2 ty3 $ trm1 $ trm2
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   226
  end 
2410
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
   227
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
   228
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
   229
2399
107c06267f33 simplified code
Christian Urban <urbanc@in.tum.de>
parents: 2398
diff changeset
   230
fun mk_minus p = @{term "uminus::perm => perm"} $ p
1896
996d4411e95e tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
parents: 1871
diff changeset
   231
2399
107c06267f33 simplified code
Christian Urban <urbanc@in.tum.de>
parents: 2398
diff changeset
   232
fun mk_plus p q = @{term "plus::perm => perm => perm"} $ p $ q
107c06267f33 simplified code
Christian Urban <urbanc@in.tum.de>
parents: 2398
diff changeset
   233
107c06267f33 simplified code
Christian Urban <urbanc@in.tum.de>
parents: 2398
diff changeset
   234
fun perm_ty ty = @{typ "perm"} --> ty --> ty
2635
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   235
fun perm_const ty  = Const (@{const_name "permute"}, perm_ty ty)
64b4cb2c2bf8 simple cases for string rule inductions
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   236
fun mk_perm_ty ty p trm = perm_const ty $ p $ trm
2399
107c06267f33 simplified code
Christian Urban <urbanc@in.tum.de>
parents: 2398
diff changeset
   237
fun mk_perm p trm = mk_perm_ty (fastype_of trm) p trm
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   238
1834
9909cc3566c5 moved a couple of more functions to the library
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
   239
fun dest_perm (Const (@{const_name "permute"}, _) $ p $ t) = (p, t)
1979
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
   240
  | dest_perm t = raise TERM ("dest_perm", [t]);
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   241
1962
84a13d1e2511 moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents: 1899
diff changeset
   242
fun mk_sort_of t = @{term "sort_of"} $ t;
84a13d1e2511 moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents: 1899
diff changeset
   243
1979
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
   244
fun atom_ty ty = ty --> @{typ "atom"};
2569
94750b31a97d fixed bug in fv function where a shallow binder binds lists of names
Christian Urban <urbanc@in.tum.de>
parents: 2568
diff changeset
   245
fun atom_const ty = Const (@{const_name "atom"}, atom_ty ty)
94750b31a97d fixed bug in fv function where a shallow binder binds lists of names
Christian Urban <urbanc@in.tum.de>
parents: 2568
diff changeset
   246
fun mk_atom_ty ty t = atom_const ty $ t;
1962
84a13d1e2511 moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents: 1899
diff changeset
   247
fun mk_atom t = mk_atom_ty (fastype_of t) t;
84a13d1e2511 moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents: 1899
diff changeset
   248
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   249
fun mk_atom_set_ty ty t =
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   250
  let
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   251
    val atom_ty = HOLogic.dest_setT ty 
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   252
    val img_ty = (atom_ty --> @{typ atom}) --> ty --> @{typ "atom set"};
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   253
  in
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   254
    Const (@{const_name image}, img_ty) $ atom_const atom_ty $ t
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   255
  end
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   256
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   257
fun mk_atom_fset_ty ty t =
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   258
  let
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   259
    val atom_ty = dest_fsetT ty
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   260
    val fmap_ty = (atom_ty --> @{typ atom}) --> ty --> @{typ "atom fset"};
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   261
  in
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   262
    Const (@{const_name map_fset}, fmap_ty) $ atom_const atom_ty $ t
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   263
  end
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   264
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   265
fun mk_atom_list_ty ty t =
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   266
  let
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   267
    val atom_ty = dest_listT ty
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   268
    val map_ty = (atom_ty --> @{typ atom}) --> ty --> @{typ "atom list"}
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   269
  in
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   270
    Const (@{const_name map}, map_ty) $ atom_const atom_ty $ t
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   271
  end
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   272
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   273
fun mk_atom_set t = mk_atom_set_ty (fastype_of t) t
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   274
fun mk_atom_fset t = mk_atom_fset_ty (fastype_of t) t
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   275
fun mk_atom_list t = mk_atom_list_ty (fastype_of t) t
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   276
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   277
(* coerces a list into a set *)
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   278
  
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   279
fun to_set_ty ty t =
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   280
  case ty of
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   281
    @{typ "atom list"} => @{term "set :: atom list => atom set"} $ t
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   282
  | @{typ "atom fset"} => @{term "fset :: atom fset => atom set"} $ t
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   283
  | _ => t
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   284
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   285
fun to_set t = to_set_ty (fastype_of t) t
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   286
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   287
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   288
(* testing for concrete atom types *)
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   289
fun is_atom ctxt ty =
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   290
  Sign.of_sort (ProofContext.theory_of ctxt) (ty, @{sort at_base})
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   291
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   292
fun is_atom_set ctxt (Type ("fun", [ty, @{typ bool}])) = is_atom ctxt ty
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   293
  | is_atom_set _ _ = false;
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   294
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   295
fun is_atom_fset ctxt (Type (@{type_name "fset"}, [ty])) = is_atom ctxt ty
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   296
  | is_atom_fset _ _ = false;
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   297
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   298
fun is_atom_list ctxt (Type (@{type_name "list"}, [ty])) = is_atom ctxt ty
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   299
  | is_atom_list _ _ = false
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   300
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   301
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   302
(* functions that coerce singletons, sets, fsets and lists of concrete 
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   303
   atoms into general atoms sets / lists *)
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   304
fun atomify_ty ctxt ty t =
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   305
  if is_atom ctxt ty
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   306
    then  mk_atom_ty ty t
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   307
  else if is_atom_set ctxt ty
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   308
    then mk_atom_set_ty ty t
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   309
  else if is_atom_fset ctxt ty
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   310
    then mk_atom_fset_ty ty t
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   311
  else if is_atom_list ctxt ty
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   312
    then mk_atom_list_ty ty t
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   313
  else raise TERM ("atomify", [t])
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   314
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   315
fun setify_ty ctxt ty t =
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   316
  if is_atom ctxt ty
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   317
    then  HOLogic.mk_set @{typ atom} [mk_atom_ty ty t]
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   318
  else if is_atom_set ctxt ty
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   319
    then mk_atom_set_ty ty t
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   320
  else if is_atom_fset ctxt ty
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   321
    then @{term "fset :: atom fset => atom set"} $ mk_atom_fset_ty ty t
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   322
  else if is_atom_list ctxt ty
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   323
    then @{term "set :: atom list => atom set"} $ mk_atom_list_ty ty t
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   324
  else raise TERM ("setify", [t])
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   325
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   326
fun listify_ty ctxt ty t =
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   327
  if is_atom ctxt ty
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   328
    then HOLogic.mk_list @{typ atom} [mk_atom_ty ty t]
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   329
  else if is_atom_list ctxt ty
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   330
    then mk_atom_list_ty ty t
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   331
  else raise TERM ("listify", [t])
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   332
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   333
fun atomify ctxt t = atomify_ty ctxt (fastype_of t) t
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   334
fun setify ctxt t  = setify_ty ctxt (fastype_of t) t
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   335
fun listify ctxt t = listify_ty ctxt (fastype_of t) t
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   336
2608
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   337
fun fresh_star_ty ty = [@{typ "atom set"}, ty] ---> @{typ bool}
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   338
fun fresh_star_const ty = Const (@{const_name fresh_star}, fresh_star_ty ty)
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   339
fun mk_fresh_star_ty ty t1 t2 = fresh_star_const ty $ t1 $ t2
86e3b39c2a60 created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents: 2607
diff changeset
   340
fun mk_fresh_star t1 t2 = mk_fresh_star_ty (fastype_of t2) t1 t2
2607
7430e07a5d61 moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents: 2603
diff changeset
   341
1979
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
   342
fun supp_ty ty = ty --> @{typ "atom set"};
2450
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
   343
fun supp_const ty = Const (@{const_name supp}, supp_ty ty)
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   344
fun mk_supp_ty ty t = supp_const ty $ t
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   345
fun mk_supp t = mk_supp_ty (fastype_of t) t
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   346
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   347
fun supp_rel_ty ty = ([ty, ty] ---> @{typ bool}) --> ty --> @{typ "atom set"};
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   348
fun supp_rel_const ty = Const (@{const_name supp_rel}, supp_rel_ty ty)
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   349
fun mk_supp_rel_ty ty r t = supp_rel_const ty $ r $ t
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2464
diff changeset
   350
fun mk_supp_rel r t = mk_supp_rel_ty (fastype_of t) r t
1979
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
   351
2450
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
   352
fun supports_const ty = Const (@{const_name supports}, [@{typ "atom set"}, ty] ---> @{typ bool});
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   353
fun mk_supports_ty ty t1 t2 = supports_const ty $ t1 $ t2;
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   354
fun mk_supports t1 t2 = mk_supports_ty (fastype_of t2) t1 t2;
1979
760257a66604 added basic functions for constructing supp-terms
Christian Urban <urbanc@in.tum.de>
parents: 1963
diff changeset
   355
2450
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
   356
fun finite_const ty = Const (@{const_name finite}, ty --> @{typ bool})
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
   357
fun mk_finite_ty ty t = finite_const ty $ t
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
   358
fun mk_finite t = mk_finite_ty (fastype_of t) t
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
   359
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2448
diff changeset
   360
1834
9909cc3566c5 moved a couple of more functions to the library
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
   361
fun mk_equiv r = r RS @{thm eq_reflection};
9909cc3566c5 moved a couple of more functions to the library
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
   362
fun safe_mk_equiv r = mk_equiv r handle Thm.THM _ => r;
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   363
1962
84a13d1e2511 moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents: 1899
diff changeset
   364
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   365
(* functions that construct differences, appends and unions
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   366
   but avoid producing empty atom sets or empty atom lists *)
2289
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   367
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   368
fun mk_diff (@{term "{}::atom set"}, _) = @{term "{}::atom set"}
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   369
  | mk_diff (t1, @{term "{}::atom set"}) = t1
2464
f4eba60cbd69 made the fv-definition aggree more with alpha (needed in the support proofs)
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
   370
  | mk_diff (@{term "set ([]::atom list)"}, _) = @{term "set ([]::atom list)"}
f4eba60cbd69 made the fv-definition aggree more with alpha (needed in the support proofs)
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
   371
  | mk_diff (t1, @{term "set ([]::atom list)"}) = t1
2289
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   372
  | mk_diff (t1, t2) = HOLogic.mk_binop @{const_name minus} (t1, t2)
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   373
2389
0f24c961b5f6 introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents: 2384
diff changeset
   374
fun mk_append (t1, @{term "[]::atom list"}) = t1
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   375
  | mk_append (@{term "[]::atom list"}, t2) = t2
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   376
  | mk_append (t1, t2) = HOLogic.mk_binop @{const_name "append"} (t1, t2) 
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   377
2389
0f24c961b5f6 introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents: 2384
diff changeset
   378
fun mk_union (t1, @{term "{}::atom set"}) = t1
2289
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   379
  | mk_union (@{term "{}::atom set"}, t2) = t2
2464
f4eba60cbd69 made the fv-definition aggree more with alpha (needed in the support proofs)
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
   380
  | mk_union (t1, @{term "set ([]::atom list)"}) = t1
f4eba60cbd69 made the fv-definition aggree more with alpha (needed in the support proofs)
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
   381
  | mk_union (@{term "set ([]::atom list)"}, t2) = t2
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   382
  | mk_union (t1, t2) = HOLogic.mk_binop @{const_name "sup"} (t1, t2)  
2289
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   383
 
2384
841b7e34e70a fixed order of fold_union to make alpha and fv agree
Christian Urban <urbanc@in.tum.de>
parents: 2375
diff changeset
   384
fun fold_union trms = fold_rev (curry mk_union) trms @{term "{}::atom set"}
2464
f4eba60cbd69 made the fv-definition aggree more with alpha (needed in the support proofs)
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
   385
fun fold_append trms = fold_rev (curry mk_append) trms @{term "[]::atom list"}
2289
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   386
2389
0f24c961b5f6 introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents: 2384
diff changeset
   387
fun mk_conj (t1, @{term "True"}) = t1
0f24c961b5f6 introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents: 2384
diff changeset
   388
  | mk_conj (@{term "True"}, t2) = t2
0f24c961b5f6 introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents: 2384
diff changeset
   389
  | mk_conj (t1, t2) = HOLogic.mk_conj (t1, t2)
2289
bf748be70109 moved some mk_union and mk_diff into the library
Christian Urban <urbanc@in.tum.de>
parents: 2288
diff changeset
   390
2389
0f24c961b5f6 introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents: 2384
diff changeset
   391
fun fold_conj trms = fold_rev (curry mk_conj) trms @{term "True"}
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   392
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   393
2625
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   394
(* functions for de-Bruijn open terms *)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   395
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   396
fun mk_binop_env tys c (t, u) =
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   397
  let 
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   398
    val ty = fastype_of1 (tys, t) 
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   399
  in
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   400
    Const (c, [ty, ty] ---> ty) $ t $ u
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   401
  end
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   402
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   403
fun mk_union_env tys (t1, @{term "{}::atom set"}) = t1
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   404
  | mk_union_env tys (@{term "{}::atom set"}, t2) = t2
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   405
  | mk_union_env tys (t1, @{term "set ([]::atom list)"}) = t1
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   406
  | mk_union_env tys (@{term "set ([]::atom list)"}, t2) = t2
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   407
  | mk_union_env tys (t1, t2) = mk_binop_env tys @{const_name "sup"} (t1, t2)  
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   408
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   409
fun fold_union_env tys trms = fold_left (mk_union_env tys) trms @{term "{}::atom set"} 
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   410
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   411
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   412
(* produces fresh arguments for a term *)
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   413
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   414
fun fresh_args ctxt f =
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   415
    f |> fastype_of
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   416
      |> binder_types
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   417
      |> map (pair "z")
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   418
      |> Variable.variant_frees ctxt [f]
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   419
      |> map Free
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   420
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   421
2625
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   422
(** some logic operations **)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   423
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   424
(* decompses a formula into params, premises and a conclusion *)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   425
fun strip_full_horn trm =
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   426
  let
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   427
    fun strip_outer_params (Const ("all", _) $ Abs (a, T, t)) = strip_outer_params t |>> cons (a, T)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   428
    | strip_outer_params B = ([], B)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   429
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   430
    val (params, body) = strip_outer_params trm
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   431
    val (prems, concl) = Logic.strip_horn body
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   432
  in
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   433
    (params, prems, concl)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   434
  end
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   435
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   436
(* composes a formula out of params, premises and a conclusion *)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   437
fun mk_full_horn params prems concl =
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   438
  Logic.list_implies (prems, concl)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   439
  |> fold_rev mk_all params
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2446
diff changeset
   440
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: 1979
diff changeset
   441
(** datatypes **)
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: 1979
diff changeset
   442
2407
49ab06c0ca64 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2399
diff changeset
   443
(* constructor infos *)
49ab06c0ca64 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2399
diff changeset
   444
type cns_info = (term * typ * typ list * bool list) list
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: 1979
diff changeset
   445
2602
bcf558c445a4 moved some code into the nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2593
diff changeset
   446
(*  - term for constructor constant
bcf558c445a4 moved some code into the nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2593
diff changeset
   447
    - type of the constructor
bcf558c445a4 moved some code into the nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2593
diff changeset
   448
    - types of the arguments
bcf558c445a4 moved some code into the nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2593
diff changeset
   449
    - flags indicating whether the argument is recursive
bcf558c445a4 moved some code into the nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2593
diff changeset
   450
*)
bcf558c445a4 moved some code into the nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2593
diff changeset
   451
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: 1979
diff changeset
   452
(* returns the type of the nth datatype *)
2296
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   453
fun all_dtyps descr sorts = 
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   454
  map (fn n => Datatype_Aux.typ_of_dtyp descr sorts (Datatype_Aux.DtRec n)) (0 upto (length descr - 1))
45a69c9cc4cc alpha works now
Christian Urban <urbanc@in.tum.de>
parents: 2289
diff changeset
   455
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: 1979
diff changeset
   456
fun nth_dtyp descr sorts 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: 1979
diff changeset
   457
  Datatype_Aux.typ_of_dtyp descr sorts (Datatype_Aux.DtRec 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: 1979
diff changeset
   458
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: 1979
diff changeset
   459
(* returns info about constructors in a datatype *)
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: 1979
diff changeset
   460
fun all_dtyp_constrs_info 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: 1979
diff changeset
   461
  map (fn (_, (ty, vs, constrs)) => map (pair (ty, vs)) constrs) 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: 1979
diff changeset
   462
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: 1979
diff changeset
   463
(* returns the constants of the constructors plus the 
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: 1979
diff changeset
   464
   corresponding type and types of arguments *)
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: 1979
diff changeset
   465
fun all_dtyp_constrs_types 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: 1979
diff changeset
   466
  let
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   467
    fun aux ((ty_name, vs), (cname, args)) =
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   468
      let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   469
        val vs_tys = map (Datatype_Aux.typ_of_dtyp descr sorts) vs
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   470
        val ty = Type (ty_name, vs_tys)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   471
        val arg_tys = map (Datatype_Aux.typ_of_dtyp descr sorts) args
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   472
        val is_rec = map Datatype_Aux.is_rec_type args
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   473
      in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   474
        (Const (cname, arg_tys ---> ty), ty, arg_tys, is_rec)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   475
      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: 1979
diff changeset
   476
  in
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   477
    map (map aux) (all_dtyp_constrs_info descr)
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: 1979
diff changeset
   478
  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: 1979
diff changeset
   479
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: 1979
diff changeset
   480
fun nth_dtyp_constrs_types descr sorts 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: 1979
diff changeset
   481
  nth (all_dtyp_constrs_types descr sorts) 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: 1979
diff changeset
   482
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: 1979
diff changeset
   483
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: 1979
diff changeset
   484
(* generates for every datatype a name str ^ dt_name 
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: 1979
diff changeset
   485
   plus and index for multiple occurences of a string *)
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: 1979
diff changeset
   486
fun prefix_dt_names descr sorts str = 
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   487
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   488
    fun get_nth_name (i, _) = 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   489
      Datatype_Aux.name_of_typ (nth_dtyp descr sorts i) 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   490
  in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   491
    Datatype_Prop.indexify_names 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   492
      (map (prefix str o get_nth_name) descr)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   493
  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: 1979
diff changeset
   494
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: 1979
diff changeset
   495
2311
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   496
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   497
(** function package tactics **)
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   498
2304
8a98171ba1fc all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents: 2296
diff changeset
   499
fun pat_completeness_simp simps lthy =
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   500
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   501
    val simp_set = HOL_basic_ss addsimps (@{thms sum.inject sum.distinct} @ simps)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   502
  in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   503
    Pat_Completeness.pat_completeness_tac lthy 1
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   504
      THEN ALLGOALS (asm_full_simp_tac simp_set)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   505
  end
2304
8a98171ba1fc all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents: 2296
diff changeset
   506
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   507
(* simpset for size goals *)
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   508
val size_simpset = HOL_ss
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   509
   addsimprocs Nat_Numeral_Simprocs.cancel_numerals
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   510
   addsimps @{thms in_measure wf_measure sum.cases add_Suc_right add.right_neutral 
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   511
     zero_less_Suc prod.size(1) mult_Suc_right}
2557
781fbc8c0591 fixed locally the problem with the function package; all tests work again
Christian Urban <urbanc@in.tum.de>
parents: 2480
diff changeset
   512
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   513
val natT = @{typ nat}
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   514
    
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   515
fun prod_size_const T1 T2 = 
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   516
  let
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   517
    val T1_fun = T1 --> natT
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   518
    val T2_fun = T2 --> natT
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   519
    val prodT = HOLogic.mk_prodT (T1, T2)
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   520
  in
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   521
    Const (@{const_name prod_size}, [T1_fun, T2_fun, prodT] ---> natT)
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   522
  end
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   523
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   524
fun snd_const T1 T2 =
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   525
  Const ("Product_Type.snd", HOLogic.mk_prodT (T1, T2) --> T2) 
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   526
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2559
diff changeset
   527
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   528
fun mk_measure_trm f ctxt T = 
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   529
  HOLogic.dest_setT T
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   530
  |> fst o HOLogic.dest_prodT
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   531
  |> f
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   532
  |> curry (op $) (Const (@{const_name "measure"}, dummyT))
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   533
  |> Syntax.check_term ctxt
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   534
  
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   535
(* wf-goal arising in induction_schema *)    
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   536
fun prove_termination_ind ctxt =
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   537
  let
2560
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2559
diff changeset
   538
    fun mk_size_measure T =
82e37a4595c7 automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents: 2559
diff changeset
   539
      case T of    
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   540
        (Type (@{type_name Sum_Type.sum}, [T1, T2])) =>
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   541
           SumTree.mk_sumcase T1 T2 natT (mk_size_measure T1) (mk_size_measure T2)
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   542
      | (Type (@{type_name Product_Type.prod}, [T1, T2])) =>
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   543
           HOLogic.mk_comp (mk_size_measure T2, snd_const T1 T2)
2611
3d101f2f817c simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents: 2609
diff changeset
   544
      | _ => HOLogic.size_const T
2304
8a98171ba1fc all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents: 2296
diff changeset
   545
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   546
    val measure_trm = mk_measure_trm (mk_size_measure) ctxt
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   547
  in 
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   548
    Function_Relation.relation_tac ctxt measure_trm
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   549
  end
2410
2bbdb9c427b5 improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2408
diff changeset
   550
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   551
(* wf-goal arising in function definitions *)
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   552
fun prove_termination_fun size_simps ctxt =
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   553
let
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   554
  fun mk_size_measure T =
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   555
    case T of    
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   556
      (Type (@{type_name Sum_Type.sum}, [T1, T2])) =>
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   557
         SumTree.mk_sumcase T1 T2 natT (mk_size_measure T1) (mk_size_measure T2)
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   558
    | (Type (@{type_name Product_Type.prod}, [T1, T2])) =>
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   559
         prod_size_const T1 T2 $ (mk_size_measure T1) $ (mk_size_measure T2)
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   560
    | _ => HOLogic.size_const T
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   561
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   562
  val measure_trm = mk_measure_trm (mk_size_measure) ctxt
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   563
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   564
  val tac = 
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   565
    Function_Relation.relation_tac ctxt measure_trm
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   566
    THEN_ALL_NEW simp_tac (size_simpset addsimps size_simps)
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   567
  in 
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   568
    Function.prove_termination NONE (HEADGOAL tac) ctxt
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2625
diff changeset
   569
  end
2311
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   570
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   571
(** transformations of premises (in inductive proofs) **)
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   572
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   573
(* 
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   574
 given the theorem F[t]; proves the theorem F[f t] 
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   575
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   576
  - F needs to be monotone
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   577
  - f returns either SOME for a term it fires on 
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   578
    and NONE elsewhere 
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   579
*)
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   580
fun map_term f t = 
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   581
  (case f t of
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   582
     NONE => map_term' f t 
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   583
   | x => x)
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   584
and map_term' f (t $ u) = 
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   585
    (case (map_term f t, map_term f u) of
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   586
        (NONE, NONE) => NONE
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   587
      | (SOME t'', NONE) => SOME (t'' $ u)
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   588
      | (NONE, SOME u'') => SOME (t $ u'')
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   589
      | (SOME t'', SOME u'') => SOME (t'' $ u''))
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   590
  | map_term' f (Abs (s, T, t)) = 
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   591
      (case map_term f t of
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   592
        NONE => NONE
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   593
      | SOME t'' => SOME (Abs (s, T, t'')))
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   594
  | map_term' _ _  = NONE;
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   595
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   596
fun map_thm_tac ctxt tac thm =
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   597
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   598
    val monos = Inductive.get_monos ctxt
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   599
    val simps = HOL_basic_ss addsimps @{thms split_def}
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   600
  in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   601
    EVERY [cut_facts_tac [thm] 1, etac rev_mp 1, 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   602
      REPEAT_DETERM (FIRSTGOAL (simp_tac simps THEN' resolve_tac monos)),
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   603
      REPEAT_DETERM (rtac impI 1 THEN (atac 1 ORELSE tac))]
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   604
  end
2311
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   605
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   606
fun map_thm ctxt f tac thm =
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   607
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   608
    val opt_goal_trm = map_term f (prop_of thm)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   609
  in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   610
    case opt_goal_trm of
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   611
      NONE => thm
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   612
    | SOME goal =>
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   613
        Goal.prove ctxt [] [] goal (fn _ => map_thm_tac ctxt tac thm) 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   614
  end
2311
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   615
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   616
(*
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   617
 inductive premises can be of the form
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   618
 R ... /\ P ...; split_conj_i picks out
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   619
 the part R or P part
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   620
*)
2480
ac7dff1194e8 introduced a general procedure for structural inductions; simplified reflexivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2477
diff changeset
   621
fun split_conj1 names (Const (@{const_name "conj"}, _) $ f1 $ _) = 
2311
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   622
  (case head_of f1 of
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   623
     Const (name, _) => if member (op =) names name then SOME f1 else NONE
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   624
   | _ => NONE)
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   625
| split_conj1 _ _ = NONE;
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   626
2446
63c936b09764 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 2420
diff changeset
   627
fun split_conj2 names (Const (@{const_name "conj"}, _) $ f1 $ f2) = 
2311
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   628
  (case head_of f1 of
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   629
     Const (name, _) => if member (op =) names name then SOME f2 else NONE
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   630
   | _ => NONE)
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   631
| split_conj2 _ _ = NONE;
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   632
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   633
fun transform_prem1 ctxt names thm =
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   634
  map_thm ctxt (split_conj1 names) (etac conjunct1 1) thm
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   635
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   636
fun transform_prem2 ctxt names thm =
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   637
  map_thm ctxt (split_conj2 names) (etac conjunct2 1) thm
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   638
4da5c5c29009 work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents: 2304
diff changeset
   639
2397
c670a849af65 more experiments with lifting
Christian Urban <urbanc@in.tum.de>
parents: 2389
diff changeset
   640
(* transformes a theorem into one of the object logic *)
c670a849af65 more experiments with lifting
Christian Urban <urbanc@in.tum.de>
parents: 2389
diff changeset
   641
val atomize = Conv.fconv_rule Object_Logic.atomize o forall_intr_vars
c670a849af65 more experiments with lifting
Christian Urban <urbanc@in.tum.de>
parents: 2389
diff changeset
   642
2625
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   643
(* applies a tactic to a formula composed of conjunctions *)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   644
fun conj_tac tac i =
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   645
  let
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   646
     fun select (trm, i) =
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   647
       case trm of
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   648
         @{term "Trueprop"} $ t' => select (t', i)
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   649
       | @{term "op &"} $ _ $ _ => EVERY' [rtac @{thm conjI}, RANGE [conj_tac tac, conj_tac tac]] i
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   650
       | _ => tac i
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   651
  in
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   652
    SUBGOAL select i
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   653
  end
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   654
478c5648e73f moved generic functions into nominal_library
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   655
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   656
end (* structure *)
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   657
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   658
open Nominal_Library;