author | wenzelm |
Thu, 01 Sep 2016 21:28:46 +0200 | |
changeset 63763 | 0f61ea70d384 |
parent 61430 | 1efe2f3728a6 |
child 67399 | eab6ce8368fa |
permissions | -rw-r--r-- |
47619 | 1 |
(* Author: Tobias Nipkow *) |
2 |
||
3 |
theory Abs_State |
|
4 |
imports Abs_Int0 |
|
5 |
begin |
|
6 |
||
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
7 |
type_synonym 'a st_rep = "(vname * 'a) list" |
47619 | 8 |
|
54930 | 9 |
fun fun_rep :: "('a::top) st_rep \<Rightarrow> vname \<Rightarrow> 'a" where |
51715
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
10 |
"fun_rep [] = (\<lambda>x. \<top>)" | |
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
11 |
"fun_rep ((x,a)#ps) = (fun_rep ps) (x := a)" |
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
12 |
|
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
13 |
lemma fun_rep_map_of[code]: --"original def is too slow" |
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
14 |
"fun_rep ps = (%x. case map_of ps x of None \<Rightarrow> \<top> | Some a \<Rightarrow> a)" |
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
15 |
by(induction ps rule: fun_rep.induct) auto |
47619 | 16 |
|
54930 | 17 |
definition eq_st :: "('a::top) st_rep \<Rightarrow> 'a st_rep \<Rightarrow> bool" where |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
18 |
"eq_st S1 S2 = (fun_rep S1 = fun_rep S2)" |
47619 | 19 |
|
51720 | 20 |
hide_type st --"hide previous def to avoid long names" |
61430 | 21 |
declare [[typedef_overloaded]] --"allow quotient types to depend on classes" |
51720 | 22 |
|
61430 | 23 |
quotient_type 'a st = "('a::top) st_rep" / eq_st |
51800 | 24 |
morphisms rep_st St |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
25 |
by (metis eq_st_def equivpI reflpI sympI transpI) |
47619 | 26 |
|
54930 | 27 |
lift_definition update :: "('a::top) st \<Rightarrow> vname \<Rightarrow> 'a \<Rightarrow> 'a st" |
51715
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
28 |
is "\<lambda>ps x a. (x,a)#ps" |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
29 |
by(auto simp: eq_st_def) |
47619 | 30 |
|
54930 | 31 |
lift_definition "fun" :: "('a::top) st \<Rightarrow> vname \<Rightarrow> 'a" is fun_rep |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
32 |
by(simp add: eq_st_def) |
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
33 |
|
54930 | 34 |
definition show_st :: "vname set \<Rightarrow> ('a::top) st \<Rightarrow> (vname * 'a)set" where |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
35 |
"show_st X S = (\<lambda>x. (x, fun S x)) ` X" |
47619 | 36 |
|
55466 | 37 |
definition "show_acom C = map_acom (map_option (show_st (vars(strip C)))) C" |
38 |
definition "show_acom_opt = map_option show_acom" |
|
47619 | 39 |
|
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
40 |
lemma fun_update[simp]: "fun (update S x y) = (fun S)(x:=y)" |
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
41 |
by transfer auto |
47619 | 42 |
|
54930 | 43 |
definition \<gamma>_st :: "(('a::top) \<Rightarrow> 'b set) \<Rightarrow> 'a st \<Rightarrow> (vname \<Rightarrow> 'b) set" where |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
44 |
"\<gamma>_st \<gamma> F = {f. \<forall>x. f x \<in> \<gamma>(fun F x)}" |
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
45 |
|
54930 | 46 |
instantiation st :: (order_top) order |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
47 |
begin |
47619 | 48 |
|
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
49 |
definition less_eq_st_rep :: "'a st_rep \<Rightarrow> 'a st_rep \<Rightarrow> bool" where |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
50 |
"less_eq_st_rep ps1 ps2 = |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
51 |
((\<forall>x \<in> set(map fst ps1) \<union> set(map fst ps2). fun_rep ps1 x \<le> fun_rep ps2 x))" |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
52 |
|
51715
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
53 |
lemma less_eq_st_rep_iff: |
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
54 |
"less_eq_st_rep r1 r2 = (\<forall>x. fun_rep r1 x \<le> fun_rep r2 x)" |
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
55 |
apply(auto simp: less_eq_st_rep_def fun_rep_map_of split: option.split) |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
56 |
apply (metis Un_iff map_of_eq_None_iff option.distinct(1)) |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
57 |
apply (metis Un_iff map_of_eq_None_iff option.distinct(1)) |
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
58 |
done |
47619 | 59 |
|
51715
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
60 |
corollary less_eq_st_rep_iff_fun: |
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
61 |
"less_eq_st_rep r1 r2 = (fun_rep r1 \<le> fun_rep r2)" |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
62 |
by (metis less_eq_st_rep_iff le_fun_def) |
47619 | 63 |
|
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
64 |
lift_definition less_eq_st :: "'a st \<Rightarrow> 'a st \<Rightarrow> bool" is less_eq_st_rep |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
65 |
by(auto simp add: eq_st_def less_eq_st_rep_iff) |
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
66 |
|
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
67 |
definition less_st where "F < (G::'a st) = (F \<le> G \<and> \<not> G \<le> F)" |
47619 | 68 |
|
69 |
instance |
|
61179 | 70 |
proof (standard, goal_cases) |
71 |
case 1 show ?case by(rule less_st_def) |
|
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
72 |
next |
61179 | 73 |
case 2 show ?case by transfer (auto simp: less_eq_st_rep_def) |
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
74 |
next |
61179 | 75 |
case 3 thus ?case by transfer (metis less_eq_st_rep_iff order_trans) |
76 |
next |
|
77 |
case 4 thus ?case |
|
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
78 |
by transfer (metis less_eq_st_rep_iff eq_st_def fun_eq_iff antisym) |
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
79 |
qed |
47619 | 80 |
|
81 |
end |
|
82 |
||
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
83 |
lemma le_st_iff: "(F \<le> G) = (\<forall>x. fun F x \<le> fun G x)" |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
84 |
by transfer (rule less_eq_st_rep_iff) |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
85 |
|
54930 | 86 |
fun map2_st_rep :: "('a::top \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> 'a st_rep \<Rightarrow> 'a st_rep \<Rightarrow> 'a st_rep" where |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
87 |
"map2_st_rep f [] ps2 = map (%(x,y). (x, f \<top> y)) ps2" | |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
88 |
"map2_st_rep f ((x,y)#ps1) ps2 = |
51715
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
89 |
(let y2 = fun_rep ps2 x |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
90 |
in (x,f y y2) # map2_st_rep f ps1 ps2)" |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
91 |
|
51715
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
92 |
lemma fun_rep_map2_rep[simp]: "f \<top> \<top> = \<top> \<Longrightarrow> |
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
93 |
fun_rep (map2_st_rep f ps1 ps2) = (\<lambda>x. f (fun_rep ps1 x) (fun_rep ps2 x))" |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
94 |
apply(induction f ps1 ps2 rule: map2_st_rep.induct) |
51715
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
95 |
apply(simp add: fun_rep_map_of map_of_map fun_eq_iff split: option.split) |
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
96 |
apply(fastforce simp: fun_rep_map_of fun_eq_iff split:option.splits) |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
97 |
done |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
98 |
|
51826 | 99 |
instantiation st :: (semilattice_sup_top) semilattice_sup_top |
47619 | 100 |
begin |
101 |
||
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
102 |
lift_definition sup_st :: "'a st \<Rightarrow> 'a st \<Rightarrow> 'a st" is "map2_st_rep (op \<squnion>)" |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
103 |
by (simp add: eq_st_def) |
47619 | 104 |
|
51994 | 105 |
lift_definition top_st :: "'a st" is "[]" . |
47619 | 106 |
|
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
107 |
instance |
61179 | 108 |
proof (standard, goal_cases) |
109 |
case 1 show ?case by transfer (simp add:less_eq_st_rep_iff) |
|
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
110 |
next |
61179 | 111 |
case 2 show ?case by transfer (simp add:less_eq_st_rep_iff) |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
112 |
next |
61179 | 113 |
case 3 thus ?case by transfer (simp add:less_eq_st_rep_iff) |
114 |
next |
|
115 |
case 4 show ?case by transfer (simp add:less_eq_st_rep_iff fun_rep_map_of) |
|
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
116 |
qed |
47619 | 117 |
|
118 |
end |
|
119 |
||
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
120 |
lemma fun_top: "fun \<top> = (\<lambda>x. \<top>)" |
51715
17b992f19b51
avoided map_of in def of fun_rep (but still needed for efficient code)
nipkow
parents:
51711
diff
changeset
|
121 |
by transfer simp |
47619 | 122 |
|
123 |
lemma mono_update[simp]: |
|
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
124 |
"a1 \<le> a2 \<Longrightarrow> S1 \<le> S2 \<Longrightarrow> update S1 x a1 \<le> update S2 x a2" |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
125 |
by transfer (auto simp add: less_eq_st_rep_def) |
47619 | 126 |
|
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
127 |
lemma mono_fun: "S1 \<le> S2 \<Longrightarrow> fun S1 x \<le> fun S2 x" |
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
128 |
by transfer (simp add: less_eq_st_rep_iff) |
47619 | 129 |
|
52504 | 130 |
locale Gamma_semilattice = Val_semilattice where \<gamma>=\<gamma> |
51826 | 131 |
for \<gamma> :: "'av::semilattice_sup_top \<Rightarrow> val set" |
47619 | 132 |
begin |
133 |
||
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
134 |
abbreviation \<gamma>\<^sub>s :: "'av st \<Rightarrow> state set" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
135 |
where "\<gamma>\<^sub>s == \<gamma>_st \<gamma>" |
47619 | 136 |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
137 |
abbreviation \<gamma>\<^sub>o :: "'av st option \<Rightarrow> state set" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
138 |
where "\<gamma>\<^sub>o == \<gamma>_option \<gamma>\<^sub>s" |
47619 | 139 |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
140 |
abbreviation \<gamma>\<^sub>c :: "'av st option acom \<Rightarrow> state set acom" |
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
141 |
where "\<gamma>\<^sub>c == map_acom \<gamma>\<^sub>o" |
47619 | 142 |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
143 |
lemma gamma_s_top[simp]: "\<gamma>\<^sub>s \<top> = UNIV" |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
144 |
by(auto simp: \<gamma>_st_def fun_top) |
47619 | 145 |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
146 |
lemma gamma_o_Top[simp]: "\<gamma>\<^sub>o \<top> = UNIV" |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
147 |
by (simp add: top_option_def) |
47619 | 148 |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
149 |
lemma mono_gamma_s: "f \<le> g \<Longrightarrow> \<gamma>\<^sub>s f \<subseteq> \<gamma>\<^sub>s g" |
51711
df3426139651
complete revision: finally got rid of annoying L-predicate
nipkow
parents:
51698
diff
changeset
|
150 |
by(simp add:\<gamma>_st_def le_st_iff subset_iff) (metis mono_gamma subsetD) |
47619 | 151 |
|
152 |
lemma mono_gamma_o: |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
153 |
"S1 \<le> S2 \<Longrightarrow> \<gamma>\<^sub>o S1 \<subseteq> \<gamma>\<^sub>o S2" |
51359
00b45c7e831f
major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents:
51036
diff
changeset
|
154 |
by(induction S1 S2 rule: less_eq_option.induct)(simp_all add: mono_gamma_s) |
47619 | 155 |
|
53015
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents:
52729
diff
changeset
|
156 |
lemma mono_gamma_c: "C1 \<le> C2 \<Longrightarrow> \<gamma>\<^sub>c C1 \<le> \<gamma>\<^sub>c C2" |
52019
a4cbca8f7342
finally: acom with pointwise access and update of annotations
nipkow
parents:
51826
diff
changeset
|
157 |
by (simp add: less_eq_acom_def mono_gamma_o size_annos anno_map_acom size_annos_same[of C1 C2]) |
47619 | 158 |
|
159 |
lemma in_gamma_option_iff: |
|
160 |
"x : \<gamma>_option r u \<longleftrightarrow> (\<exists>u'. u = Some u' \<and> x : r u')" |
|
161 |
by (cases u) auto |
|
162 |
||
163 |
end |
|
164 |
||
165 |
end |