src/HOL/IMP/Abs_Int_Den/Abs_State_den.thy
author wenzelm
Sat, 07 Apr 2012 16:41:59 +0200
changeset 47389 e8552cba702d
parent 45111 054a9ac0d7ef
child 58249 180f1b3508ed
permissions -rw-r--r--
explicit checks stable_finished_theory/stable_command allow parallel asynchronous command transactions; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     1
(* Author: Tobias Nipkow *)
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     2
45111
054a9ac0d7ef Added Hoare-like Abstract Interpretation
nipkow
parents: 45110
diff changeset
     3
theory Abs_State_den
054a9ac0d7ef Added Hoare-like Abstract Interpretation
nipkow
parents: 45110
diff changeset
     4
imports Abs_Int_den0_fun
44932
7c93ee993cae revised AbsInt and added widening and narrowing
nipkow
parents: 44923
diff changeset
     5
  "~~/src/HOL/Library/Char_ord" "~~/src/HOL/Library/List_lexord"
7c93ee993cae revised AbsInt and added widening and narrowing
nipkow
parents: 44923
diff changeset
     6
  (* Library import merely to allow string lists to be sorted for output *)
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     7
begin
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     8
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     9
subsection "Abstract State with Computable Ordering"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    10
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    11
text{* A concrete type of state with computable @{text"\<sqsubseteq>"}: *}
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    12
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    13
datatype 'a astate = FunDom "string \<Rightarrow> 'a" "string list"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    14
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    15
fun "fun" where "fun (FunDom f _) = f"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    16
fun dom where "dom (FunDom _ A) = A"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    17
44932
7c93ee993cae revised AbsInt and added widening and narrowing
nipkow
parents: 44923
diff changeset
    18
definition [simp]: "inter_list xs ys = [x\<leftarrow>xs. x \<in> set ys]"
7c93ee993cae revised AbsInt and added widening and narrowing
nipkow
parents: 44923
diff changeset
    19
7c93ee993cae revised AbsInt and added widening and narrowing
nipkow
parents: 44923
diff changeset
    20
definition "list S = [(x,fun S x). x \<leftarrow> sort(dom S)]"
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    21
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    22
definition "lookup F x = (if x : set(dom F) then fun F x else Top)"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    23
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    24
definition "update F x y =
44932
7c93ee993cae revised AbsInt and added widening and narrowing
nipkow
parents: 44923
diff changeset
    25
  FunDom ((fun F)(x:=y)) (if x \<in> set(dom F) then dom F else x # dom F)"
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    26
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    27
lemma lookup_update: "lookup (update S x y) = (lookup S)(x:=y)"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    28
by(rule ext)(auto simp: lookup_def update_def)
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    29
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    30
instantiation astate :: (SL_top) SL_top
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    31
begin
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    32
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    33
definition "le_astate F G = (ALL x : set(dom G). lookup F x \<sqsubseteq> fun G x)"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    34
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    35
definition
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    36
"join_astate F G =
44932
7c93ee993cae revised AbsInt and added widening and narrowing
nipkow
parents: 44923
diff changeset
    37
 FunDom (\<lambda>x. fun F x \<squnion> fun G x) (inter_list (dom F) (dom G))"
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    38
44923
b80108b346a9 cleand up AbsInt fixpoint iteration; tuned syntax
nipkow
parents: 44656
diff changeset
    39
definition "Top = FunDom (\<lambda>x. Top) []"
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    40
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    41
instance
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    42
proof
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    43
  case goal2 thus ?case
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    44
    apply(auto simp: le_astate_def)
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    45
    by (metis lookup_def preord_class.le_trans top)
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    46
qed (auto simp: le_astate_def lookup_def join_astate_def Top_astate_def)
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    47
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    48
end
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    49
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    50
end