src/HOL/IMP/Abs_State.thy
author nipkow
Sun, 10 Mar 2013 18:29:10 +0100
changeset 51389 8a9f0503b1c0
parent 51359 00b45c7e831f
child 51698 c0af8bbc5825
permissions -rw-r--r--
factored out Step
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
     1
(* Author: Tobias Nipkow *)
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
     2
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
     3
theory Abs_State
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
     4
imports Abs_Int0
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
     5
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
     6
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
     7
subsubsection "Set-based lattices"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
     8
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
     9
instantiation com :: vars
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    10
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    11
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    12
fun vars_com :: "com \<Rightarrow> vname set" where
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    13
"vars com.SKIP = {}" |
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    14
"vars (x::=e) = {x} \<union> vars e" |
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    15
"vars (c1;c2) = vars c1 \<union> vars c2" |
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    16
"vars (IF b THEN c1 ELSE c2) = vars b \<union> vars c1 \<union> vars c2" |
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    17
"vars (WHILE b DO c) = vars b \<union> vars c"
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    18
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    19
instance ..
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    20
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    21
end
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    22
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    23
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    24
lemma finite_avars: "finite(vars(a::aexp))"
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    25
by(induction a) simp_all
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    26
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    27
lemma finite_bvars: "finite(vars(b::bexp))"
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    28
by(induction b) (simp_all add: finite_avars)
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    29
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    30
lemma finite_cvars: "finite(vars(c::com))"
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    31
by(induction c) (simp_all add: finite_avars finite_bvars)
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    32
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    33
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    34
class L =
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    35
fixes L :: "vname set \<Rightarrow> 'a set"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    36
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    37
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    38
instantiation acom :: (L)L
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    39
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    40
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    41
definition L_acom where
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    42
"L X = {C. vars(strip C) \<subseteq> X \<and> (\<forall>a \<in> set(annos C). a \<in> L X)}"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    43
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    44
instance ..
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    45
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    46
end
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    47
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    48
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    49
instantiation option :: (L)L
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    50
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    51
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    52
definition L_option where
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    53
"L X = {opt. case opt of None \<Rightarrow> True | Some x \<Rightarrow> x \<in> L X}"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    54
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    55
lemma L_option_simps[simp]: "None \<in> L X" "(Some x \<in> L X) = (x \<in> L X)"
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    56
by(simp_all add: L_option_def)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    57
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    58
instance ..
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    59
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    60
end
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    61
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    62
class semilatticeL = order + sup + L +
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    63
fixes Top :: "vname set \<Rightarrow> 'a"
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    64
assumes sup_ge1 [simp]: "x \<in> L X \<Longrightarrow> y \<in> L X \<Longrightarrow> x \<le> x \<squnion> y"
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    65
and sup_ge2 [simp]: "x \<in> L X \<Longrightarrow> y \<in> L X \<Longrightarrow> y \<le> x \<squnion> y"
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    66
and sup_least[simp]: "x \<le> z \<Longrightarrow> y \<le> z \<Longrightarrow> x \<squnion> y \<le> z"
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    67
and Top[simp]: "x \<in> L X \<Longrightarrow> x \<le> Top X"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    68
and Top_in_L[simp]: "Top X \<in> L X"
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    69
and sup_in_L[simp]: "x \<in> L X \<Longrightarrow> y \<in> L X \<Longrightarrow> x \<squnion> y \<in> L X"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    70
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    71
notation (input) Top ("\<top>\<^bsub>_\<^esub>")
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    72
notation (latex output) Top ("\<top>\<^bsub>\<^raw:\isa{>_\<^raw:}>\<^esub>")
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    73
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    74
instantiation option :: (semilatticeL)semilatticeL
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    75
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    76
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    77
definition Top_option where "Top c = Some(Top c)"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    78
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    79
instance proof
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    80
  case goal1 thus ?case by(cases x, simp, cases y, simp_all)
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    81
next
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    82
  case goal2 thus ?case by(cases y, simp, cases x, simp_all)
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    83
next
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    84
  case goal3 thus ?case by(cases z, simp, cases y, simp, cases x, simp_all)
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    85
next
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    86
  case goal4 thus ?case by(cases x, simp_all add: Top_option_def)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    87
next
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    88
  case goal5 thus ?case by(simp add: Top_option_def)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    89
next
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
    90
  case goal6 thus ?case by(simp add: L_option_def split: option.splits)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    91
qed
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    92
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    93
end
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    94
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    95
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    96
subsection "Abstract State with Computable Ordering"
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    97
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    98
hide_type  st  --"to avoid long names"
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
    99
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   100
text{* A concrete type of state with computable @{text"\<le>"}: *}
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   101
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   102
fun st :: "(vname \<Rightarrow> 'a) * vname set \<Rightarrow> bool" where
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   103
"st (f,X) = (\<forall>x. x \<notin> X \<longrightarrow> f x = undefined)"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   104
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   105
typedef 'a st = "{p :: (vname \<Rightarrow> 'a) * vname set. st p}"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   106
proof
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   107
  show "(\<lambda>x. undefined,{}) \<in> {p. st p}" by simp
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   108
qed
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   109
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   110
setup_lifting type_definition_st
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   111
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   112
lift_definition St :: "(vname \<Rightarrow> 'a) \<Rightarrow> vname set \<Rightarrow> 'a st" is
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   113
  "\<lambda>f X. (\<lambda>x. if x \<in> X then f x else undefined, X)"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   114
by(simp)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   115
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   116
lift_definition update :: "'a st \<Rightarrow> vname \<Rightarrow> 'a \<Rightarrow> 'a st" is
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   117
  "\<lambda>(f,X) x a. (f(x := a), insert x X)"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   118
by(auto)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   119
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   120
lift_definition "fun" :: "'a st \<Rightarrow> vname \<Rightarrow> 'a" is fst ..
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   121
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   122
lift_definition dom :: "'a st \<Rightarrow> vname set" is snd ..
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   123
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   124
lemma dom_St[simp]: "dom(St f X) = X"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   125
by(simp add: St.rep_eq dom.rep_eq)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   126
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   127
lemma fun_St[simp]: "fun(St f X) = (\<lambda>x. if x \<in> X then f x else undefined)"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   128
by(simp add: St.rep_eq fun.rep_eq)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   129
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   130
definition show_st :: "'a st \<Rightarrow> (vname * 'a)set" where
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   131
"show_st S = (\<lambda>x. (x, fun S x)) ` dom S"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   132
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   133
definition "show_acom = map_acom (Option.map show_st)"
51036
e7b54119c436 tuned top
nipkow
parents: 50995
diff changeset
   134
definition "show_acom_opt = Option.map show_acom"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   135
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   136
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
   137
by transfer auto
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   138
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   139
lemma dom_update[simp]: "dom (update S x y) = insert x (dom S)"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   140
by transfer auto
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   141
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   142
definition \<gamma>_st :: "('a \<Rightarrow> 'b set) \<Rightarrow> 'a st \<Rightarrow> (vname \<Rightarrow> 'b) set" where
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   143
"\<gamma>_st \<gamma> F = {f. \<forall>x\<in>dom  F. f x \<in> \<gamma>(fun F x)}"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   144
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   145
lemma ext_st: "dom F = dom G \<Longrightarrow> \<forall>x \<in> dom G. fun F x = fun G x \<Longrightarrow> F=G"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   146
apply(induct F rule:Abs_st_induct)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   147
apply(induct G rule:Abs_st_induct)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   148
apply (auto simp:Abs_st_inject fun_def dom_def Abs_st_inverse simp del: st.simps)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   149
apply(rule ext)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   150
apply auto
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   151
done
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   152
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   153
instantiation st :: (order) order
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   154
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   155
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   156
definition less_eq_st :: "'a st \<Rightarrow> 'a st \<Rightarrow> bool" where
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   157
"F \<le> (G::'a st) = (dom F = dom G \<and> (\<forall>x \<in> dom F. fun F x \<le> fun G x))"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   158
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   159
definition less_st where "F < (G::'a st) = (F \<le> G \<and> \<not> G \<le> F)"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   160
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   161
instance
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   162
proof
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   163
  case goal1 show ?case by(rule less_st_def)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   164
next
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   165
  case goal2 show ?case by(auto simp: less_eq_st_def)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   166
next
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   167
  case goal3 thus ?case by(fastforce simp: less_eq_st_def)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   168
next
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   169
  case goal4 thus ?case by (metis less_eq_st_def antisym ext_st)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   170
qed
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   171
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   172
end
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   173
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
   174
instantiation st :: (sup) sup
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   175
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   176
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
   177
definition sup_st :: "'a st \<Rightarrow> 'a st \<Rightarrow> 'a st" where
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   178
"F \<squnion> (G::'a st) = St (\<lambda>x. fun F x \<squnion> fun G x) (dom F)"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   179
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   180
instance ..
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   181
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   182
end
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   183
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
   184
instantiation st :: (type) L
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   185
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   186
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
   187
definition L_st :: "vname set \<Rightarrow> 'a st set" where
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   188
"L(X::vname set) = {F. dom F = X}"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   189
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   190
instance ..
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   191
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   192
end
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   193
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
   194
instantiation st :: (semilattice) semilatticeL
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   195
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   196
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   197
definition Top_st :: "vname set \<Rightarrow> 'a st" where "Top(X) = St (\<lambda>x. \<top>) X"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   198
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   199
instance
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
   200
proof qed(auto simp add: less_eq_st_def sup_st_def Top_st_def L_st_def)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   201
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   202
end
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   203
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   204
49399
nipkow
parents: 49396
diff changeset
   205
text{* Trick to make code generator happy. *}
nipkow
parents: 49396
diff changeset
   206
lemma [code]: "L = (L :: _ \<Rightarrow> _ st set)"
nipkow
parents: 49396
diff changeset
   207
by(rule refl)
nipkow
parents: 49396
diff changeset
   208
(* L is not used in the code but is part of a type class that is used.
nipkow
parents: 49396
diff changeset
   209
   Hence the code generator wants to build a dictionary with L in it.
nipkow
parents: 49396
diff changeset
   210
   But L is not executable. This looping defn makes it look as if it were. *)
nipkow
parents: 49396
diff changeset
   211
nipkow
parents: 49396
diff changeset
   212
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   213
lemma mono_fun: "F \<le> G \<Longrightarrow> x : dom F \<Longrightarrow> fun F x \<le> fun G x"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   214
by(auto simp: less_eq_st_def)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   215
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   216
lemma mono_update[simp]:
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   217
  "a1 \<le> a2 \<Longrightarrow> S1 \<le> S2 \<Longrightarrow> update S1 x a1 \<le> update S2 x a2"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   218
by(auto simp add: less_eq_st_def)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   219
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   220
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49353
diff changeset
   221
locale Gamma = Val_abs where \<gamma>=\<gamma> for \<gamma> :: "'av::semilattice \<Rightarrow> val set"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   222
begin
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   223
49497
860b7c6bd913 tuned names
nipkow
parents: 49399
diff changeset
   224
abbreviation \<gamma>\<^isub>s :: "'av st \<Rightarrow> state set"
860b7c6bd913 tuned names
nipkow
parents: 49399
diff changeset
   225
where "\<gamma>\<^isub>s == \<gamma>_st \<gamma>"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   226
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   227
abbreviation \<gamma>\<^isub>o :: "'av st option \<Rightarrow> state set"
49497
860b7c6bd913 tuned names
nipkow
parents: 49399
diff changeset
   228
where "\<gamma>\<^isub>o == \<gamma>_option \<gamma>\<^isub>s"
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   229
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   230
abbreviation \<gamma>\<^isub>c :: "'av st option acom \<Rightarrow> state set acom"
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   231
where "\<gamma>\<^isub>c == map_acom \<gamma>\<^isub>o"
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   232
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   233
lemma gamma_s_Top[simp]: "\<gamma>\<^isub>s (Top X) = UNIV"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   234
by(auto simp: Top_st_def \<gamma>_st_def)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   235
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   236
lemma gamma_o_Top[simp]: "\<gamma>\<^isub>o (Top X) = UNIV"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   237
by (simp add: Top_option_def)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   238
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   239
lemma mono_gamma_s: "f \<le> g \<Longrightarrow> \<gamma>\<^isub>s f \<subseteq> \<gamma>\<^isub>s g"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   240
apply(simp add:\<gamma>_st_def subset_iff less_eq_st_def split: if_splits)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   241
by (metis mono_gamma subsetD)
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   242
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   243
lemma mono_gamma_o:
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   244
  "S1 \<le> S2 \<Longrightarrow> \<gamma>\<^isub>o S1 \<subseteq> \<gamma>\<^isub>o S2"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   245
by(induction S1 S2 rule: less_eq_option.induct)(simp_all add: mono_gamma_s)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   246
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   247
lemma mono_gamma_c: "C1 \<le> C2 \<Longrightarrow> \<gamma>\<^isub>c C1 \<le> \<gamma>\<^isub>c C2"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   248
by (induction C1 C2 rule: less_eq_acom.induct) (simp_all add:mono_gamma_o)
47619
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   249
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   250
lemma in_gamma_option_iff:
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   251
  "x : \<gamma>_option r u \<longleftrightarrow> (\<exists>u'. u = Some u' \<and> x : r u')"
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   252
by (cases u) auto
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   253
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   254
end
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   255
0d3e95375bb7 forgot to add file
nipkow
parents:
diff changeset
   256
end