author | Christian Urban <urbanc@in.tum.de> |
Wed, 22 Dec 2010 21:13:32 +0000 | |
changeset 2621 | 02b24877be3e |
parent 2619 | 25fb0dbe9f13 |
child 2623 | 2d2e610a0de3 |
permissions | -rw-r--r-- |
2454
9ffee4eb1ae1
renamed NewParser to Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
2451
diff
changeset
|
1 |
theory Nominal2 |
2435
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
2 |
imports |
2568
8193bbaa07fe
merged Nominal-General directory into Nominal; renamed Abs.thy to Nominal2_Abs.thy
Christian Urban <urbanc@in.tum.de>
parents:
2566
diff
changeset
|
3 |
Nominal2_Base Nominal2_Eqvt Nominal2_Abs |
2598
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2595
diff
changeset
|
4 |
uses ("nominal_dt_rawfuns.ML") |
2435
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
5 |
("nominal_dt_alpha.ML") |
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
6 |
("nominal_dt_quot.ML") |
1941 | 7 |
begin |
8 |
||
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
9 |
|
2435
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
10 |
use "nominal_dt_rawfuns.ML" |
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
11 |
ML {* open Nominal_Dt_RawFuns *} |
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
12 |
|
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
13 |
use "nominal_dt_alpha.ML" |
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
14 |
ML {* open Nominal_Dt_Alpha *} |
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
15 |
|
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
16 |
use "nominal_dt_quot.ML" |
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
17 |
ML {* open Nominal_Dt_Quot *} |
3772bb3bd7ce
cleaning of unused files and code
Christian Urban <urbanc@in.tum.de>
parents:
2434
diff
changeset
|
18 |
|
2607
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
19 |
text {* TEST *} |
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
20 |
|
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
21 |
ML {* |
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
22 |
fun strip_outer_params (Const("all", _) $ Abs (a, T, t)) = strip_outer_params t |>> cons (a, T) |
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
23 |
| strip_outer_params B = ([], B) |
2608
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
24 |
|
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
25 |
fun strip_params_prems_concl trm = |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
26 |
let |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
27 |
val (params, body) = strip_outer_params trm |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
28 |
val (prems, concl) = Logic.strip_horn body |
2608
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
29 |
in |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
30 |
(params, prems, concl) |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
31 |
end |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
32 |
|
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
33 |
fun list_params_prems_concl params prems concl = |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
34 |
Logic.list_implies (prems, concl) |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
35 |
|> fold_rev mk_all params |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
36 |
|
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
37 |
fun mk_binop_env tys c (t, u) = |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
38 |
let val ty = fastype_of1 (tys, t) in |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
39 |
Const (c, [ty, ty] ---> ty) $ t $ u |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
40 |
end |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
41 |
|
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
42 |
fun mk_union_env tys (t1, @{term "{}::atom set"}) = t1 |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
43 |
| mk_union_env tys (@{term "{}::atom set"}, t2) = t2 |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
44 |
| mk_union_env tys (t1, @{term "set ([]::atom list)"}) = t1 |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
45 |
| mk_union_env tys (@{term "set ([]::atom list)"}, t2) = t2 |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
46 |
| mk_union_env tys (t1, t2) = mk_binop_env tys @{const_name "sup"} (t1, t2) |
2621
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
47 |
*} |
2608
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
48 |
|
2621
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
49 |
ML {* |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
50 |
fun fold_left f [] z = z |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
51 |
| fold_left f [x] z = x |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
52 |
| fold_left f (x :: y :: xs) z = fold_left f (f (x, y) :: xs) z |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
53 |
*} |
2608
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
54 |
|
2621
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
55 |
ML {* |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
56 |
fun fold_union_env tys trms = fold_left (mk_union_env tys) trms @{term "{}::atom set"} |
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
57 |
*} |
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
58 |
|
2621
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
59 |
ML {* |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
60 |
fold_union_env [] [@{term "t1::atom set"}, @{term "t2::atom set"}, @{term "t3::atom set"}] |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
61 |
|> Syntax.string_of_term @{context} |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
62 |
|> writeln |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
63 |
*} |
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
64 |
|
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
65 |
|
02b24877be3e
added fold_right which produces the correct term for left-infix operators
Christian Urban <urbanc@in.tum.de>
parents:
2619
diff
changeset
|
66 |
|
2607
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
67 |
|
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
68 |
ML {* |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
69 |
fun process_ecase lthy c (params, prems, concl) bclauses = |
2607
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
70 |
let |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
71 |
val tys = map snd params |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
72 |
val binders = get_all_binders bclauses |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
73 |
|
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
74 |
fun prep_binder (opt, i) = |
2608
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
75 |
let |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
76 |
val t = Bound (length tys - i - 1) |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
77 |
in |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
78 |
case opt of |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
79 |
NONE => setify_ty lthy (nth tys i) t |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
80 |
| SOME bn => to_set_ty (fastype_of1 (tys, bn $ t)) (bn $ t) |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
81 |
end |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
82 |
|
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
83 |
val fresh_prem = |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
84 |
case binders of |
2613 | 85 |
[] => [] (* case: no binders *) |
86 |
| _ => binders (* case: binders *) |
|
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
87 |
|> map prep_binder |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
88 |
|> fold_union_env tys |
2608
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
89 |
|> (fn t => mk_fresh_star t c) |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
90 |
|> HOLogic.mk_Trueprop |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
91 |
|> single |
2607
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
92 |
in |
2608
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
93 |
list_params_prems_concl params (fresh_prem @ prems) concl |
86e3b39c2a60
created strong_exhausts terms
Christian Urban <urbanc@in.tum.de>
parents:
2607
diff
changeset
|
94 |
end |
2607
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
95 |
*} |
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
96 |
|
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
97 |
|
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
98 |
ML {* |
2613 | 99 |
(* derives the freshness theorem that there exists a p, such that |
100 |
(p o as) #* (c, t1,\<dots>, tn) *) |
|
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
101 |
fun fresh_thm ctxt c parms binders bn_finite_thms = |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
102 |
let |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
103 |
fun prep_binder (opt, i) = |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
104 |
case opt of |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
105 |
NONE => setify ctxt (nth parms i) |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
106 |
| SOME bn => to_set (bn $ (nth parms i)) |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
107 |
|
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
108 |
fun prep_binder2 (opt, i) = |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
109 |
case opt of |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
110 |
NONE => atomify ctxt (nth parms i) |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
111 |
| SOME bn => bn $ (nth parms i) |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
112 |
|
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
113 |
val rhs = HOLogic.mk_tuple ([c] @ parms @ (map prep_binder2 binders)) |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
114 |
val lhs = binders |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
115 |
|> map prep_binder |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
116 |
|> fold_union |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
117 |
|> mk_perm (Bound 0) |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
118 |
|
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
119 |
val goal = mk_fresh_star lhs rhs |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
120 |
|> (fn t => HOLogic.mk_exists ("p", @{typ perm}, t)) |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
121 |
|> HOLogic.mk_Trueprop |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
122 |
|
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
123 |
val ss = bn_finite_thms @ @{thms supp_Pair finite_supp finite_sets_supp} |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
124 |
@ @{thms finite.intros finite_Un finite_set finite_fset} |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
125 |
in |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
126 |
Goal.prove ctxt [] [] goal |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
127 |
(K (HEADGOAL (rtac @{thm at_set_avoiding1} |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
128 |
THEN_ALL_NEW (simp_tac (HOL_ss addsimps ss))))) |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
129 |
end |
2613 | 130 |
*} |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
131 |
|
2613 | 132 |
ML {* |
133 |
(* derives abs_eq theorems of the form Exists s. [as].t = [p o as].s *) |
|
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
134 |
fun abs_eq_thm ctxt fprops p parms bn_finite_thms bn_eqvt permute_bns |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
135 |
(bclause as (BC (bmode, binders, bodies))) = |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
136 |
case binders of |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
137 |
[] => [] |
2613 | 138 |
| _ => |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
139 |
let |
2613 | 140 |
val binder_trm = comb_binders ctxt bmode parms binders |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
141 |
val body_trm = foldl1 HOLogic.mk_prod (map (nth parms) bodies) |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
142 |
val body_ty = fastype_of body_trm |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
143 |
|
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
144 |
val (abs_name, binder_ty, abs_ty) = |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
145 |
case bmode of |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
146 |
Lst => (@{const_name "Abs_lst"}, @{typ "atom list"}, @{type_name abs_lst}) |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
147 |
| Set => (@{const_name "Abs_set"}, @{typ "atom set"}, @{type_name abs_set}) |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
148 |
| Res => (@{const_name "Abs_res"}, @{typ "atom set"}, @{type_name abs_res}) |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
149 |
|
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
150 |
val abs = Const (abs_name, [binder_ty, body_ty] ---> Type (abs_ty, [body_ty])) |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
151 |
val abs_lhs = abs $ binder_trm $ body_trm |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
152 |
val abs_rhs = abs $ mk_perm p binder_trm $ mk_perm (Bound 0) body_trm |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
153 |
val abs_rhs' = abs $ mk_perm (Bound 0) binder_trm $ mk_perm (Bound 0) body_trm |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
154 |
val abs_eq = HOLogic.mk_eq (abs_lhs, abs_rhs) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
155 |
val abs_eq' = HOLogic.mk_eq (abs_lhs, abs_rhs') |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
156 |
val eq = HOLogic.mk_eq (mk_perm (Bound 0) binder_trm, mk_perm p binder_trm) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
157 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
158 |
val goal = HOLogic.mk_conj (abs_eq, eq) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
159 |
|> (fn t => HOLogic.mk_exists ("q", @{typ "perm"}, t)) |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
160 |
|> HOLogic.mk_Trueprop |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
161 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
162 |
val goal' = HOLogic.mk_conj (abs_eq', eq) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
163 |
|> (fn t => HOLogic.mk_exists ("q", @{typ "perm"}, t)) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
164 |
|> HOLogic.mk_Trueprop |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
165 |
|
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
166 |
val ss = fprops @ bn_finite_thms @ @{thms set.simps set_append union_eqvt} |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
167 |
@ @{thms fresh_star_Un fresh_star_Pair fresh_star_list fresh_star_singleton fresh_star_fset |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
168 |
fresh_star_set} @ @{thms finite.intros finite_fset} |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
169 |
in |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
170 |
if is_recursive_binder bclause |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
171 |
then |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
172 |
(tracing "recursive"; |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
173 |
[ Goal.prove ctxt [] [] goal' |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
174 |
(K (HEADGOAL (resolve_tac @{thms Abs_rename_set' Abs_rename_res' Abs_rename_lst'} |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
175 |
THEN_ALL_NEW (simp_tac (HOL_basic_ss addsimps ss) THEN' TRY o simp_tac HOL_ss)))) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
176 |
|> Nominal_Permeq.eqvt_strict_rule ctxt bn_eqvt [] |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
177 |
]) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
178 |
else |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
179 |
(tracing "non-recursive"; |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
180 |
[ Goal.prove ctxt [] [] goal |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
181 |
(K (HEADGOAL (resolve_tac @{thms Abs_rename_set Abs_rename_res Abs_rename_lst} |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
182 |
THEN_ALL_NEW (simp_tac (HOL_basic_ss addsimps ss) THEN' TRY o simp_tac HOL_ss)))) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
183 |
|> Nominal_Permeq.eqvt_strict_rule ctxt permute_bns [] |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
184 |
]) |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
185 |
end |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
186 |
*} |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
187 |
|
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
188 |
ML {* |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
189 |
fun conj_tac tac i = |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
190 |
let |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
191 |
fun select (t, i) = |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
192 |
case t of |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
193 |
@{term "Trueprop"} $ t' => select (t', i) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
194 |
| @{term "op \<and>"} $ _ $ _ => (rtac @{thm conjI} THEN' RANGE [conj_tac tac, conj_tac tac]) i |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
195 |
| _ => tac i |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
196 |
in |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
197 |
SUBGOAL select i |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
198 |
end |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
199 |
*} |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
200 |
|
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
201 |
ML {* |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
202 |
fun is_abs_eq thm = |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
203 |
let |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
204 |
fun is_abs trm = |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
205 |
case (head_of trm) of |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
206 |
Const (@{const_name "Abs_set"}, _) => true |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
207 |
| Const (@{const_name "Abs_lst"}, _) => true |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
208 |
| Const (@{const_name "Abs_res"}, _) => true |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
209 |
| _ => false |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
210 |
in |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
211 |
thm |> prop_of |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
212 |
|> HOLogic.dest_Trueprop |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
213 |
|> HOLogic.dest_eq |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
214 |
|> fst |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
215 |
|> is_abs |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
216 |
end |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
217 |
*} |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
218 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
219 |
lemma setify: |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
220 |
shows "xs = ys \<Longrightarrow> set xs = set ys" |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
221 |
by simp |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
222 |
|
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
223 |
ML {* |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
224 |
fun case_tac ctxt c bn_finite_thms eq_iff_thms bn_eqvt permute_bns perm_bn_alphas |
2619 | 225 |
prems bclausess qexhaust_thm = |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
226 |
let |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
227 |
fun aux_tac prem bclauses = |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
228 |
case (get_all_binders bclauses) of |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
229 |
[] => EVERY' [rtac prem, atac] |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
230 |
| binders => Subgoal.SUBPROOF (fn {params, prems, concl, context = ctxt, ...} => |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
231 |
let |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
232 |
val parms = map (term_of o snd) params |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
233 |
val fthm = fresh_thm ctxt c parms binders bn_finite_thms |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
234 |
|
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
235 |
val ss = @{thms fresh_star_Pair union_eqvt fresh_star_Un} |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
236 |
val (([(_, fperm)], fprops), ctxt') = Obtain.result |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
237 |
(K (EVERY1 [etac exE, |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
238 |
full_simp_tac (HOL_basic_ss addsimps ss), |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
239 |
REPEAT o (etac @{thm conjE})])) [fthm] ctxt |
2613 | 240 |
|
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
241 |
val abs_eq_thms = flat |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
242 |
(map (abs_eq_thm ctxt fprops (term_of fperm) parms bn_finite_thms bn_eqvt permute_bns) bclauses) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
243 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
244 |
val ((_, eqs), ctxt'') = Obtain.result |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
245 |
(K (EVERY1 |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
246 |
[ REPEAT o (etac @{thm exE}), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
247 |
REPEAT o (etac @{thm conjE}), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
248 |
REPEAT o (dtac @{thm setify}), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
249 |
full_simp_tac (HOL_basic_ss addsimps @{thms set_append set.simps})])) abs_eq_thms ctxt' |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
250 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
251 |
val (abs_eqs, peqs) = split_filter is_abs_eq eqs |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
252 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
253 |
val fprops' = map (Nominal_Permeq.eqvt_strict_rule ctxt permute_bns []) fprops |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
254 |
val fprops'' = map (Nominal_Permeq.eqvt_strict_rule ctxt bn_eqvt []) fprops |
2613 | 255 |
|
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
256 |
val _ = tracing ("prem:\n" ^ (Syntax.string_of_term ctxt'' o prop_of) prem) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
257 |
val _ = tracing ("prems:\n" ^ cat_lines (map (Syntax.string_of_term ctxt'' o prop_of) prems)) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
258 |
val _ = tracing ("fprop':\n" ^ cat_lines (map (Syntax.string_of_term ctxt'' o prop_of) fprops')) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
259 |
val _ = tracing ("fprop'':\n" ^ cat_lines (map (Syntax.string_of_term ctxt'' o prop_of) fprops'')) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
260 |
val _ = tracing ("abseq:\n" ^ cat_lines (map (Syntax.string_of_term ctxt'' o prop_of) abs_eqs)) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
261 |
val _ = tracing ("peqs:\n" ^ cat_lines (map (Syntax.string_of_term ctxt'' o prop_of) peqs)) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
262 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
263 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
264 |
val tac1 = EVERY' |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
265 |
[ simp_tac (HOL_basic_ss addsimps peqs), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
266 |
rewrite_goal_tac (@{thms fresh_star_Un[THEN eq_reflection]}), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
267 |
K (print_tac "before solving freshness"), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
268 |
conj_tac (TRY o DETERM o resolve_tac (fprops' @ fprops'')) ] |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
269 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
270 |
val tac2 = EVERY' |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
271 |
[ rtac (@{thm ssubst} OF prems), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
272 |
rewrite_goal_tac (map safe_mk_equiv eq_iff_thms), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
273 |
K (print_tac "before substituting"), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
274 |
rewrite_goal_tac (map safe_mk_equiv abs_eqs), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
275 |
K (print_tac "after substituting"), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
276 |
conj_tac (TRY o DETERM o resolve_tac (@{thms refl} @ perm_bn_alphas)), |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
277 |
K (print_tac "end") |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
278 |
] |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
279 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
280 |
val side_thm = Goal.prove ctxt'' [] [] (term_of concl) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
281 |
(fn _ => (* Skip_Proof.cheat_tac (ProofContext.theory_of ctxt'') *) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
282 |
EVERY |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
283 |
[ rtac prem 1, |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
284 |
print_tac "after applying prem", |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
285 |
RANGE [SOLVED' tac1, SOLVED' tac2] 1, |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
286 |
print_tac "final" ] ) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
287 |
|> singleton (ProofContext.export ctxt'' ctxt) |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
288 |
|
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
289 |
val _ = tracing ("side_thm:\n" ^ (Syntax.string_of_term ctxt o prop_of) side_thm) |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
290 |
in |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
291 |
rtac side_thm 1 |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
292 |
end) ctxt |
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
293 |
in |
2619 | 294 |
EVERY1 [rtac qexhaust_thm, RANGE (map2 aux_tac prems bclausess)] |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
295 |
end |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
296 |
*} |
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
297 |
|
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
298 |
ML {* |
2619 | 299 |
fun prove_strong_exhausts lthy exhausts bclausesss bn_finite_thms eq_iff_thms bn_eqvt permute_bns |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
300 |
perm_bn_alphas = |
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
301 |
let |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
302 |
val ((_, exhausts'), lthy') = Variable.import true exhausts lthy |
2607
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
303 |
|
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
304 |
val ([c, a], lthy'') = Variable.variant_fixes ["c", "'a"] lthy' |
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
305 |
val c = Free (c, TFree (a, @{sort fs})) |
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
306 |
|
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
307 |
val (ecases, main_concls) = exhausts' (* ecases or of the form (params, prems, concl) *) |
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
308 |
|> map prop_of |
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
309 |
|> map Logic.strip_horn |
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
310 |
|> split_list |
2612 | 311 |
|>> (map o map) strip_params_prems_concl |
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
312 |
|
2619 | 313 |
val premss = (map2 o map2) (process_ecase lthy'' c) ecases bclausesss |
314 |
||
315 |
fun tac bclausess exhaust {prems, context} = |
|
316 |
case_tac context c bn_finite_thms eq_iff_thms bn_eqvt permute_bns perm_bn_alphas |
|
317 |
prems bclausess exhaust |
|
2618
d17fadc20507
corrected premises of strong exhausts theorems
Christian Urban <urbanc@in.tum.de>
parents:
2617
diff
changeset
|
318 |
|
2619 | 319 |
fun prove prems bclausess exhaust concl = |
320 |
Goal.prove lthy'' [] prems concl (tac bclausess exhaust) |
|
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
321 |
in |
2619 | 322 |
map4 prove premss bclausesss exhausts' main_concls |
323 |
|> ProofContext.export lthy'' lthy |
|
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
324 |
end |
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
325 |
*} |
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
326 |
|
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
327 |
|
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
parents:
2608
diff
changeset
|
328 |
|
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
329 |
ML {* |
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
330 |
val eqvt_attr = Attrib.internal (K Nominal_ThmDecls.eqvt_add) |
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
331 |
val rsp_attr = Attrib.internal (K Quotient_Info.rsp_rules_add) |
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
332 |
val simp_attr = Attrib.internal (K Simplifier.simp_add) |
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
333 |
*} |
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
2146
diff
changeset
|
334 |
|
1941 | 335 |
section{* Interface for nominal_datatype *} |
336 |
||
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
337 |
ML {* print_depth 50 *} |
1941 | 338 |
|
339 |
ML {* |
|
340 |
fun get_cnstrs dts = |
|
341 |
map (fn (_, _, _, constrs) => constrs) dts |
|
342 |
||
343 |
fun get_typed_cnstrs dts = |
|
344 |
flat (map (fn (_, bn, _, constrs) => |
|
345 |
(map (fn (bn', _, _) => (Binding.name_of bn, Binding.name_of bn')) constrs)) dts) |
|
346 |
||
347 |
fun get_cnstr_strs dts = |
|
348 |
map (fn (bn, _, _) => Binding.name_of bn) (flat (get_cnstrs dts)) |
|
349 |
||
350 |
fun get_bn_fun_strs bn_funs = |
|
351 |
map (fn (bn_fun, _, _) => Binding.name_of bn_fun) bn_funs |
|
352 |
*} |
|
353 |
||
2106
409ecb7284dd
properly exported defined bn-functions
Christian Urban <urbanc@in.tum.de>
parents:
2105
diff
changeset
|
354 |
|
1944 | 355 |
text {* Infrastructure for adding "_raw" to types and terms *} |
356 |
||
1941 | 357 |
ML {* |
358 |
fun add_raw s = s ^ "_raw" |
|
359 |
fun add_raws ss = map add_raw ss |
|
360 |
fun raw_bind bn = Binding.suffix_name "_raw" bn |
|
361 |
||
362 |
fun replace_str ss s = |
|
363 |
case (AList.lookup (op=) ss s) of |
|
364 |
SOME s' => s' |
|
365 |
| NONE => s |
|
366 |
||
367 |
fun replace_typ ty_ss (Type (a, Ts)) = Type (replace_str ty_ss a, map (replace_typ ty_ss) Ts) |
|
368 |
| replace_typ ty_ss T = T |
|
369 |
||
370 |
fun raw_dts ty_ss dts = |
|
371 |
let |
|
372 |
fun raw_dts_aux1 (bind, tys, mx) = |
|
373 |
(raw_bind bind, map (replace_typ ty_ss) tys, mx) |
|
374 |
||
375 |
fun raw_dts_aux2 (ty_args, bind, mx, constrs) = |
|
376 |
(ty_args, raw_bind bind, mx, map raw_dts_aux1 constrs) |
|
377 |
in |
|
378 |
map raw_dts_aux2 dts |
|
379 |
end |
|
380 |
||
381 |
fun replace_aterm trm_ss (Const (a, T)) = Const (replace_str trm_ss a, T) |
|
382 |
| replace_aterm trm_ss (Free (a, T)) = Free (replace_str trm_ss a, T) |
|
383 |
| replace_aterm trm_ss trm = trm |
|
384 |
||
385 |
fun replace_term trm_ss ty_ss trm = |
|
386 |
trm |> Term.map_aterms (replace_aterm trm_ss) |> map_types (replace_typ ty_ss) |
|
387 |
*} |
|
388 |
||
389 |
ML {* |
|
390 |
fun rawify_dts dt_names dts dts_env = |
|
391 |
let |
|
392 |
val raw_dts = raw_dts dts_env dts |
|
393 |
val raw_dt_names = add_raws dt_names |
|
394 |
in |
|
395 |
(raw_dt_names, raw_dts) |
|
396 |
end |
|
397 |
*} |
|
398 |
||
399 |
ML {* |
|
400 |
fun rawify_bn_funs dts_env cnstrs_env bn_fun_env bn_funs bn_eqs = |
|
401 |
let |
|
402 |
val bn_funs' = map (fn (bn, ty, mx) => |
|
2304
8a98171ba1fc
all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents:
2302
diff
changeset
|
403 |
(raw_bind bn, SOME (replace_typ dts_env ty), mx)) bn_funs |
1941 | 404 |
|
405 |
val bn_eqs' = map (fn (attr, trm) => |
|
406 |
(attr, replace_term (cnstrs_env @ bn_fun_env) dts_env trm)) bn_eqs |
|
407 |
in |
|
408 |
(bn_funs', bn_eqs') |
|
409 |
end |
|
410 |
*} |
|
411 |
||
412 |
ML {* |
|
413 |
fun rawify_bclauses dts_env cnstrs_env bn_fun_env bclauses = |
|
414 |
let |
|
415 |
fun rawify_bnds bnds = |
|
416 |
map (apfst (Option.map (replace_term (cnstrs_env @ bn_fun_env) dts_env))) bnds |
|
417 |
||
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
2146
diff
changeset
|
418 |
fun rawify_bclause (BC (mode, bnds, bdys)) = BC (mode, rawify_bnds bnds, bdys) |
1941 | 419 |
in |
2612 | 420 |
(map o map o map) rawify_bclause bclauses |
1941 | 421 |
end |
422 |
*} |
|
423 |
||
424 |
||
425 |
ML {* |
|
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
426 |
fun define_raw_dts dts bn_funs bn_eqs bclauses lthy = |
1941 | 427 |
let |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
428 |
val thy = Local_Theory.exit_global lthy |
1941 | 429 |
val thy_name = Context.theory_name thy |
430 |
||
431 |
val dt_names = map (fn (_, s, _, _) => Binding.name_of s) dts |
|
432 |
val dt_full_names = map (Long_Name.qualify thy_name) dt_names |
|
433 |
val dt_full_names' = add_raws dt_full_names |
|
434 |
val dts_env = dt_full_names ~~ dt_full_names' |
|
435 |
||
436 |
val cnstrs = get_cnstr_strs dts |
|
437 |
val cnstrs_ty = get_typed_cnstrs dts |
|
438 |
val cnstrs_full_names = map (Long_Name.qualify thy_name) cnstrs |
|
439 |
val cnstrs_full_names' = map (fn (x, y) => Long_Name.qualify thy_name |
|
440 |
(Long_Name.qualify (add_raw x) (add_raw y))) cnstrs_ty |
|
441 |
val cnstrs_env = cnstrs_full_names ~~ cnstrs_full_names' |
|
442 |
||
443 |
val bn_fun_strs = get_bn_fun_strs bn_funs |
|
444 |
val bn_fun_strs' = add_raws bn_fun_strs |
|
445 |
val bn_fun_env = bn_fun_strs ~~ bn_fun_strs' |
|
446 |
val bn_fun_full_env = map (pairself (Long_Name.qualify thy_name)) |
|
447 |
(bn_fun_strs ~~ bn_fun_strs') |
|
448 |
||
449 |
val (raw_dt_names, raw_dts) = rawify_dts dt_names dts dts_env |
|
450 |
val (raw_bn_funs, raw_bn_eqs) = rawify_bn_funs dts_env cnstrs_env bn_fun_env bn_funs bn_eqs |
|
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
451 |
val raw_bclauses = rawify_bclauses dts_env cnstrs_env bn_fun_full_env bclauses |
1941 | 452 |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
453 |
val (raw_dt_full_names, thy1) = |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
454 |
Datatype.add_datatype Datatype.default_config raw_dt_names raw_dts thy |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
455 |
|
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
456 |
val lthy1 = Named_Target.theory_init thy1 |
2304
8a98171ba1fc
all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents:
2302
diff
changeset
|
457 |
in |
2337
b151399bd2c3
fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
2336
diff
changeset
|
458 |
(raw_dt_full_names, raw_dts, raw_bclauses, raw_bn_funs, raw_bn_eqs, lthy1) |
2304
8a98171ba1fc
all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents:
2302
diff
changeset
|
459 |
end |
8a98171ba1fc
all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents:
2302
diff
changeset
|
460 |
*} |
8a98171ba1fc
all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents:
2302
diff
changeset
|
461 |
|
2046
73c50e913db6
tuned and added some comments to the code; added also an exception for early exit of the nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
parents:
2037
diff
changeset
|
462 |
ML {* |
73c50e913db6
tuned and added some comments to the code; added also an exception for early exit of the nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
parents:
2037
diff
changeset
|
463 |
(* for testing porposes - to exit the procedure early *) |
73c50e913db6
tuned and added some comments to the code; added also an exception for early exit of the nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
parents:
2037
diff
changeset
|
464 |
exception TEST of Proof.context |
73c50e913db6
tuned and added some comments to the code; added also an exception for early exit of the nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
parents:
2037
diff
changeset
|
465 |
|
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
466 |
val (STEPS, STEPS_setup) = Attrib.config_int "STEPS" (K 100); |
2125
60ee289a8c63
made out of STEPS a configuration value so that it can be set individually in each file
Christian Urban <urbanc@in.tum.de>
parents:
2122
diff
changeset
|
467 |
|
60ee289a8c63
made out of STEPS a configuration value so that it can be set individually in each file
Christian Urban <urbanc@in.tum.de>
parents:
2122
diff
changeset
|
468 |
fun get_STEPS ctxt = Config.get ctxt STEPS |
2046
73c50e913db6
tuned and added some comments to the code; added also an exception for early exit of the nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
parents:
2037
diff
changeset
|
469 |
*} |
2008
1bddffddc03f
attempted to remove dependency on (old) Fv and (old) Parser; lifting still uses Fv.thy; the examples do not work at the moment (with equivp proofs failing)
Christian Urban <urbanc@in.tum.de>
parents:
2007
diff
changeset
|
470 |
|
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:
2474
diff
changeset
|
471 |
|
2125
60ee289a8c63
made out of STEPS a configuration value so that it can be set individually in each file
Christian Urban <urbanc@in.tum.de>
parents:
2122
diff
changeset
|
472 |
setup STEPS_setup |
60ee289a8c63
made out of STEPS a configuration value so that it can be set individually in each file
Christian Urban <urbanc@in.tum.de>
parents:
2122
diff
changeset
|
473 |
|
1941 | 474 |
ML {* |
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
475 |
fun nominal_datatype2 opt_thms_name dts bn_funs bn_eqs bclauses lthy = |
1941 | 476 |
let |
2294
72ad4e766acf
properly exported bn_descr
Christian Urban <urbanc@in.tum.de>
parents:
2293
diff
changeset
|
477 |
(* definition of the raw datatypes *) |
2316 | 478 |
val _ = warning "Definition of raw datatypes"; |
2337
b151399bd2c3
fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
2336
diff
changeset
|
479 |
val (raw_dt_names, raw_dts, raw_bclauses, raw_bn_funs, raw_bn_eqs, lthy0) = |
2308
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2306
diff
changeset
|
480 |
if get_STEPS lthy > 0 |
2410
2bbdb9c427b5
improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2409
diff
changeset
|
481 |
then define_raw_dts dts bn_funs bn_eqs bclauses lthy |
2046
73c50e913db6
tuned and added some comments to the code; added also an exception for early exit of the nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
parents:
2037
diff
changeset
|
482 |
else raise TEST lthy |
1941 | 483 |
|
2304
8a98171ba1fc
all raw definitions are defined using function
Christian Urban <urbanc@in.tum.de>
parents:
2302
diff
changeset
|
484 |
val dtinfo = Datatype.the_info (ProofContext.theory_of lthy0) (hd raw_dt_names) |
2143
871d8a5e0c67
somewhat simplified the main parsing function; failed to move a Note-statement to define_raw_perms
Christian Urban <urbanc@in.tum.de>
parents:
2142
diff
changeset
|
485 |
val {descr, sorts, ...} = dtinfo |
2407 | 486 |
|
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
487 |
val raw_tys = all_dtyps descr sorts |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
488 |
val raw_full_ty_names = map (fst o dest_Type) raw_tys |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
489 |
val tvs = hd raw_tys |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
490 |
|> snd o dest_Type |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
491 |
|> map dest_TFree |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
492 |
|
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
493 |
val dtinfos = map (Datatype.the_info (ProofContext.theory_of lthy0)) raw_full_ty_names |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
494 |
|
2407 | 495 |
val raw_cns_info = all_dtyp_constrs_types descr sorts |
2612 | 496 |
val raw_constrs = (map o map) (fn (c, _, _, _) => c) raw_cns_info |
2407 | 497 |
|
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
498 |
val raw_inject_thms = flat (map #inject dtinfos) |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
499 |
val raw_distinct_thms = flat (map #distinct dtinfos) |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
500 |
val raw_induct_thm = #induct dtinfo |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
501 |
val raw_induct_thms = #inducts dtinfo |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
502 |
val raw_exhaust_thms = map #exhaust dtinfos |
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
503 |
val raw_size_trms = map HOLogic.size_const raw_tys |
2388 | 504 |
val raw_size_thms = Size.size_thms (ProofContext.theory_of lthy0) (hd raw_dt_names) |
505 |
|> `(fn thms => (length thms) div 2) |
|
2392
9294d7cec5e2
proved rsp-helper lemmas of size functions
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
506 |
|> uncurry drop |
2388 | 507 |
|
2409
83990a42a068
more tuning of the code
Christian Urban <urbanc@in.tum.de>
parents:
2407
diff
changeset
|
508 |
(* definitions of raw permutations by primitive recursion *) |
2316 | 509 |
val _ = warning "Definition of raw permutations"; |
2401
7645e18e8b19
modified the code for class instantiations (with help from Florian)
Christian Urban <urbanc@in.tum.de>
parents:
2400
diff
changeset
|
510 |
val ((raw_perm_funs, raw_perm_simps, raw_perm_laws), lthy2a) = |
2560
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
511 |
if get_STEPS lthy0 > 0 |
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
512 |
then define_raw_perms raw_full_ty_names raw_tys tvs (flat raw_constrs) raw_induct_thm lthy0 |
2308
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2306
diff
changeset
|
513 |
else raise TEST lthy0 |
2144 | 514 |
|
515 |
(* noting the raw permutations as eqvt theorems *) |
|
2448 | 516 |
val (_, lthy3) = Local_Theory.note ((Binding.empty, [eqvt_attr]), raw_perm_simps) lthy2a |
2011
12ce87b55f97
tried to add some comments in the huge(!) nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
parents:
2008
diff
changeset
|
517 |
|
2560
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
518 |
(* definition of raw fv and bn functions *) |
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
519 |
val _ = warning "Definition of raw fv- and bn-functions"; |
2405
29ebbe56f450
also able to lift the bn_defs
Christian Urban <urbanc@in.tum.de>
parents:
2404
diff
changeset
|
520 |
val (raw_bns, raw_bn_defs, raw_bn_info, raw_bn_induct, lthy3a) = |
2560
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
521 |
if get_STEPS lthy3 > 1 |
2410
2bbdb9c427b5
improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2409
diff
changeset
|
522 |
then define_raw_bns raw_full_ty_names raw_dts raw_bn_funs raw_bn_eqs |
2bbdb9c427b5
improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2409
diff
changeset
|
523 |
(raw_inject_thms @ raw_distinct_thms) raw_size_thms lthy3 |
2046
73c50e913db6
tuned and added some comments to the code; added also an exception for early exit of the nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
parents:
2037
diff
changeset
|
524 |
else raise TEST lthy3 |
2292 | 525 |
|
2560
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
526 |
(* defining the permute_bn functions *) |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
527 |
val (raw_perm_bns, raw_perm_bn_simps, lthy3b) = |
2560
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
528 |
if get_STEPS lthy3a > 2 |
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
529 |
then define_raw_bn_perms raw_tys raw_bn_info raw_cns_info |
2410
2bbdb9c427b5
improved runtime slightly, by constructing an explicit size measure for the function definitions
Christian Urban <urbanc@in.tum.de>
parents:
2409
diff
changeset
|
530 |
(raw_inject_thms @ raw_distinct_thms) raw_size_thms lthy3a |
2308
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2306
diff
changeset
|
531 |
else raise TEST lthy3a |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2306
diff
changeset
|
532 |
|
2560
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
533 |
val (raw_fvs, raw_fv_bns, raw_fv_defs, raw_fv_bns_induct, lthy3c) = |
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
534 |
if get_STEPS lthy3b > 3 |
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
535 |
then define_raw_fvs raw_full_ty_names raw_tys raw_cns_info raw_bn_info raw_bclauses |
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
536 |
(raw_inject_thms @ raw_distinct_thms) raw_size_thms lthy3b |
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
537 |
else raise TEST lthy3b |
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
538 |
|
2011
12ce87b55f97
tried to add some comments in the huge(!) nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
parents:
2008
diff
changeset
|
539 |
(* definition of raw alphas *) |
2316 | 540 |
val _ = warning "Definition of alphas"; |
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
541 |
val (alpha_trms, alpha_bn_trms, alpha_intros, alpha_cases, alpha_induct, lthy4) = |
2560
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
542 |
if get_STEPS lthy3c > 4 |
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
543 |
then define_raw_alpha raw_full_ty_names raw_tys raw_cns_info raw_bn_info raw_bclauses raw_fvs lthy3c |
82e37a4595c7
automated permute_bn functions (raw ones first)
Christian Urban <urbanc@in.tum.de>
parents:
2559
diff
changeset
|
544 |
else raise TEST lthy3c |
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
545 |
val alpha_tys = map (domain_type o fastype_of) alpha_trms |
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
546 |
|
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
547 |
(* definition of alpha-distinct lemmas *) |
2316 | 548 |
val _ = warning "Distinct theorems"; |
2399 | 549 |
val alpha_distincts = |
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
550 |
mk_alpha_distincts lthy4 alpha_cases raw_distinct_thms alpha_trms raw_tys |
2300
9fb315392493
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2299
diff
changeset
|
551 |
|
2361 | 552 |
(* definition of alpha_eq_iff lemmas *) |
2316 | 553 |
val _ = warning "Eq-iff theorems"; |
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:
2474
diff
changeset
|
554 |
val alpha_eq_iff = |
2295
8aff3f3ce47f
started to work on alpha
Christian Urban <urbanc@in.tum.de>
parents:
2294
diff
changeset
|
555 |
if get_STEPS lthy > 5 |
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
556 |
then mk_alpha_eq_iff lthy4 alpha_intros raw_distinct_thms raw_inject_thms alpha_cases |
2295
8aff3f3ce47f
started to work on alpha
Christian Urban <urbanc@in.tum.de>
parents:
2294
diff
changeset
|
557 |
else raise TEST lthy4 |
2022
8ffede2c8ce9
Introduce eq_iff_simp to match the one from Parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2020
diff
changeset
|
558 |
|
2388 | 559 |
(* proving equivariance lemmas for bns, fvs, size and alpha *) |
2001
7c8242a02f39
NewParser with Parser functionality, but some cheats included since the order of datayupes is wrong.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2000
diff
changeset
|
560 |
val _ = warning "Proving equivariance"; |
2406
428d9cb9a243
can also lift the various eqvt lemmas for bn, fv, fv_bn and size
Christian Urban <urbanc@in.tum.de>
parents:
2405
diff
changeset
|
561 |
val raw_bn_eqvt = |
2298 | 562 |
if get_STEPS lthy > 6 |
2405
29ebbe56f450
also able to lift the bn_defs
Christian Urban <urbanc@in.tum.de>
parents:
2404
diff
changeset
|
563 |
then raw_prove_eqvt raw_bns raw_bn_induct (raw_bn_defs @ raw_perm_simps) lthy4 |
2298 | 564 |
else raise TEST lthy4 |
565 |
||
2406
428d9cb9a243
can also lift the various eqvt lemmas for bn, fv, fv_bn and size
Christian Urban <urbanc@in.tum.de>
parents:
2405
diff
changeset
|
566 |
(* noting the raw_bn_eqvt lemmas in a temprorary theory *) |
2448 | 567 |
val lthy_tmp = snd (Local_Theory.note ((Binding.empty, [eqvt_attr]), raw_bn_eqvt) lthy4) |
2305
93ab397f5980
smaller code for raw-eqvt proofs
Christian Urban <urbanc@in.tum.de>
parents:
2304
diff
changeset
|
568 |
|
2406
428d9cb9a243
can also lift the various eqvt lemmas for bn, fv, fv_bn and size
Christian Urban <urbanc@in.tum.de>
parents:
2405
diff
changeset
|
569 |
val raw_fv_eqvt = |
2298 | 570 |
if get_STEPS lthy > 7 |
2384
841b7e34e70a
fixed order of fold_union to make alpha and fv agree
Christian Urban <urbanc@in.tum.de>
parents:
2378
diff
changeset
|
571 |
then raw_prove_eqvt (raw_fvs @ raw_fv_bns) raw_fv_bns_induct (raw_fv_defs @ raw_perm_simps) |
2388 | 572 |
(Local_Theory.restore lthy_tmp) |
573 |
else raise TEST lthy4 |
|
574 |
||
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2388
diff
changeset
|
575 |
val raw_size_eqvt = |
2388 | 576 |
if get_STEPS lthy > 8 |
577 |
then raw_prove_eqvt raw_size_trms raw_induct_thms (raw_size_thms @ raw_perm_simps) |
|
578 |
(Local_Theory.restore lthy_tmp) |
|
2389
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2388
diff
changeset
|
579 |
|> map (rewrite_rule @{thms permute_nat_def[THEN eq_reflection]}) |
0f24c961b5f6
introduced a general alpha_prove method
Christian Urban <urbanc@in.tum.de>
parents:
2388
diff
changeset
|
580 |
|> map (fn thm => thm RS @{thm sym}) |
2305
93ab397f5980
smaller code for raw-eqvt proofs
Christian Urban <urbanc@in.tum.de>
parents:
2304
diff
changeset
|
581 |
else raise TEST lthy4 |
93ab397f5980
smaller code for raw-eqvt proofs
Christian Urban <urbanc@in.tum.de>
parents:
2304
diff
changeset
|
582 |
|
2448 | 583 |
val lthy5 = snd (Local_Theory.note ((Binding.empty, [eqvt_attr]), raw_fv_eqvt) lthy_tmp) |
2306 | 584 |
|
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
585 |
val (alpha_eqvt, lthy6) = |
2388 | 586 |
if get_STEPS lthy > 9 |
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
587 |
then Nominal_Eqvt.equivariance true (alpha_trms @ alpha_bn_trms) alpha_induct alpha_intros lthy5 |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2309
diff
changeset
|
588 |
else raise TEST lthy4 |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2309
diff
changeset
|
589 |
|
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2309
diff
changeset
|
590 |
(* proving alpha equivalence *) |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2309
diff
changeset
|
591 |
val _ = warning "Proving equivalence" |
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2309
diff
changeset
|
592 |
|
2316 | 593 |
val alpha_refl_thms = |
2388 | 594 |
if get_STEPS lthy > 10 |
595 |
then raw_prove_refl alpha_trms alpha_bn_trms alpha_intros raw_induct_thm lthy6 |
|
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
596 |
else raise TEST lthy6 |
2316 | 597 |
|
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2309
diff
changeset
|
598 |
val alpha_sym_thms = |
2388 | 599 |
if get_STEPS lthy > 11 |
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
600 |
then raw_prove_sym (alpha_trms @ alpha_bn_trms) alpha_intros alpha_induct lthy6 |
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
601 |
else raise TEST lthy6 |
2298 | 602 |
|
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2309
diff
changeset
|
603 |
val alpha_trans_thms = |
2388 | 604 |
if get_STEPS lthy > 12 |
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
605 |
then raw_prove_trans (alpha_trms @ alpha_bn_trms) (raw_distinct_thms @ raw_inject_thms) |
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
606 |
alpha_intros alpha_induct alpha_cases lthy6 |
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
607 |
else raise TEST lthy6 |
2311
4da5c5c29009
work on transitivity proof
Christian Urban <urbanc@in.tum.de>
parents:
2309
diff
changeset
|
608 |
|
2404
66ae73fd66c0
added rsp-lemmas for alpha_bns
Christian Urban <urbanc@in.tum.de>
parents:
2401
diff
changeset
|
609 |
val (alpha_equivp_thms, alpha_bn_equivp_thms) = |
2388 | 610 |
if get_STEPS lthy > 13 |
2404
66ae73fd66c0
added rsp-lemmas for alpha_bns
Christian Urban <urbanc@in.tum.de>
parents:
2401
diff
changeset
|
611 |
then raw_prove_equivp alpha_trms alpha_bn_trms alpha_refl_thms alpha_sym_thms |
66ae73fd66c0
added rsp-lemmas for alpha_bns
Christian Urban <urbanc@in.tum.de>
parents:
2401
diff
changeset
|
612 |
alpha_trans_thms lthy6 |
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
613 |
else raise TEST lthy6 |
2322
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2321
diff
changeset
|
614 |
|
2320
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
615 |
(* proving alpha implies alpha_bn *) |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
616 |
val _ = warning "Proving alpha implies bn" |
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
617 |
|
d835a2771608
prove that alpha implies alpha_bn (needed for rsp proofs)
Christian Urban <urbanc@in.tum.de>
parents:
2316
diff
changeset
|
618 |
val alpha_bn_imp_thms = |
2388 | 619 |
if get_STEPS lthy > 14 |
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
620 |
then raw_prove_bn_imp alpha_trms alpha_bn_trms alpha_intros alpha_induct lthy6 |
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
621 |
else raise TEST lthy6 |
2322
24de7e548094
proved eqvip theorems for alphas
Christian Urban <urbanc@in.tum.de>
parents:
2321
diff
changeset
|
622 |
|
2397
c670a849af65
more experiments with lifting
Christian Urban <urbanc@in.tum.de>
parents:
2396
diff
changeset
|
623 |
(* respectfulness proofs *) |
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
624 |
val raw_funs_rsp_aux = |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
625 |
if get_STEPS lthy > 15 |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
626 |
then raw_fv_bn_rsp_aux alpha_trms alpha_bn_trms raw_fvs |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
627 |
raw_bns raw_fv_bns alpha_induct (raw_bn_defs @ raw_fv_defs) lthy6 |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
628 |
else raise TEST lthy6 |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
629 |
|
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
630 |
val raw_funs_rsp = |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
631 |
if get_STEPS lthy > 16 |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
632 |
then map mk_funs_rsp raw_funs_rsp_aux |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
633 |
else raise TEST lthy6 |
2388 | 634 |
|
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
635 |
val raw_size_rsp = |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
636 |
if get_STEPS lthy > 17 |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
637 |
then |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
638 |
raw_size_rsp_aux (alpha_trms @ alpha_bn_trms) alpha_induct |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
639 |
(raw_size_thms @ raw_size_eqvt) lthy6 |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
640 |
|> map mk_funs_rsp |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
641 |
else raise TEST lthy6 |
2392
9294d7cec5e2
proved rsp-helper lemmas of size functions
Christian Urban <urbanc@in.tum.de>
parents:
2389
diff
changeset
|
642 |
|
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
643 |
val raw_constrs_rsp = |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
644 |
if get_STEPS lthy > 18 |
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
645 |
then raw_constrs_rsp (flat raw_constrs) alpha_trms alpha_intros |
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
646 |
(alpha_bn_imp_thms @ raw_funs_rsp_aux) lthy6 |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
647 |
else raise TEST lthy6 |
2397
c670a849af65
more experiments with lifting
Christian Urban <urbanc@in.tum.de>
parents:
2396
diff
changeset
|
648 |
|
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
649 |
val alpha_permute_rsp = |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
650 |
if get_STEPS lthy > 19 |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
651 |
then map mk_alpha_permute_rsp alpha_eqvt |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
652 |
else raise TEST lthy6 |
2384
841b7e34e70a
fixed order of fold_union to make alpha and fv agree
Christian Urban <urbanc@in.tum.de>
parents:
2378
diff
changeset
|
653 |
|
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
654 |
val alpha_bn_rsp = |
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
655 |
if get_STEPS lthy > 20 |
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
|
656 |
then raw_alpha_bn_rsp alpha_bn_trms alpha_bn_equivp_thms alpha_bn_imp_thms |
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
parents:
2436
diff
changeset
|
657 |
else raise TEST lthy6 |
2404
66ae73fd66c0
added rsp-lemmas for alpha_bns
Christian Urban <urbanc@in.tum.de>
parents:
2401
diff
changeset
|
658 |
|
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
659 |
val raw_perm_bn_rsp = |
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
660 |
if get_STEPS lthy > 21 |
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
661 |
then raw_perm_bn_rsp (alpha_trms @ alpha_bn_trms) raw_perm_bns alpha_induct |
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
662 |
alpha_intros raw_perm_bn_simps lthy6 |
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
663 |
else raise TEST lthy6 |
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
664 |
|
2398 | 665 |
(* noting the quot_respects lemmas *) |
666 |
val (_, lthy6a) = |
|
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
667 |
if get_STEPS lthy > 22 |
2448 | 668 |
then Local_Theory.note ((Binding.empty, [rsp_attr]), |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
669 |
raw_constrs_rsp @ raw_funs_rsp @ raw_size_rsp @ alpha_permute_rsp @ |
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
670 |
alpha_bn_rsp @ raw_perm_bn_rsp) lthy6 |
2398 | 671 |
else raise TEST lthy6 |
672 |
||
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
673 |
(* defining the quotient type *) |
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
674 |
val _ = warning "Declaring the quotient types" |
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
675 |
val qty_descr = map (fn (vs, bind, mx, _) => (vs, bind, mx)) dts |
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
676 |
|
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
677 |
val (qty_infos, lthy7) = |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
678 |
if get_STEPS lthy > 23 |
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
679 |
then define_qtypes qty_descr alpha_tys alpha_trms alpha_equivp_thms lthy6a |
2398 | 680 |
else raise TEST lthy6a |
2336
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
681 |
|
f2d545b77b31
added definition of the quotient types
Christian Urban <urbanc@in.tum.de>
parents:
2324
diff
changeset
|
682 |
val qtys = map #qtyp qty_infos |
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
683 |
val qty_full_names = map (fst o dest_Type) qtys |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
684 |
val qty_names = map Long_Name.base_name qty_full_names |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
685 |
|
2339
1e0b3992189c
more quotient-definitions
Christian Urban <urbanc@in.tum.de>
parents:
2338
diff
changeset
|
686 |
(* defining of quotient term-constructors, binding functions, free vars functions *) |
2378
2f13fe48c877
updated to new Isabelle; made FSet more "quiet"
Christian Urban <urbanc@in.tum.de>
parents:
2361
diff
changeset
|
687 |
val _ = warning "Defining the quotient constants" |
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
688 |
val qconstrs_descrs = |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
689 |
(map2 o map2) (fn (b, _, mx) => fn t => (Name.of_binding b, t, mx)) (get_cnstrs dts) raw_constrs |
2338 | 690 |
|
2339
1e0b3992189c
more quotient-definitions
Christian Urban <urbanc@in.tum.de>
parents:
2338
diff
changeset
|
691 |
val qbns_descr = |
2346 | 692 |
map2 (fn (b, _, mx) => fn t => (Name.of_binding b, t, mx)) bn_funs raw_bns |
2339
1e0b3992189c
more quotient-definitions
Christian Urban <urbanc@in.tum.de>
parents:
2338
diff
changeset
|
693 |
|
1e0b3992189c
more quotient-definitions
Christian Urban <urbanc@in.tum.de>
parents:
2338
diff
changeset
|
694 |
val qfvs_descr = |
2346 | 695 |
map2 (fn n => fn t => ("fv_" ^ n, t, NoSyn)) qty_names raw_fvs |
2339
1e0b3992189c
more quotient-definitions
Christian Urban <urbanc@in.tum.de>
parents:
2338
diff
changeset
|
696 |
|
2346 | 697 |
val qfv_bns_descr = |
2398 | 698 |
map2 (fn (b, _, _) => fn t => ("fv_" ^ Name.of_binding b, t, NoSyn)) bn_funs raw_fv_bns |
2339
1e0b3992189c
more quotient-definitions
Christian Urban <urbanc@in.tum.de>
parents:
2338
diff
changeset
|
699 |
|
2384
841b7e34e70a
fixed order of fold_union to make alpha and fv agree
Christian Urban <urbanc@in.tum.de>
parents:
2378
diff
changeset
|
700 |
val qalpha_bns_descr = |
841b7e34e70a
fixed order of fold_union to make alpha and fv agree
Christian Urban <urbanc@in.tum.de>
parents:
2378
diff
changeset
|
701 |
map2 (fn (b, _, _) => fn t => ("alpha_" ^ Name.of_binding b, t, NoSyn)) bn_funs alpha_bn_trms |
841b7e34e70a
fixed order of fold_union to make alpha and fv agree
Christian Urban <urbanc@in.tum.de>
parents:
2378
diff
changeset
|
702 |
|
2398 | 703 |
val qperm_descr = |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
704 |
map2 (fn n => fn t => ("permute_" ^ n, Type.legacy_freeze t, NoSyn)) qty_names raw_perm_funs |
2398 | 705 |
|
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
706 |
val qsize_descr = |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
707 |
map2 (fn n => fn t => ("size_" ^ n, t, NoSyn)) qty_names raw_size_trms |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
708 |
|
2562
e8ec504dddf2
lifted permute_bn constants
Christian Urban <urbanc@in.tum.de>
parents:
2561
diff
changeset
|
709 |
val qperm_bn_descr = |
e8ec504dddf2
lifted permute_bn constants
Christian Urban <urbanc@in.tum.de>
parents:
2561
diff
changeset
|
710 |
map2 (fn (b, _, _) => fn t => ("permute_" ^ Name.of_binding b, t, NoSyn)) bn_funs raw_perm_bns |
e8ec504dddf2
lifted permute_bn constants
Christian Urban <urbanc@in.tum.de>
parents:
2561
diff
changeset
|
711 |
|
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
712 |
val ((((((qconstrs_infos, qbns_info), qfvs_info), qfv_bns_info), qalpha_bns_info), qperm_bns_info), |
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
713 |
lthy8) = |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
714 |
if get_STEPS lthy > 24 |
2346 | 715 |
then |
716 |
lthy7 |
|
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
717 |
|> fold_map (define_qconsts qtys) qconstrs_descrs |
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
718 |
||>> define_qconsts qtys qbns_descr |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
719 |
||>> define_qconsts qtys qfvs_descr |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
720 |
||>> define_qconsts qtys qfv_bns_descr |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
721 |
||>> define_qconsts qtys qalpha_bns_descr |
2562
e8ec504dddf2
lifted permute_bn constants
Christian Urban <urbanc@in.tum.de>
parents:
2561
diff
changeset
|
722 |
||>> define_qconsts qtys qperm_bn_descr |
2338 | 723 |
else raise TEST lthy7 |
724 |
||
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
725 |
(* definition of the quotient permfunctions and pt-class *) |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
726 |
val lthy9 = |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
727 |
if get_STEPS lthy > 25 |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
728 |
then define_qperms qtys qty_full_names tvs qperm_descr raw_perm_laws lthy8 |
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
729 |
else raise TEST lthy8 |
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
730 |
|
2401
7645e18e8b19
modified the code for class instantiations (with help from Florian)
Christian Urban <urbanc@in.tum.de>
parents:
2400
diff
changeset
|
731 |
val lthy9a = |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
732 |
if get_STEPS lthy > 26 |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
733 |
then define_qsizes qtys qty_full_names tvs qsize_descr lthy9 |
2400
c6d30d5f5ba1
defined qperms and qsizes
Christian Urban <urbanc@in.tum.de>
parents:
2399
diff
changeset
|
734 |
else raise TEST lthy9 |
2398 | 735 |
|
2612 | 736 |
val qtrms = (map o map) #qconst qconstrs_infos |
2346 | 737 |
val qbns = map #qconst qbns_info |
738 |
val qfvs = map #qconst qfvs_info |
|
739 |
val qfv_bns = map #qconst qfv_bns_info |
|
2384
841b7e34e70a
fixed order of fold_union to make alpha and fv agree
Christian Urban <urbanc@in.tum.de>
parents:
2378
diff
changeset
|
740 |
val qalpha_bns = map #qconst qalpha_bns_info |
2593
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2571
diff
changeset
|
741 |
val qperm_bns = map #qconst qperm_bns_info |
2434 | 742 |
|
743 |
(* lifting of the theorems *) |
|
744 |
val _ = warning "Lifting of Theorems" |
|
745 |
||
2559
add799cf0817
adapted to changes by Florian on the quotient package and removed local fix for function package
Christian Urban <urbanc@in.tum.de>
parents:
2500
diff
changeset
|
746 |
val eq_iff_simps = @{thms alphas permute_prod.simps prod_fv.simps prod_alpha_def prod_rel_def |
2434 | 747 |
prod.cases} |
748 |
||
749 |
val ((((((qdistincts, qeq_iffs), qfv_defs), qbn_defs), qperm_simps), qfv_qbn_eqvts), lthyA) = |
|
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
750 |
if get_STEPS lthy > 27 |
2434 | 751 |
then |
752 |
lthy9a |
|
753 |
|> lift_thms qtys [] alpha_distincts |
|
754 |
||>> lift_thms qtys eq_iff_simps alpha_eq_iff |
|
755 |
||>> lift_thms qtys [] raw_fv_defs |
|
756 |
||>> lift_thms qtys [] raw_bn_defs |
|
757 |
||>> lift_thms qtys [] raw_perm_simps |
|
758 |
||>> lift_thms qtys [] (raw_fv_eqvt @ raw_bn_eqvt) |
|
759 |
else raise TEST lthy9a |
|
760 |
||
2594
515e5496171c
automated alpha_perm_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2593
diff
changeset
|
761 |
val ((((((qsize_eqvt, [qinduct]), qexhausts), qsize_simps), qperm_bn_simps), qalpha_refl_thms), lthyB) = |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
762 |
if get_STEPS lthy > 28 |
2434 | 763 |
then |
764 |
lthyA |
|
765 |
|> lift_thms qtys [] raw_size_eqvt |
|
766 |
||>> lift_thms qtys [] [raw_induct_thm] |
|
767 |
||>> lift_thms qtys [] raw_exhaust_thms |
|
2487
fbdaaa20396b
lifted size_thms and exported them as <name>.size
Christian Urban <urbanc@in.tum.de>
parents:
2483
diff
changeset
|
768 |
||>> lift_thms qtys [] raw_size_thms |
2563
7c8bfc35663a
lifted permute_bn simp rules
Christian Urban <urbanc@in.tum.de>
parents:
2562
diff
changeset
|
769 |
||>> lift_thms qtys [] raw_perm_bn_simps |
2594
515e5496171c
automated alpha_perm_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2593
diff
changeset
|
770 |
||>> lift_thms qtys [] alpha_refl_thms |
2434 | 771 |
else raise TEST lthyA |
772 |
||
2474
6e37bfb62474
generated inducts rule by Project_Rule.projections
Christian Urban <urbanc@in.tum.de>
parents:
2471
diff
changeset
|
773 |
val qinducts = Project_Rule.projections lthyA qinduct |
6e37bfb62474
generated inducts rule by Project_Rule.projections
Christian Urban <urbanc@in.tum.de>
parents:
2471
diff
changeset
|
774 |
|
2451
d2e929f51fa9
added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents:
2450
diff
changeset
|
775 |
(* supports lemmas *) |
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:
2474
diff
changeset
|
776 |
val _ = warning "Proving Supports Lemmas and fs-Instances" |
2448 | 777 |
val qsupports_thms = |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
778 |
if get_STEPS lthy > 29 |
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
779 |
then prove_supports lthyB qperm_simps (flat qtrms) |
2448 | 780 |
else raise TEST lthyB |
781 |
||
2451
d2e929f51fa9
added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents:
2450
diff
changeset
|
782 |
(* finite supp lemmas *) |
2450
217ef3e4282e
added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents:
2448
diff
changeset
|
783 |
val qfsupp_thms = |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
784 |
if get_STEPS lthy > 30 |
2450
217ef3e4282e
added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents:
2448
diff
changeset
|
785 |
then prove_fsupp lthyB qtys qinduct qsupports_thms |
217ef3e4282e
added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents:
2448
diff
changeset
|
786 |
else raise TEST lthyB |
217ef3e4282e
added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents:
2448
diff
changeset
|
787 |
|
2451
d2e929f51fa9
added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents:
2450
diff
changeset
|
788 |
(* fs instances *) |
d2e929f51fa9
added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents:
2450
diff
changeset
|
789 |
val lthyC = |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
790 |
if get_STEPS lthy > 31 |
2451
d2e929f51fa9
added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents:
2450
diff
changeset
|
791 |
then fs_instance qtys qty_full_names tvs qfsupp_thms lthyB |
d2e929f51fa9
added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents:
2450
diff
changeset
|
792 |
else raise TEST lthyB |
2448 | 793 |
|
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:
2474
diff
changeset
|
794 |
(* fv - supp equality *) |
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents:
2474
diff
changeset
|
795 |
val _ = warning "Proving Equality between fv and supp" |
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents:
2474
diff
changeset
|
796 |
val qfv_supp_thms = |
2561
7926f1cb45eb
respectfulness for permute_bn functions
Christian Urban <urbanc@in.tum.de>
parents:
2560
diff
changeset
|
797 |
if get_STEPS lthy > 32 |
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
parents:
2598
diff
changeset
|
798 |
then prove_fv_supp qtys (flat qtrms) qfvs qfv_bns qalpha_bns qfv_defs qeq_iffs |
2481
3a5ebb2fcdbf
made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents:
2475
diff
changeset
|
799 |
qperm_simps qfv_qbn_eqvts qinduct (flat raw_bclauses) lthyC |
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:
2474
diff
changeset
|
800 |
else [] |
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents:
2474
diff
changeset
|
801 |
|
2492
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents:
2487
diff
changeset
|
802 |
(* postprocessing of eq and fv theorems *) |
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents:
2487
diff
changeset
|
803 |
|
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents:
2487
diff
changeset
|
804 |
val qeq_iffs' = qeq_iffs |
2493
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
805 |
|> map (simplify (HOL_basic_ss addsimps qfv_supp_thms)) |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
806 |
|> map (simplify (HOL_basic_ss addsimps @{thms prod_fv_supp prod_alpha_eq Abs_eq_iff[symmetric]})) |
2492
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents:
2487
diff
changeset
|
807 |
|
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents:
2487
diff
changeset
|
808 |
val qsupp_constrs = qfv_defs |
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents:
2487
diff
changeset
|
809 |
|> map (simplify (HOL_basic_ss addsimps (take (length qfvs) qfv_supp_thms))) |
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents:
2487
diff
changeset
|
810 |
|
2493
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
811 |
val transform_thm = @{lemma "x = y \<Longrightarrow> a \<notin> x \<longleftrightarrow> a \<notin> y" by simp} |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
812 |
val transform_thms = |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
813 |
[ @{lemma "a \<notin> (S \<union> T) \<longleftrightarrow> a \<notin> S \<and> a \<notin> T" by simp}, |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
814 |
@{lemma "a \<notin> (S - T) \<longleftrightarrow> a \<notin> S \<or> a \<in> T" by simp}, |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
815 |
@{lemma "(lhs = (a \<notin> {})) \<longleftrightarrow> lhs" by simp}, |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
816 |
@{thm fresh_def[symmetric]}] |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
817 |
|
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
818 |
val qfresh_constrs = qsupp_constrs |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
819 |
|> map (fn thm => thm RS transform_thm) |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
820 |
|> map (simplify (HOL_basic_ss addsimps transform_thms)) |
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
821 |
|
2593
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2571
diff
changeset
|
822 |
(* proving that the qbn result is finite *) |
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2571
diff
changeset
|
823 |
val qbn_finite_thms = |
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2571
diff
changeset
|
824 |
if get_STEPS lthy > 33 |
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2571
diff
changeset
|
825 |
then prove_bns_finite qtys qbns qinduct qbn_defs lthyC |
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2571
diff
changeset
|
826 |
else [] |
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2571
diff
changeset
|
827 |
|
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2571
diff
changeset
|
828 |
(* proving that perm_bns preserve alpha *) |
2594
515e5496171c
automated alpha_perm_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2593
diff
changeset
|
829 |
val qperm_bn_alpha_thms = |
515e5496171c
automated alpha_perm_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2593
diff
changeset
|
830 |
if get_STEPS lthy > 33 |
515e5496171c
automated alpha_perm_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2593
diff
changeset
|
831 |
then prove_perm_bn_alpha_thms qtys qperm_bns qalpha_bns qinduct qperm_bn_simps qeq_iffs' |
515e5496171c
automated alpha_perm_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2593
diff
changeset
|
832 |
qalpha_refl_thms lthyC |
515e5496171c
automated alpha_perm_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2593
diff
changeset
|
833 |
else [] |
2493
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
834 |
|
2598
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2595
diff
changeset
|
835 |
(* proving the relationship of bn and permute_bn *) |
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2595
diff
changeset
|
836 |
val qpermute_bn_thms = |
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2595
diff
changeset
|
837 |
if get_STEPS lthy > 33 |
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2595
diff
changeset
|
838 |
then prove_permute_bn_thms qtys qbns qperm_bns qinduct qperm_bn_simps qbn_defs qfv_qbn_eqvts lthyC |
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2595
diff
changeset
|
839 |
else [] |
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2595
diff
changeset
|
840 |
|
2619 | 841 |
val qstrong_exhaust_thms = prove_strong_exhausts lthyC qexhausts bclauses qbn_finite_thms qeq_iffs' |
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
842 |
qfv_qbn_eqvts qpermute_bn_thms qperm_bn_alpha_thms |
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
843 |
|
2603
90779aefbf1a
first tests about exhaust
Christian Urban <urbanc@in.tum.de>
parents:
2602
diff
changeset
|
844 |
|
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
845 |
(* noting the theorems *) |
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
846 |
|
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
847 |
(* generating the prefix for the theorem names *) |
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
848 |
val thms_name = |
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
849 |
the_default (Binding.name (space_implode "_" qty_names)) opt_thms_name |
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
850 |
fun thms_suffix s = Binding.qualified true s thms_name |
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
851 |
|
2451
d2e929f51fa9
added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents:
2450
diff
changeset
|
852 |
val (_, lthy9') = lthyC |
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
853 |
|> Local_Theory.note ((thms_suffix "distinct", []), qdistincts) |
2492
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents:
2487
diff
changeset
|
854 |
||>> Local_Theory.note ((thms_suffix "eq_iff", []), qeq_iffs') |
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
855 |
||>> Local_Theory.note ((thms_suffix "fv_defs", []), qfv_defs) |
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
856 |
||>> Local_Theory.note ((thms_suffix "bn_defs", []), qbn_defs) |
2448 | 857 |
||>> Local_Theory.note ((thms_suffix "perm_simps", [eqvt_attr, simp_attr]), qperm_simps) |
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
858 |
||>> Local_Theory.note ((thms_suffix "fv_bn_eqvt", []), qfv_qbn_eqvts) |
2487
fbdaaa20396b
lifted size_thms and exported them as <name>.size
Christian Urban <urbanc@in.tum.de>
parents:
2483
diff
changeset
|
859 |
||>> Local_Theory.note ((thms_suffix "size", []), qsize_simps) |
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
860 |
||>> Local_Theory.note ((thms_suffix "size_eqvt", []), qsize_eqvt) |
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
861 |
||>> Local_Theory.note ((thms_suffix "induct", []), [qinduct]) |
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:
2474
diff
changeset
|
862 |
||>> Local_Theory.note ((thms_suffix "inducts", []), qinducts) |
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
863 |
||>> Local_Theory.note ((thms_suffix "exhaust", []), qexhausts) |
2617
e44551d067e6
properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents:
2616
diff
changeset
|
864 |
||>> Local_Theory.note ((thms_suffix "strong_exhaust", []), qstrong_exhaust_thms) |
2448 | 865 |
||>> Local_Theory.note ((thms_suffix "supports", []), qsupports_thms) |
2450
217ef3e4282e
added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents:
2448
diff
changeset
|
866 |
||>> Local_Theory.note ((thms_suffix "fsupp", []), qfsupp_thms) |
2492
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents:
2487
diff
changeset
|
867 |
||>> Local_Theory.note ((thms_suffix "supp", []), qsupp_constrs) |
2493
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2492
diff
changeset
|
868 |
||>> Local_Theory.note ((thms_suffix "fresh", []), qfresh_constrs) |
2500
3b6a70e73006
worked example Foo1 with induct_schema
Christian Urban <urbanc@in.tum.de>
parents:
2493
diff
changeset
|
869 |
||>> Local_Theory.note ((thms_suffix "raw_alpha", []), alpha_intros) |
2563
7c8bfc35663a
lifted permute_bn simp rules
Christian Urban <urbanc@in.tum.de>
parents:
2562
diff
changeset
|
870 |
||>> Local_Theory.note ((thms_suffix "perm_bn_simps", []), qperm_bn_simps) |
2571
f0252365936c
proved that bn functions return a finite set
Christian Urban <urbanc@in.tum.de>
parents:
2568
diff
changeset
|
871 |
||>> Local_Theory.note ((thms_suffix "bn_finite", []), qbn_finite_thms) |
2593
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2571
diff
changeset
|
872 |
||>> Local_Theory.note ((thms_suffix "perm_bn_alpha", []), qperm_bn_alpha_thms) |
2598
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2595
diff
changeset
|
873 |
||>> Local_Theory.note ((thms_suffix "permute_bn", []), qpermute_bn_thms) |
1941 | 874 |
in |
2601
89c55d36980f
moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents:
2600
diff
changeset
|
875 |
lthy9' |
89c55d36980f
moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents:
2600
diff
changeset
|
876 |
end handle TEST ctxt => ctxt |
1941 | 877 |
*} |
878 |
||
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:
2474
diff
changeset
|
879 |
|
1941 | 880 |
section {* Preparing and parsing of the specification *} |
881 |
||
882 |
ML {* |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
883 |
(* generates the parsed datatypes and |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
884 |
declares the constructors |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
885 |
*) |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
886 |
fun prepare_dts dt_strs thy = |
1941 | 887 |
let |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
888 |
fun inter_fs_sort thy (a, S) = |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
889 |
(a, Type.inter_sort (Sign.tsig_of thy) (@{sort fs}, S)) |
1941 | 890 |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
891 |
fun mk_type tname sorts (cname, cargs, mx) = |
1941 | 892 |
let |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
893 |
val full_tname = Sign.full_name thy tname |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
894 |
val ty = Type (full_tname, map (TFree o inter_fs_sort thy) sorts) |
1941 | 895 |
in |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
896 |
(cname, cargs ---> ty, mx) |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
897 |
end |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
898 |
|
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
899 |
fun prep_constr (cname, cargs, mx, _) (constrs, sorts) = |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
900 |
let |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
901 |
val (cargs', sorts') = |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
902 |
fold_map (Datatype.read_typ thy) (map snd cargs) sorts |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
903 |
|>> map (map_type_tfree (TFree o inter_fs_sort thy)) |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
904 |
in |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
905 |
(constrs @ [(cname, cargs', mx)], sorts') |
1941 | 906 |
end |
907 |
||
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
908 |
fun prep_dts (tvs, tname, mx, constrs) (constr_trms, dts, sorts) = |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
909 |
let |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
910 |
val (constrs', sorts') = |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
911 |
fold prep_constr constrs ([], sorts) |
1941 | 912 |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
913 |
val constr_trms' = |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
914 |
map (mk_type tname (rev sorts')) constrs' |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
915 |
in |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
916 |
(constr_trms @ constr_trms', dts @ [(tvs, tname, mx, constrs')], sorts') |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
917 |
end |
2425
715ab84065a0
nominal_datatypes with type variables do not work
Christian Urban <urbanc@in.tum.de>
parents:
2424
diff
changeset
|
918 |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
919 |
val (constr_trms, dts, sorts) = fold prep_dts dt_strs ([], [], []); |
1941 | 920 |
in |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
921 |
thy |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
922 |
|> Sign.add_consts_i constr_trms |
1941 | 923 |
|> pair dts |
924 |
end |
|
925 |
*} |
|
926 |
||
927 |
ML {* |
|
928 |
(* parsing the binding function specification and *) |
|
929 |
(* declaring the functions in the local theory *) |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
930 |
fun prepare_bn_funs bn_fun_strs bn_eq_strs thy = |
1941 | 931 |
let |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
932 |
val lthy = Named_Target.theory_init thy |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
933 |
|
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
934 |
val ((bn_funs, bn_eqs), lthy') = |
1941 | 935 |
Specification.read_spec bn_fun_strs bn_eq_strs lthy |
936 |
||
937 |
fun prep_bn_fun ((bn, T), mx) = (bn, T, mx) |
|
938 |
||
939 |
val bn_funs' = map prep_bn_fun bn_funs |
|
940 |
in |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
941 |
(Local_Theory.exit_global lthy') |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
942 |
|> Sign.add_consts_i bn_funs' |
1941 | 943 |
|> pair (bn_funs', bn_eqs) |
944 |
end |
|
945 |
*} |
|
946 |
||
947 |
text {* associates every SOME with the index in the list; drops NONEs *} |
|
948 |
ML {* |
|
949 |
fun indexify xs = |
|
950 |
let |
|
951 |
fun mapp _ [] = [] |
|
952 |
| mapp i (NONE :: xs) = mapp (i + 1) xs |
|
953 |
| mapp i (SOME x :: xs) = (x, i) :: mapp (i + 1) xs |
|
954 |
in |
|
955 |
mapp 0 xs |
|
956 |
end |
|
957 |
||
958 |
fun index_lookup xs x = |
|
959 |
case AList.lookup (op=) xs x of |
|
960 |
SOME x => x |
|
961 |
| NONE => error ("Cannot find " ^ x ^ " as argument annotation."); |
|
962 |
*} |
|
963 |
||
964 |
ML {* |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
965 |
fun prepare_bclauses dt_strs thy = |
1941 | 966 |
let |
967 |
val annos_bclauses = |
|
968 |
get_cnstrs dt_strs |
|
2612 | 969 |
|> (map o map) (fn (_, antys, _, bns) => (map fst antys, bns)) |
1941 | 970 |
|
971 |
fun prep_binder env bn_str = |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
972 |
case (Syntax.read_term_global thy bn_str) of |
1941 | 973 |
Free (x, _) => (NONE, index_lookup env x) |
974 |
| Const (a, T) $ Free (x, _) => (SOME (Const (a, T)), index_lookup env x) |
|
975 |
| _ => error ("The term " ^ bn_str ^ " is not allowed as binding function.") |
|
976 |
||
977 |
fun prep_body env bn_str = index_lookup env bn_str |
|
978 |
||
979 |
fun prep_bclause env (mode, binders, bodies) = |
|
980 |
let |
|
981 |
val binders' = map (prep_binder env) binders |
|
982 |
val bodies' = map (prep_body env) bodies |
|
983 |
in |
|
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
984 |
BC (mode, binders', bodies') |
1941 | 985 |
end |
986 |
||
987 |
fun prep_bclauses (annos, bclause_strs) = |
|
988 |
let |
|
989 |
val env = indexify annos (* for every label, associate the index *) |
|
990 |
in |
|
991 |
map (prep_bclause env) bclause_strs |
|
992 |
end |
|
993 |
in |
|
2612 | 994 |
((map o map) prep_bclauses annos_bclauses, thy) |
1941 | 995 |
end |
996 |
*} |
|
997 |
||
1943 | 998 |
text {* |
999 |
adds an empty binding clause for every argument |
|
1000 |
that is not already part of a binding clause |
|
1001 |
*} |
|
1002 |
||
1941 | 1003 |
ML {* |
1004 |
fun included i bcs = |
|
1005 |
let |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1006 |
fun incl (BC (_, bns, bds)) = |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1007 |
member (op =) (map snd bns) i orelse member (op =) bds i |
1941 | 1008 |
in |
1009 |
exists incl bcs |
|
1010 |
end |
|
1011 |
*} |
|
1012 |
||
1013 |
ML {* |
|
1014 |
fun complete dt_strs bclauses = |
|
1015 |
let |
|
1016 |
val args = |
|
1017 |
get_cnstrs dt_strs |
|
2612 | 1018 |
|> (map o map) (fn (_, antys, _, _) => length antys) |
1941 | 1019 |
|
1020 |
fun complt n bcs = |
|
1021 |
let |
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
parents:
2146
diff
changeset
|
1022 |
fun add bcs i = (if included i bcs then [] else [BC (Lst, [], [i])]) |
1941 | 1023 |
in |
1024 |
bcs @ (flat (map_range (add bcs) n)) |
|
1025 |
end |
|
1026 |
in |
|
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2613
diff
changeset
|
1027 |
(map2 o map2) complt args bclauses |
1941 | 1028 |
end |
1029 |
*} |
|
1030 |
||
1031 |
ML {* |
|
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
1032 |
fun nominal_datatype2_cmd (opt_thms_name, dt_strs, bn_fun_strs, bn_eq_strs) lthy = |
1941 | 1033 |
let |
2436
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
1034 |
val pre_typs = |
3885dc2669f9
cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents:
2435
diff
changeset
|
1035 |
map (fn (tvs, tname, mx, _) => (tname, length tvs, mx)) dt_strs |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1036 |
|
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1037 |
(* this theory is used just for parsing *) |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1038 |
val thy = ProofContext.theory_of lthy |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1039 |
val tmp_thy = Theory.copy thy |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1040 |
|
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1041 |
val (((dts, (bn_funs, bn_eqs)), bclauses), tmp_thy') = |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1042 |
tmp_thy |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1043 |
|> Sign.add_types pre_typs |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1044 |
|> prepare_dts dt_strs |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1045 |
||>> prepare_bn_funs bn_fun_strs bn_eq_strs |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1046 |
||>> prepare_bclauses dt_strs |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1047 |
|
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1048 |
val bclauses' = complete dt_strs bclauses |
1941 | 1049 |
in |
2601
89c55d36980f
moved definition of raw bn-functions into nominal_dt_rawfuns
Christian Urban <urbanc@in.tum.de>
parents:
2600
diff
changeset
|
1050 |
timeit (fn () => nominal_datatype2 opt_thms_name dts bn_funs bn_eqs bclauses' lthy) |
1941 | 1051 |
end |
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1052 |
*} |
1941 | 1053 |
|
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1054 |
ML {* |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1055 |
(* nominal datatype parser *) |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1056 |
local |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1057 |
structure P = Parse; |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1058 |
structure S = Scan |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1059 |
|
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1060 |
fun triple ((x, y), z) = (x, y, z) |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1061 |
fun tuple1 ((x, y, z), u) = (x, y, z, u) |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1062 |
fun tuple2 (((x, y), z), u) = (x, y, u, z) |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1063 |
fun tuple3 ((x, y), (z, u)) = (x, y, z, u) |
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1064 |
in |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1065 |
|
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1066 |
val _ = Keyword.keyword "bind" |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1067 |
|
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1068 |
val opt_name = Scan.option (P.binding --| Args.colon) |
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1069 |
|
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1070 |
val anno_typ = S.option (P.name --| P.$$$ "::") -- P.typ |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1071 |
|
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1072 |
val bind_mode = P.$$$ "bind" |-- |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1073 |
S.optional (Args.parens |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1074 |
(Args.$$$ "list" >> K Lst || Args.$$$ "set" >> K Set || Args.$$$ "res" >> K Res)) Lst |
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1075 |
|
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1076 |
val bind_clauses = |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1077 |
P.enum "," (bind_mode -- S.repeat1 P.term -- (P.$$$ "in" |-- S.repeat1 P.name) >> triple) |
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1078 |
|
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1079 |
val cnstr_parser = |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1080 |
P.binding -- S.repeat anno_typ -- bind_clauses -- P.opt_mixfix >> tuple2 |
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1081 |
|
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1082 |
(* datatype parser *) |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1083 |
val dt_parser = |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1084 |
(P.type_args -- P.binding -- P.opt_mixfix >> triple) -- |
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1085 |
(P.$$$ "=" |-- P.enum1 "|" cnstr_parser) >> tuple1 |
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1086 |
|
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1087 |
(* binding function parser *) |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1088 |
val bnfun_parser = |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1089 |
S.optional (P.$$$ "binder" |-- P.fixes -- Parse_Spec.where_alt_specs) ([], []) |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1090 |
|
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1091 |
(* main parser *) |
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1092 |
val main_parser = |
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2430
diff
changeset
|
1093 |
opt_name -- P.and_list1 dt_parser -- bnfun_parser >> tuple3 |
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1094 |
|
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
parents:
2411
diff
changeset
|
1095 |
end |
1941 | 1096 |
|
1097 |
(* Command Keyword *) |
|
2168 | 1098 |
val _ = Outer_Syntax.local_theory "nominal_datatype" "test" Keyword.thy_decl |
1941 | 1099 |
(main_parser >> nominal_datatype2_cmd) |
1100 |
*} |
|
1101 |
||
2292 | 1102 |
|
1941 | 1103 |
end |
1104 |
||
1105 |
||
1106 |