src/HOL/ex/CTL.thy
 author nipkow Sun Nov 12 19:22:10 2006 +0100 (2006-11-12) changeset 21312 1d39091a3208 parent 21026 3b2821e0d541 child 21404 eb85850d3eb7 permissions -rw-r--r--
started reorgnization of lattice theories
 bauerg@15871  1 (* Title: HOL/ex/CTL.thy  bauerg@15871  2  ID: $Id$  bauerg@15871  3  Author: Gertrud Bauer  bauerg@15871  4 *)  bauerg@15871  5 bauerg@15871  6 header {* CTL formulae *}  bauerg@15871  7 haftmann@16417  8 theory CTL imports Main begin  bauerg@15871  9 bauerg@15871  10 text {*  bauerg@15871  11  We formalize basic concepts of Computational Tree Logic (CTL)  bauerg@15871  12  \cite{McMillan-PhDThesis,McMillan-LectureNotes} within the  bauerg@15871  13  simply-typed set theory of HOL.  bauerg@15871  14 bauerg@15871  15  By using the common technique of shallow embedding'', a CTL  bauerg@15871  16  formula is identified with the corresponding set of states where it  bauerg@15871  17  holds. Consequently, CTL operations such as negation, conjunction,  bauerg@15871  18  disjunction simply become complement, intersection, union of sets.  bauerg@15871  19  We only require a separate operation for implication, as point-wise  bauerg@15871  20  inclusion is usually not encountered in plain set-theory.  bauerg@15871  21 *}  bauerg@15871  22 bauerg@15871  23 lemmas [intro!] = Int_greatest Un_upper2 Un_upper1 Int_lower1 Int_lower2  bauerg@15871  24 bauerg@15871  25 types 'a ctl = "'a set"  wenzelm@20807  26 wenzelm@20807  27 definition  bauerg@15871  28  imp :: "'a ctl \ 'a ctl \ 'a ctl" (infixr "\" 75)  wenzelm@20807  29  "p \ q = - p \ q"  bauerg@15871  30 wenzelm@20807  31 lemma [intro!]: "p \ p \ q \ q" unfolding imp_def by auto  wenzelm@20807  32 lemma [intro!]: "p \ (q \ p)" unfolding imp_def by rule  bauerg@15871  33 bauerg@15871  34 bauerg@15871  35 text {*  bauerg@15871  36  \smallskip The CTL path operators are more interesting; they are  bauerg@15871  37  based on an arbitrary, but fixed model @{text \}, which is simply  bauerg@15871  38  a transition relation over states @{typ "'a"}.  bauerg@15871  39 *}  bauerg@15871  40 wenzelm@20807  41 axiomatization \ :: "('a \ 'a) set"  bauerg@15871  42 bauerg@15871  43 text {*  bauerg@15871  44  The operators @{text \}, @{text \}, @{text \} are taken  bauerg@15871  45  as primitives, while @{text \}, @{text \}, @{text \} are  bauerg@15871  46  defined as derived ones. The formula @{text "\ p"} holds in a  bauerg@15871  47  state @{term s}, iff there is a successor state @{term s'} (with  bauerg@15871  48  respect to the model @{term \}), such that @{term p} holds in  bauerg@15871  49  @{term s'}. The formula @{text "\ p"} holds in a state @{term  bauerg@15871  50  s}, iff there is a path in @{text \}, starting from @{term s},  bauerg@15871  51  such that there exists a state @{term s'} on the path, such that  bauerg@15871  52  @{term p} holds in @{term s'}. The formula @{text "\ p"} holds  bauerg@15871  53  in a state @{term s}, iff there is a path, starting from @{term s},  bauerg@15871  54  such that for all states @{term s'} on the path, @{term p} holds in  bauerg@15871  55  @{term s'}. It is easy to see that @{text "\ p"} and @{text  bauerg@15871  56  "\ p"} may be expressed using least and greatest fixed points  bauerg@15871  57  \cite{McMillan-PhDThesis}.  bauerg@15871  58 *}  bauerg@15871  59 wenzelm@20807  60 definition  wenzelm@20807  61  EX :: "'a ctl \ 'a ctl" ("\ _" [80] 90) "\ p = {s. \s'. (s, s') \ \ \ s' \ p}"  wenzelm@20807  62  EF :: "'a ctl \ 'a ctl" ("\ _" [80] 90) "\ p = lfp (\s. p \ \ s)"  wenzelm@20807  63  EG :: "'a ctl \ 'a ctl" ("\ _" [80] 90) "\ p = gfp (\s. p \ \ s)"  bauerg@15871  64 bauerg@15871  65 text {*  bauerg@15871  66  @{text "\"}, @{text "\"} and @{text "\"} are now defined  bauerg@15871  67  dually in terms of @{text "\"}, @{text "\"} and @{text  bauerg@15871  68  "\"}.  bauerg@15871  69 *}  bauerg@15871  70 wenzelm@20807  71 definition  wenzelm@20807  72  AX :: "'a ctl \ 'a ctl" ("\ _" [80] 90) "\ p = - \ - p"  wenzelm@20807  73  AF :: "'a ctl \ 'a ctl" ("\ _" [80] 90) "\ p = - \ - p"  wenzelm@20807  74  AG :: "'a ctl \ 'a ctl" ("\ _" [80] 90) "\ p = - \ - p"  bauerg@15871  75 bauerg@15871  76 lemmas [simp] = EX_def EG_def AX_def EF_def AF_def AG_def  bauerg@15871  77 bauerg@15871  78 bauerg@15871  79 section {* Basic fixed point properties *}  bauerg@15871  80 bauerg@15871  81 text {*  bauerg@15871  82  First of all, we use the de-Morgan property of fixed points  bauerg@15871  83 *}  bauerg@15871  84 berghofe@21026  85 lemma lfp_gfp: "lfp f = - gfp (\s::'a set. - (f (- s)))"  bauerg@15871  86 proof  bauerg@15871  87  show "lfp f \ - gfp (\s. - f (- s))"  bauerg@15871  88  proof  bauerg@15871  89  fix x assume l: "x \ lfp f"  bauerg@15871  90  show "x \ - gfp (\s. - f (- s))"  bauerg@15871  91  proof  bauerg@15871  92  assume "x \ gfp (\s. - f (- s))"  berghofe@21026  93  then obtain u where "x \ u" and "u \ - f (- u)"  nipkow@21312  94  by (auto simp add: gfp_def Sup_set_eq)  bauerg@15871  95  then have "f (- u) \ - u" by auto  bauerg@15871  96  then have "lfp f \ - u" by (rule lfp_lowerbound)  bauerg@15871  97  from l and this have "x \ u" by auto  bauerg@15871  98  then show False by contradiction  bauerg@15871  99  qed  bauerg@15871  100  qed  bauerg@15871  101  show "- gfp (\s. - f (- s)) \ lfp f"  bauerg@15871  102  proof (rule lfp_greatest)  bauerg@15871  103  fix u assume "f u \ u"  bauerg@15871  104  then have "- u \ - f u" by auto  bauerg@15871  105  then have "- u \ - f (- (- u))" by simp  bauerg@15871  106  then have "- u \ gfp (\s. - f (- s))" by (rule gfp_upperbound)  bauerg@15871  107  then show "- gfp (\s. - f (- s)) \ u" by auto  bauerg@15871  108  qed  bauerg@15871  109 qed  bauerg@15871  110 berghofe@21026  111 lemma lfp_gfp': "- lfp f = gfp (\s::'a set. - (f (- s)))"  bauerg@15871  112  by (simp add: lfp_gfp)  bauerg@15871  113 berghofe@21026  114 lemma gfp_lfp': "- gfp f = lfp (\s::'a set. - (f (- s)))"  bauerg@15871  115  by (simp add: lfp_gfp)  bauerg@15871  116 bauerg@15871  117 text {*  bauerg@15871  118  in order to give dual fixed point representations of @{term "AF p"}  bauerg@15871  119  and @{term "AG p"}:  bauerg@15871  120 *}  bauerg@15871  121 bauerg@15871  122 lemma AF_lfp: "\ p = lfp (\s. p \ \ s)" by (simp add: lfp_gfp)  bauerg@15871  123 lemma AG_gfp: "\ p = gfp (\s. p \ \ s)" by (simp add: lfp_gfp)  bauerg@15871  124 bauerg@15871  125 lemma EF_fp: "\ p = p \ \ \ p"  bauerg@15871  126 proof -  bauerg@15871  127  have "mono (\s. p \ \ s)" by rule (auto simp add: EX_def)  bauerg@15871  128  then show ?thesis by (simp only: EF_def) (rule lfp_unfold)  bauerg@15871  129 qed  bauerg@15871  130 bauerg@15871  131 lemma AF_fp: "\ p = p \ \ \ p"  bauerg@15871  132 proof -  bauerg@15871  133  have "mono (\s. p \ \ s)" by rule (auto simp add: AX_def EX_def)  bauerg@15871  134  then show ?thesis by (simp only: AF_lfp) (rule lfp_unfold)  bauerg@15871  135 qed  bauerg@15871  136 bauerg@15871  137 lemma EG_fp: "\ p = p \ \ \ p"  bauerg@15871  138 proof -  bauerg@15871  139  have "mono (\s. p \ \ s)" by rule (auto simp add: EX_def)  bauerg@15871  140  then show ?thesis by (simp only: EG_def) (rule gfp_unfold)  bauerg@15871  141 qed  bauerg@15871  142 bauerg@15871  143 text {*  bauerg@15871  144  From the greatest fixed point definition of @{term "\ p"}, we  bauerg@15871  145  derive as a consequence of the Knaster-Tarski theorem on the one  bauerg@15871  146  hand that @{term "\ p"} is a fixed point of the monotonic  bauerg@15871  147  function @{term "\s. p \ \ s"}.  bauerg@15871  148 *}  bauerg@15871  149 bauerg@15871  150 lemma AG_fp: "\ p = p \ \ \ p"  bauerg@15871  151 proof -  bauerg@15871  152  have "mono (\s. p \ \ s)" by rule (auto simp add: AX_def EX_def)  bauerg@15871  153  then show ?thesis by (simp only: AG_gfp) (rule gfp_unfold)  bauerg@15871  154 qed  bauerg@15871  155 bauerg@15871  156 text {*  bauerg@15871  157  This fact may be split up into two inequalities (merely using  bauerg@15871  158  transitivity of @{text "\" }, which is an instance of the overloaded  bauerg@15871  159  @{text "\"} in Isabelle/HOL).  bauerg@15871  160 *}  bauerg@15871  161 bauerg@15871  162 lemma AG_fp_1: "\ p \ p"  bauerg@15871  163 proof -  bauerg@15871  164  note AG_fp also have "p \ \ \ p \ p" by auto  bauerg@15871  165  finally show ?thesis .  bauerg@15871  166 qed  bauerg@15871  167 bauerg@15871  168 lemma AG_fp_2: "\ p \ \ \ p"  bauerg@15871  169 proof -  bauerg@15871  170  note AG_fp also have "p \ \ \ p \ \ \ p" by auto  bauerg@15871  171  finally show ?thesis .  bauerg@15871  172 qed  bauerg@15871  173 bauerg@15871  174 text {*  bauerg@15871  175  On the other hand, we have from the Knaster-Tarski fixed point  bauerg@15871  176  theorem that any other post-fixed point of @{term "\s. p \ AX s"} is  bauerg@15871  177  smaller than @{term "AG p"}. A post-fixed point is a set of states  bauerg@15871  178  @{term q} such that @{term "q \ p \ AX q"}. This leads to the  bauerg@15871  179  following co-induction principle for @{term "AG p"}.  bauerg@15871  180 *}  bauerg@15871  181 bauerg@15871  182 lemma AG_I: "q \ p \ \ q \ q \ \ p"  bauerg@15871  183  by (simp only: AG_gfp) (rule gfp_upperbound)  bauerg@15871  184 bauerg@15871  185 bauerg@15871  186 section {* The tree induction principle \label{sec:calc-ctl-tree-induct} *}  bauerg@15871  187 bauerg@15871  188 text {*  bauerg@15871  189  With the most basic facts available, we are now able to establish a  bauerg@15871  190  few more interesting results, leading to the \emph{tree induction}  bauerg@15871  191  principle for @{text AG} (see below). We will use some elementary  bauerg@15871  192  monotonicity and distributivity rules.  bauerg@15871  193 *}  bauerg@15871  194 bauerg@15871  195 lemma AX_int: "\ (p \ q) = \ p \ \ q" by auto  bauerg@15871  196 lemma AX_mono: "p \ q \ \ p \ \ q" by auto  bauerg@15871  197 lemma AG_mono: "p \ q \ \ p \ \ q"  bauerg@15871  198  by (simp only: AG_gfp, rule gfp_mono) auto  bauerg@15871  199 bauerg@15871  200 text {*  bauerg@15871  201  The formula @{term "AG p"} implies @{term "AX p"} (we use  bauerg@15871  202  substitution of @{text "\"} with monotonicity).  bauerg@15871  203 *}  bauerg@15871  204 bauerg@15871  205 lemma AG_AX: "\ p \ \ p"  bauerg@15871  206 proof -  bauerg@15871  207  have "\ p \ \ \ p" by (rule AG_fp_2)  bauerg@15871  208  also have "\ p \ p" by (rule AG_fp_1) moreover note AX_mono  bauerg@15871  209  finally show ?thesis .  bauerg@15871  210 qed  bauerg@15871  211 bauerg@15871  212 text {*  bauerg@15871  213  Furthermore we show idempotency of the @{text "\"} operator.  bauerg@15871  214  The proof is a good example of how accumulated facts may get  bauerg@15871  215  used to feed a single rule step.  bauerg@15871  216 *}  bauerg@15871  217 bauerg@15871  218 lemma AG_AG: "\ \ p = \ p"  bauerg@15871  219 proof  bauerg@15871  220  show "\ \ p \ \ p" by (rule AG_fp_1)  bauerg@15871  221 next  bauerg@15871  222  show "\ p \ \ \ p"  bauerg@15871  223  proof (rule AG_I)  bauerg@15871  224  have "\ p \ \ p" ..  bauerg@15871  225  moreover have "\ p \ \ \ p" by (rule AG_fp_2)  bauerg@15871  226  ultimately show "\ p \ \ p \ \ \ p" ..  bauerg@15871  227  qed  bauerg@15871  228 qed  bauerg@15871  229 bauerg@15871  230 text {*  bauerg@15871  231  \smallskip We now give an alternative characterization of the @{text  bauerg@15871  232  "\"} operator, which describes the @{text "\"} operator in  bauerg@15871  233  an operational'' way by tree induction: In a state holds @{term  bauerg@15871  234  "AG p"} iff in that state holds @{term p}, and in all reachable  bauerg@15871  235  states @{term s} follows from the fact that @{term p} holds in  bauerg@15871  236  @{term s}, that @{term p} also holds in all successor states of  bauerg@15871  237  @{term s}. We use the co-induction principle @{thm [source] AG_I}  bauerg@15871  238  to establish this in a purely algebraic manner.  bauerg@15871  239 *}  bauerg@15871  240 bauerg@15871  241 theorem AG_induct: "p \ \ (p \ \ p) = \ p"  bauerg@15871  242 proof  bauerg@15871  243  show "p \ \ (p \ \ p) \ \ p" (is "?lhs \ _")  bauerg@15871  244  proof (rule AG_I)  bauerg@15871  245  show "?lhs \ p \ \ ?lhs"  bauerg@15871  246  proof  bauerg@15871  247  show "?lhs \ p" ..  bauerg@15871  248  show "?lhs \ \ ?lhs"  bauerg@15871  249  proof -  bauerg@15871  250  {  bauerg@15871  251  have "\ (p \ \ p) \ p \ \ p" by (rule AG_fp_1)  bauerg@15871  252  also have "p \ p \ \ p \ \ p" ..  bauerg@15871  253  finally have "?lhs \ \ p" by auto  bauerg@15871  254  }  bauerg@15871  255  moreover  bauerg@15871  256  {  bauerg@15871  257  have "p \ \ (p \ \ p) \ \ (p \ \ p)" ..  bauerg@15871  258  also have "\ \ \ \" by (rule AG_fp_2)  bauerg@15871  259  finally have "?lhs \ \ \ (p \ \ p)" .  bauerg@15871  260  }  bauerg@15871  261  ultimately have "?lhs \ \ p \ \ \ (p \ \ p)" ..  bauerg@15871  262  also have "\ = \ ?lhs" by (simp only: AX_int)  bauerg@15871  263  finally show ?thesis .  bauerg@15871  264  qed  bauerg@15871  265  qed  bauerg@15871  266  qed  bauerg@15871  267 next  bauerg@15871  268  show "\ p \ p \ \ (p \ \ p)"  bauerg@15871  269  proof  bauerg@15871  270  show "\ p \ p" by (rule AG_fp_1)  bauerg@15871  271  show "\ p \ \ (p \ \ p)"  bauerg@15871  272  proof -  bauerg@15871  273  have "\ p = \ \ p" by (simp only: AG_AG)  bauerg@15871  274  also have "\ p \ \ p" by (rule AG_AX) moreover note AG_mono  bauerg@15871  275  also have "\ p \ (p \ \ p)" .. moreover note AG_mono  bauerg@15871  276  finally show ?thesis .  bauerg@15871  277  qed  bauerg@15871  278  qed  bauerg@15871  279 qed  bauerg@15871  280 bauerg@15871  281 bauerg@15871  282 section {* An application of tree induction \label{sec:calc-ctl-commute} *}  bauerg@15871  283 bauerg@15871  284 text {*  bauerg@15871  285  Further interesting properties of CTL expressions may be  bauerg@15871  286  demonstrated with the help of tree induction; here we show that  bauerg@15871  287  @{text \} and @{text \} commute.  bauerg@15871  288 *}  bauerg@15871  289 bauerg@15871  290 theorem AG_AX_commute: "\ \ p = \ \ p"  bauerg@15871  291 proof -  bauerg@15871  292  have "\ \ p = \ p \ \ \ \ p" by (rule AG_fp)  bauerg@15871  293  also have "\ = \ (p \ \ \ p)" by (simp only: AX_int)  bauerg@15871  294  also have "p \ \ \ p = \ p" (is "?lhs = _")  bauerg@15871  295  proof  bauerg@15871  296  have "\ p \ p \ \ p" ..  bauerg@15871  297  also have "p \ \ (p \ \ p) = \ p" by (rule AG_induct)  bauerg@15871  298  also note Int_mono AG_mono  bauerg@15871  299  ultimately show "?lhs \ \ p" by fast  bauerg@15871  300  next  bauerg@15871  301  have "\ p \ p" by (rule AG_fp_1)  bauerg@15871  302  moreover  bauerg@15871  303  {  bauerg@15871  304  have "\ p = \ \ p" by (simp only: AG_AG)  bauerg@15871  305  also have "\ p \ \ p" by (rule AG_AX)  bauerg@15871  306  also note AG_mono  bauerg@15871  307  ultimately have "\ p \ \ \ p" .  bauerg@15871  308  }  bauerg@15871  309  ultimately show "\ p \ ?lhs" ..  bauerg@15871  310  qed  bauerg@15871  311  finally show ?thesis .  bauerg@15871  312 qed  bauerg@15871  313 bauerg@15871  314 end