author | Christian Urban <urbanc@in.tum.de> |
Tue, 27 Oct 2009 14:46:38 +0100 | |
changeset 205 | 2a803a1556d5 |
parent 202 | 8ca1150f34d0 |
child 206 | 1e227c9ee915 |
child 212 | ca9eae5bd871 |
permissions | -rw-r--r-- |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
1 |
theory FSet |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
2 |
imports QuotMain |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
3 |
begin |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
4 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
5 |
inductive |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
6 |
list_eq (infix "\<approx>" 50) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
7 |
where |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
8 |
"a#b#xs \<approx> b#a#xs" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
9 |
| "[] \<approx> []" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
10 |
| "xs \<approx> ys \<Longrightarrow> ys \<approx> xs" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
11 |
| "a#a#xs \<approx> a#xs" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
12 |
| "xs \<approx> ys \<Longrightarrow> a#xs \<approx> a#ys" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
13 |
| "\<lbrakk>xs1 \<approx> xs2; xs2 \<approx> xs3\<rbrakk> \<Longrightarrow> xs1 \<approx> xs3" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
14 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
15 |
lemma list_eq_refl: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
16 |
shows "xs \<approx> xs" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
17 |
apply (induct xs) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
18 |
apply (auto intro: list_eq.intros) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
19 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
20 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
21 |
lemma equiv_list_eq: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
22 |
shows "EQUIV list_eq" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
23 |
unfolding EQUIV_REFL_SYM_TRANS REFL_def SYM_def TRANS_def |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
24 |
apply(auto intro: list_eq.intros list_eq_refl) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
25 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
26 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
27 |
quotient fset = "'a list" / "list_eq" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
28 |
apply(rule equiv_list_eq) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
29 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
30 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
31 |
print_theorems |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
32 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
33 |
typ "'a fset" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
34 |
thm "Rep_fset" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
35 |
thm "ABS_fset_def" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
36 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
37 |
ML {* @{term "Abs_fset"} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
38 |
local_setup {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
39 |
make_const_def @{binding EMPTY} @{term "[]"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
40 |
*} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
41 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
42 |
term Nil |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
43 |
term EMPTY |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
44 |
thm EMPTY_def |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
45 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
46 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
47 |
local_setup {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
48 |
make_const_def @{binding INSERT} @{term "op #"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
49 |
*} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
50 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
51 |
term Cons |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
52 |
term INSERT |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
53 |
thm INSERT_def |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
54 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
55 |
local_setup {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
56 |
make_const_def @{binding UNION} @{term "op @"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
57 |
*} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
58 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
59 |
term append |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
60 |
term UNION |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
61 |
thm UNION_def |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
62 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
63 |
thm QUOTIENT_fset |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
64 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
65 |
thm QUOT_TYPE_I_fset.thm11 |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
66 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
67 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
68 |
fun |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
69 |
membship :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" (infix "memb" 100) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
70 |
where |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
71 |
m1: "(x memb []) = False" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
72 |
| m2: "(x memb (y#xs)) = ((x=y) \<or> (x memb xs))" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
73 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
74 |
fun |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
75 |
card1 :: "'a list \<Rightarrow> nat" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
76 |
where |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
77 |
card1_nil: "(card1 []) = 0" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
78 |
| card1_cons: "(card1 (x # xs)) = (if (x memb xs) then (card1 xs) else (Suc (card1 xs)))" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
79 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
80 |
local_setup {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
81 |
make_const_def @{binding card} @{term "card1"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
82 |
*} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
83 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
84 |
term card1 |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
85 |
term card |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
86 |
thm card_def |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
87 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
88 |
(* text {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
89 |
Maybe make_const_def should require a theorem that says that the particular lifted function |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
90 |
respects the relation. With it such a definition would be impossible: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
91 |
make_const_def @{binding CARD} @{term "length"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
92 |
*}*) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
93 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
94 |
lemma card1_0: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
95 |
fixes a :: "'a list" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
96 |
shows "(card1 a = 0) = (a = [])" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
97 |
apply (induct a) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
98 |
apply (simp) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
99 |
apply (simp_all) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
100 |
apply meson |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
101 |
apply (simp_all) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
102 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
103 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
104 |
lemma not_mem_card1: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
105 |
fixes x :: "'a" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
106 |
fixes xs :: "'a list" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
107 |
shows "~(x memb xs) \<Longrightarrow> card1 (x # xs) = Suc (card1 xs)" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
108 |
by simp |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
109 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
110 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
111 |
lemma mem_cons: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
112 |
fixes x :: "'a" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
113 |
fixes xs :: "'a list" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
114 |
assumes a : "x memb xs" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
115 |
shows "x # xs \<approx> xs" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
116 |
using a |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
117 |
apply (induct xs) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
118 |
apply (auto intro: list_eq.intros) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
119 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
120 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
121 |
lemma card1_suc: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
122 |
fixes xs :: "'a list" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
123 |
fixes n :: "nat" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
124 |
assumes c: "card1 xs = Suc n" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
125 |
shows "\<exists>a ys. ~(a memb ys) \<and> xs \<approx> (a # ys)" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
126 |
using c |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
127 |
apply(induct xs) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
128 |
apply (metis Suc_neq_Zero card1_0) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
129 |
apply (metis QUOT_TYPE_I_fset.R_trans card1_cons list_eq_refl mem_cons) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
130 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
131 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
132 |
primrec |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
133 |
fold1 |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
134 |
where |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
135 |
"fold1 f (g :: 'a \<Rightarrow> 'b) (z :: 'b) [] = z" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
136 |
| "fold1 f g z (a # A) = |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
137 |
(if ((!u v. (f u v = f v u)) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
138 |
\<and> (!u v w. ((f u (f v w) = f (f u v) w)))) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
139 |
then ( |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
140 |
if (a memb A) then (fold1 f g z A) else (f (g a) (fold1 f g z A)) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
141 |
) else z)" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
142 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
143 |
(* fold1_def is not usable, but: *) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
144 |
thm fold1.simps |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
145 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
146 |
lemma fs1_strong_cases: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
147 |
fixes X :: "'a list" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
148 |
shows "(X = []) \<or> (\<exists>a. \<exists> Y. (~(a memb Y) \<and> (X \<approx> a # Y)))" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
149 |
apply (induct X) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
150 |
apply (simp) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
151 |
apply (metis QUOT_TYPE_I_fset.thm11 list_eq_refl mem_cons m1) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
152 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
153 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
154 |
local_setup {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
155 |
make_const_def @{binding IN} @{term "membship"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
156 |
*} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
157 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
158 |
term membship |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
159 |
term IN |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
160 |
thm IN_def |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
161 |
|
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
162 |
local_setup {* |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
163 |
make_const_def @{binding fold} @{term "fold1::('b \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
164 |
*} |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
165 |
|
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
166 |
term fold1 |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
167 |
term fold |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
168 |
thm fold_def |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
169 |
|
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
170 |
local_setup {* |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
171 |
make_const_def @{binding fmap} @{term "map::('a \<Rightarrow> 'a) \<Rightarrow> 'a list \<Rightarrow> 'a list"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
172 |
*} |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
173 |
|
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
174 |
term map |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
175 |
term fmap |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
176 |
thm fmap_def |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
177 |
|
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
178 |
|
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
179 |
ML {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
180 |
val consts = [@{const_name "Nil"}, @{const_name "Cons"}, |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
181 |
@{const_name "membship"}, @{const_name "card1"}, |
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
182 |
@{const_name "append"}, @{const_name "fold1"}, |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
183 |
@{const_name "map"}]; |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
184 |
*} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
185 |
|
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
186 |
ML {* val fset_defs = @{thms EMPTY_def IN_def UNION_def card_def INSERT_def fmap_def fold_def} *} |
190
ca1a24aa822e
Finished the code for adding lower defs, and more things moved to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
189
diff
changeset
|
187 |
ML {* val fset_defs_sym = add_lower_defs @{context} fset_defs *} |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
188 |
|
164
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
189 |
lemma memb_rsp: |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
190 |
fixes z |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
191 |
assumes a: "list_eq x y" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
192 |
shows "(z memb x) = (z memb y)" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
193 |
using a by induct auto |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
194 |
|
164
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
195 |
lemma ho_memb_rsp: |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
196 |
"(op = ===> (op \<approx> ===> op =)) (op memb) (op memb)" |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
197 |
apply (simp add: FUN_REL.simps) |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
198 |
apply (metis memb_rsp) |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
199 |
done |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
200 |
|
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
201 |
lemma card1_rsp: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
202 |
fixes a b :: "'a list" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
203 |
assumes e: "a \<approx> b" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
204 |
shows "card1 a = card1 b" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
205 |
using e apply induct |
164
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
206 |
apply (simp_all add:memb_rsp) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
207 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
208 |
|
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
209 |
lemma ho_card1_rsp: "op \<approx> ===> op = card1 card1" |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
210 |
apply (simp add: FUN_REL.simps) |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
211 |
apply (metis card1_rsp) |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
212 |
done |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
213 |
|
164
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
214 |
lemma cons_rsp: |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
215 |
fixes z |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
216 |
assumes a: "xs \<approx> ys" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
217 |
shows "(z # xs) \<approx> (z # ys)" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
218 |
using a by (rule list_eq.intros(5)) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
219 |
|
164
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
220 |
lemma ho_cons_rsp: |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
221 |
"op = ===> op \<approx> ===> op \<approx> op # op #" |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
222 |
apply (simp add: FUN_REL.simps) |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
223 |
apply (metis cons_rsp) |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
224 |
done |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
225 |
|
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
226 |
lemma append_rsp_fst: |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
227 |
assumes a : "list_eq l1 l2" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
228 |
shows "list_eq (l1 @ s) (l2 @ s)" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
229 |
using a |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
230 |
apply(induct) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
231 |
apply(auto intro: list_eq.intros) |
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
232 |
apply(rule list_eq_refl) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
233 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
234 |
|
187 | 235 |
(* Need stronger induction... *) |
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
236 |
lemma "(a @ b) \<approx> (b @ a)" |
187 | 237 |
apply(induct a) |
238 |
sorry |
|
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
239 |
|
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
240 |
lemma ho_append_rsp: |
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
241 |
"op \<approx> ===> op \<approx> ===> op \<approx> op @ op @" |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
242 |
sorry |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
243 |
|
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
244 |
lemma map_rsp: |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
245 |
assumes a: "a \<approx> b" |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
246 |
shows "map f a \<approx> map f b" |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
247 |
using a |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
248 |
apply (induct) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
249 |
apply(auto intro: list_eq.intros) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
250 |
done |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
251 |
|
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
252 |
lemma ho_map_rsp: |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
253 |
"op = ===> op = ===> op \<approx> ===> op \<approx> map map" |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
254 |
apply (simp add: FUN_REL.simps) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
255 |
apply (rule allI) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
256 |
apply (rule allI) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
257 |
apply (rule impI) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
258 |
apply (rule allI) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
259 |
apply (rule allI) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
260 |
apply (rule impI) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
261 |
sorry (* apply (auto simp add: map_rsp[of "xa" "ya"]) *) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
262 |
|
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
263 |
lemma map_append : |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
264 |
"(map f ((a::'a list) @ b)) \<approx> |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
265 |
((map f a) ::'a list) @ (map f b)" |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
266 |
apply simp |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
267 |
apply (rule list_eq_refl) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
268 |
done |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
269 |
|
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
270 |
thm list.induct |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
271 |
lemma list_induct_hol4: |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
272 |
fixes P :: "'a list \<Rightarrow> bool" |
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
273 |
assumes a: "((P []) \<and> (\<forall>t. (P t) \<longrightarrow> (\<forall>h. (P (h # t)))))" |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
274 |
shows "\<forall>l. (P l)" |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
275 |
using a |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
276 |
apply (rule_tac allI) |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
277 |
apply (induct_tac "l") |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
278 |
apply (simp) |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
279 |
apply (metis) |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
280 |
done |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
281 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
282 |
prove list_induct_r: {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
283 |
build_regularize_goal (atomize_thm @{thm list_induct_hol4}) @{typ "'a List.list"} @{term "op \<approx>"} @{context} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
284 |
apply (simp only: equiv_res_forall[OF equiv_list_eq]) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
285 |
thm RIGHT_RES_FORALL_REGULAR |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
286 |
apply (rule RIGHT_RES_FORALL_REGULAR) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
287 |
prefer 2 |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
288 |
apply (assumption) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
289 |
apply (metis) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
290 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
291 |
|
187 | 292 |
(* The all_prs and ex_prs should be proved for the instance... *) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
293 |
ML {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
294 |
fun r_mk_comb_tac_fset ctxt = |
187 | 295 |
r_mk_comb_tac ctxt @{thm QUOTIENT_fset} @{thm list_eq_refl} @{thm QUOT_TYPE_I_fset.R_trans2} |
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
296 |
(@{thms ho_memb_rsp ho_cons_rsp ho_card1_rsp ho_map_rsp ho_append_rsp} @ @{thms ho_all_prs ho_ex_prs}) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
297 |
*} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
298 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
299 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
300 |
ML {* val thm = @{thm list_induct_r} OF [atomize_thm @{thm list_induct_hol4}] *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
301 |
ML {* val trm_r = build_repabs_goal @{context} thm consts @{typ "'a list"} @{typ "'a fset"} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
302 |
ML {* val trm = build_repabs_term @{context} thm consts @{typ "'a list"} @{typ "'a fset"} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
303 |
|
166
3300260b63a1
Better tactic and simplified the proof further
cek@localhost.localdomain
parents:
164
diff
changeset
|
304 |
ML {* trm_r *} |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
305 |
prove list_induct_tr: trm_r |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
306 |
apply (atomize(full)) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
307 |
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_fset @{context}) 1 *}) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
308 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
309 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
310 |
prove list_induct_t: trm |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
311 |
apply (simp only: list_induct_tr[symmetric]) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
312 |
apply (tactic {* rtac thm 1 *}) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
313 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
314 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
315 |
thm m2 |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
316 |
ML {* atomize_thm @{thm m2} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
317 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
318 |
prove m2_r_p: {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
319 |
build_regularize_goal (atomize_thm @{thm m2}) @{typ "'a List.list"} @{term "op \<approx>"} @{context} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
320 |
apply (simp add: equiv_res_forall[OF equiv_list_eq]) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
321 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
322 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
323 |
ML {* val m2_r = @{thm m2_r_p} OF [atomize_thm @{thm m2}] *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
324 |
ML {* val m2_t_g = build_repabs_goal @{context} m2_r consts @{typ "'a list"} @{typ "'a fset"} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
325 |
ML {* val m2_t = build_repabs_term @{context} m2_r consts @{typ "'a list"} @{typ "'a fset"} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
326 |
prove m2_t_p: m2_t_g |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
327 |
apply (atomize(full)) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
328 |
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_fset @{context}) 1 *}) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
329 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
330 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
331 |
prove m2_t: m2_t |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
332 |
apply (simp only: m2_t_p[symmetric]) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
333 |
apply (tactic {* rtac m2_r 1 *}) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
334 |
done |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
335 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
336 |
lemma id_apply2 [simp]: "id x \<equiv> x" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
337 |
by (simp add: id_def) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
338 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
339 |
ML {* |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
340 |
val lpis = @{thm LAMBDA_PRS} OF [@{thm QUOTIENT_fset}, @{thm IDENTITY_QUOTIENT}]; |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
341 |
val lpist = @{thm "HOL.sym"} OF [lpis]; |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
342 |
val lam_prs = MetaSimplifier.rewrite_rule [@{thm id_apply2}] lpist |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
343 |
*} |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
344 |
|
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
345 |
text {* the proper way to do it *} |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
346 |
ML {* |
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
347 |
fun findabs rty tm = |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
348 |
case tm of |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
349 |
Abs(_, T, b) => |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
350 |
let |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
351 |
val b' = subst_bound ((Free ("x", T)), b); |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
352 |
val tys = findabs rty b' |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
353 |
val ty = fastype_of tm |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
354 |
in if needs_lift rty ty then (ty :: tys) else tys |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
355 |
end |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
356 |
| f $ a => (findabs rty f) @ (findabs rty a) |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
357 |
| _ => [] |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
358 |
*} |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
359 |
|
202
8ca1150f34d0
Simplifying FSet with new functions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
194
diff
changeset
|
360 |
ML {* val quot = @{thm QUOTIENT_fset} *} |
8ca1150f34d0
Simplifying FSet with new functions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
194
diff
changeset
|
361 |
ML {* val abs = findabs @{typ "'a list"} (prop_of (atomize_thm @{thm list_induct_hol4})) *} |
8ca1150f34d0
Simplifying FSet with new functions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
194
diff
changeset
|
362 |
ML {* val simp_lam_prs_thms = map (make_simp_lam_prs_thm @{context} quot) abs *} |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
363 |
|
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
364 |
ML {* |
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
365 |
fun simp_lam_prs lthy thm = |
202
8ca1150f34d0
Simplifying FSet with new functions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
194
diff
changeset
|
366 |
simp_lam_prs lthy (eqsubst_thm lthy simp_lam_prs_thms thm) |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
367 |
handle _ => thm |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
368 |
*} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
369 |
|
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
370 |
ML {* val m2_t' = eqsubst_thm @{context} [lam_prs] @{thm m2_t} *} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
371 |
|
202
8ca1150f34d0
Simplifying FSet with new functions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
194
diff
changeset
|
372 |
ML {* val ithm = simp_allex_prs @{context} quot m2_t' *} |
189
01151c3853ce
Making all the definitions from the original ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
187
diff
changeset
|
373 |
ML fset_defs_sym |
01151c3853ce
Making all the definitions from the original ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
187
diff
changeset
|
374 |
|
164
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
375 |
ML {* val rthm = MetaSimplifier.rewrite_rule fset_defs_sym ithm *} |
4f00ca4f5ef4
Stronger tactic, simpler proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
163
diff
changeset
|
376 |
ML {* ObjectLogic.rulify rthm *} |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
377 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
378 |
|
190
ca1a24aa822e
Finished the code for adding lower defs, and more things moved to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
189
diff
changeset
|
379 |
ML {* val card1_suc_a = atomize_thm @{thm card1_suc} *} |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
380 |
|
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
381 |
prove card1_suc_r_p: {* |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
382 |
build_regularize_goal (atomize_thm @{thm card1_suc}) @{typ "'a List.list"} @{term "op \<approx>"} @{context} *} |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
383 |
apply (simp add: equiv_res_forall[OF equiv_list_eq] equiv_res_exists[OF equiv_list_eq]) |
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
384 |
done |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
385 |
|
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
386 |
ML {* val card1_suc_r = @{thm card1_suc_r_p} OF [atomize_thm @{thm card1_suc}] *} |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
387 |
ML {* val card1_suc_t_g = build_repabs_goal @{context} card1_suc_r consts @{typ "'a list"} @{typ "'a fset"} *} |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
388 |
ML {* val card1_suc_t = build_repabs_term @{context} card1_suc_r consts @{typ "'a list"} @{typ "'a fset"} *} |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
389 |
prove card1_suc_t_p: card1_suc_t_g |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
390 |
apply (atomize(full)) |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
391 |
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_fset @{context}) 1 *}) |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
392 |
done |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
393 |
|
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
394 |
prove card1_suc_t: card1_suc_t |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
395 |
apply (simp only: card1_suc_t_p[symmetric]) |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
396 |
apply (tactic {* rtac card1_suc_r 1 *}) |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
397 |
done |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
398 |
|
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
399 |
ML {* val card1_suc_t_n = @{thm card1_suc_t} *} |
202
8ca1150f34d0
Simplifying FSet with new functions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
194
diff
changeset
|
400 |
ML {* val card1_suc_t' = simp_lam_prs @{context} @{thm card1_suc_t} *} |
8ca1150f34d0
Simplifying FSet with new functions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
194
diff
changeset
|
401 |
ML {* val ithm = simp_allex_prs @{context} quot card1_suc_t' *} |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
402 |
ML {* val rthm = MetaSimplifier.rewrite_rule fset_defs_sym ithm *} |
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
403 |
ML {* val qthm = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same} rthm *} |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
404 |
ML {* ObjectLogic.rulify qthm *} |
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
168
diff
changeset
|
405 |
|
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
406 |
thm fold1.simps(2) |
173
7cf227756e2a
Finally completely lift the previously lifted theorems + clean some old stuff
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
172
diff
changeset
|
407 |
thm list.recs(2) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
408 |
|
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
409 |
ML {* val ind_r_a = atomize_thm @{thm map_append} *} |
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
410 |
(* prove {* build_regularize_goal ind_r_a @{typ "'a List.list"} @{term "op \<approx>"} @{context} *} |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
411 |
ML_prf {* fun tac ctxt = |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
412 |
(asm_full_simp_tac ((Simplifier.context ctxt HOL_ss) addsimps |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
413 |
[(@{thm equiv_res_forall} OF [@{thm equiv_list_eq}]), |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
414 |
(@{thm equiv_res_exists} OF [@{thm equiv_list_eq}])])) THEN_ALL_NEW |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
415 |
(((rtac @{thm RIGHT_RES_FORALL_REGULAR}) THEN' (RANGE [fn _ => all_tac, atac]) THEN' |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
416 |
(MetisTools.metis_tac ctxt [])) ORELSE' (MetisTools.metis_tac ctxt [])); *} |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
417 |
apply (tactic {* tac @{context} 1 *}) *) |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
418 |
ML {* val ind_r_r = regularize ind_r_a @{typ "'a List.list"} @{term "op \<approx>"} @{thm equiv_list_eq} @{context} *} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
419 |
ML {* |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
420 |
val rt = build_repabs_term @{context} ind_r_r consts @{typ "'a list"} @{typ "'a fset"} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
421 |
val rg = Logic.mk_equals ((Thm.prop_of ind_r_r), rt); |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
422 |
*} |
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
423 |
prove rg |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
424 |
apply(atomize(full)) |
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
425 |
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_fset @{context}) 1 *}) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
426 |
apply (auto) |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
427 |
done |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
428 |
|
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
429 |
ML {* val (g, thm, othm) = |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
430 |
Toplevel.program (fn () => |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
431 |
repabs_eq @{context} ind_r_r consts @{typ "'a list"} @{typ "'a fset"} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
432 |
@{thm QUOTIENT_fset} @{thm list_eq_refl} @{thm QUOT_TYPE_I_fset.R_trans2} |
202
8ca1150f34d0
Simplifying FSet with new functions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
194
diff
changeset
|
433 |
(@{thms ho_memb_rsp ho_cons_rsp ho_card1_rsp ho_map_rsp ho_append_rsp} @ @{thms ho_all_prs ho_ex_prs}) |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
434 |
) |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
435 |
*} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
436 |
ML {* |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
437 |
fun tac2 ctxt = |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
438 |
(simp_tac ((Simplifier.context ctxt empty_ss) addsimps [symmetric thm])) |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
439 |
THEN' (rtac othm); *} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
440 |
(* ML {* val cthm = Goal.prove @{context} [] [] g (fn x => tac2 (#context x) 1); |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
441 |
*} *) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
442 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
443 |
ML {* |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
444 |
val ind_r_t2 = |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
445 |
Toplevel.program (fn () => |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
446 |
repabs_eq2 @{context} (g, thm, othm) |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
447 |
) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
448 |
*} |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
449 |
ML {* val ind_r_l = simp_lam_prs @{context} ind_r_t2 *} |
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
450 |
lemma app_prs_for_induct: "(ABS_fset ---> id) f (REP_fset T1) = f T1" |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
451 |
apply (simp add: fun_map.simps QUOT_TYPE_I_fset.thm10) |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
452 |
done |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
453 |
|
178
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
454 |
ML {* val ind_r_l1 = eqsubst_thm @{context} @{thms app_prs_for_induct} ind_r_l *} |
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
455 |
ML {* val ind_r_l2 = eqsubst_thm @{context} @{thms app_prs_for_induct} ind_r_l1 *} |
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
456 |
ML {* val ind_r_l3 = eqsubst_thm @{context} @{thms app_prs_for_induct} ind_r_l2 *} |
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
457 |
ML {* val ind_r_l4 = eqsubst_thm @{context} @{thms app_prs_for_induct} ind_r_l3 *} |
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
458 |
ML {* val ind_r_a = simp_allex_prs @{context} ind_r_l4 *} |
183
6acf9e001038
proved the two lemmas in QuotScript (reformulated them without leading forall)
Christian Urban <urbanc@in.tum.de>
parents:
180
diff
changeset
|
459 |
ML {* val thm = @{thm FORALL_PRS[OF FUN_QUOTIENT[OF QUOTIENT_fset IDENTITY_QUOTIENT], symmetric]} *} |
178
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
460 |
ML {* val ind_r_a1 = eqsubst_thm @{context} [thm] ind_r_a *} |
187 | 461 |
|
189
01151c3853ce
Making all the definitions from the original ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
187
diff
changeset
|
462 |
|
01151c3853ce
Making all the definitions from the original ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
187
diff
changeset
|
463 |
ML {* hd fset_defs_sym *} |
178
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
464 |
ML {* val ind_r_d = MetaSimplifier.rewrite_rule fset_defs_sym ind_r_a1 *} |
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
465 |
ML {* val ind_r_s = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same} ind_r_d *} |
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
466 |
ML {* ObjectLogic.rulify ind_r_s *} |
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
176
diff
changeset
|
467 |
|
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
468 |
ML {* |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
469 |
fun lift thm = |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
470 |
let |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
471 |
val ind_r_a = atomize_thm thm; |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
472 |
val ind_r_r = regularize ind_r_a @{typ "'a List.list"} @{term "op \<approx>"} @{thm equiv_list_eq} @{context}; |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
473 |
val (g, t, ot) = |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
474 |
repabs_eq @{context} ind_r_r consts @{typ "'a list"} @{typ "'a fset"} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
475 |
@{thm QUOTIENT_fset} @{thm list_eq_refl} @{thm QUOT_TYPE_I_fset.R_trans2} |
187 | 476 |
(@{thms ho_memb_rsp ho_cons_rsp ho_card1_rsp} @ @{thms ho_all_prs ho_ex_prs}); |
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
477 |
val ind_r_t = repabs_eq2 @{context} (g, t, ot); |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
478 |
val ind_r_l = simp_lam_prs @{context} ind_r_t; |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
479 |
val ind_r_a = simp_allex_prs @{context} ind_r_l; |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
480 |
val ind_r_d = MetaSimplifier.rewrite_rule fset_defs_sym ind_r_a; |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
481 |
val ind_r_s = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same} ind_r_d |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
482 |
in |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
483 |
ObjectLogic.rulify ind_r_s |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
484 |
end |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
485 |
*} |
187 | 486 |
ML fset_defs |
487 |
||
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
488 |
|
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
489 |
ML {* lift @{thm m2} *} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
490 |
ML {* lift @{thm m1} *} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
491 |
ML {* lift @{thm list_eq.intros(4)} *} |
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
171
diff
changeset
|
492 |
ML {* lift @{thm list_eq.intros(5)} *} |
175
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
493 |
ML {* lift @{thm card1_suc} *} |
f7602653dddd
Preparing infrastructire for LAMBDA_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
173
diff
changeset
|
494 |
(* ML {* lift @{thm append_assoc} *} *) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
495 |
|
194
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
496 |
thm |
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
497 |
|
03c03e88efa9
Simplifying Int and Working on map
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
190
diff
changeset
|
498 |
|
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
499 |
(*notation ( output) "prop" ("#_" [1000] 1000) *) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
500 |
notation ( output) "Trueprop" ("#_" [1000] 1000) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
501 |
|
183
6acf9e001038
proved the two lemmas in QuotScript (reformulated them without leading forall)
Christian Urban <urbanc@in.tum.de>
parents:
180
diff
changeset
|
502 |
(* |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
503 |
ML {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
504 |
fun lift_theorem_fset_aux thm lthy = |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
505 |
let |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
506 |
val ((_, [novars]), lthy2) = Variable.import true [thm] lthy; |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
507 |
val goal = build_repabs_goal @{context} novars consts @{typ "'a list"} @{typ "'a fset"}; |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
508 |
val cgoal = cterm_of @{theory} goal; |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
509 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite true fset_defs_sym cgoal); |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
510 |
val tac = transconv_fset_tac' @{context}; |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
511 |
val cthm = Goal.prove_internal [] cgoal2 (fn _ => tac); |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
512 |
val nthm = MetaSimplifier.rewrite_rule [symmetric cthm] (snd (no_vars (Context.Theory @{theory}, thm))) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
513 |
val nthm2 = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same QUOT_TYPE_I_fset.thm10} nthm; |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
514 |
val [nthm3] = ProofContext.export lthy2 lthy [nthm2] |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
515 |
in |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
516 |
nthm3 |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
517 |
end |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
518 |
*} |
183
6acf9e001038
proved the two lemmas in QuotScript (reformulated them without leading forall)
Christian Urban <urbanc@in.tum.de>
parents:
180
diff
changeset
|
519 |
*) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
520 |
|
183
6acf9e001038
proved the two lemmas in QuotScript (reformulated them without leading forall)
Christian Urban <urbanc@in.tum.de>
parents:
180
diff
changeset
|
521 |
(* |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
522 |
ML {* lift_theorem_fset_aux @{thm m1} @{context} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
523 |
ML {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
524 |
fun lift_theorem_fset name thm lthy = |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
525 |
let |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
526 |
val lifted_thm = lift_theorem_fset_aux thm lthy; |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
527 |
val (_, lthy2) = note (name, lifted_thm) lthy; |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
528 |
in |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
529 |
lthy2 |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
530 |
end; |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
531 |
*} |
183
6acf9e001038
proved the two lemmas in QuotScript (reformulated them without leading forall)
Christian Urban <urbanc@in.tum.de>
parents:
180
diff
changeset
|
532 |
*) |
163
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
533 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
534 |
(* These do not work without proper definitions to rewrite back *) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
535 |
local_setup {* lift_theorem_fset @{binding "m1_lift"} @{thm m1} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
536 |
local_setup {* lift_theorem_fset @{binding "leqi4_lift"} @{thm list_eq.intros(4)} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
537 |
local_setup {* lift_theorem_fset @{binding "leqi5_lift"} @{thm list_eq.intros(5)} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
538 |
local_setup {* lift_theorem_fset @{binding "m2_lift"} @{thm m2} *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
539 |
thm m1_lift |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
540 |
thm leqi4_lift |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
541 |
thm leqi5_lift |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
542 |
thm m2_lift |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
543 |
ML {* @{thm card1_suc_r} OF [card1_suc_f] *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
544 |
(*ML {* Toplevel.program (fn () => lift_theorem_fset @{binding "card_suc"} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
545 |
(@{thm card1_suc_r} OF [card1_suc_f]) @{context}) *}*) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
546 |
(*local_setup {* lift_theorem_fset @{binding "card_suc"} @{thm card1_suc} *}*) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
547 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
548 |
thm leqi4_lift |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
549 |
ML {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
550 |
val (nam, typ) = hd (Term.add_vars (prop_of @{thm leqi4_lift}) []) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
551 |
val (_, l) = dest_Type typ |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
552 |
val t = Type ("FSet.fset", l) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
553 |
val v = Var (nam, t) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
554 |
val cv = cterm_of @{theory} ((term_of @{cpat "REP_fset"}) $ v) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
555 |
*} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
556 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
557 |
ML {* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
558 |
Toplevel.program (fn () => |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
559 |
MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.thm10} ( |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
560 |
Drule.instantiate' [] [NONE, SOME (cv)] @{thm leqi4_lift} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
561 |
) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
562 |
) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
563 |
*} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
564 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
565 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
566 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
567 |
(*prove aaa: {* (Thm.term_of cgoal2) *} |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
568 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
569 |
apply (atomize(full)) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
570 |
apply (tactic {* transconv_fset_tac' @{context} 1 *}) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
571 |
done*) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
572 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
573 |
(* |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
574 |
datatype obj1 = |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
575 |
OVAR1 "string" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
576 |
| OBJ1 "(string * (string \<Rightarrow> obj1)) list" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
577 |
| INVOKE1 "obj1 \<Rightarrow> string" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
578 |
| UPDATE1 "obj1 \<Rightarrow> string \<Rightarrow> (string \<Rightarrow> obj1)" |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
579 |
*) |
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
580 |
|
3da18bf6886c
Split Finite Set example into separate file
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
581 |
end |