author | Christian Urban <urbanc@in.tum.de> |
Mon, 04 Jun 2012 21:39:51 +0100 | |
changeset 3183 | 313e6f2cdd89 |
parent 2781 | 542ff50555f5 |
child 3229 | b52e8651591f |
permissions | -rw-r--r-- |
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
1 |
(* Title: nominal_permeq.ML |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
2 |
Author: Christian Urban |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
3 |
Author: Brian Huffman |
1037
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 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
6 |
infix 4 addpres addposts addexcls |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
7 |
|
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
signature NOMINAL_PERMEQ = |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
sig |
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
10 |
datatype eqvt_config = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
11 |
Eqvt_Config of {strict_mode: bool, pre_thms: thm list, post_thms: thm list, excluded: string list} |
2610
f5c7375ab465
added theorem-rewriter conversion
Christian Urban <urbanc@in.tum.de>
parents:
2568
diff
changeset
|
12 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
13 |
val eqvt_relaxed_config: eqvt_config |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
14 |
val eqvt_strict_config: eqvt_config |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
15 |
val addpres : (eqvt_config * thm list) -> eqvt_config |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
16 |
val addposts : (eqvt_config * thm list) -> eqvt_config |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
17 |
val addexcls : (eqvt_config * string list) -> eqvt_config |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
18 |
val delpres : eqvt_config -> eqvt_config |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
19 |
val delposts : eqvt_config -> eqvt_config |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
20 |
|
3183
313e6f2cdd89
added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents:
2781
diff
changeset
|
21 |
val eqvt_conv: Proof.context -> eqvt_config -> conv |
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
22 |
val eqvt_rule: Proof.context -> eqvt_config -> thm -> thm |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
23 |
val eqvt_tac: Proof.context -> eqvt_config -> int -> tactic |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
24 |
|
1947 | 25 |
val perm_simp_meth: thm list * string list -> Proof.context -> Method.method |
26 |
val perm_strict_simp_meth: thm list * string list -> Proof.context -> Method.method |
|
27 |
val args_parser: (thm list * string list) context_parser |
|
28 |
||
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
29 |
val trace_eqvt: bool Config.T |
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
30 |
end; |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
32 |
(* |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
33 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
34 |
- eqvt_tac and eqvt_rule take a list of theorems which |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
35 |
are first tried to simplify permutations |
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
36 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
37 |
- the string list contains constants that should not be |
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
38 |
analysed (for example there is no raw eqvt-lemma for |
2080
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
39 |
the constant The); therefore it should not be analysed |
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
41 |
- setting [[trace_eqvt = true]] switches on tracing |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
42 |
information |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
43 |
|
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
*) |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
|
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
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
|
47 |
struct |
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
49 |
open Nominal_ThmDecls; |
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
50 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
51 |
datatype eqvt_config = Eqvt_Config of |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
52 |
{strict_mode: bool, pre_thms: thm list, post_thms: thm list, excluded: string list} |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
53 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
54 |
fun (Eqvt_Config {strict_mode, pre_thms, post_thms, excluded}) addpres thms = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
55 |
Eqvt_Config { strict_mode = strict_mode, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
56 |
pre_thms = thms @ pre_thms, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
57 |
post_thms = post_thms, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
58 |
excluded = excluded } |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
59 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
60 |
fun (Eqvt_Config {strict_mode, pre_thms, post_thms, excluded}) addposts thms = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
61 |
Eqvt_Config { strict_mode = strict_mode, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
62 |
pre_thms = pre_thms, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
63 |
post_thms = thms @ post_thms, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
64 |
excluded = excluded } |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
65 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
66 |
fun (Eqvt_Config {strict_mode, pre_thms, post_thms, excluded}) addexcls excls = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
67 |
Eqvt_Config { strict_mode = strict_mode, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
68 |
pre_thms = pre_thms, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
69 |
post_thms = post_thms, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
70 |
excluded = excls @ excluded } |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
71 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
72 |
fun delpres (Eqvt_Config {strict_mode, pre_thms, post_thms, excluded}) = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
73 |
Eqvt_Config { strict_mode = strict_mode, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
74 |
pre_thms = [], |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
75 |
post_thms = post_thms, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
76 |
excluded = excluded } |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
77 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
78 |
fun delposts (Eqvt_Config {strict_mode, pre_thms, post_thms, excluded}) = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
79 |
Eqvt_Config { strict_mode = strict_mode, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
80 |
pre_thms = pre_thms, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
81 |
post_thms = [], |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
82 |
excluded = excluded } |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
83 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
84 |
val eqvt_relaxed_config = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
85 |
Eqvt_Config { strict_mode = false, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
86 |
pre_thms = @{thms eqvt_bound}, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
87 |
post_thms = @{thms permute_pure}, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
88 |
excluded = [] } |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
89 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
90 |
val eqvt_strict_config = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
91 |
Eqvt_Config { strict_mode = true, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
92 |
pre_thms = @{thms eqvt_bound}, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
93 |
post_thms = @{thms permute_pure}, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
94 |
excluded = [] } |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
95 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
96 |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
97 |
(* tracing infrastructure *) |
2781
542ff50555f5
updated to new Isabelle (> 9 May)
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
98 |
val trace_eqvt = Attrib.setup_config_bool @{binding "trace_eqvt"} (K false); |
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
99 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
100 |
fun trace_enabled ctxt = Config.get ctxt trace_eqvt |
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
101 |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
102 |
fun trace_msg ctxt result = |
2477 | 103 |
let |
104 |
val lhs_str = Syntax.string_of_term ctxt (term_of (Thm.lhs_of result)) |
|
105 |
val rhs_str = Syntax.string_of_term ctxt (term_of (Thm.rhs_of result)) |
|
106 |
in |
|
107 |
warning (Pretty.string_of (Pretty.strs ["Rewriting", lhs_str, "to", rhs_str])) |
|
108 |
end |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
109 |
|
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
110 |
fun trace_conv ctxt conv ctrm = |
2477 | 111 |
let |
112 |
val result = conv ctrm |
|
113 |
in |
|
114 |
if Thm.is_reflexive result |
|
115 |
then result |
|
116 |
else (trace_msg ctxt result; result) |
|
117 |
end |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
118 |
|
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
119 |
(* this conversion always fails, but prints |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
120 |
out the analysed term *) |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
121 |
fun trace_info_conv ctxt ctrm = |
2477 | 122 |
let |
123 |
val trm = term_of ctrm |
|
124 |
val _ = case (head_of trm) of |
|
125 |
@{const "Trueprop"} => () |
|
126 |
| _ => warning ("Analysing term " ^ Syntax.string_of_term ctxt trm) |
|
127 |
in |
|
128 |
Conv.no_conv ctrm |
|
129 |
end |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
130 |
|
2080
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
131 |
(* conversion for applications *) |
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
132 |
fun eqvt_apply_conv ctrm = |
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
133 |
case (term_of ctrm) of |
2080
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
134 |
Const (@{const_name "permute"}, _) $ _ $ (_ $ _) => |
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
135 |
let |
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
136 |
val (perm, t) = Thm.dest_comb ctrm |
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
val ty_insts = map SOME [b, a] |
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
142 |
val term_insts = map SOME [p, f, x] |
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
143 |
in |
2080
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
144 |
Drule.instantiate' ty_insts term_insts @{thm eqvt_apply} |
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
145 |
end |
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
146 |
| _ => Conv.no_conv ctrm |
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
147 |
|
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
148 |
(* conversion for lambdas *) |
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
149 |
fun eqvt_lambda_conv ctrm = |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
150 |
case (term_of ctrm) of |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
151 |
Const (@{const_name "permute"}, _) $ _ $ (Abs _) => |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
152 |
Conv.rewr_conv @{thm eqvt_lambda} ctrm |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
153 |
| _ => Conv.no_conv ctrm |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
154 |
|
2080
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
155 |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
156 |
(* conversion that raises an error or prints a warning message, |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
157 |
if a permutation on a constant or application cannot be analysed *) |
2080
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
158 |
|
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
159 |
fun is_excluded excluded (Const (a, _)) = member (op=) excluded a |
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
160 |
| is_excluded _ _ = false |
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
161 |
|
0532006ec7ec
added eqvt-lemma for split; changed semantics of perm_simp: excluded stands for constants about which no complaint is written out...eqvt_apply is now always applied
Christian Urban <urbanc@in.tum.de>
parents:
2069
diff
changeset
|
162 |
fun progress_info_conv ctxt strict_flag excluded ctrm = |
2477 | 163 |
let |
164 |
fun msg trm = |
|
165 |
if is_excluded excluded trm then () else |
|
166 |
(if strict_flag then error else warning) |
|
167 |
("Cannot solve equivariance for " ^ (Syntax.string_of_term ctxt trm)) |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
168 |
|
2477 | 169 |
val _ = case (term_of ctrm) of |
170 |
Const (@{const_name "permute"}, _) $ _ $ (trm as Const _) => msg trm |
|
171 |
| Const (@{const_name "permute"}, _) $ _ $ (trm as _ $ _) => msg trm |
|
172 |
| _ => () |
|
173 |
in |
|
174 |
Conv.all_conv ctrm |
|
175 |
end |
|
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
176 |
|
2064
2725853f43b9
solved the problem with equivariance by first eta-normalising the goal
Christian Urban <urbanc@in.tum.de>
parents:
1947
diff
changeset
|
177 |
(* main conversion *) |
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
178 |
fun main_eqvt_conv ctxt config ctrm = |
2477 | 179 |
let |
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
180 |
val Eqvt_Config {strict_mode, pre_thms, post_thms, excluded} = config |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
181 |
|
2477 | 182 |
val first_conv_wrapper = |
183 |
if trace_enabled ctxt |
|
184 |
then Conv.first_conv o (cons (trace_info_conv ctxt)) o (map (trace_conv ctxt)) |
|
185 |
else Conv.first_conv |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
186 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
187 |
val all_pre_thms = map safe_mk_equiv (pre_thms @ get_eqvts_raw_thms ctxt) |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
188 |
val all_post_thms = map safe_mk_equiv post_thms |
2477 | 189 |
in |
190 |
first_conv_wrapper |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
191 |
[ Conv.rewrs_conv all_pre_thms, |
2477 | 192 |
eqvt_apply_conv, |
193 |
eqvt_lambda_conv, |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
194 |
Conv.rewrs_conv all_post_thms, |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
195 |
progress_info_conv ctxt strict_mode excluded |
2477 | 196 |
] ctrm |
197 |
end |
|
1037
2845e736dc1a
added a first eqvt_tac which pushes permutations inside terms
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
198 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
199 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
200 |
(* the eqvt-conversion first eta-normalises goals in |
2064
2725853f43b9
solved the problem with equivariance by first eta-normalising the goal
Christian Urban <urbanc@in.tum.de>
parents:
1947
diff
changeset
|
201 |
order to avoid problems with inductions in the |
2610
f5c7375ab465
added theorem-rewriter conversion
Christian Urban <urbanc@in.tum.de>
parents:
2568
diff
changeset
|
202 |
equivariance command. *) |
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
203 |
fun eqvt_conv ctxt config = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
204 |
Conv.top_conv (fn ctxt => Thm.eta_conversion then_conv (main_eqvt_conv ctxt config)) ctxt |
2610
f5c7375ab465
added theorem-rewriter conversion
Christian Urban <urbanc@in.tum.de>
parents:
2568
diff
changeset
|
205 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
206 |
(* thms rewriter *) |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
207 |
fun eqvt_rule ctxt config = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
208 |
Conv.fconv_rule (eqvt_conv ctxt config) |
2610
f5c7375ab465
added theorem-rewriter conversion
Christian Urban <urbanc@in.tum.de>
parents:
2568
diff
changeset
|
209 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
210 |
(* tactic *) |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
211 |
fun eqvt_tac ctxt config = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
212 |
CONVERSION (eqvt_conv ctxt config) |
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
213 |
|
1947 | 214 |
|
215 |
(** methods **) |
|
2291
20ee31bc34d5
proper parser for "exclude:"
Christian Urban <urbanc@in.tum.de>
parents:
2150
diff
changeset
|
216 |
fun unless_more_args scan = Scan.unless (Scan.lift ((Args.$$$ "exclude") -- Args.colon)) scan |
20ee31bc34d5
proper parser for "exclude:"
Christian Urban <urbanc@in.tum.de>
parents:
2150
diff
changeset
|
217 |
|
20ee31bc34d5
proper parser for "exclude:"
Christian Urban <urbanc@in.tum.de>
parents:
2150
diff
changeset
|
218 |
val add_thms_parser = Scan.optional (Scan.lift (Args.add -- Args.colon) |-- |
20ee31bc34d5
proper parser for "exclude:"
Christian Urban <urbanc@in.tum.de>
parents:
2150
diff
changeset
|
219 |
Scan.repeat (unless_more_args Attrib.multi_thm) >> flat) []; |
20ee31bc34d5
proper parser for "exclude:"
Christian Urban <urbanc@in.tum.de>
parents:
2150
diff
changeset
|
220 |
|
1947 | 221 |
val exclude_consts_parser = Scan.optional (Scan.lift ((Args.$$$ "exclude") -- Args.colon) |-- |
222 |
(Scan.repeat (Args.const true))) [] |
|
223 |
||
2064
2725853f43b9
solved the problem with equivariance by first eta-normalising the goal
Christian Urban <urbanc@in.tum.de>
parents:
1947
diff
changeset
|
224 |
val args_parser = add_thms_parser -- exclude_consts_parser |
1947 | 225 |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
226 |
fun perm_simp_meth (thms, consts) ctxt = |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
227 |
SIMPLE_METHOD (HEADGOAL (eqvt_tac ctxt (eqvt_relaxed_config addpres thms addexcls consts))) |
1947 | 228 |
|
229 |
fun perm_strict_simp_meth (thms, consts) ctxt = |
|
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2610
diff
changeset
|
230 |
SIMPLE_METHOD (HEADGOAL (eqvt_tac ctxt (eqvt_strict_config addpres thms addexcls consts))) |
1947 | 231 |
|
2069
2b6ba4d4e19a
Fixes for new isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2064
diff
changeset
|
232 |
end; (* structure *) |