| author | Christian Urban <urbanc@in.tum.de> | 
| Sun, 12 Sep 2010 22:46:40 +0800 | |
| changeset 2477 | 2f289c1f6cf1 | 
| parent 2476 | 8f8652a8107f | 
| child 2480 | ac7dff1194e8 | 
| permissions | -rw-r--r-- | 
| 2297 | 1  | 
(* Title: nominal_dt_alpha.ML  | 
2  | 
Author: Cezary Kaliszyk  | 
|
3  | 
Author: Christian Urban  | 
|
4  | 
||
| 
2313
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
5  | 
Definitions and proofs for the alpha-relations.  | 
| 2297 | 6  | 
*)  | 
7  | 
||
8  | 
signature NOMINAL_DT_ALPHA =  | 
|
9  | 
sig  | 
|
| 2407 | 10  | 
val define_raw_alpha: string list -> typ list -> cns_info list -> bn_info -> bclause list list list ->  | 
11  | 
term list -> Proof.context -> term list * term list * thm list * thm list * thm * local_theory  | 
|
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
12  | 
|
| 2399 | 13  | 
val mk_alpha_distincts: Proof.context -> thm list -> thm list ->  | 
14  | 
term list -> typ list -> thm list  | 
|
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
15  | 
|
| 
2387
 
082d9fd28f89
helper lemmas for rsp-lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2385 
diff
changeset
 | 
16  | 
val mk_alpha_eq_iff: Proof.context -> thm list -> thm list -> thm list ->  | 
| 
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: 
2469 
diff
changeset
 | 
17  | 
thm list -> thm list  | 
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
18  | 
|
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
19  | 
val alpha_prove: term list -> (term * ((term * term) -> term)) list -> thm ->  | 
| 
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
20  | 
(Proof.context -> int -> tactic) -> Proof.context -> thm list  | 
| 
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
21  | 
|
| 2316 | 22  | 
val raw_prove_refl: term list -> term list -> thm list -> thm -> Proof.context -> thm list  | 
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
23  | 
val raw_prove_sym: term list -> thm list -> thm -> Proof.context -> thm list  | 
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
24  | 
val raw_prove_trans: term list -> thm list -> thm list -> thm -> thm list -> Proof.context -> thm list  | 
| 
2404
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
25  | 
val raw_prove_equivp: term list -> term list -> thm list -> thm list -> thm list ->  | 
| 
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
26  | 
Proof.context -> thm list * thm list  | 
| 
2320
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
27  | 
val raw_prove_bn_imp: term list -> term list -> thm list -> thm -> Proof.context -> thm list  | 
| 
2387
 
082d9fd28f89
helper lemmas for rsp-lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2385 
diff
changeset
 | 
28  | 
val raw_fv_bn_rsp_aux: term list -> term list -> term list -> term list ->  | 
| 
 
082d9fd28f89
helper lemmas for rsp-lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2385 
diff
changeset
 | 
29  | 
term list -> thm -> thm list -> Proof.context -> thm list  | 
| 
2392
 
9294d7cec5e2
proved rsp-helper lemmas of size functions
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2391 
diff
changeset
 | 
30  | 
val raw_size_rsp_aux: term list -> thm -> thm list -> Proof.context -> thm list  | 
| 2395 | 31  | 
val raw_constrs_rsp: term list -> term list -> thm list -> thm list -> Proof.context -> thm list  | 
| 
2440
 
0a36825b16c1
"isabelle make test" makes all major examples....they work up to supp theorems (excluding)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2438 
diff
changeset
 | 
32  | 
val raw_alpha_bn_rsp: term list -> thm list -> thm list -> thm list  | 
| 
2393
 
d9a0cf26a88c
added a function that transforms the helper-rsp lemmas into real rsp lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2392 
diff
changeset
 | 
33  | 
|
| 
2397
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
34  | 
val mk_funs_rsp: thm -> thm  | 
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
35  | 
val mk_alpha_permute_rsp: thm -> thm  | 
| 2297 | 36  | 
end  | 
37  | 
||
38  | 
structure Nominal_Dt_Alpha: NOMINAL_DT_ALPHA =  | 
|
39  | 
struct  | 
|
40  | 
||
| 
2320
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
41  | 
fun lookup xs x = the (AList.lookup (op=) xs x)  | 
| 
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
42  | 
fun group xs = AList.group (op=) xs  | 
| 
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
43  | 
|
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
44  | 
(** definition of the inductive rules for alpha and alpha_bn **)  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
45  | 
|
| 2297 | 46  | 
(* construct the compound terms for prod_fv and prod_alpha *)  | 
47  | 
fun mk_prod_fv (t1, t2) =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
48  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
49  | 
val ty1 = fastype_of t1  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
50  | 
val ty2 = fastype_of t2  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
51  | 
    val resT = HOLogic.mk_prodT (domain_type ty1, domain_type ty2) --> @{typ "atom set"}
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
52  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
53  | 
    Const (@{const_name "prod_fv"}, [ty1, ty2] ---> resT) $ t1 $ t2
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
54  | 
end  | 
| 2297 | 55  | 
|
56  | 
fun mk_prod_alpha (t1, t2) =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
57  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
58  | 
val ty1 = fastype_of t1  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
59  | 
val ty2 = fastype_of t2  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
60  | 
val prodT = HOLogic.mk_prodT (domain_type ty1, domain_type ty2)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
61  | 
    val resT = [prodT, prodT] ---> @{typ "bool"}
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
62  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
63  | 
    Const (@{const_name "prod_alpha"}, [ty1, ty2] ---> resT) $ t1 $ t2
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
64  | 
end  | 
| 2297 | 65  | 
|
66  | 
(* generates the compound binder terms *)  | 
|
| 
2464
 
f4eba60cbd69
made the fv-definition aggree more with alpha (needed in the support proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2440 
diff
changeset
 | 
67  | 
fun mk_binders lthy bmode args binders =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
68  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
69  | 
fun bind_set lthy args (NONE, i) = setify lthy (nth args i)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
70  | 
| bind_set _ args (SOME bn, i) = bn $ (nth args i)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
71  | 
fun bind_lst lthy args (NONE, i) = listify lthy (nth args i)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
72  | 
| bind_lst _ args (SOME bn, i) = bn $ (nth args i)  | 
| 2297 | 73  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
74  | 
val (combine_fn, bind_fn) =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
75  | 
case bmode of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
76  | 
Lst => (mk_append, bind_lst)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
77  | 
| Set => (mk_union, bind_set)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
78  | 
| Res => (mk_union, bind_set)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
79  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
80  | 
binders  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
81  | 
|> map (bind_fn lthy args)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
82  | 
|> foldl1 combine_fn  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
83  | 
end  | 
| 2297 | 84  | 
|
85  | 
(* produces the term for an alpha with abstraction *)  | 
|
86  | 
fun mk_alpha_term bmode fv alpha args args' binders binders' =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
87  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
88  | 
val (alpha_name, binder_ty) =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
89  | 
case bmode of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
90  | 
        Lst => (@{const_name "alpha_lst"}, @{typ "atom list"})
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
91  | 
      | Set => (@{const_name "alpha_set"}, @{typ "atom set"})
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
92  | 
      | Res => (@{const_name "alpha_res"}, @{typ "atom set"})
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
93  | 
val ty = fastype_of args  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
94  | 
val pair_ty = HOLogic.mk_prodT (binder_ty, ty)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
95  | 
    val alpha_ty = [ty, ty] ---> @{typ "bool"}
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
96  | 
    val fv_ty = ty --> @{typ "atom set"}
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
97  | 
val pair_lhs = HOLogic.mk_prod (binders, args)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
98  | 
val pair_rhs = HOLogic.mk_prod (binders', args')  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
99  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
100  | 
    HOLogic.exists_const @{typ perm} $ Abs ("p", @{typ perm},
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
101  | 
      Const (alpha_name, [pair_ty, alpha_ty, fv_ty, @{typ "perm"}, pair_ty] ---> @{typ bool}) 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
102  | 
$ pair_lhs $ alpha $ fv $ (Bound 0) $ pair_rhs)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
103  | 
end  | 
| 2297 | 104  | 
|
105  | 
(* for non-recursive binders we have to produce alpha_bn premises *)  | 
|
106  | 
fun mk_alpha_bn_prem alpha_bn_map args args' bodies binder =  | 
|
107  | 
case binder of  | 
|
108  | 
(NONE, _) => []  | 
|
109  | 
| (SOME bn, i) =>  | 
|
110  | 
if member (op=) bodies i then []  | 
|
| 
2320
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
111  | 
else [lookup alpha_bn_map bn $ nth args i $ nth args' i]  | 
| 2297 | 112  | 
|
| 
2438
 
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2435 
diff
changeset
 | 
113  | 
(* generate the premises for an alpha rule; mk_frees is used  | 
| 2297 | 114  | 
if no binders are present *)  | 
115  | 
fun mk_alpha_prems lthy alpha_map alpha_bn_map is_rec (args, args') bclause =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
116  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
117  | 
fun mk_frees i =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
118  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
119  | 
val arg = nth args i  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
120  | 
val arg' = nth args' i  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
121  | 
val ty = fastype_of arg  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
122  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
123  | 
if nth is_rec i  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
124  | 
then fst (lookup alpha_map ty) $ arg $ arg'  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
125  | 
else HOLogic.mk_eq (arg, arg')  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
126  | 
end  | 
| 2297 | 127  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
128  | 
fun mk_alpha_fv i =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
129  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
130  | 
val ty = fastype_of (nth args i)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
131  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
132  | 
case AList.lookup (op=) alpha_map ty of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
133  | 
NONE => (HOLogic.eq_const ty, supp_const ty)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
134  | 
| SOME (alpha, fv) => (alpha, fv)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
135  | 
end  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
136  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
137  | 
case bclause of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
138  | 
BC (_, [], bodies) => map (HOLogic.mk_Trueprop o mk_frees) bodies  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
139  | 
| BC (bmode, binders, bodies) =>  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
140  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
141  | 
val (alphas, fvs) = split_list (map mk_alpha_fv bodies)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
142  | 
val comp_fv = foldl1 mk_prod_fv fvs  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
143  | 
val comp_alpha = foldl1 mk_prod_alpha alphas  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
144  | 
val comp_args = foldl1 HOLogic.mk_prod (map (nth args) bodies)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
145  | 
val comp_args' = foldl1 HOLogic.mk_prod (map (nth args') bodies)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
146  | 
val comp_binders = mk_binders lthy bmode args binders  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
147  | 
val comp_binders' = mk_binders lthy bmode args' binders  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
148  | 
val alpha_prem =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
149  | 
mk_alpha_term bmode comp_fv comp_alpha comp_args comp_args' comp_binders comp_binders'  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
150  | 
val alpha_bn_prems = flat (map (mk_alpha_bn_prem alpha_bn_map args args' bodies) binders)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
151  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
152  | 
map HOLogic.mk_Trueprop (alpha_prem::alpha_bn_prems)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
153  | 
end  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
154  | 
end  | 
| 2297 | 155  | 
|
156  | 
(* produces the introduction rule for an alpha rule *)  | 
|
157  | 
fun mk_alpha_intros lthy alpha_map alpha_bn_map (constr, ty, arg_tys, is_rec) bclauses =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
158  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
159  | 
val arg_names = Datatype_Prop.make_tnames arg_tys  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
160  | 
val arg_names' = Name.variant_list arg_names arg_names  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
161  | 
val args = map Free (arg_names ~~ arg_tys)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
162  | 
val args' = map Free (arg_names' ~~ arg_tys)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
163  | 
val alpha = fst (lookup alpha_map ty)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
164  | 
val concl = HOLogic.mk_Trueprop (alpha $ list_comb (constr, args) $ list_comb (constr, args'))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
165  | 
val prems = map (mk_alpha_prems lthy alpha_map alpha_bn_map is_rec (args, args')) bclauses  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
166  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
167  | 
Library.foldr Logic.mk_implies (flat prems, concl)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
168  | 
end  | 
| 2297 | 169  | 
|
170  | 
(* produces the premise of an alpha-bn rule; we only need to  | 
|
171  | 
treat the case special where the binding clause is empty;  | 
|
172  | 
||
173  | 
- if the body is not included in the bn_info, then we either  | 
|
174  | 
produce an equation or an alpha-premise  | 
|
175  | 
||
176  | 
- if the body is included in the bn_info, then we create  | 
|
177  | 
either a recursive call to alpha-bn, or no premise *)  | 
|
178  | 
fun mk_alpha_bn lthy alpha_map alpha_bn_map bn_args is_rec (args, args') bclause =  | 
|
179  | 
let  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
180  | 
fun mk_alpha_bn_prem i =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
181  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
182  | 
val arg = nth args i  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
183  | 
val arg' = nth args' i  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
184  | 
val ty = fastype_of arg  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
185  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
186  | 
case AList.lookup (op=) bn_args i of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
187  | 
NONE => (case (AList.lookup (op=) alpha_map ty) of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
188  | 
NONE => [HOLogic.mk_eq (arg, arg')]  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
189  | 
| SOME (alpha, _) => [alpha $ arg $ arg'])  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
190  | 
| SOME (NONE) => []  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
191  | 
| SOME (SOME bn) => [lookup alpha_bn_map bn $ arg $ arg']  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
192  | 
end  | 
| 2297 | 193  | 
in  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
194  | 
case bclause of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
195  | 
BC (_, [], bodies) =>  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
196  | 
map HOLogic.mk_Trueprop (flat (map mk_alpha_bn_prem bodies))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
197  | 
| _ => mk_alpha_prems lthy alpha_map alpha_bn_map is_rec (args, args') bclause  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
198  | 
end  | 
| 2297 | 199  | 
|
200  | 
fun mk_alpha_bn_intro lthy bn_trm alpha_map alpha_bn_map (bn_args, (constr, _, arg_tys, is_rec)) bclauses =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
201  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
202  | 
val arg_names = Datatype_Prop.make_tnames arg_tys  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
203  | 
val arg_names' = Name.variant_list arg_names arg_names  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
204  | 
val args = map Free (arg_names ~~ arg_tys)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
205  | 
val args' = map Free (arg_names' ~~ arg_tys)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
206  | 
val alpha_bn = lookup alpha_bn_map bn_trm  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
207  | 
val concl = HOLogic.mk_Trueprop (alpha_bn $ list_comb (constr, args) $ list_comb (constr, args'))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
208  | 
val prems = map (mk_alpha_bn lthy alpha_map alpha_bn_map bn_args is_rec (args, args')) bclauses  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
209  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
210  | 
Library.foldr Logic.mk_implies (flat prems, concl)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
211  | 
end  | 
| 2297 | 212  | 
|
213  | 
fun mk_alpha_bn_intros lthy alpha_map alpha_bn_map constrs_info bclausesss (bn_trm, bn_n, bn_argss) =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
214  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
215  | 
val nth_constrs_info = nth constrs_info bn_n  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
216  | 
val nth_bclausess = nth bclausesss bn_n  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
217  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
218  | 
map2 (mk_alpha_bn_intro lthy bn_trm alpha_map alpha_bn_map) (bn_argss ~~ nth_constrs_info) nth_bclausess  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
219  | 
end  | 
| 2297 | 220  | 
|
| 2407 | 221  | 
fun define_raw_alpha raw_full_ty_names raw_tys cns_info bn_info bclausesss fvs lthy =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
222  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
223  | 
val alpha_names = map (prefix "alpha_" o Long_Name.base_name) raw_full_ty_names  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
224  | 
    val alpha_tys = map (fn ty => [ty, ty] ---> @{typ bool}) raw_tys
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
225  | 
val alpha_frees = map Free (alpha_names ~~ alpha_tys)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
226  | 
val alpha_map = raw_tys ~~ (alpha_frees ~~ fvs)  | 
| 2297 | 227  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
228  | 
val (bns, bn_tys) = split_list (map (fn (bn, i, _) => (bn, i)) bn_info)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
229  | 
val bn_names = map (fn bn => Long_Name.base_name (fst (dest_Const bn))) bns  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
230  | 
val alpha_bn_names = map (prefix "alpha_") bn_names  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
231  | 
val alpha_bn_arg_tys = map (nth raw_tys) bn_tys  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
232  | 
    val alpha_bn_tys = map (fn ty => [ty, ty] ---> @{typ "bool"}) alpha_bn_arg_tys
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
233  | 
val alpha_bn_frees = map Free (alpha_bn_names ~~ alpha_bn_tys)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
234  | 
val alpha_bn_map = bns ~~ alpha_bn_frees  | 
| 2297 | 235  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
236  | 
val alpha_intros = map2 (map2 (mk_alpha_intros lthy alpha_map alpha_bn_map)) cns_info bclausesss  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
237  | 
val alpha_bn_intros = map (mk_alpha_bn_intros lthy alpha_map alpha_bn_map cns_info bclausesss) bn_info  | 
| 2297 | 238  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
239  | 
val all_alpha_names = map (fn (a, ty) => ((Binding.name a, ty), NoSyn))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
240  | 
(alpha_names @ alpha_bn_names ~~ alpha_tys @ alpha_bn_tys)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
241  | 
val all_alpha_intros = map (pair Attrib.empty_binding) (flat alpha_intros @ flat alpha_bn_intros)  | 
| 
2431
 
331873ebc5cd
can now deal with type variables in nominal datatype definitions
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2407 
diff
changeset
 | 
242  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
243  | 
val (alphas, lthy') = Inductive.add_inductive_i  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
244  | 
       {quiet_mode = true, verbose = false, alt_name = Binding.empty,
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
245  | 
coind = false, no_elim = false, no_ind = false, skip_mono = false, fork_mono = false}  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
246  | 
all_alpha_names [] all_alpha_intros [] lthy  | 
| 2297 | 247  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
248  | 
val all_alpha_trms_loc = #preds alphas;  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
249  | 
val alpha_induct_loc = #raw_induct alphas;  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
250  | 
val alpha_intros_loc = #intrs alphas;  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
251  | 
val alpha_cases_loc = #elims alphas;  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
252  | 
val phi = ProofContext.export_morphism lthy' lthy;  | 
| 2297 | 253  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
254  | 
val all_alpha_trms = map (Morphism.term phi) all_alpha_trms_loc  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
255  | 
val (all_alpha_trms', _) = Variable.importT_terms all_alpha_trms lthy  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
256  | 
val alpha_induct = Morphism.thm phi alpha_induct_loc;  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
257  | 
val alpha_intros = map (Morphism.thm phi) alpha_intros_loc  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
258  | 
val alpha_cases = map (Morphism.thm phi) alpha_cases_loc  | 
| 2298 | 259  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
260  | 
val (alpha_trms, alpha_bn_trms) = chop (length fvs) all_alpha_trms'  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
261  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
262  | 
(alpha_trms, alpha_bn_trms, alpha_intros, alpha_cases, alpha_induct, lthy')  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
263  | 
end  | 
| 2297 | 264  | 
|
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
265  | 
|
| 2316 | 266  | 
|
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
267  | 
(** produces the distinctness theorems **)  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
268  | 
|
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
269  | 
(* transforms the distinctness theorems of the constructors  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
270  | 
to "not-alphas" of the constructors *)  | 
| 2399 | 271  | 
fun mk_distinct_goal ty_trm_assoc neq =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
272  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
273  | 
val (lhs, rhs) =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
274  | 
neq  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
275  | 
|> HOLogic.dest_Trueprop  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
276  | 
|> HOLogic.dest_not  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
277  | 
|> HOLogic.dest_eq  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
278  | 
val ty = fastype_of lhs  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
279  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
280  | 
(lookup ty_trm_assoc ty) $ lhs $ rhs  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
281  | 
|> HOLogic.mk_not  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
282  | 
|> HOLogic.mk_Trueprop  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
283  | 
end  | 
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
284  | 
|
| 2399 | 285  | 
fun distinct_tac cases_thms distinct_thms =  | 
286  | 
rtac notI THEN' eresolve_tac cases_thms  | 
|
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
287  | 
THEN_ALL_NEW asm_full_simp_tac (HOL_ss addsimps distinct_thms)  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
288  | 
|
| 2399 | 289  | 
|
290  | 
fun mk_alpha_distincts ctxt cases_thms distinct_thms alpha_trms alpha_tys =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
291  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
292  | 
(* proper import of type-variables does not work,  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
293  | 
since then they are replaced by new variables, messing  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
294  | 
up the ty_trm assoc list *)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
295  | 
val distinct_thms' = map Thm.legacy_freezeT distinct_thms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
296  | 
val ty_trm_assoc = alpha_tys ~~ alpha_trms  | 
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
297  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
298  | 
fun mk_alpha_distinct distinct_trm =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
299  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
300  | 
val ([trm'], ctxt') = Variable.import_terms true [distinct_trm] ctxt  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
301  | 
val goal = mk_distinct_goal ty_trm_assoc distinct_trm  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
302  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
303  | 
Goal.prove ctxt' [] [] goal  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
304  | 
(K (distinct_tac cases_thms distinct_thms 1))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
305  | 
|> singleton (Variable.export ctxt' ctxt)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
306  | 
end  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
307  | 
|
| 2399 | 308  | 
in  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
309  | 
map (mk_alpha_distinct o prop_of) distinct_thms'  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
310  | 
|> map Thm.varifyT_global  | 
| 2399 | 311  | 
end  | 
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
312  | 
|
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
313  | 
|
| 2316 | 314  | 
|
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
315  | 
(** produces the alpha_eq_iff simplification rules **)  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
316  | 
|
| 
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: 
2469 
diff
changeset
 | 
317  | 
(* in case a theorem is of the form (Rel Const Const), it will be  | 
| 
 
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2469 
diff
changeset
 | 
318  | 
rewritten to ((Rel Const = Const) = True)  | 
| 
 
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2469 
diff
changeset
 | 
319  | 
*)  | 
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
320  | 
fun mk_simp_rule thm =  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
321  | 
case (prop_of thm) of  | 
| 
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: 
2469 
diff
changeset
 | 
322  | 
    @{term "Trueprop"} $ (_ $ Const _ $ Const _) => thm RS @{thm eqTrueI}
 | 
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
323  | 
| _ => thm  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
324  | 
|
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
325  | 
fun alpha_eq_iff_tac dist_inj intros elims =  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
326  | 
SOLVED' (asm_full_simp_tac (HOL_ss addsimps intros)) ORELSE'  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
327  | 
  (rtac @{thm iffI} THEN' 
 | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
328  | 
RANGE [eresolve_tac elims THEN_ALL_NEW asm_full_simp_tac (HOL_ss addsimps dist_inj),  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
329  | 
asm_full_simp_tac (HOL_ss addsimps intros)])  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
330  | 
|
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
331  | 
fun mk_alpha_eq_iff_goal thm =  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
332  | 
let  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
333  | 
val prop = prop_of thm;  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
334  | 
val concl = HOLogic.dest_Trueprop (Logic.strip_imp_concl prop);  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
335  | 
val hyps = map HOLogic.dest_Trueprop (Logic.strip_imp_prems prop);  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
336  | 
fun list_conj l = foldr1 HOLogic.mk_conj l;  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
337  | 
in  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
338  | 
if hyps = [] then HOLogic.mk_Trueprop concl  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
339  | 
else HOLogic.mk_Trueprop (HOLogic.mk_eq (concl, list_conj hyps))  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
340  | 
end;  | 
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
341  | 
|
| 
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
342  | 
fun mk_alpha_eq_iff ctxt alpha_intros distinct_thms inject_thms alpha_elims =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
343  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
344  | 
val ((_, thms_imp), ctxt') = Variable.import false alpha_intros ctxt;  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
345  | 
val goals = map mk_alpha_eq_iff_goal thms_imp;  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
346  | 
val tac = alpha_eq_iff_tac (distinct_thms @ inject_thms) alpha_intros alpha_elims 1;  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
347  | 
val thms = map (fn goal => Goal.prove ctxt' [] [] goal (K tac)) goals;  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
348  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
349  | 
Variable.export ctxt' ctxt thms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
350  | 
|> map mk_simp_rule  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
351  | 
end  | 
| 
2300
 
9fb315392493
added FSet to the correct paper
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2299 
diff
changeset
 | 
352  | 
|
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
353  | 
|
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
354  | 
(** proof by induction over the alpha-definitions **)  | 
| 
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
355  | 
|
| 
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
356  | 
fun is_true @{term "Trueprop True"} = true
 | 
| 
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
357  | 
| is_true _ = false  | 
| 
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
358  | 
|
| 
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
359  | 
fun alpha_prove alphas props alpha_induct_thm cases_tac ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
360  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
361  | 
val arg_tys = map (domain_type o fastype_of) alphas  | 
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
362  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
363  | 
val ((arg_names1, arg_names2), ctxt') =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
364  | 
ctxt  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
365  | 
|> Variable.variant_fixes (replicate (length alphas) "x")  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
366  | 
||>> Variable.variant_fixes (replicate (length alphas) "y")  | 
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
367  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
368  | 
val args1 = map2 (curry Free) arg_names1 arg_tys  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
369  | 
val args2 = map2 (curry Free) arg_names2 arg_tys  | 
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
370  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
371  | 
    val true_trms = replicate (length alphas) (K @{term True})
 | 
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
372  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
373  | 
fun apply_all x fs = map (fn f => f x) fs  | 
| 2477 | 374  | 
|
375  | 
val goals_rhs =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
376  | 
group (props @ (alphas ~~ true_trms))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
377  | 
|> map snd  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
378  | 
|> map2 apply_all (args1 ~~ args2)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
379  | 
|> map fold_conj  | 
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
380  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
381  | 
fun apply_trm_pair t (ar1, ar2) = t $ ar1 $ ar2  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
382  | 
val goals_lhs = map2 apply_trm_pair alphas (args1 ~~ args2)  | 
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
383  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
384  | 
val goals =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
385  | 
(map2 (curry HOLogic.mk_imp) goals_lhs goals_rhs)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
386  | 
|> foldr1 HOLogic.mk_conj  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
387  | 
|> HOLogic.mk_Trueprop  | 
| 2391 | 388  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
389  | 
fun tac ctxt =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
390  | 
HEADGOAL  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
391  | 
(DETERM o (rtac alpha_induct_thm)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
392  | 
         THEN_ALL_NEW FIRST' [rtac @{thm TrueI}, cases_tac ctxt])
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
393  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
394  | 
    Goal.prove ctxt' [] [] goals (fn {context, ...} => tac context)
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
395  | 
|> singleton (ProofContext.export ctxt' ctxt)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
396  | 
|> Datatype_Aux.split_conj_thm  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
397  | 
|> map (fn th => th RS mp)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
398  | 
|> map Datatype_Aux.split_conj_thm  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
399  | 
|> flat  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
400  | 
|> map zero_var_indexes  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
401  | 
|> filter_out (is_true o concl_of)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
402  | 
end  | 
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
403  | 
|
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
404  | 
|
| 2316 | 405  | 
(** reflexivity proof for the alphas **)  | 
406  | 
||
407  | 
val exi_zero = @{lemma "P (0::perm) ==> (? x. P x)" by auto}
 | 
|
408  | 
||
409  | 
fun cases_tac intros =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
410  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
411  | 
    val prod_simps = @{thms split_conv prod_alpha_def prod_rel.simps}
 | 
| 2316 | 412  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
413  | 
    val unbound_tac = REPEAT o (etac @{thm conjE}) THEN' atac  
 | 
| 2316 | 414  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
415  | 
val bound_tac =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
416  | 
EVERY' [ rtac exi_zero,  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
417  | 
               resolve_tac @{thms alpha_refl}, 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
418  | 
asm_full_simp_tac (HOL_ss addsimps prod_simps) ]  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
419  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
420  | 
    REPEAT o FIRST' [rtac @{thm conjI}, 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
421  | 
      resolve_tac intros THEN_ALL_NEW FIRST' [rtac @{thm refl}, unbound_tac, bound_tac]]
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
422  | 
end  | 
| 2316 | 423  | 
|
424  | 
fun raw_prove_refl alpha_trms alpha_bns alpha_intros raw_dt_induct ctxt =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
425  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
426  | 
val arg_tys =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
427  | 
alpha_trms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
428  | 
|> map fastype_of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
429  | 
|> map domain_type  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
430  | 
val arg_bn_tys =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
431  | 
alpha_bns  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
432  | 
|> map fastype_of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
433  | 
|> map domain_type  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
434  | 
val arg_names = Datatype_Prop.make_tnames arg_tys  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
435  | 
val arg_bn_names = map (lookup (arg_tys ~~ arg_names)) arg_bn_tys  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
436  | 
val args = map Free (arg_names ~~ arg_tys)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
437  | 
val arg_bns = map Free (arg_bn_names ~~ arg_bn_tys)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
438  | 
val goal =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
439  | 
group ((arg_bns ~~ alpha_bns) @ (args ~~ alpha_trms))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
440  | 
|> map (fn (ar, cnsts) => map (fn c => c $ ar $ ar) cnsts)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
441  | 
|> map (foldr1 HOLogic.mk_conj)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
442  | 
|> foldr1 HOLogic.mk_conj  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
443  | 
|> HOLogic.mk_Trueprop  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
444  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
445  | 
Goal.prove ctxt arg_names [] goal  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
446  | 
      (fn {context, ...} => 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
447  | 
HEADGOAL (DETERM o (rtac raw_dt_induct) THEN_ALL_NEW cases_tac alpha_intros))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
448  | 
|> Datatype_Aux.split_conj_thm  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
449  | 
|> map Datatype_Aux.split_conj_thm  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
450  | 
|> flat  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
451  | 
end  | 
| 2316 | 452  | 
|
453  | 
||
454  | 
||
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
455  | 
(** symmetry proof for the alphas **)  | 
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
456  | 
|
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
457  | 
val exi_neg = @{lemma "(EX (p::perm). P p) ==> (!!q. P q ==> Q (- q)) ==> EX p. Q p"
 | 
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
458  | 
by (erule exE, rule_tac x="-p" in exI, auto)}  | 
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
459  | 
|
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
460  | 
(* for premises that contain binders *)  | 
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
461  | 
fun prem_bound_tac pred_names ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
462  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
463  | 
fun trans_prem_tac pred_names ctxt =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
464  | 
      SUBPROOF (fn {prems, context, ...} => 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
465  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
466  | 
val prems' = map (transform_prem1 context pred_names) prems  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
467  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
468  | 
resolve_tac prems' 1  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
469  | 
end) ctxt  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
470  | 
    val prod_simps = @{thms split_conv permute_prod.simps prod_alpha_def prod_rel.simps alphas}
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
471  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
472  | 
EVERY'  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
473  | 
[ etac exi_neg,  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
474  | 
        resolve_tac @{thms alpha_sym_eqvt},
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
475  | 
asm_full_simp_tac (HOL_ss addsimps prod_simps),  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
476  | 
        Nominal_Permeq.eqvt_tac ctxt [] [] THEN' rtac @{thm refl},
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
477  | 
trans_prem_tac pred_names ctxt ]  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
478  | 
end  | 
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
479  | 
|
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
480  | 
fun raw_prove_sym alpha_trms alpha_intros alpha_induct ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
481  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
482  | 
val props = map (fn t => fn (x, y) => t $ y $ x) alpha_trms  | 
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
483  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
484  | 
fun tac ctxt =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
485  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
486  | 
val alpha_names = map (fst o dest_Const) alpha_trms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
487  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
488  | 
resolve_tac alpha_intros THEN_ALL_NEW  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
489  | 
        FIRST' [atac, rtac @{thm sym} THEN' atac, prem_bound_tac alpha_names ctxt]
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
490  | 
end  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
491  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
492  | 
alpha_prove alpha_trms (alpha_trms ~~ props) alpha_induct tac ctxt  | 
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
493  | 
end  | 
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
494  | 
|
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
495  | 
|
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
496  | 
(** transitivity proof for alphas **)  | 
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
497  | 
|
| 2314 | 498  | 
(* applies cases rules and resolves them with the last premise *)  | 
| 
2313
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
499  | 
fun ecases_tac cases =  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
500  | 
  Subgoal.FOCUS (fn {prems, ...} =>
 | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
501  | 
HEADGOAL (resolve_tac cases THEN' rtac (List.last prems)))  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
502  | 
|
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
503  | 
fun aatac pred_names =  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
504  | 
  SUBPROOF (fn {prems, context, ...} =>
 | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
505  | 
HEADGOAL (resolve_tac (map (transform_prem1 context pred_names) prems)))  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
506  | 
|
| 2314 | 507  | 
(* instantiates exI with the permutation p + q *)  | 
| 
2313
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
508  | 
val perm_inst_tac =  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
509  | 
  Subgoal.FOCUS (fn {params, ...} => 
 | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
510  | 
let  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
511  | 
val (p, q) = pairself snd (last2 params)  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
512  | 
      val pq_inst = foldl1 (uncurry Thm.capply) [@{cterm "plus::perm => perm => perm"}, p, q]
 | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
513  | 
      val exi_inst = Drule.instantiate' [SOME (@{ctyp "perm"})] [NONE, SOME pq_inst] @{thm exI}
 | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
514  | 
in  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
515  | 
HEADGOAL (rtac exi_inst)  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
516  | 
end)  | 
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
517  | 
|
| 
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
518  | 
fun non_trivial_cases_tac pred_names intros ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
519  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
520  | 
    val prod_simps = @{thms split_conv alphas permute_prod.simps prod_alpha_def prod_rel.simps}
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
521  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
522  | 
resolve_tac intros  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
523  | 
THEN_ALL_NEW (asm_simp_tac HOL_basic_ss THEN'  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
524  | 
TRY o EVERY' (* if binders are present *)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
525  | 
        [ etac @{thm exE},
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
526  | 
          etac @{thm exE},
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
527  | 
perm_inst_tac ctxt,  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
528  | 
          resolve_tac @{thms alpha_trans_eqvt}, 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
529  | 
atac,  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
530  | 
aatac pred_names ctxt,  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
531  | 
          Nominal_Permeq.eqvt_tac ctxt [] [] THEN' rtac @{thm refl},
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
532  | 
asm_full_simp_tac (HOL_ss addsimps prod_simps) ])  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
533  | 
end  | 
| 
2313
 
25d2cdf7d7e4
transitivity proofs done
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2311 
diff
changeset
 | 
534  | 
|
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
535  | 
fun prove_trans_tac pred_names raw_dt_thms intros cases ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
536  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
537  | 
fun all_cases ctxt =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
538  | 
asm_full_simp_tac (HOL_basic_ss addsimps raw_dt_thms)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
539  | 
THEN' TRY o non_trivial_cases_tac pred_names intros ctxt  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
540  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
541  | 
    EVERY' [ rtac @{thm allI}, rtac @{thm impI}, 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
542  | 
ecases_tac cases ctxt THEN_ALL_NEW all_cases ctxt ]  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
543  | 
end  | 
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
544  | 
|
| 
2389
 
0f24c961b5f6
introduced a general alpha_prove method
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2387 
diff
changeset
 | 
545  | 
fun prep_trans_goal alpha_trm (arg1, arg2) =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
546  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
547  | 
val arg_ty = fastype_of arg1  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
548  | 
val mid = alpha_trm $ arg2 $ (Bound 0)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
549  | 
val rhs = alpha_trm $ arg1 $ (Bound 0)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
550  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
551  | 
    HOLogic.all_const arg_ty $ Abs ("z", arg_ty, HOLogic.mk_imp (mid, rhs))
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
552  | 
end  | 
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
553  | 
|
| 
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
554  | 
fun raw_prove_trans alpha_trms raw_dt_thms alpha_intros alpha_induct alpha_cases ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
555  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
556  | 
val alpha_names = map (fst o dest_Const) alpha_trms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
557  | 
val props = map prep_trans_goal alpha_trms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
558  | 
    val norm = @{lemma "A ==> (!x. B x --> C x) ==> (!!x. [|A; B x|] ==> C x)" by simp}  
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
559  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
560  | 
alpha_prove alpha_trms (alpha_trms ~~ props) alpha_induct  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
561  | 
(prove_trans_tac alpha_names raw_dt_thms alpha_intros alpha_cases) ctxt  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
562  | 
end  | 
| 
2311
 
4da5c5c29009
work on transitivity proof
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2300 
diff
changeset
 | 
563  | 
|
| 
2390
 
920366e646b0
further simplification with alpha_prove
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2389 
diff
changeset
 | 
564  | 
|
| 
 
920366e646b0
further simplification with alpha_prove
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2389 
diff
changeset
 | 
565  | 
(** proves the equivp predicate for all alphas **)  | 
| 
2322
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
566  | 
|
| 
2397
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
567  | 
val transp_def' =  | 
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
568  | 
  @{lemma "transp R == !x y. R x y --> (!z. R y z --> R x z)" 
 | 
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
569  | 
by (rule eq_reflection, auto simp add: transp_def)}  | 
| 
2322
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
570  | 
|
| 
2404
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
571  | 
fun raw_prove_equivp alphas alpha_bns refl symm trans ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
572  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
573  | 
    val refl' = map (fold_rule @{thms reflp_def} o atomize) refl
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
574  | 
    val symm' = map (fold_rule @{thms symp_def} o atomize) symm
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
575  | 
val trans' = map (fold_rule [transp_def'] o atomize) trans  | 
| 
2397
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
576  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
577  | 
fun prep_goal t =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
578  | 
      HOLogic.mk_Trueprop (Const (@{const_name "equivp"}, fastype_of t --> @{typ bool}) $ t) 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
579  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
580  | 
Goal.prove_multi ctxt [] [] (map prep_goal (alphas @ alpha_bns))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
581  | 
    (K (HEADGOAL (Goal.conjunction_tac THEN_ALL_NEW (rtac @{thm equivpI} THEN' 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
582  | 
RANGE [resolve_tac refl', resolve_tac symm', resolve_tac trans']))))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
583  | 
|> chop (length alphas)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
584  | 
end  | 
| 
2322
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
585  | 
|
| 
2320
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
586  | 
|
| 
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
587  | 
(* proves that alpha_raw implies alpha_bn *)  | 
| 
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
588  | 
|
| 
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
589  | 
fun raw_prove_bn_imp_tac pred_names alpha_intros ctxt =  | 
| 
2322
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
590  | 
  SUBPROOF (fn {prems, context, ...} => 
 | 
| 
2320
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
591  | 
let  | 
| 
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
592  | 
val prems' = flat (map Datatype_Aux.split_conj_thm prems)  | 
| 
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
593  | 
val prems'' = map (transform_prem1 context pred_names) prems'  | 
| 
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
594  | 
in  | 
| 
2322
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
595  | 
HEADGOAL  | 
| 
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
596  | 
(REPEAT_ALL_NEW  | 
| 
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
597  | 
           (FIRST' [ rtac @{thm TrueI}, 
 | 
| 
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
598  | 
                     rtac @{thm conjI}, 
 | 
| 
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
599  | 
resolve_tac prems',  | 
| 
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
600  | 
resolve_tac prems'',  | 
| 
 
24de7e548094
proved eqvip theorems for alphas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2320 
diff
changeset
 | 
601  | 
resolve_tac alpha_intros ]))  | 
| 
2320
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
602  | 
end) ctxt  | 
| 
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
603  | 
|
| 
2390
 
920366e646b0
further simplification with alpha_prove
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2389 
diff
changeset
 | 
604  | 
fun raw_prove_bn_imp alpha_trms alpha_bn_trms alpha_intros alpha_induct ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
605  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
606  | 
val arg_ty = domain_type o fastype_of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
607  | 
val alpha_names = map (fst o dest_Const) alpha_trms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
608  | 
val ty_assoc = map (fn t => (arg_ty t, t)) alpha_trms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
609  | 
val props = map (fn t => (lookup ty_assoc (arg_ty t), fn (x, y) => t $ x $ y)) alpha_bn_trms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
610  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
611  | 
alpha_prove (alpha_trms @ alpha_bn_trms) props alpha_induct  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
612  | 
(raw_prove_bn_imp_tac alpha_names alpha_intros) ctxt  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
613  | 
end  | 
| 
2320
 
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2316 
diff
changeset
 | 
614  | 
|
| 
2387
 
082d9fd28f89
helper lemmas for rsp-lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2385 
diff
changeset
 | 
615  | 
|
| 
2393
 
d9a0cf26a88c
added a function that transforms the helper-rsp lemmas into real rsp lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2392 
diff
changeset
 | 
616  | 
(* respectfulness for fv_raw / bn_raw *)  | 
| 
2387
 
082d9fd28f89
helper lemmas for rsp-lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2385 
diff
changeset
 | 
617  | 
|
| 
 
082d9fd28f89
helper lemmas for rsp-lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2385 
diff
changeset
 | 
618  | 
fun raw_fv_bn_rsp_aux alpha_trms alpha_bn_trms fvs bns fv_bns alpha_induct simps ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
619  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
620  | 
val arg_ty = domain_type o fastype_of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
621  | 
val ty_assoc = map (fn t => (arg_ty t, t)) alpha_trms  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
622  | 
fun mk_eq' t x y = HOLogic.mk_eq (t $ x, t $ y)  | 
| 
2387
 
082d9fd28f89
helper lemmas for rsp-lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2385 
diff
changeset
 | 
623  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
624  | 
val prop1 = map (fn t => (lookup ty_assoc (arg_ty t), fn (x, y) => mk_eq' t x y)) fvs  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
625  | 
val prop2 = map (fn t => (lookup ty_assoc (arg_ty t), fn (x, y) => mk_eq' t x y)) (bns @ fv_bns)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
626  | 
val prop3 = map2 (fn t1 => fn t2 => (t1, fn (x, y) => mk_eq' t2 x y)) alpha_bn_trms fv_bns  | 
| 
2387
 
082d9fd28f89
helper lemmas for rsp-lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2385 
diff
changeset
 | 
627  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
628  | 
    val ss = HOL_ss addsimps (simps @ @{thms alphas prod_fv.simps set.simps append.simps} 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
629  | 
      @ @{thms Un_assoc Un_insert_left Un_empty_right Un_empty_left}) 
 | 
| 
2438
 
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2435 
diff
changeset
 | 
630  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
631  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
632  | 
alpha_prove (alpha_trms @ alpha_bn_trms) (prop1 @ prop2 @ prop3) alpha_induct  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
633  | 
(K (asm_full_simp_tac ss)) ctxt  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
634  | 
end  | 
| 
2387
 
082d9fd28f89
helper lemmas for rsp-lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2385 
diff
changeset
 | 
635  | 
|
| 2395 | 636  | 
|
| 
2393
 
d9a0cf26a88c
added a function that transforms the helper-rsp lemmas into real rsp lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2392 
diff
changeset
 | 
637  | 
(* respectfulness for size *)  | 
| 
2392
 
9294d7cec5e2
proved rsp-helper lemmas of size functions
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2391 
diff
changeset
 | 
638  | 
|
| 
 
9294d7cec5e2
proved rsp-helper lemmas of size functions
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2391 
diff
changeset
 | 
639  | 
fun raw_size_rsp_aux all_alpha_trms alpha_induct simps ctxt =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
640  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
641  | 
val arg_tys = map (domain_type o fastype_of) all_alpha_trms  | 
| 
2392
 
9294d7cec5e2
proved rsp-helper lemmas of size functions
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2391 
diff
changeset
 | 
642  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
643  | 
fun mk_prop ty (x, y) = HOLogic.mk_eq  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
644  | 
(HOLogic.size_const ty $ x, HOLogic.size_const ty $ y)  | 
| 
2392
 
9294d7cec5e2
proved rsp-helper lemmas of size functions
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2391 
diff
changeset
 | 
645  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
646  | 
val props = map2 (fn trm => fn ty => (trm, mk_prop ty)) all_alpha_trms arg_tys  | 
| 
2392
 
9294d7cec5e2
proved rsp-helper lemmas of size functions
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2391 
diff
changeset
 | 
647  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
648  | 
    val ss = HOL_ss addsimps (simps @ @{thms alphas prod_alpha_def prod_rel.simps 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
649  | 
permute_prod_def prod.cases prod.recs})  | 
| 
2392
 
9294d7cec5e2
proved rsp-helper lemmas of size functions
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2391 
diff
changeset
 | 
650  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
651  | 
    val tac = (TRY o REPEAT o etac @{thm exE}) THEN' asm_full_simp_tac ss
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
652  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
653  | 
alpha_prove all_alpha_trms props alpha_induct (K tac) ctxt  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
654  | 
end  | 
| 
2392
 
9294d7cec5e2
proved rsp-helper lemmas of size functions
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2391 
diff
changeset
 | 
655  | 
|
| 
2393
 
d9a0cf26a88c
added a function that transforms the helper-rsp lemmas into real rsp lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2392 
diff
changeset
 | 
656  | 
|
| 2395 | 657  | 
(* respectfulness for constructors *)  | 
658  | 
||
659  | 
fun raw_constr_rsp_tac alpha_intros simps =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
660  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
661  | 
    val pre_ss = HOL_ss addsimps @{thms fun_rel_def}
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
662  | 
    val post_ss = HOL_ss addsimps @{thms alphas prod_alpha_def prod_rel.simps 
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
663  | 
prod_fv.simps fresh_star_zero permute_zero prod.cases} @ simps  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
664  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
665  | 
asm_full_simp_tac pre_ss  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
666  | 
    THEN' REPEAT o (resolve_tac @{thms allI impI})
 | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
667  | 
THEN' resolve_tac alpha_intros  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
668  | 
THEN_ALL_NEW (TRY o (rtac exi_zero) THEN' asm_full_simp_tac post_ss)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
669  | 
end  | 
| 2395 | 670  | 
|
671  | 
||
672  | 
fun raw_constrs_rsp constrs alpha_trms alpha_intros simps ctxt =  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
673  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
674  | 
val alpha_arg_tys = map (domain_type o fastype_of) alpha_trms  | 
| 2395 | 675  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
676  | 
fun lookup ty =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
677  | 
case AList.lookup (op=) (alpha_arg_tys ~~ alpha_trms) ty of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
678  | 
NONE => HOLogic.eq_const ty  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
679  | 
| SOME alpha => alpha  | 
| 2395 | 680  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
681  | 
fun fun_rel_app t1 t2 =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
682  | 
      Const (@{const_name "fun_rel"}, dummyT) $ t1 $ t2
 | 
| 2395 | 683  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
684  | 
fun prep_goal trm =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
685  | 
trm  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
686  | 
|> strip_type o fastype_of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
687  | 
|>> map lookup  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
688  | 
||> lookup  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
689  | 
|> uncurry (fold_rev fun_rel_app)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
690  | 
|> (fn t => t $ trm $ trm)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
691  | 
|> Syntax.check_term ctxt  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
692  | 
|> HOLogic.mk_Trueprop  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
693  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
694  | 
Goal.prove_multi ctxt [] [] (map prep_goal constrs)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
695  | 
(K (HEADGOAL  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
696  | 
(Goal.conjunction_tac THEN_ALL_NEW raw_constr_rsp_tac alpha_intros simps)))  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
697  | 
end  | 
| 2395 | 698  | 
|
699  | 
||
| 
2404
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
700  | 
(* rsp lemmas for alpha_bn relations *)  | 
| 
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
701  | 
|
| 
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
702  | 
val rsp_equivp =  | 
| 
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
703  | 
  @{lemma "[|equivp Q; !!x y. R x y ==> Q x y|] ==> (R ===> R ===> op =) Q Q"
 | 
| 
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
704  | 
by (simp only: fun_rel_def equivp_def, metis)}  | 
| 
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
705  | 
|
| 
2440
 
0a36825b16c1
"isabelle make test" makes all major examples....they work up to supp theorems (excluding)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2438 
diff
changeset
 | 
706  | 
|
| 
 
0a36825b16c1
"isabelle make test" makes all major examples....they work up to supp theorems (excluding)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2438 
diff
changeset
 | 
707  | 
(* we have to reorder the alpha_bn_imps theorems in order  | 
| 
 
0a36825b16c1
"isabelle make test" makes all major examples....they work up to supp theorems (excluding)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2438 
diff
changeset
 | 
708  | 
to be in order with alpha_bn_trms *)  | 
| 
 
0a36825b16c1
"isabelle make test" makes all major examples....they work up to supp theorems (excluding)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2438 
diff
changeset
 | 
709  | 
fun raw_alpha_bn_rsp alpha_bn_trms alpha_bn_equivp alpha_bn_imps =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
710  | 
let  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
711  | 
fun mk_map thm =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
712  | 
thm |> `prop_of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
713  | 
|>> List.last o snd o strip_comb  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
714  | 
|>> HOLogic.dest_Trueprop  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
715  | 
|>> head_of  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
716  | 
|>> fst o dest_Const  | 
| 
2440
 
0a36825b16c1
"isabelle make test" makes all major examples....they work up to supp theorems (excluding)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2438 
diff
changeset
 | 
717  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
718  | 
val alpha_bn_imps' =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
719  | 
map (lookup (map mk_map alpha_bn_imps) o fst o dest_Const) alpha_bn_trms  | 
| 
2440
 
0a36825b16c1
"isabelle make test" makes all major examples....they work up to supp theorems (excluding)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2438 
diff
changeset
 | 
720  | 
|
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
721  | 
fun mk_thm thm1 thm2 =  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
722  | 
(forall_intr_vars thm2) COMP (thm1 RS rsp_equivp)  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
723  | 
in  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
724  | 
map2 mk_thm alpha_bn_equivp alpha_bn_imps'  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
725  | 
end  | 
| 
2404
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
726  | 
|
| 
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
727  | 
|
| 2399 | 728  | 
(* transformation of the natural rsp-lemmas into standard form *)  | 
| 
2397
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
729  | 
|
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
730  | 
val fun_rsp = @{lemma
 | 
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
731  | 
"(!x y. R x y --> f x = f y) ==> (R ===> (op =)) f f" by simp}  | 
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
732  | 
|
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
733  | 
fun mk_funs_rsp thm =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
734  | 
thm  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
735  | 
|> atomize  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
736  | 
|> single  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
737  | 
|> curry (op OF) fun_rsp  | 
| 
2393
 
d9a0cf26a88c
added a function that transforms the helper-rsp lemmas into real rsp lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2392 
diff
changeset
 | 
738  | 
|
| 
2397
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
739  | 
|
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
740  | 
val permute_rsp = @{lemma 
 | 
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
741  | 
"(!x y p. R x y --> R (permute p x) (permute p y))  | 
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
742  | 
==> ((op =) ===> R ===> R) permute permute" by simp}  | 
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
743  | 
|
| 
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
744  | 
fun mk_alpha_permute_rsp thm =  | 
| 
2476
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
745  | 
thm  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
746  | 
|> atomize  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
747  | 
|> single  | 
| 
 
8f8652a8107f
tuned (to conform with indentation policy of Markus)
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2475 
diff
changeset
 | 
748  | 
|> curry (op OF) permute_rsp  | 
| 
2397
 
c670a849af65
more experiments with lifting
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2395 
diff
changeset
 | 
749  | 
|
| 
2393
 
d9a0cf26a88c
added a function that transforms the helper-rsp lemmas into real rsp lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2392 
diff
changeset
 | 
750  | 
|
| 
 
d9a0cf26a88c
added a function that transforms the helper-rsp lemmas into real rsp lemmas
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2392 
diff
changeset
 | 
751  | 
|
| 
2404
 
66ae73fd66c0
added rsp-lemmas for alpha_bns
 
Christian Urban <urbanc@in.tum.de> 
parents: 
2399 
diff
changeset
 | 
752  | 
|
| 2297 | 753  | 
end (* structure *)  | 
754  |