author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Tue, 23 Feb 2010 09:34:41 +0100 | |
changeset 1218 | 2bbfbc9a81fc |
parent 1066 | 96651cddeba9 |
permissions | -rw-r--r-- |
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
(* Title: nominal_thmdecls.ML |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
Author: Brian Huffman, Christian Urban |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
*) |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
signature NOMINAL_PERMEQ = |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
sig |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
val eqvt_tac: Proof.context -> int -> tactic |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
end; |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
(* TODO: |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
- provide a method interface with the usual add and del options |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
- print a warning if for a constant no eqvt lemma is stored |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
- there seems to be too much simplified in case of multiple |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
permutations, like |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
p o q o r o x |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
we usually only want the outermost permutation to "float" in |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
*) |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
structure Nominal_Permeq: NOMINAL_PERMEQ = |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
struct |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
local |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
30 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
fun eqvt_apply_conv ctxt ct = |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
case (term_of ct) of |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
(Const (@{const_name "permute"}, _) $ _ $ (_ $ _)) => |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
let |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
35 |
val (perm, t) = Thm.dest_comb ct |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
36 |
val (_, p) = Thm.dest_comb perm |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
val (f, x) = Thm.dest_comb t |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
val a = ctyp_of_term x; |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
val b = ctyp_of_term t; |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
val ty_insts = map SOME [b, a] |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
val term_insts = map SOME [p, f, x] |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
in |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
43 |
Drule.instantiate' ty_insts term_insts @{thm eqvt_apply} |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
end |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
| _ => Conv.no_conv ct |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
fun eqvt_lambda_conv ctxt ct = |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
case (term_of ct) of |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
(Const (@{const_name "permute"}, _) $ _ $ Abs _) => |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
50 |
Conv.rewr_conv @{thm eqvt_lambda} ct |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
51 |
| _ => Conv.no_conv ct |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
53 |
in |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
54 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
fun eqvt_conv ctxt ct = |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
Conv.first_conv |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
[ Conv.rewr_conv @{thm eqvt_bound}, |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
eqvt_apply_conv ctxt |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
then_conv Conv.comb_conv (eqvt_conv ctxt), |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
eqvt_lambda_conv ctxt |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
then_conv Conv.abs_conv (fn (v, ctxt) => eqvt_conv ctxt) ctxt, |
1066
96651cddeba9
eqvts and eqvts_raw are separate thm-lists; otherwise permute_eqvt is problematic as it causes looks in eqvts
Christian Urban <urbanc@in.tum.de>
parents:
1059
diff
changeset
|
62 |
More_Conv.rewrs_conv (Nominal_ThmDecls.get_eqvts_raw_thms ctxt), |
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
Conv.all_conv |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
64 |
] ct |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
65 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
66 |
fun eqvt_tac ctxt = |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
CONVERSION (More_Conv.bottom_conv (fn ctxt => eqvt_conv ctxt) ctxt) |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
end |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
end; (* structure *) |