src/HOL/UNITY/UNITY.thy
author hoelzl
Thu Sep 02 10:14:32 2010 +0200 (2010-09-02)
changeset 39072 1030b1a166ef
parent 36866 426d5781bb25
child 45605 a89b4bc311a5
permissions -rw-r--r--
Add lessThan_Suc_eq_insert_0
wenzelm@32960
     1
(*  Title:      HOL/UNITY/UNITY.thy
paulson@4776
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@4776
     3
    Copyright   1998  University of Cambridge
paulson@4776
     4
wenzelm@32960
     5
The basic UNITY theory (revised version, based upon the "co"
wenzelm@32960
     6
operator).
paulson@4776
     7
wenzelm@32960
     8
From Misra, "A Logic for Concurrent Programming", 1994.
paulson@4776
     9
*)
paulson@4776
    10
paulson@13798
    11
header {*The Basic UNITY Theory*}
paulson@13798
    12
haftmann@16417
    13
theory UNITY imports Main begin
paulson@6535
    14
paulson@6535
    15
typedef (Program)
paulson@10064
    16
  'a program = "{(init:: 'a set, acts :: ('a * 'a)set set,
wenzelm@32960
    17
                   allowed :: ('a * 'a)set set). Id \<in> acts & Id: allowed}" 
paulson@13797
    18
  by blast
paulson@6536
    19
haftmann@35416
    20
definition Acts :: "'a program => ('a * 'a)set set" where
wenzelm@14653
    21
    "Acts F == (%(init, acts, allowed). acts) (Rep_Program F)"
wenzelm@14653
    22
haftmann@35416
    23
definition "constrains" :: "['a set, 'a set] => 'a program set"  (infixl "co"     60) where
paulson@13805
    24
    "A co B == {F. \<forall>act \<in> Acts F. act``A \<subseteq> B}"
paulson@13797
    25
haftmann@35416
    26
definition unless  :: "['a set, 'a set] => 'a program set"  (infixl "unless" 60)  where
paulson@13805
    27
    "A unless B == (A-B) co (A \<union> B)"
paulson@13797
    28
haftmann@35416
    29
definition mk_program :: "('a set * ('a * 'a)set set * ('a * 'a)set set)
haftmann@35416
    30
                   => 'a program" where
paulson@10064
    31
    "mk_program == %(init, acts, allowed).
paulson@10064
    32
                      Abs_Program (init, insert Id acts, insert Id allowed)"
paulson@6535
    33
haftmann@35416
    34
definition Init :: "'a program => 'a set" where
paulson@10064
    35
    "Init F == (%(init, acts, allowed). init) (Rep_Program F)"
paulson@6535
    36
haftmann@35416
    37
definition AllowedActs :: "'a program => ('a * 'a)set set" where
paulson@10064
    38
    "AllowedActs F == (%(init, acts, allowed). allowed) (Rep_Program F)"
paulson@10064
    39
haftmann@35416
    40
definition Allowed :: "'a program => 'a program set" where
paulson@13805
    41
    "Allowed F == {G. Acts G \<subseteq> AllowedActs F}"
paulson@4776
    42
haftmann@35416
    43
definition stable     :: "'a set => 'a program set" where
paulson@6536
    44
    "stable A == A co A"
paulson@4776
    45
haftmann@35416
    46
definition strongest_rhs :: "['a program, 'a set] => 'a set" where
paulson@13805
    47
    "strongest_rhs F A == Inter {B. F \<in> A co B}"
paulson@4776
    48
haftmann@35416
    49
definition invariant :: "'a set => 'a program set" where
paulson@13805
    50
    "invariant A == {F. Init F \<subseteq> A} \<inter> stable A"
paulson@4776
    51
haftmann@35416
    52
definition increasing :: "['a => 'b::{order}] => 'a program set" where
paulson@13812
    53
    --{*Polymorphic in both states and the meaning of @{text "\<le>"}*}
paulson@13805
    54
    "increasing f == \<Inter>z. stable {s. z \<le> f s}"
paulson@4776
    55
paulson@6536
    56
wenzelm@24147
    57
text{*Perhaps HOL shouldn't add this in the first place!*}
paulson@13797
    58
declare image_Collect [simp del]
paulson@13797
    59
paulson@16184
    60
subsubsection{*The abstract type of programs*}
paulson@13797
    61
paulson@13797
    62
lemmas program_typedef =
paulson@13797
    63
     Rep_Program Rep_Program_inverse Abs_Program_inverse 
paulson@13797
    64
     Program_def Init_def Acts_def AllowedActs_def mk_program_def
paulson@13797
    65
paulson@13805
    66
lemma Id_in_Acts [iff]: "Id \<in> Acts F"
paulson@13797
    67
apply (cut_tac x = F in Rep_Program)
paulson@13797
    68
apply (auto simp add: program_typedef) 
paulson@13797
    69
done
paulson@13797
    70
paulson@13797
    71
lemma insert_Id_Acts [iff]: "insert Id (Acts F) = Acts F"
paulson@13797
    72
by (simp add: insert_absorb Id_in_Acts)
paulson@13797
    73
paulson@13861
    74
lemma Acts_nonempty [simp]: "Acts F \<noteq> {}"
paulson@13861
    75
by auto
paulson@13861
    76
paulson@13805
    77
lemma Id_in_AllowedActs [iff]: "Id \<in> AllowedActs F"
paulson@13797
    78
apply (cut_tac x = F in Rep_Program)
paulson@13797
    79
apply (auto simp add: program_typedef) 
paulson@13797
    80
done
paulson@13797
    81
paulson@13797
    82
lemma insert_Id_AllowedActs [iff]: "insert Id (AllowedActs F) = AllowedActs F"
paulson@13797
    83
by (simp add: insert_absorb Id_in_AllowedActs)
paulson@13797
    84
paulson@16184
    85
subsubsection{*Inspectors for type "program"*}
paulson@13797
    86
paulson@13797
    87
lemma Init_eq [simp]: "Init (mk_program (init,acts,allowed)) = init"
paulson@13812
    88
by (simp add: program_typedef)
paulson@13797
    89
paulson@13797
    90
lemma Acts_eq [simp]: "Acts (mk_program (init,acts,allowed)) = insert Id acts"
paulson@13812
    91
by (simp add: program_typedef)
paulson@13797
    92
paulson@13797
    93
lemma AllowedActs_eq [simp]:
paulson@13797
    94
     "AllowedActs (mk_program (init,acts,allowed)) = insert Id allowed"
paulson@13812
    95
by (simp add: program_typedef)
paulson@13797
    96
paulson@16184
    97
subsubsection{*Equality for UNITY programs*}
paulson@13797
    98
paulson@13797
    99
lemma surjective_mk_program [simp]:
paulson@13797
   100
     "mk_program (Init F, Acts F, AllowedActs F) = F"
paulson@13797
   101
apply (cut_tac x = F in Rep_Program)
paulson@13797
   102
apply (auto simp add: program_typedef)
paulson@13797
   103
apply (drule_tac f = Abs_Program in arg_cong)+
paulson@13797
   104
apply (simp add: program_typedef insert_absorb)
paulson@13797
   105
done
paulson@13797
   106
paulson@13797
   107
lemma program_equalityI:
paulson@13797
   108
     "[| Init F = Init G; Acts F = Acts G; AllowedActs F = AllowedActs G |]  
paulson@13797
   109
      ==> F = G"
paulson@13797
   110
apply (rule_tac t = F in surjective_mk_program [THEN subst])
paulson@13797
   111
apply (rule_tac t = G in surjective_mk_program [THEN subst], simp)
paulson@13797
   112
done
paulson@13797
   113
paulson@13797
   114
lemma program_equalityE:
paulson@13797
   115
     "[| F = G;  
paulson@13797
   116
         [| Init F = Init G; Acts F = Acts G; AllowedActs F = AllowedActs G |] 
paulson@13797
   117
         ==> P |] ==> P"
paulson@13797
   118
by simp 
paulson@13797
   119
paulson@13797
   120
lemma program_equality_iff:
paulson@13797
   121
     "(F=G) =   
paulson@13797
   122
      (Init F = Init G & Acts F = Acts G &AllowedActs F = AllowedActs G)"
paulson@13797
   123
by (blast intro: program_equalityI program_equalityE)
paulson@13797
   124
paulson@13797
   125
paulson@16184
   126
subsubsection{*co*}
paulson@13797
   127
paulson@13797
   128
lemma constrainsI: 
paulson@13805
   129
    "(!!act s s'. [| act: Acts F;  (s,s') \<in> act;  s \<in> A |] ==> s': A')  
paulson@13805
   130
     ==> F \<in> A co A'"
paulson@13797
   131
by (simp add: constrains_def, blast)
paulson@13797
   132
paulson@13797
   133
lemma constrainsD: 
paulson@13805
   134
    "[| F \<in> A co A'; act: Acts F;  (s,s'): act;  s \<in> A |] ==> s': A'"
paulson@13797
   135
by (unfold constrains_def, blast)
paulson@13797
   136
paulson@13805
   137
lemma constrains_empty [iff]: "F \<in> {} co B"
paulson@13797
   138
by (unfold constrains_def, blast)
paulson@13797
   139
paulson@13805
   140
lemma constrains_empty2 [iff]: "(F \<in> A co {}) = (A={})"
paulson@13797
   141
by (unfold constrains_def, blast)
paulson@13797
   142
paulson@13805
   143
lemma constrains_UNIV [iff]: "(F \<in> UNIV co B) = (B = UNIV)"
paulson@13797
   144
by (unfold constrains_def, blast)
paulson@13797
   145
paulson@13805
   146
lemma constrains_UNIV2 [iff]: "F \<in> A co UNIV"
paulson@13797
   147
by (unfold constrains_def, blast)
paulson@13797
   148
paulson@13812
   149
text{*monotonic in 2nd argument*}
paulson@13797
   150
lemma constrains_weaken_R: 
paulson@13805
   151
    "[| F \<in> A co A'; A'<=B' |] ==> F \<in> A co B'"
paulson@13797
   152
by (unfold constrains_def, blast)
paulson@13797
   153
paulson@13812
   154
text{*anti-monotonic in 1st argument*}
paulson@13797
   155
lemma constrains_weaken_L: 
paulson@13805
   156
    "[| F \<in> A co A'; B \<subseteq> A |] ==> F \<in> B co A'"
paulson@13797
   157
by (unfold constrains_def, blast)
paulson@13797
   158
paulson@13797
   159
lemma constrains_weaken: 
paulson@13805
   160
   "[| F \<in> A co A'; B \<subseteq> A; A'<=B' |] ==> F \<in> B co B'"
paulson@13797
   161
by (unfold constrains_def, blast)
paulson@13797
   162
paulson@16184
   163
subsubsection{*Union*}
paulson@13797
   164
paulson@13797
   165
lemma constrains_Un: 
paulson@13805
   166
    "[| F \<in> A co A'; F \<in> B co B' |] ==> F \<in> (A \<union> B) co (A' \<union> B')"
paulson@13797
   167
by (unfold constrains_def, blast)
paulson@13797
   168
paulson@13797
   169
lemma constrains_UN: 
paulson@13805
   170
    "(!!i. i \<in> I ==> F \<in> (A i) co (A' i)) 
paulson@13805
   171
     ==> F \<in> (\<Union>i \<in> I. A i) co (\<Union>i \<in> I. A' i)"
paulson@13797
   172
by (unfold constrains_def, blast)
paulson@13797
   173
paulson@13805
   174
lemma constrains_Un_distrib: "(A \<union> B) co C = (A co C) \<inter> (B co C)"
paulson@13797
   175
by (unfold constrains_def, blast)
paulson@13797
   176
paulson@13805
   177
lemma constrains_UN_distrib: "(\<Union>i \<in> I. A i) co B = (\<Inter>i \<in> I. A i co B)"
paulson@13797
   178
by (unfold constrains_def, blast)
paulson@13797
   179
paulson@13805
   180
lemma constrains_Int_distrib: "C co (A \<inter> B) = (C co A) \<inter> (C co B)"
paulson@13797
   181
by (unfold constrains_def, blast)
paulson@13797
   182
paulson@13805
   183
lemma constrains_INT_distrib: "A co (\<Inter>i \<in> I. B i) = (\<Inter>i \<in> I. A co B i)"
paulson@13797
   184
by (unfold constrains_def, blast)
paulson@13797
   185
paulson@16184
   186
subsubsection{*Intersection*}
paulson@6536
   187
paulson@13797
   188
lemma constrains_Int: 
paulson@13805
   189
    "[| F \<in> A co A'; F \<in> B co B' |] ==> F \<in> (A \<inter> B) co (A' \<inter> B')"
paulson@13797
   190
by (unfold constrains_def, blast)
paulson@13797
   191
paulson@13797
   192
lemma constrains_INT: 
paulson@13805
   193
    "(!!i. i \<in> I ==> F \<in> (A i) co (A' i)) 
paulson@13805
   194
     ==> F \<in> (\<Inter>i \<in> I. A i) co (\<Inter>i \<in> I. A' i)"
paulson@13797
   195
by (unfold constrains_def, blast)
paulson@13797
   196
paulson@13805
   197
lemma constrains_imp_subset: "F \<in> A co A' ==> A \<subseteq> A'"
paulson@13797
   198
by (unfold constrains_def, auto)
paulson@13797
   199
paulson@13812
   200
text{*The reasoning is by subsets since "co" refers to single actions
paulson@13812
   201
  only.  So this rule isn't that useful.*}
paulson@13797
   202
lemma constrains_trans: 
paulson@13805
   203
    "[| F \<in> A co B; F \<in> B co C |] ==> F \<in> A co C"
paulson@13797
   204
by (unfold constrains_def, blast)
paulson@13797
   205
paulson@13797
   206
lemma constrains_cancel: 
paulson@13805
   207
   "[| F \<in> A co (A' \<union> B); F \<in> B co B' |] ==> F \<in> A co (A' \<union> B')"
paulson@13797
   208
by (unfold constrains_def, clarify, blast)
paulson@13797
   209
paulson@13797
   210
paulson@16184
   211
subsubsection{*unless*}
paulson@13797
   212
paulson@13805
   213
lemma unlessI: "F \<in> (A-B) co (A \<union> B) ==> F \<in> A unless B"
paulson@13797
   214
by (unfold unless_def, assumption)
paulson@13797
   215
paulson@13805
   216
lemma unlessD: "F \<in> A unless B ==> F \<in> (A-B) co (A \<union> B)"
paulson@13797
   217
by (unfold unless_def, assumption)
paulson@13797
   218
paulson@13797
   219
paulson@16184
   220
subsubsection{*stable*}
paulson@13797
   221
paulson@13805
   222
lemma stableI: "F \<in> A co A ==> F \<in> stable A"
paulson@13797
   223
by (unfold stable_def, assumption)
paulson@13797
   224
paulson@13805
   225
lemma stableD: "F \<in> stable A ==> F \<in> A co A"
paulson@13797
   226
by (unfold stable_def, assumption)
paulson@13797
   227
paulson@13797
   228
lemma stable_UNIV [simp]: "stable UNIV = UNIV"
paulson@13797
   229
by (unfold stable_def constrains_def, auto)
paulson@13797
   230
paulson@16184
   231
subsubsection{*Union*}
paulson@13797
   232
paulson@13797
   233
lemma stable_Un: 
paulson@13805
   234
    "[| F \<in> stable A; F \<in> stable A' |] ==> F \<in> stable (A \<union> A')"
paulson@13797
   235
paulson@13797
   236
apply (unfold stable_def)
paulson@13797
   237
apply (blast intro: constrains_Un)
paulson@13797
   238
done
paulson@13797
   239
paulson@13797
   240
lemma stable_UN: 
paulson@13805
   241
    "(!!i. i \<in> I ==> F \<in> stable (A i)) ==> F \<in> stable (\<Union>i \<in> I. A i)"
paulson@13797
   242
apply (unfold stable_def)
paulson@13797
   243
apply (blast intro: constrains_UN)
paulson@13797
   244
done
paulson@13797
   245
paulson@13870
   246
lemma stable_Union: 
paulson@13870
   247
    "(!!A. A \<in> X ==> F \<in> stable A) ==> F \<in> stable (\<Union>X)"
paulson@13870
   248
by (unfold stable_def constrains_def, blast)
paulson@13870
   249
paulson@16184
   250
subsubsection{*Intersection*}
paulson@13797
   251
paulson@13797
   252
lemma stable_Int: 
paulson@13805
   253
    "[| F \<in> stable A;  F \<in> stable A' |] ==> F \<in> stable (A \<inter> A')"
paulson@13797
   254
apply (unfold stable_def)
paulson@13797
   255
apply (blast intro: constrains_Int)
paulson@13797
   256
done
paulson@13797
   257
paulson@13797
   258
lemma stable_INT: 
paulson@13805
   259
    "(!!i. i \<in> I ==> F \<in> stable (A i)) ==> F \<in> stable (\<Inter>i \<in> I. A i)"
paulson@13797
   260
apply (unfold stable_def)
paulson@13797
   261
apply (blast intro: constrains_INT)
paulson@13797
   262
done
paulson@13797
   263
paulson@13870
   264
lemma stable_Inter: 
paulson@13870
   265
    "(!!A. A \<in> X ==> F \<in> stable A) ==> F \<in> stable (\<Inter>X)"
paulson@13870
   266
by (unfold stable_def constrains_def, blast)
paulson@13870
   267
paulson@13797
   268
lemma stable_constrains_Un: 
paulson@13805
   269
    "[| F \<in> stable C; F \<in> A co (C \<union> A') |] ==> F \<in> (C \<union> A) co (C \<union> A')"
paulson@13797
   270
by (unfold stable_def constrains_def, blast)
paulson@13797
   271
paulson@13797
   272
lemma stable_constrains_Int: 
paulson@13805
   273
  "[| F \<in> stable C; F \<in>  (C \<inter> A) co A' |] ==> F \<in> (C \<inter> A) co (C \<inter> A')"
paulson@13797
   274
by (unfold stable_def constrains_def, blast)
paulson@13797
   275
paulson@13805
   276
(*[| F \<in> stable C; F \<in>  (C \<inter> A) co A |] ==> F \<in> stable (C \<inter> A) *)
paulson@13870
   277
lemmas stable_constrains_stable = stable_constrains_Int[THEN stableI, standard]
paulson@13797
   278
paulson@13797
   279
paulson@16184
   280
subsubsection{*invariant*}
paulson@13797
   281
paulson@13805
   282
lemma invariantI: "[| Init F \<subseteq> A;  F \<in> stable A |] ==> F \<in> invariant A"
paulson@13797
   283
by (simp add: invariant_def)
paulson@13797
   284
paulson@14150
   285
text{*Could also say @{term "invariant A \<inter> invariant B \<subseteq> invariant(A \<inter> B)"}*}
paulson@13797
   286
lemma invariant_Int:
paulson@13805
   287
     "[| F \<in> invariant A;  F \<in> invariant B |] ==> F \<in> invariant (A \<inter> B)"
paulson@13797
   288
by (auto simp add: invariant_def stable_Int)
paulson@13797
   289
paulson@13797
   290
paulson@16184
   291
subsubsection{*increasing*}
paulson@13797
   292
paulson@13797
   293
lemma increasingD: 
paulson@13805
   294
     "F \<in> increasing f ==> F \<in> stable {s. z \<subseteq> f s}"
paulson@13797
   295
by (unfold increasing_def, blast)
paulson@13797
   296
paulson@13805
   297
lemma increasing_constant [iff]: "F \<in> increasing (%s. c)"
paulson@13797
   298
by (unfold increasing_def stable_def, auto)
paulson@13797
   299
paulson@13797
   300
lemma mono_increasing_o: 
paulson@13805
   301
     "mono g ==> increasing f \<subseteq> increasing (g o f)"
paulson@13797
   302
apply (unfold increasing_def stable_def constrains_def, auto)
paulson@13797
   303
apply (blast intro: monoD order_trans)
paulson@13797
   304
done
paulson@13797
   305
paulson@13805
   306
(*Holds by the theorem (Suc m \<subseteq> n) = (m < n) *)
paulson@13797
   307
lemma strict_increasingD: 
paulson@13805
   308
     "!!z::nat. F \<in> increasing f ==> F \<in> stable {s. z < f s}"
paulson@13797
   309
by (simp add: increasing_def Suc_le_eq [symmetric])
paulson@13797
   310
paulson@13797
   311
paulson@13797
   312
(** The Elimination Theorem.  The "free" m has become universally quantified!
paulson@13805
   313
    Should the premise be !!m instead of \<forall>m ?  Would make it harder to use
paulson@13797
   314
    in forward proof. **)
paulson@13797
   315
paulson@13797
   316
lemma elimination: 
paulson@13805
   317
    "[| \<forall>m \<in> M. F \<in> {s. s x = m} co (B m) |]  
paulson@13805
   318
     ==> F \<in> {s. s x \<in> M} co (\<Union>m \<in> M. B m)"
paulson@13797
   319
by (unfold constrains_def, blast)
paulson@13797
   320
paulson@13812
   321
text{*As above, but for the trivial case of a one-variable state, in which the
paulson@13812
   322
  state is identified with its one variable.*}
paulson@13797
   323
lemma elimination_sing: 
paulson@13805
   324
    "(\<forall>m \<in> M. F \<in> {m} co (B m)) ==> F \<in> M co (\<Union>m \<in> M. B m)"
paulson@13797
   325
by (unfold constrains_def, blast)
paulson@13797
   326
paulson@13797
   327
paulson@13797
   328
paulson@16184
   329
subsubsection{*Theoretical Results from Section 6*}
paulson@13797
   330
paulson@13797
   331
lemma constrains_strongest_rhs: 
paulson@13805
   332
    "F \<in> A co (strongest_rhs F A )"
paulson@13797
   333
by (unfold constrains_def strongest_rhs_def, blast)
paulson@13797
   334
paulson@13797
   335
lemma strongest_rhs_is_strongest: 
paulson@13805
   336
    "F \<in> A co B ==> strongest_rhs F A \<subseteq> B"
paulson@13797
   337
by (unfold constrains_def strongest_rhs_def, blast)
paulson@13797
   338
paulson@13797
   339
paulson@16184
   340
subsubsection{*Ad-hoc set-theory rules*}
paulson@13797
   341
paulson@13805
   342
lemma Un_Diff_Diff [simp]: "A \<union> B - (A - B) = B"
paulson@13797
   343
by blast
paulson@13797
   344
paulson@13805
   345
lemma Int_Union_Union: "Union(B) \<inter> A = Union((%C. C \<inter> A)`B)"
paulson@13797
   346
by blast
paulson@13797
   347
wenzelm@24147
   348
text{*Needed for WF reasoning in WFair.thy*}
paulson@13797
   349
paulson@13797
   350
lemma Image_less_than [simp]: "less_than `` {k} = greaterThan k"
paulson@13797
   351
by blast
paulson@13797
   352
paulson@13797
   353
lemma Image_inverse_less_than [simp]: "less_than^-1 `` {k} = lessThan k"
paulson@13797
   354
by blast
paulson@6536
   355
paulson@13812
   356
paulson@13812
   357
subsection{*Partial versus Total Transitions*}
paulson@13812
   358
haftmann@35416
   359
definition totalize_act :: "('a * 'a)set => ('a * 'a)set" where
nipkow@30198
   360
    "totalize_act act == act \<union> Id_on (-(Domain act))"
paulson@13812
   361
haftmann@35416
   362
definition totalize :: "'a program => 'a program" where
paulson@13812
   363
    "totalize F == mk_program (Init F,
wenzelm@32960
   364
                               totalize_act ` Acts F,
wenzelm@32960
   365
                               AllowedActs F)"
paulson@13812
   366
haftmann@35416
   367
definition mk_total_program :: "('a set * ('a * 'a)set set * ('a * 'a)set set)
haftmann@35416
   368
                   => 'a program" where
paulson@13812
   369
    "mk_total_program args == totalize (mk_program args)"
paulson@13812
   370
haftmann@35416
   371
definition all_total :: "'a program => bool" where
paulson@13812
   372
    "all_total F == \<forall>act \<in> Acts F. Domain act = UNIV"
paulson@13812
   373
  
paulson@13812
   374
lemma insert_Id_image_Acts: "f Id = Id ==> insert Id (f`Acts F) = f ` Acts F"
paulson@13812
   375
by (blast intro: sym [THEN image_eqI])
paulson@13812
   376
paulson@13812
   377
paulson@16184
   378
subsubsection{*Basic properties*}
paulson@13812
   379
paulson@13812
   380
lemma totalize_act_Id [simp]: "totalize_act Id = Id"
paulson@13812
   381
by (simp add: totalize_act_def) 
paulson@13812
   382
paulson@13812
   383
lemma Domain_totalize_act [simp]: "Domain (totalize_act act) = UNIV"
paulson@13812
   384
by (auto simp add: totalize_act_def)
paulson@13812
   385
paulson@13812
   386
lemma Init_totalize [simp]: "Init (totalize F) = Init F"
paulson@13812
   387
by (unfold totalize_def, auto)
paulson@13812
   388
paulson@13812
   389
lemma Acts_totalize [simp]: "Acts (totalize F) = (totalize_act ` Acts F)"
paulson@13812
   390
by (simp add: totalize_def insert_Id_image_Acts) 
paulson@13812
   391
paulson@13812
   392
lemma AllowedActs_totalize [simp]: "AllowedActs (totalize F) = AllowedActs F"
paulson@13812
   393
by (simp add: totalize_def)
paulson@13812
   394
paulson@13812
   395
lemma totalize_constrains_iff [simp]: "(totalize F \<in> A co B) = (F \<in> A co B)"
paulson@13812
   396
by (simp add: totalize_def totalize_act_def constrains_def, blast)
paulson@13812
   397
paulson@13812
   398
lemma totalize_stable_iff [simp]: "(totalize F \<in> stable A) = (F \<in> stable A)"
paulson@13812
   399
by (simp add: stable_def)
paulson@13812
   400
paulson@13812
   401
lemma totalize_invariant_iff [simp]:
paulson@13812
   402
     "(totalize F \<in> invariant A) = (F \<in> invariant A)"
paulson@13812
   403
by (simp add: invariant_def)
paulson@13812
   404
paulson@13812
   405
lemma all_total_totalize: "all_total (totalize F)"
paulson@13812
   406
by (simp add: totalize_def all_total_def)
paulson@13812
   407
paulson@13812
   408
lemma Domain_iff_totalize_act: "(Domain act = UNIV) = (totalize_act act = act)"
paulson@13812
   409
by (force simp add: totalize_act_def)
paulson@13812
   410
paulson@13812
   411
lemma all_total_imp_totalize: "all_total F ==> (totalize F = F)"
paulson@13812
   412
apply (simp add: all_total_def totalize_def) 
paulson@13812
   413
apply (rule program_equalityI)
paulson@13812
   414
  apply (simp_all add: Domain_iff_totalize_act image_def)
paulson@13812
   415
done
paulson@13812
   416
paulson@13812
   417
lemma all_total_iff_totalize: "all_total F = (totalize F = F)"
paulson@13812
   418
apply (rule iffI) 
paulson@13812
   419
 apply (erule all_total_imp_totalize) 
paulson@13812
   420
apply (erule subst) 
paulson@13812
   421
apply (rule all_total_totalize) 
paulson@13812
   422
done
paulson@13812
   423
paulson@13812
   424
lemma mk_total_program_constrains_iff [simp]:
paulson@13812
   425
     "(mk_total_program args \<in> A co B) = (mk_program args \<in> A co B)"
paulson@13812
   426
by (simp add: mk_total_program_def)
paulson@13812
   427
paulson@13812
   428
paulson@13812
   429
subsection{*Rules for Lazy Definition Expansion*}
paulson@13812
   430
paulson@13812
   431
text{*They avoid expanding the full program, which is a large expression*}
paulson@13812
   432
paulson@13812
   433
lemma def_prg_Init:
wenzelm@36866
   434
     "F = mk_total_program (init,acts,allowed) ==> Init F = init"
paulson@13812
   435
by (simp add: mk_total_program_def)
paulson@13812
   436
paulson@13812
   437
lemma def_prg_Acts:
wenzelm@36866
   438
     "F = mk_total_program (init,acts,allowed) 
paulson@13812
   439
      ==> Acts F = insert Id (totalize_act ` acts)"
paulson@13812
   440
by (simp add: mk_total_program_def)
paulson@13812
   441
paulson@13812
   442
lemma def_prg_AllowedActs:
wenzelm@36866
   443
     "F = mk_total_program (init,acts,allowed)  
paulson@13812
   444
      ==> AllowedActs F = insert Id allowed"
paulson@13812
   445
by (simp add: mk_total_program_def)
paulson@13812
   446
paulson@13812
   447
text{*An action is expanded if a pair of states is being tested against it*}
paulson@13812
   448
lemma def_act_simp:
wenzelm@36866
   449
     "act = {(s,s'). P s s'} ==> ((s,s') \<in> act) = P s s'"
paulson@13812
   450
by (simp add: mk_total_program_def)
paulson@13812
   451
paulson@13812
   452
text{*A set is expanded only if an element is being tested against it*}
wenzelm@36866
   453
lemma def_set_simp: "A = B ==> (x \<in> A) = (x \<in> B)"
paulson@13812
   454
by (simp add: mk_total_program_def)
paulson@13812
   455
paulson@16184
   456
subsubsection{*Inspectors for type "program"*}
paulson@13812
   457
paulson@13812
   458
lemma Init_total_eq [simp]:
paulson@13812
   459
     "Init (mk_total_program (init,acts,allowed)) = init"
paulson@13812
   460
by (simp add: mk_total_program_def)
paulson@13812
   461
paulson@13812
   462
lemma Acts_total_eq [simp]:
paulson@13812
   463
    "Acts(mk_total_program(init,acts,allowed)) = insert Id (totalize_act`acts)"
paulson@13812
   464
by (simp add: mk_total_program_def)
paulson@13812
   465
paulson@13812
   466
lemma AllowedActs_total_eq [simp]:
paulson@13812
   467
     "AllowedActs (mk_total_program (init,acts,allowed)) = insert Id allowed"
paulson@13812
   468
by (auto simp add: mk_total_program_def)
paulson@13812
   469
paulson@4776
   470
end