src/HOL/IMP/Abs_Int_Den/Abs_Int_den0.thy
author wenzelm
Sat, 07 Apr 2012 16:41:59 +0200
changeset 47389 e8552cba702d
parent 45111 054a9ac0d7ef
child 47818 151d137f1095
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_Int_den0
054a9ac0d7ef Added Hoare-like Abstract Interpretation
nipkow
parents: 45110
diff changeset
     4
imports Abs_State_den
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     5
begin
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     6
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     7
subsection "Computable Abstract Interpretation"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     8
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
     9
text{* Abstract interpretation over type @{text astate} instead of
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    10
functions. *}
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    11
44932
7c93ee993cae revised AbsInt and added widening and narrowing
nipkow
parents: 44923
diff changeset
    12
locale Abs_Int = Val_abs +
44944
f136409c2cef tuned post fixpoint setup
nipkow
parents: 44932
diff changeset
    13
fixes pfp :: "('a astate \<Rightarrow> 'a astate) \<Rightarrow> 'a astate \<Rightarrow> 'a astate"
f136409c2cef tuned post fixpoint setup
nipkow
parents: 44932
diff changeset
    14
assumes pfp: "f(pfp f x0) \<sqsubseteq> pfp f x0"
f136409c2cef tuned post fixpoint setup
nipkow
parents: 44932
diff changeset
    15
assumes above: "x0 \<sqsubseteq> pfp f x0"
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    16
begin
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
fun aval' :: "aexp \<Rightarrow> 'a astate \<Rightarrow> 'a" where
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    19
"aval' (N n) _ = num' n" |
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    20
"aval' (V x) S = lookup S x" |
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    21
"aval' (Plus e1 e2) S = plus' (aval' e1 S) (aval' e2 S)"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    22
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    23
abbreviation astate_in_rep (infix "<:" 50) where
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    24
"s <: S == ALL x. s x <: lookup S x"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    25
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    26
lemma astate_in_rep_le: "(s::state) <: S \<Longrightarrow> S \<sqsubseteq> T \<Longrightarrow> s <: T"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    27
by (metis in_mono le_astate_def le_rep lookup_def top)
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    28
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    29
lemma aval'_sound: "s <: S \<Longrightarrow> aval a s <: aval' a S"
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    30
by (induct a) (auto simp: rep_num' rep_plus')
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    31
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    32
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    33
fun AI :: "com \<Rightarrow> 'a astate \<Rightarrow> 'a astate" where
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    34
"AI SKIP S = S" |
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    35
"AI (x ::= a) S = update S x (aval' a S)" |
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    36
"AI (c1;c2) S = AI c2 (AI c1 S)" |
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    37
"AI (IF b THEN c1 ELSE c2) S = (AI c1 S) \<squnion> (AI c2 S)" |
44944
f136409c2cef tuned post fixpoint setup
nipkow
parents: 44932
diff changeset
    38
"AI (WHILE b DO c) S = pfp (AI c) S"
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    39
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    40
lemma AI_sound: "(c,s) \<Rightarrow> t \<Longrightarrow> s <: S0 \<Longrightarrow> t <: AI c S0"
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44944
diff changeset
    41
proof(induction c arbitrary: s t S0)
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44656
diff changeset
    42
  case SKIP thus ?case by fastforce
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    43
next
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    44
  case Assign thus ?case
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    45
    by (auto simp: lookup_update aval'_sound)
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    46
next
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    47
  case Semi thus ?case by auto
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    48
next
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    49
  case If thus ?case
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    50
    by (metis AI.simps(4) IfE astate_in_rep_le join_ge1 join_ge2)
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    51
next
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    52
  case (While b c)
44944
f136409c2cef tuned post fixpoint setup
nipkow
parents: 44932
diff changeset
    53
  let ?P = "pfp (AI c) S0"
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    54
  { fix s t have "(WHILE b DO c,s) \<Rightarrow> t \<Longrightarrow> s <: ?P \<Longrightarrow> t <: ?P"
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44944
diff changeset
    55
    proof(induction "WHILE b DO c" s t rule: big_step_induct)
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    56
      case WhileFalse thus ?case by simp
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    57
    next
45015
fdac1e9880eb Updated IMP to use new induction method
nipkow
parents: 44944
diff changeset
    58
      case WhileTrue thus ?case using While.IH pfp astate_in_rep_le by metis
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    59
    qed
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    60
  }
44932
7c93ee993cae revised AbsInt and added widening and narrowing
nipkow
parents: 44923
diff changeset
    61
  with astate_in_rep_le[OF `s <: S0` above]
44656
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    62
  show ?case by (metis While(2) AI.simps(5))
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    63
qed
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    64
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    65
end
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    66
22bbd0d1b943 Added Abstract Interpretation theories
nipkow
parents:
diff changeset
    67
end