src/HOL/IMP/Abs_Int0.thy
author nipkow
Thu, 11 Apr 2013 15:10:22 +0200
changeset 51694 6ae88642962f
parent 51628 0a6d576da295
child 51710 f692657e0f71
permissions -rw-r--r--
tuned
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
51625
bd3358aac5d2 tuned document
nipkow
parents: 51390
diff changeset
     9
text{* The basic type classes @{class order}, @{class semilattice_sup} and @{class top} are
bd3358aac5d2 tuned document
nipkow
parents: 51390
diff changeset
    10
defined in @{theory Main}, more precisely in theories @{theory Orderings} and @{theory Lattices}.
bd3358aac5d2 tuned document
nipkow
parents: 51390
diff changeset
    11
If you view this theory with jedit, just click on the names to get there. *}
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    12
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    13
class semilattice = semilattice_sup + top
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    14
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    15
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    16
instance "fun" :: (type, semilattice) semilattice ..
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    17
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    18
instantiation option :: (order)order
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    19
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    20
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    21
fun less_eq_option where
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    22
"Some x \<le> Some y = (x \<le> y)" |
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    23
"None \<le> y = True" |
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    24
"Some _ \<le> None = False"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    25
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    26
definition less_option where "x < (y::'a option) = (x \<le> y \<and> \<not> y \<le> x)"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    27
51628
nipkow
parents: 51625
diff changeset
    28
lemma le_None[simp]: "(x \<le> None) = (x = None)"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    29
by (cases x) simp_all
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    30
51628
nipkow
parents: 51625
diff changeset
    31
lemma Some_le[simp]: "(Some x \<le> u) = (\<exists>y. u = Some y \<and> x \<le> y)"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    32
by (cases u) auto
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    33
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    34
instance proof
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    35
  case goal1 show ?case by(rule less_option_def)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    36
next
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    37
  case goal2 show ?case by(cases x, simp_all)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    38
next
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    39
  case goal3 thus ?case by(cases z, simp, cases y, simp, cases x, auto)
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    40
next
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    41
  case goal4 thus ?case by(cases y, simp, cases x, auto)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    42
qed
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
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    46
instantiation option :: (sup)sup
47613
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
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    49
fun sup_option where
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    50
"Some x \<squnion> Some y = Some(x \<squnion> y)" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    51
"None \<squnion> y = y" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    52
"x \<squnion> None = x"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    53
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    54
lemma sup_None2[simp]: "x \<squnion> None = x"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    55
by (cases x) simp_all
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    56
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    57
instance ..
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    58
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    59
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    60
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49344
diff changeset
    61
instantiation option :: (semilattice)semilattice
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    62
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    63
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    64
definition top_option where "\<top> = Some \<top>"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    65
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    66
instance proof
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    67
  case goal4 show ?case by(cases a, simp_all add: top_option_def)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    68
next
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    69
  case goal1 thus ?case by(cases x, simp, cases y, simp_all)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    70
next
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    71
  case goal2 thus ?case by(cases y, simp, cases x, simp_all)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    72
next
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
    73
  case goal3 thus ?case by(cases z, simp, cases y, simp, cases x, simp_all)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    74
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    75
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    76
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    77
51390
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
    78
lemma [simp]: "(Some x < Some y) = (x < y)"
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
    79
by(auto simp: less_le)
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
    80
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    81
instantiation option :: (order)bot
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    82
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    83
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49344
diff changeset
    84
definition bot_option :: "'a option" where
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    85
"\<bottom> = None"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    86
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    87
instance
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    88
proof
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49344
diff changeset
    89
  case goal1 thus ?case by(auto simp: bot_option_def)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    90
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    91
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    92
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    93
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    94
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    95
definition bot :: "com \<Rightarrow> 'a option acom" where
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    96
"bot c = anno None c"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    97
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
    98
lemma bot_least: "strip C = c \<Longrightarrow> bot c \<le> C"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
    99
by(induct C arbitrary: c)(auto simp: bot_def)
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 strip_bot[simp]: "strip(bot c) = c"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   102
by(simp add: bot_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   103
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   104
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   105
subsubsection "Post-fixed point iteration"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   106
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   107
definition pfp :: "(('a::order) \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'a option" where
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   108
"pfp f = while_option (\<lambda>x. \<not> f x \<le> x) f"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   109
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   110
lemma pfp_pfp: assumes "pfp f x0 = Some x" shows "f x \<le> x"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   111
using while_option_stop[OF assms[simplified pfp_def]] by simp
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   112
49464
4e4bdd12280f removed lpfp and proved least pfp thm
nipkow
parents: 49396
diff changeset
   113
lemma while_least:
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   114
fixes q :: "'a::order"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   115
assumes "\<forall>x\<in>L.\<forall>y\<in>L. x \<le> y \<longrightarrow> f x \<le> f y" and "\<forall>x. x \<in> L \<longrightarrow> f x \<in> L"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   116
and "\<forall>x \<in> L. b \<le> x" and "b \<in> L" and "f q \<le> q" and "q \<in> L"
49464
4e4bdd12280f removed lpfp and proved least pfp thm
nipkow
parents: 49396
diff changeset
   117
and "while_option P f b = Some p"
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   118
shows "p \<le> q"
49464
4e4bdd12280f removed lpfp and proved least pfp thm
nipkow
parents: 49396
diff changeset
   119
using while_option_rule[OF _  assms(7)[unfolded pfp_def],
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   120
                        where P = "%x. x \<in> L \<and> x \<le> q"]
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   121
by (metis assms(1-6) order_trans)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   122
49464
4e4bdd12280f removed lpfp and proved least pfp thm
nipkow
parents: 49396
diff changeset
   123
lemma pfp_inv:
4e4bdd12280f removed lpfp and proved least pfp thm
nipkow
parents: 49396
diff changeset
   124
  "pfp f x = Some y \<Longrightarrow> (\<And>x. P x \<Longrightarrow> P(f x)) \<Longrightarrow> P x \<Longrightarrow> P y"
4e4bdd12280f removed lpfp and proved least pfp thm
nipkow
parents: 49396
diff changeset
   125
unfolding pfp_def by (metis (lifting) while_option_rule)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   126
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   127
lemma strip_pfp:
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   128
assumes "\<And>x. g(f x) = g x" and "pfp f x0 = Some x" shows "g x = g x0"
49464
4e4bdd12280f removed lpfp and proved least pfp thm
nipkow
parents: 49396
diff changeset
   129
using pfp_inv[OF assms(2), where P = "%x. g x = g x0"] assms(1) by simp
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   130
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   131
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   132
subsection "Abstract Interpretation"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   133
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   134
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
   135
"\<gamma>_fun \<gamma> F = {f. \<forall>x. f x \<in> \<gamma>(F x)}"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   136
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   137
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
   138
"\<gamma>_option \<gamma> None = {}" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   139
"\<gamma>_option \<gamma> (Some a) = \<gamma> a"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   140
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   141
text{* The interface for abstract values: *}
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   142
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   143
locale Val_abs =
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49344
diff changeset
   144
fixes \<gamma> :: "'av::semilattice \<Rightarrow> val set"
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   145
  assumes mono_gamma: "a \<le> b \<Longrightarrow> \<gamma> a \<le> \<gamma> b"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   146
  and gamma_Top[simp]: "\<gamma> \<top> = UNIV"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   147
fixes num' :: "val \<Rightarrow> 'av"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   148
and plus' :: "'av \<Rightarrow> 'av \<Rightarrow> 'av"
51036
e7b54119c436 tuned top
nipkow
parents: 50986
diff changeset
   149
  assumes gamma_num': "i \<in> \<gamma>(num' i)"
e7b54119c436 tuned top
nipkow
parents: 50986
diff changeset
   150
  and gamma_plus': "i1 \<in> \<gamma> a1 \<Longrightarrow> i2 \<in> \<gamma> a2 \<Longrightarrow> i1+i2 \<in> \<gamma>(plus' a1 a2)"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   151
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   152
type_synonym 'av st = "(vname \<Rightarrow> 'av)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   153
49396
73fb17ed2e08 converted wt into a set, tuned names
nipkow
parents: 49344
diff changeset
   154
locale Abs_Int_Fun = Val_abs \<gamma> for \<gamma> :: "'av::semilattice \<Rightarrow> val set"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   155
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   156
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   157
fun aval' :: "aexp \<Rightarrow> 'av st \<Rightarrow> 'av" where
50896
nipkow
parents: 49497
diff changeset
   158
"aval' (N i) S = num' i" |
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   159
"aval' (V x) S = S x" |
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   160
"aval' (Plus a1 a2) S = plus' (aval' a1 S) (aval' a2 S)"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   161
51694
nipkow
parents: 51628
diff changeset
   162
definition "fa x e S = (case S of None \<Rightarrow> None | Some S \<Rightarrow> Some(S(x := aval' e S)))"
nipkow
parents: 51628
diff changeset
   163
nipkow
parents: 51628
diff changeset
   164
definition "step' = Step fa (\<lambda>b S. S)"
51389
8a9f0503b1c0 factored out Step
nipkow
parents: 51359
diff changeset
   165
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   166
definition AI :: "com \<Rightarrow> 'av st option acom option" where
49464
4e4bdd12280f removed lpfp and proved least pfp thm
nipkow
parents: 49396
diff changeset
   167
"AI c = pfp (step' \<top>) (bot c)"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   168
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   169
49497
860b7c6bd913 tuned names
nipkow
parents: 49464
diff changeset
   170
abbreviation \<gamma>\<^isub>s :: "'av st \<Rightarrow> state set"
860b7c6bd913 tuned names
nipkow
parents: 49464
diff changeset
   171
where "\<gamma>\<^isub>s == \<gamma>_fun \<gamma>"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   172
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   173
abbreviation \<gamma>\<^isub>o :: "'av st option \<Rightarrow> state set"
49497
860b7c6bd913 tuned names
nipkow
parents: 49464
diff changeset
   174
where "\<gamma>\<^isub>o == \<gamma>_option \<gamma>\<^isub>s"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   175
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   176
abbreviation \<gamma>\<^isub>c :: "'av st option acom \<Rightarrow> state set acom"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   177
where "\<gamma>\<^isub>c == map_acom \<gamma>\<^isub>o"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   178
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   179
lemma gamma_s_Top[simp]: "\<gamma>\<^isub>s \<top> = UNIV"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   180
by(simp add: top_fun_def \<gamma>_fun_def)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   181
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   182
lemma gamma_o_Top[simp]: "\<gamma>\<^isub>o \<top> = UNIV"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   183
by (simp add: top_option_def)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   184
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   185
lemma mono_gamma_s: "f1 \<le> f2 \<Longrightarrow> \<gamma>\<^isub>s f1 \<subseteq> \<gamma>\<^isub>s f2"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   186
by(auto simp: le_fun_def \<gamma>_fun_def dest: mono_gamma)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   187
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   188
lemma mono_gamma_o:
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   189
  "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
   190
by(induction S1 S2 rule: less_eq_option.induct)(simp_all add: mono_gamma_s)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   191
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   192
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
   193
by (induction C1 C2 rule: less_eq_acom.induct) (simp_all add:mono_gamma_o)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   194
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   195
text{* Soundness: *}
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   196
49497
860b7c6bd913 tuned names
nipkow
parents: 49464
diff changeset
   197
lemma aval'_sound: "s : \<gamma>\<^isub>s S \<Longrightarrow> aval a s : \<gamma>(aval' a S)"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   198
by (induct a) (auto simp: gamma_num' gamma_plus' \<gamma>_fun_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   199
51390
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   200
lemma in_gamma_update: "\<lbrakk> s : \<gamma>\<^isub>s S; i : \<gamma> a \<rbrakk> \<Longrightarrow> s(x := i) : \<gamma>\<^isub>s(S(x := a))"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   201
by(simp add: \<gamma>_fun_def)
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   202
51390
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   203
lemma gamma_Step_subcomm:
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   204
  assumes "!!x e S. f1 x e (\<gamma>\<^isub>o S) \<subseteq> \<gamma>\<^isub>o (f2 x e S)"  "!!b S. g1 b (\<gamma>\<^isub>o S) \<subseteq> \<gamma>\<^isub>o (g2 b S)"
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   205
  shows "Step f1 g1 (\<gamma>\<^isub>o S) (\<gamma>\<^isub>c C) \<le> \<gamma>\<^isub>c (Step f2 g2 S C)"
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   206
proof(induction C arbitrary: S)
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   207
qed  (auto simp: mono_gamma_o assms)
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   208
50986
c54ea7f5418f simplified proofs
nipkow
parents: 50896
diff changeset
   209
lemma step_step': "step (\<gamma>\<^isub>o S) (\<gamma>\<^isub>c C) \<le> \<gamma>\<^isub>c (step' S C)"
51390
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   210
unfolding step_def step'_def
51694
nipkow
parents: 51628
diff changeset
   211
by(rule gamma_Step_subcomm)
nipkow
parents: 51628
diff changeset
   212
  (auto simp: aval'_sound in_gamma_update fa_def split: option.splits)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   213
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   214
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
   215
proof(simp add: CS_def AI_def)
49464
4e4bdd12280f removed lpfp and proved least pfp thm
nipkow
parents: 49396
diff changeset
   216
  assume 1: "pfp (step' \<top>) (bot c) = Some C"
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   217
  have pfp': "step' \<top> C \<le> C" by(rule pfp_pfp[OF 1])
50986
c54ea7f5418f simplified proofs
nipkow
parents: 50896
diff changeset
   218
  have 2: "step (\<gamma>\<^isub>o \<top>) (\<gamma>\<^isub>c C) \<le> \<gamma>\<^isub>c C"  --"transfer the pfp'"
c54ea7f5418f simplified proofs
nipkow
parents: 50896
diff changeset
   219
  proof(rule order_trans)
c54ea7f5418f simplified proofs
nipkow
parents: 50896
diff changeset
   220
    show "step (\<gamma>\<^isub>o \<top>) (\<gamma>\<^isub>c C) \<le> \<gamma>\<^isub>c (step' \<top> C)" by(rule step_step')
c54ea7f5418f simplified proofs
nipkow
parents: 50896
diff changeset
   221
    show "... \<le> \<gamma>\<^isub>c C" by (metis mono_gamma_c[OF pfp'])
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   222
  qed
51390
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   223
  have 3: "strip (\<gamma>\<^isub>c C) = c" by(simp add: strip_pfp[OF _ 1] step'_def)
50986
c54ea7f5418f simplified proofs
nipkow
parents: 50896
diff changeset
   224
  have "lfp c (step (\<gamma>\<^isub>o \<top>)) \<le> \<gamma>\<^isub>c C"
c54ea7f5418f simplified proofs
nipkow
parents: 50896
diff changeset
   225
    by(rule lfp_lowerbound[simplified,where f="step (\<gamma>\<^isub>o \<top>)", OF 3 2])
c54ea7f5418f simplified proofs
nipkow
parents: 50896
diff changeset
   226
  thus "lfp c (step UNIV) \<le> \<gamma>\<^isub>c C" by simp
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   227
qed
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   228
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   229
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   230
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   231
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   232
subsubsection "Monotonicity"
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   233
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   234
lemma mono_post: "C1 \<le> C2 \<Longrightarrow> post C1 \<le> post C2"
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   235
by(induction C1 C2 rule: less_eq_acom.induct) (auto)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   236
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   237
locale Abs_Int_Fun_mono = Abs_Int_Fun +
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   238
assumes mono_plus': "a1 \<le> b1 \<Longrightarrow> a2 \<le> b2 \<Longrightarrow> plus' a1 a2 \<le> plus' b1 b2"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   239
begin
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   240
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   241
lemma mono_aval': "S \<le> S' \<Longrightarrow> aval' e S \<le> aval' e S'"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   242
by(induction e)(auto simp: le_fun_def mono_plus')
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   243
51359
00b45c7e831f major redesign: order instead of preorder, new definition of intervals as quotients
nipkow
parents: 51036
diff changeset
   244
lemma mono_update: "a \<le> a' \<Longrightarrow> S \<le> S' \<Longrightarrow> S(x := a) \<le> S'(x := a')"
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   245
by(simp add: le_fun_def)
e72e44cee6f2 added revised version of Abs_Int
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_step': "S1 \<le> S2 \<Longrightarrow> C1 \<le> C2 \<Longrightarrow> step' S1 C1 \<le> step' S2 C2"
51390
1dff81cf425b more factorisation of Step & Co
nipkow
parents: 51389
diff changeset
   248
unfolding step'_def
51694
nipkow
parents: 51628
diff changeset
   249
by(rule mono2_Step)
nipkow
parents: 51628
diff changeset
   250
  (auto simp: mono_update mono_aval' fa_def split: option.split)
47613
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   251
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   252
end
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   253
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   254
text{* Problem: not executable because of the comparison of abstract states,
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   255
i.e. functions, in the post-fixedpoint computation. *}
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   256
e72e44cee6f2 added revised version of Abs_Int
nipkow
parents:
diff changeset
   257
end