src/HOL/IMP/Abs_Int0.thy
changeset 51826 054a40461449
parent 51807 d694233adeae
child 51974 9c80e62161a5
equal deleted inserted replaced
51825:d4f1e439e1bd 51826:054a40461449
     8 
     8 
     9 text{* The basic type classes @{class order}, @{class semilattice_sup} and @{class top} are
     9 text{* The basic type classes @{class order}, @{class semilattice_sup} and @{class top} are
    10 defined in @{theory Main}, more precisely in theories @{theory Orderings} and @{theory Lattices}.
    10 defined in @{theory Main}, more precisely in theories @{theory Orderings} and @{theory Lattices}.
    11 If you view this theory with jedit, just click on the names to get there. *}
    11 If you view this theory with jedit, just click on the names to get there. *}
    12 
    12 
    13 class semilattice = semilattice_sup + top
    13 class semilattice_sup_top = semilattice_sup + top
    14 
    14 
    15 
    15 
    16 instance "fun" :: (type, semilattice) semilattice ..
    16 instance "fun" :: (type, semilattice_sup_top) semilattice_sup_top ..
    17 
    17 
    18 instantiation option :: (order)order
    18 instantiation option :: (order)order
    19 begin
    19 begin
    20 
    20 
    21 fun less_eq_option where
    21 fun less_eq_option where
    56 
    56 
    57 instance ..
    57 instance ..
    58 
    58 
    59 end
    59 end
    60 
    60 
    61 instantiation option :: (semilattice)semilattice
    61 instantiation option :: (semilattice_sup_top)semilattice_sup_top
    62 begin
    62 begin
    63 
    63 
    64 definition top_option where "\<top> = Some \<top>"
    64 definition top_option where "\<top> = Some \<top>"
    65 
    65 
    66 instance proof
    66 instance proof
   147 "\<gamma>_option \<gamma> (Some a) = \<gamma> a"
   147 "\<gamma>_option \<gamma> (Some a) = \<gamma> a"
   148 
   148 
   149 text{* The interface for abstract values: *}
   149 text{* The interface for abstract values: *}
   150 
   150 
   151 locale Val_abs =
   151 locale Val_abs =
   152 fixes \<gamma> :: "'av::semilattice \<Rightarrow> val set"
   152 fixes \<gamma> :: "'av::semilattice_sup_top \<Rightarrow> val set"
   153   assumes mono_gamma: "a \<le> b \<Longrightarrow> \<gamma> a \<le> \<gamma> b"
   153   assumes mono_gamma: "a \<le> b \<Longrightarrow> \<gamma> a \<le> \<gamma> b"
   154   and gamma_Top[simp]: "\<gamma> \<top> = UNIV"
   154   and gamma_Top[simp]: "\<gamma> \<top> = UNIV"
   155 fixes num' :: "val \<Rightarrow> 'av"
   155 fixes num' :: "val \<Rightarrow> 'av"
   156 and plus' :: "'av \<Rightarrow> 'av \<Rightarrow> 'av"
   156 and plus' :: "'av \<Rightarrow> 'av \<Rightarrow> 'av"
   157   assumes gamma_num': "i \<in> \<gamma>(num' i)"
   157   assumes gamma_num': "i \<in> \<gamma>(num' i)"
   158   and gamma_plus': "i1 \<in> \<gamma> a1 \<Longrightarrow> i2 \<in> \<gamma> a2 \<Longrightarrow> i1+i2 \<in> \<gamma>(plus' a1 a2)"
   158   and gamma_plus': "i1 \<in> \<gamma> a1 \<Longrightarrow> i2 \<in> \<gamma> a2 \<Longrightarrow> i1+i2 \<in> \<gamma>(plus' a1 a2)"
   159 
   159 
   160 type_synonym 'av st = "(vname \<Rightarrow> 'av)"
   160 type_synonym 'av st = "(vname \<Rightarrow> 'av)"
   161 
   161 
   162 locale Abs_Int_fun = Val_abs \<gamma> for \<gamma> :: "'av::semilattice \<Rightarrow> val set"
   162 text{* The for-clause (here and elsewhere) only serves the purpose of fixing
       
   163 the name of the type parameter @{typ 'av} which would otherwise be renamed to
       
   164 @{typ 'a}. *}
       
   165 
       
   166 locale Abs_Int_fun = Val_abs where \<gamma>=\<gamma>
       
   167   for \<gamma> :: "'av::semilattice_sup_top \<Rightarrow> val set"
   163 begin
   168 begin
   164 
   169 
   165 fun aval' :: "aexp \<Rightarrow> 'av st \<Rightarrow> 'av" where
   170 fun aval' :: "aexp \<Rightarrow> 'av st \<Rightarrow> 'av" where
   166 "aval' (N i) S = num' i" |
   171 "aval' (N i) S = num' i" |
   167 "aval' (V x) S = S x" |
   172 "aval' (V x) S = S x" |
   347 lemma le_iff_le_annos: "C1 \<le> C2 \<longleftrightarrow>
   352 lemma le_iff_le_annos: "C1 \<le> C2 \<longleftrightarrow>
   348   strip C1 = strip C2 \<and> (\<forall> i<size(annos C1). annos C1 ! i \<le> annos C2 ! i)"
   353   strip C1 = strip C2 \<and> (\<forall> i<size(annos C1). annos C1 ! i \<le> annos C2 ! i)"
   349 by(auto simp add: le_iff_le_annos_zip set_zip) (metis size_annos_same2)
   354 by(auto simp add: le_iff_le_annos_zip set_zip) (metis size_annos_same2)
   350 
   355 
   351 
   356 
   352 locale Measure_fun = Measure1_fun where m=m for m :: "'av::semilattice \<Rightarrow> nat" +
   357 locale Measure_fun = Measure1_fun where m=m
       
   358   for m :: "'av::semilattice_sup_top \<Rightarrow> nat" +
   353 assumes m2: "x < y \<Longrightarrow> m x > m y"
   359 assumes m2: "x < y \<Longrightarrow> m x > m y"
   354 begin
   360 begin
   355 
   361 
   356 text{* The predicates @{text "top_on_ty a X"} that follow describe that any abstract
   362 text{* The predicates @{text "top_on_ty a X"} that follow describe that any abstract
   357 state in @{text a} maps all variables in @{text X} to @{term \<top>}.
   363 state in @{text a} maps all variables in @{text X} to @{term \<top>}.
   463 end
   469 end
   464 
   470 
   465 
   471 
   466 locale Abs_Int_fun_measure =
   472 locale Abs_Int_fun_measure =
   467   Abs_Int_fun_mono where \<gamma>=\<gamma> + Measure_fun where m=m
   473   Abs_Int_fun_mono where \<gamma>=\<gamma> + Measure_fun where m=m
   468   for \<gamma> :: "'av::semilattice \<Rightarrow> val set" and m :: "'av \<Rightarrow> nat"
   474   for \<gamma> :: "'av::semilattice_sup_top \<Rightarrow> val set" and m :: "'av \<Rightarrow> nat"
   469 begin
   475 begin
   470 
   476 
   471 lemma top_on_step': "top_on_acom C (-vars C) \<Longrightarrow> top_on_acom (step' \<top> C) (-vars C)"
   477 lemma top_on_step': "top_on_acom C (-vars C) \<Longrightarrow> top_on_acom (step' \<top> C) (-vars C)"
   472 unfolding step'_def
   478 unfolding step'_def
   473 by(rule top_on_Step)
   479 by(rule top_on_Step)