src/HOL/IMP/Abs_Int0.thy
author nipkow
Fri, 10 Aug 2012 17:17:05 +0200
changeset 48759 ff570720ba1c
parent 47818 151d137f1095
child 49095 7df19036392e
permissions -rw-r--r--
Improved complete lattice formalisation - no more index set.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
     1
(* Author: Tobias Nipkow *)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
     2
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
     3
theory Abs_Int0
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
     4
imports Abs_Int_init
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
     5
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
     6
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
     7
subsection "Orderings"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
     8
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
     9
class preord =
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    10
fixes le :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubseteq>" 50)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    11
assumes le_refl[simp]: "x \<sqsubseteq> x"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    12
and le_trans: "x \<sqsubseteq> y \<Longrightarrow> y \<sqsubseteq> z \<Longrightarrow> x \<sqsubseteq> z"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    13
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    14
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    15
definition mono where "mono f = (\<forall>x y. x \<sqsubseteq> y \<longrightarrow> f x \<sqsubseteq> f y)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    16
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    17
declare le_trans[trans]
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    18
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    19
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    20
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    21
text{* Note: no antisymmetry. Allows implementations where some abstract
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    22
element is implemented by two different values @{prop "x \<noteq> y"}
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    23
such that @{prop"x \<sqsubseteq> y"} and @{prop"y \<sqsubseteq> x"}. Antisymmetry is not
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    24
needed because we never compare elements for equality but only for @{text"\<sqsubseteq>"}.
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    25
*}
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    26
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    27
class join = preord +
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    28
fixes join :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<squnion>" 65)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    29
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    30
class SL_top = join +
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    31
fixes Top :: "'a" ("\<top>")
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    32
assumes join_ge1 [simp]: "x \<sqsubseteq> x \<squnion> y"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    33
and join_ge2 [simp]: "y \<sqsubseteq> x \<squnion> y"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    34
and join_least: "x \<sqsubseteq> z \<Longrightarrow> y \<sqsubseteq> z \<Longrightarrow> x \<squnion> y \<sqsubseteq> z"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    35
and top[simp]: "x \<sqsubseteq> \<top>"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    36
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    37
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    38
lemma join_le_iff[simp]: "x \<squnion> y \<sqsubseteq> z \<longleftrightarrow> x \<sqsubseteq> z \<and> y \<sqsubseteq> z"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    39
by (metis join_ge1 join_ge2 join_least le_trans)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    40
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    41
lemma le_join_disj: "x \<sqsubseteq> y \<or> x \<sqsubseteq> z \<Longrightarrow> x \<sqsubseteq> y \<squnion> z"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    42
by (metis join_ge1 join_ge2 le_trans)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    43
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    44
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    45
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    46
instantiation "fun" :: (type, preord) preord
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    47
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    48
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    49
definition "f \<sqsubseteq> g = (\<forall>x. f x \<sqsubseteq> g x)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    50
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    51
instance
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    52
proof
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    53
  case goal2 thus ?case by (metis le_fun_def preord_class.le_trans)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    54
qed (simp_all add: le_fun_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    55
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    56
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    57
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    58
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    59
instantiation "fun" :: (type, SL_top) SL_top
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    60
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    61
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    62
definition "f \<squnion> g = (\<lambda>x. f x \<squnion> g x)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    63
definition "\<top> = (\<lambda>x. \<top>)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    64
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    65
lemma join_apply[simp]: "(f \<squnion> g) x = f x \<squnion> g x"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    66
by (simp add: join_fun_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    67
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    68
instance
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    69
proof
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    70
qed (simp_all add: le_fun_def Top_fun_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    71
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    72
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    73
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    74
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    75
instantiation acom :: (preord) preord
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    76
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    77
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    78
fun le_acom :: "('a::preord)acom \<Rightarrow> 'a acom \<Rightarrow> bool" where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    79
"le_acom (SKIP {S}) (SKIP {S'}) = (S \<sqsubseteq> S')" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    80
"le_acom (x ::= e {S}) (x' ::= e' {S'}) = (x=x' \<and> e=e' \<and> S \<sqsubseteq> S')" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    81
"le_acom (C1;C2) (D1;D2) = (C1 \<sqsubseteq> D1 \<and> C2 \<sqsubseteq> D2)" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    82
"le_acom (IF b THEN C1 ELSE C2 {S}) (IF b' THEN D1 ELSE D2 {S'}) =
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    83
  (b=b' \<and> C1 \<sqsubseteq> D1 \<and> C2 \<sqsubseteq> D2 \<and> S \<sqsubseteq> S')" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    84
"le_acom ({I} WHILE b DO C {P}) ({I'} WHILE b' DO C' {P'}) =
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    85
  (b=b' \<and> C \<sqsubseteq> C' \<and> I \<sqsubseteq> I' \<and> P \<sqsubseteq> P')" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    86
"le_acom _ _ = False"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    87
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    88
lemma [simp]: "SKIP {S} \<sqsubseteq> C \<longleftrightarrow> (\<exists>S'. C = SKIP {S'} \<and> S \<sqsubseteq> S')"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    89
by (cases C) auto
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    90
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    91
lemma [simp]: "x ::= e {S} \<sqsubseteq> C \<longleftrightarrow> (\<exists>S'. C = x ::= e {S'} \<and> S \<sqsubseteq> S')"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    92
by (cases C) auto
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    93
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    94
lemma [simp]: "C1;C2 \<sqsubseteq> C \<longleftrightarrow> (\<exists>D1 D2. C = D1;D2 \<and> C1 \<sqsubseteq> D1 \<and> C2 \<sqsubseteq> D2)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    95
by (cases C) auto
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    96
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    97
lemma [simp]: "IF b THEN C1 ELSE C2 {S} \<sqsubseteq> C \<longleftrightarrow>
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    98
  (\<exists>D1 D2 S'. C = IF b THEN D1 ELSE D2 {S'} \<and> C1 \<sqsubseteq> D1 \<and> C2 \<sqsubseteq> D2 \<and> S \<sqsubseteq> S')"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    99
by (cases C) auto
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   100
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   101
lemma [simp]: "{I} WHILE b DO C {P} \<sqsubseteq> W \<longleftrightarrow>
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   102
  (\<exists>I' C' P'. W = {I'} WHILE b DO C' {P'} \<and> C \<sqsubseteq> C' \<and> I \<sqsubseteq> I' \<and> P \<sqsubseteq> P')"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   103
by (cases W) auto
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   104
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   105
instance
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   106
proof
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   107
  case goal1 thus ?case by (induct x) auto
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   108
next
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   109
  case goal2 thus ?case
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   110
  apply(induct x y arbitrary: z rule: le_acom.induct)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   111
  apply (auto intro: le_trans)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   112
  done
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   113
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   114
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   115
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   116
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   117
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   118
instantiation option :: (preord)preord
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   119
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   120
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   121
fun le_option where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   122
"Some x \<sqsubseteq> Some y = (x \<sqsubseteq> y)" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   123
"None \<sqsubseteq> y = True" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   124
"Some _ \<sqsubseteq> None = False"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   125
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   126
lemma [simp]: "(x \<sqsubseteq> None) = (x = None)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   127
by (cases x) simp_all
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   128
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   129
lemma [simp]: "(Some x \<sqsubseteq> u) = (\<exists>y. u = Some y \<and> x \<sqsubseteq> y)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   130
by (cases u) auto
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   131
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   132
instance proof
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   133
  case goal1 show ?case by(cases x, simp_all)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   134
next
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   135
  case goal2 thus ?case
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   136
    by(cases z, simp, cases y, simp, cases x, auto intro: le_trans)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   137
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   138
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   139
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   140
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   141
instantiation option :: (join)join
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   142
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   143
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   144
fun join_option where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   145
"Some x \<squnion> Some y = Some(x \<squnion> y)" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   146
"None \<squnion> y = y" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   147
"x \<squnion> None = x"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   148
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   149
lemma join_None2[simp]: "x \<squnion> None = x"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   150
by (cases x) simp_all
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   151
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   152
instance ..
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   153
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   154
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   155
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   156
instantiation option :: (SL_top)SL_top
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   157
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   158
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   159
definition "\<top> = Some \<top>"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   160
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   161
instance proof
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   162
  case goal1 thus ?case by(cases x, simp, cases y, simp_all)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   163
next
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   164
  case goal2 thus ?case by(cases y, simp, cases x, simp_all)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   165
next
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   166
  case goal3 thus ?case by(cases z, simp, cases y, simp, cases x, simp_all)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   167
next
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   168
  case goal4 thus ?case by(cases x, simp_all add: Top_option_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   169
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   170
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   171
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   172
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   173
class Bot = preord +
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   174
fixes Bot :: "'a" ("\<bottom>")
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   175
assumes Bot[simp]: "\<bottom> \<sqsubseteq> x"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   176
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   177
instantiation option :: (preord)Bot
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   178
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   179
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   180
definition Bot_option :: "'a option" where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   181
"\<bottom> = None"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   182
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   183
instance
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   184
proof
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   185
  case goal1 thus ?case by(auto simp: Bot_option_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   186
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   187
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   188
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   189
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   190
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   191
definition bot :: "com \<Rightarrow> 'a option acom" where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   192
"bot c = anno None c"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   193
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   194
lemma bot_least: "strip C = c \<Longrightarrow> bot c \<sqsubseteq> C"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   195
by(induct C arbitrary: c)(auto simp: bot_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   196
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   197
lemma strip_bot[simp]: "strip(bot c) = c"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   198
by(simp add: bot_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   199
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   200
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   201
subsubsection "Post-fixed point iteration"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   202
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   203
definition
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   204
  pfp :: "(('a::preord) \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'a option" where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   205
"pfp f = while_option (\<lambda>x. \<not> f x \<sqsubseteq> x) f"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   206
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   207
lemma pfp_pfp: assumes "pfp f x0 = Some x" shows "f x \<sqsubseteq> x"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   208
using while_option_stop[OF assms[simplified pfp_def]] by simp
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   209
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   210
lemma pfp_least:
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   211
assumes mono: "\<And>x y. x \<sqsubseteq> y \<Longrightarrow> f x \<sqsubseteq> f y"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   212
and "f p \<sqsubseteq> p" and "x0 \<sqsubseteq> p" and "pfp f x0 = Some x" shows "x \<sqsubseteq> p"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   213
proof-
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   214
  { fix x assume "x \<sqsubseteq> p"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   215
    hence  "f x \<sqsubseteq> f p" by(rule mono)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   216
    from this `f p \<sqsubseteq> p` have "f x \<sqsubseteq> p" by(rule le_trans)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   217
  }
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   218
  thus "x \<sqsubseteq> p" using assms(2-) while_option_rule[where P = "%x. x \<sqsubseteq> p"]
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   219
    unfolding pfp_def by blast
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   220
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   221
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   222
definition
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   223
 lpfp :: "('a::preord option acom \<Rightarrow> 'a option acom) \<Rightarrow> com \<Rightarrow> 'a option acom option"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   224
where "lpfp f c = pfp f (bot c)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   225
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   226
lemma lpfpc_pfp: "lpfp f c = Some p \<Longrightarrow> f p \<sqsubseteq> p"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   227
by(simp add: pfp_pfp lpfp_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   228
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   229
lemma strip_pfp:
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   230
assumes "\<And>x. g(f x) = g x" and "pfp f x0 = Some x" shows "g x = g x0"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   231
using assms while_option_rule[where P = "%x. g x = g x0" and c = f]
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   232
unfolding pfp_def by metis
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   233
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   234
lemma strip_lpfp: assumes "\<And>C. strip(f C) = strip C" and "lpfp f c = Some C"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   235
shows "strip C = c"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   236
using assms(1) strip_pfp[OF _ assms(2)[simplified lpfp_def]]
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   237
by(metis strip_bot)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   238
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   239
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   240
subsection "Abstract Interpretation"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   241
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   242
definition \<gamma>_fun :: "('a \<Rightarrow> 'b set) \<Rightarrow> ('c \<Rightarrow> 'a) \<Rightarrow> ('c \<Rightarrow> 'b)set" where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   243
"\<gamma>_fun \<gamma> F = {f. \<forall>x. f x \<in> \<gamma>(F x)}"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   244
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   245
fun \<gamma>_option :: "('a \<Rightarrow> 'b set) \<Rightarrow> 'a option \<Rightarrow> 'b set" where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   246
"\<gamma>_option \<gamma> None = {}" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   247
"\<gamma>_option \<gamma> (Some a) = \<gamma> a"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   248
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   249
text{* The interface for abstract values: *}
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   250
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   251
locale Val_abs =
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   252
fixes \<gamma> :: "'av::SL_top \<Rightarrow> val set"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   253
  assumes mono_gamma: "a \<sqsubseteq> b \<Longrightarrow> \<gamma> a \<subseteq> \<gamma> b"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   254
  and gamma_Top[simp]: "\<gamma> \<top> = UNIV"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   255
fixes num' :: "val \<Rightarrow> 'av"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   256
and plus' :: "'av \<Rightarrow> 'av \<Rightarrow> 'av"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   257
  assumes gamma_num': "n : \<gamma>(num' n)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   258
  and gamma_plus':
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   259
 "n1 : \<gamma> a1 \<Longrightarrow> n2 : \<gamma> a2 \<Longrightarrow> n1+n2 : \<gamma>(plus' a1 a2)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   260
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   261
type_synonym 'av st = "(vname \<Rightarrow> 'av)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   262
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   263
locale Abs_Int_Fun = Val_abs \<gamma> for \<gamma> :: "'av::SL_top \<Rightarrow> val set"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   264
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   265
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   266
fun aval' :: "aexp \<Rightarrow> 'av st \<Rightarrow> 'av" where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   267
"aval' (N n) S = num' n" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   268
"aval' (V x) S = S x" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   269
"aval' (Plus a1 a2) S = plus' (aval' a1 S) (aval' a2 S)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   270
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   271
fun step' :: "'av st option \<Rightarrow> 'av st option acom \<Rightarrow> 'av st option acom"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   272
 where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   273
"step' S (SKIP {P}) = (SKIP {S})" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   274
"step' S (x ::= e {P}) =
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   275
  x ::= e {case S of None \<Rightarrow> None | Some S \<Rightarrow> Some(S(x := aval' e S))}" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   276
"step' S (C1; C2) = step' S C1; step' (post C1) C2" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   277
"step' S (IF b THEN C1 ELSE C2 {P}) =
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   278
   IF b THEN step' S C1 ELSE step' S C2 {post C1 \<squnion> post C2}" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   279
"step' S ({Inv} WHILE b DO C {P}) =
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   280
  {S \<squnion> post C} WHILE b DO (step' Inv C) {Inv}"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   281
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   282
definition AI :: "com \<Rightarrow> 'av st option acom option" where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   283
"AI = lpfp (step' \<top>)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   284
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   285
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   286
lemma strip_step'[simp]: "strip(step' S C) = strip C"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   287
by(induct C arbitrary: S) (simp_all add: Let_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   288
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   289
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   290
abbreviation \<gamma>\<^isub>f :: "'av st \<Rightarrow> state set"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   291
where "\<gamma>\<^isub>f == \<gamma>_fun \<gamma>"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   292
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   293
abbreviation \<gamma>\<^isub>o :: "'av st option \<Rightarrow> state set"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   294
where "\<gamma>\<^isub>o == \<gamma>_option \<gamma>\<^isub>f"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   295
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   296
abbreviation \<gamma>\<^isub>c :: "'av st option acom \<Rightarrow> state set acom"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   297
where "\<gamma>\<^isub>c == map_acom \<gamma>\<^isub>o"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   298
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   299
lemma gamma_f_Top[simp]: "\<gamma>\<^isub>f Top = UNIV"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   300
by(simp add: Top_fun_def \<gamma>_fun_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   301
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   302
lemma gamma_o_Top[simp]: "\<gamma>\<^isub>o Top = UNIV"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   303
by (simp add: Top_option_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   304
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   305
(* FIXME (maybe also le \<rightarrow> sqle?) *)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   306
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   307
lemma mono_gamma_f: "f1 \<sqsubseteq> f2 \<Longrightarrow> \<gamma>\<^isub>f f1 \<subseteq> \<gamma>\<^isub>f f2"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   308
by(auto simp: le_fun_def \<gamma>_fun_def dest: mono_gamma)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   309
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   310
lemma mono_gamma_o:
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   311
  "S1 \<sqsubseteq> S2 \<Longrightarrow> \<gamma>\<^isub>o S1 \<subseteq> \<gamma>\<^isub>o S2"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   312
by(induction S1 S2 rule: le_option.induct)(simp_all add: mono_gamma_f)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   313
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   314
lemma mono_gamma_c: "C1 \<sqsubseteq> C2 \<Longrightarrow> \<gamma>\<^isub>c C1 \<le> \<gamma>\<^isub>c C2"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   315
by (induction C1 C2 rule: le_acom.induct) (simp_all add:mono_gamma_o)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   316
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   317
text{* Soundness: *}
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   318
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   319
lemma aval'_sound: "s : \<gamma>\<^isub>f S \<Longrightarrow> aval a s : \<gamma>(aval' a S)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   320
by (induct a) (auto simp: gamma_num' gamma_plus' \<gamma>_fun_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   321
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   322
lemma in_gamma_update:
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   323
  "\<lbrakk> s : \<gamma>\<^isub>f S; i : \<gamma> a \<rbrakk> \<Longrightarrow> s(x := i) : \<gamma>\<^isub>f(S(x := a))"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   324
by(simp add: \<gamma>_fun_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   325
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   326
lemma step_preserves_le:
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   327
  "\<lbrakk> S \<subseteq> \<gamma>\<^isub>o S'; C \<le> \<gamma>\<^isub>c C' \<rbrakk> \<Longrightarrow> step S C \<le> \<gamma>\<^isub>c (step' S' C')"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   328
proof(induction C arbitrary: C' S S')
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   329
  case SKIP thus ?case by(auto simp:SKIP_le map_acom_SKIP)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   330
next
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   331
  case Assign thus ?case
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   332
    by (fastforce simp: Assign_le  map_acom_Assign intro: aval'_sound in_gamma_update
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   333
      split: option.splits del:subsetD)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   334
next
47818
151d137f1095 renamed Semi to Seq
nipkow
parents: 47613
diff changeset
   335
  case Seq thus ?case apply (auto simp: Seq_le map_acom_Seq)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   336
    by (metis le_post post_map_acom)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   337
next
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   338
  case (If b C1 C2 P)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   339
  then obtain D1 D2 P' where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   340
      "C' = IF b THEN D1 ELSE D2 {P'}"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   341
      "P \<subseteq> \<gamma>\<^isub>o P'" "C1 \<le> \<gamma>\<^isub>c D1" "C2 \<le> \<gamma>\<^isub>c D2"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   342
    by (fastforce simp: If_le map_acom_If)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   343
  moreover have "post C1 \<subseteq> \<gamma>\<^isub>o(post D1 \<squnion> post D2)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   344
    by (metis (no_types) `C1 \<le> \<gamma>\<^isub>c D1` join_ge1 le_post mono_gamma_o order_trans post_map_acom)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   345
  moreover have "post C2 \<subseteq> \<gamma>\<^isub>o(post D1 \<squnion> post D2)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   346
    by (metis (no_types) `C2 \<le> \<gamma>\<^isub>c D2` join_ge2 le_post mono_gamma_o order_trans post_map_acom)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   347
  ultimately show ?case using `S \<subseteq> \<gamma>\<^isub>o S'` by (simp add: If.IH subset_iff)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   348
next
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   349
  case (While I b C1 P)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   350
  then obtain D1 I' P' where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   351
    "C' = {I'} WHILE b DO D1 {P'}"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   352
    "I \<subseteq> \<gamma>\<^isub>o I'" "P \<subseteq> \<gamma>\<^isub>o P'" "C1 \<le> \<gamma>\<^isub>c D1"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   353
    by (fastforce simp: map_acom_While While_le)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   354
  moreover have "S \<union> post C1 \<subseteq> \<gamma>\<^isub>o (S' \<squnion> post D1)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   355
    using `S \<subseteq> \<gamma>\<^isub>o S'` le_post[OF `C1 \<le> \<gamma>\<^isub>c D1`, simplified]
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   356
    by (metis (no_types) join_ge1 join_ge2 le_sup_iff mono_gamma_o order_trans)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   357
  ultimately show ?case by (simp add: While.IH subset_iff)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   358
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   359
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   360
lemma AI_sound: "AI c = Some C \<Longrightarrow> CS c \<le> \<gamma>\<^isub>c C"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   361
proof(simp add: CS_def AI_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   362
  assume 1: "lpfp (step' \<top>) c = Some C"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   363
  have 2: "step' \<top> C \<sqsubseteq> C" by(rule lpfpc_pfp[OF 1])
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   364
  have 3: "strip (\<gamma>\<^isub>c (step' \<top> C)) = c"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   365
    by(simp add: strip_lpfp[OF _ 1])
48759
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents: 47818
diff changeset
   366
  have "lfp c (step UNIV) \<le> \<gamma>\<^isub>c (step' \<top> C)"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   367
  proof(rule lfp_lowerbound[simplified,OF 3])
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   368
    show "step UNIV (\<gamma>\<^isub>c (step' \<top> C)) \<le> \<gamma>\<^isub>c (step' \<top> C)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   369
    proof(rule step_preserves_le[OF _ _])
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   370
      show "UNIV \<subseteq> \<gamma>\<^isub>o \<top>" by simp
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   371
      show "\<gamma>\<^isub>c (step' \<top> C) \<le> \<gamma>\<^isub>c C" by(rule mono_gamma_c[OF 2])
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   372
    qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   373
  qed
48759
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents: 47818
diff changeset
   374
  with 2 show "lfp c (step UNIV) \<le> \<gamma>\<^isub>c C"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   375
    by (blast intro: mono_gamma_c order_trans)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   376
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   377
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   378
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   379
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   380
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   381
subsubsection "Monotonicity"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   382
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   383
lemma mono_post: "C1 \<sqsubseteq> C2 \<Longrightarrow> post C1 \<sqsubseteq> post C2"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   384
by(induction C1 C2 rule: le_acom.induct) (auto)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   385
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   386
locale Abs_Int_Fun_mono = Abs_Int_Fun +
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   387
assumes mono_plus': "a1 \<sqsubseteq> b1 \<Longrightarrow> a2 \<sqsubseteq> b2 \<Longrightarrow> plus' a1 a2 \<sqsubseteq> plus' b1 b2"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   388
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   389
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   390
lemma mono_aval': "S \<sqsubseteq> S' \<Longrightarrow> aval' e S \<sqsubseteq> aval' e S'"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   391
by(induction e)(auto simp: le_fun_def mono_plus')
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   392
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   393
lemma mono_update: "a \<sqsubseteq> a' \<Longrightarrow> S \<sqsubseteq> S' \<Longrightarrow> S(x := a) \<sqsubseteq> S'(x := a')"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   394
by(simp add: le_fun_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   395
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   396
lemma mono_step': "S1 \<sqsubseteq> S2 \<Longrightarrow> C1 \<sqsubseteq> C2 \<Longrightarrow> step' S1 C1 \<sqsubseteq> step' S2 C2"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   397
apply(induction C1 C2 arbitrary: S1 S2 rule: le_acom.induct)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   398
apply (auto simp: Let_def mono_update mono_aval' mono_post le_join_disj
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   399
            split: option.split)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   400
done
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   401
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   402
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   403
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   404
text{* Problem: not executable because of the comparison of abstract states,
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   405
i.e. functions, in the post-fixedpoint computation. *}
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   406
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   407
end