src/HOL/UNITY/UNITY.thy
changeset 35416 d8d7d1b785af
parent 32960 69916a850301
child 36866 426d5781bb25
equal deleted inserted replaced
35342:4dc65845eab3 35416:d8d7d1b785af
    15 typedef (Program)
    15 typedef (Program)
    16   'a program = "{(init:: 'a set, acts :: ('a * 'a)set set,
    16   'a program = "{(init:: 'a set, acts :: ('a * 'a)set set,
    17                    allowed :: ('a * 'a)set set). Id \<in> acts & Id: allowed}" 
    17                    allowed :: ('a * 'a)set set). Id \<in> acts & Id: allowed}" 
    18   by blast
    18   by blast
    19 
    19 
    20 constdefs
    20 definition Acts :: "'a program => ('a * 'a)set set" where
    21   Acts :: "'a program => ('a * 'a)set set"
       
    22     "Acts F == (%(init, acts, allowed). acts) (Rep_Program F)"
    21     "Acts F == (%(init, acts, allowed). acts) (Rep_Program F)"
    23 
    22 
    24   "constrains" :: "['a set, 'a set] => 'a program set"  (infixl "co"     60)
    23 definition "constrains" :: "['a set, 'a set] => 'a program set"  (infixl "co"     60) where
    25     "A co B == {F. \<forall>act \<in> Acts F. act``A \<subseteq> B}"
    24     "A co B == {F. \<forall>act \<in> Acts F. act``A \<subseteq> B}"
    26 
    25 
    27   unless  :: "['a set, 'a set] => 'a program set"  (infixl "unless" 60)
    26 definition unless  :: "['a set, 'a set] => 'a program set"  (infixl "unless" 60)  where
    28     "A unless B == (A-B) co (A \<union> B)"
    27     "A unless B == (A-B) co (A \<union> B)"
    29 
    28 
    30   mk_program :: "('a set * ('a * 'a)set set * ('a * 'a)set set)
    29 definition mk_program :: "('a set * ('a * 'a)set set * ('a * 'a)set set)
    31                    => 'a program"
    30                    => 'a program" where
    32     "mk_program == %(init, acts, allowed).
    31     "mk_program == %(init, acts, allowed).
    33                       Abs_Program (init, insert Id acts, insert Id allowed)"
    32                       Abs_Program (init, insert Id acts, insert Id allowed)"
    34 
    33 
    35   Init :: "'a program => 'a set"
    34 definition Init :: "'a program => 'a set" where
    36     "Init F == (%(init, acts, allowed). init) (Rep_Program F)"
    35     "Init F == (%(init, acts, allowed). init) (Rep_Program F)"
    37 
    36 
    38   AllowedActs :: "'a program => ('a * 'a)set set"
    37 definition AllowedActs :: "'a program => ('a * 'a)set set" where
    39     "AllowedActs F == (%(init, acts, allowed). allowed) (Rep_Program F)"
    38     "AllowedActs F == (%(init, acts, allowed). allowed) (Rep_Program F)"
    40 
    39 
    41   Allowed :: "'a program => 'a program set"
    40 definition Allowed :: "'a program => 'a program set" where
    42     "Allowed F == {G. Acts G \<subseteq> AllowedActs F}"
    41     "Allowed F == {G. Acts G \<subseteq> AllowedActs F}"
    43 
    42 
    44   stable     :: "'a set => 'a program set"
    43 definition stable     :: "'a set => 'a program set" where
    45     "stable A == A co A"
    44     "stable A == A co A"
    46 
    45 
    47   strongest_rhs :: "['a program, 'a set] => 'a set"
    46 definition strongest_rhs :: "['a program, 'a set] => 'a set" where
    48     "strongest_rhs F A == Inter {B. F \<in> A co B}"
    47     "strongest_rhs F A == Inter {B. F \<in> A co B}"
    49 
    48 
    50   invariant :: "'a set => 'a program set"
    49 definition invariant :: "'a set => 'a program set" where
    51     "invariant A == {F. Init F \<subseteq> A} \<inter> stable A"
    50     "invariant A == {F. Init F \<subseteq> A} \<inter> stable A"
    52 
    51 
    53   increasing :: "['a => 'b::{order}] => 'a program set"
    52 definition increasing :: "['a => 'b::{order}] => 'a program set" where
    54     --{*Polymorphic in both states and the meaning of @{text "\<le>"}*}
    53     --{*Polymorphic in both states and the meaning of @{text "\<le>"}*}
    55     "increasing f == \<Inter>z. stable {s. z \<le> f s}"
    54     "increasing f == \<Inter>z. stable {s. z \<le> f s}"
    56 
    55 
    57 
    56 
    58 text{*Perhaps HOL shouldn't add this in the first place!*}
    57 text{*Perhaps HOL shouldn't add this in the first place!*}
   355 by blast
   354 by blast
   356 
   355 
   357 
   356 
   358 subsection{*Partial versus Total Transitions*}
   357 subsection{*Partial versus Total Transitions*}
   359 
   358 
   360 constdefs
   359 definition totalize_act :: "('a * 'a)set => ('a * 'a)set" where
   361   totalize_act :: "('a * 'a)set => ('a * 'a)set"
       
   362     "totalize_act act == act \<union> Id_on (-(Domain act))"
   360     "totalize_act act == act \<union> Id_on (-(Domain act))"
   363 
   361 
   364   totalize :: "'a program => 'a program"
   362 definition totalize :: "'a program => 'a program" where
   365     "totalize F == mk_program (Init F,
   363     "totalize F == mk_program (Init F,
   366                                totalize_act ` Acts F,
   364                                totalize_act ` Acts F,
   367                                AllowedActs F)"
   365                                AllowedActs F)"
   368 
   366 
   369   mk_total_program :: "('a set * ('a * 'a)set set * ('a * 'a)set set)
   367 definition mk_total_program :: "('a set * ('a * 'a)set set * ('a * 'a)set set)
   370                    => 'a program"
   368                    => 'a program" where
   371     "mk_total_program args == totalize (mk_program args)"
   369     "mk_total_program args == totalize (mk_program args)"
   372 
   370 
   373   all_total :: "'a program => bool"
   371 definition all_total :: "'a program => bool" where
   374     "all_total F == \<forall>act \<in> Acts F. Domain act = UNIV"
   372     "all_total F == \<forall>act \<in> Acts F. Domain act = UNIV"
   375   
   373   
   376 lemma insert_Id_image_Acts: "f Id = Id ==> insert Id (f`Acts F) = f ` Acts F"
   374 lemma insert_Id_image_Acts: "f Id = Id ==> insert Id (f`Acts F) = f ` Acts F"
   377 by (blast intro: sym [THEN image_eqI])
   375 by (blast intro: sym [THEN image_eqI])
   378 
   376