src/HOL/Library/Linear_Temporal_Logic_on_Streams.thy
author hoelzl
Wed Oct 08 10:22:00 2014 +0200 (2014-10-08)
changeset 58627 1329679abb2d
child 58881 b9556a055632
permissions -rw-r--r--
add Linear Temporal Logic on Streams
hoelzl@58627
     1
(*  Title:      HOL/Library/Linear_Temporal_Logic_on_Streams.thy
hoelzl@58627
     2
    Author:     Andrei Popescu, TU Muenchen
hoelzl@58627
     3
    Author:     Dmitriy Traytel, TU Muenchen
hoelzl@58627
     4
*)
hoelzl@58627
     5
hoelzl@58627
     6
header {* Linear Temporal Logic on Streams *}
hoelzl@58627
     7
hoelzl@58627
     8
theory Linear_Temporal_Logic_on_Streams
hoelzl@58627
     9
  imports Stream Sublist
hoelzl@58627
    10
begin
hoelzl@58627
    11
hoelzl@58627
    12
section{* Preliminaries *}
hoelzl@58627
    13
hoelzl@58627
    14
lemma shift_prefix:
hoelzl@58627
    15
assumes "xl @- xs = yl @- ys" and "length xl \<le> length yl"
hoelzl@58627
    16
shows "prefixeq xl yl"
hoelzl@58627
    17
using assms proof(induct xl arbitrary: yl xs ys)
hoelzl@58627
    18
  case (Cons x xl yl xs ys)
hoelzl@58627
    19
  thus ?case by (cases yl) auto
hoelzl@58627
    20
qed auto
hoelzl@58627
    21
hoelzl@58627
    22
lemma shift_prefix_cases:
hoelzl@58627
    23
assumes "xl @- xs = yl @- ys"
hoelzl@58627
    24
shows "prefixeq xl yl \<or> prefixeq yl xl"
hoelzl@58627
    25
using shift_prefix[OF assms] apply(cases "length xl \<le> length yl")
hoelzl@58627
    26
by (metis, metis assms nat_le_linear shift_prefix)
hoelzl@58627
    27
hoelzl@58627
    28
hoelzl@58627
    29
section{* Linear temporal logic *}
hoelzl@58627
    30
hoelzl@58627
    31
(* Propositional connectives: *)
hoelzl@58627
    32
abbreviation (input) IMPL (infix "impl" 60)
hoelzl@58627
    33
where "\<phi> impl \<psi> \<equiv> \<lambda> xs. \<phi> xs \<longrightarrow> \<psi> xs"
hoelzl@58627
    34
hoelzl@58627
    35
abbreviation (input) OR (infix "or" 60)
hoelzl@58627
    36
where "\<phi> or \<psi> \<equiv> \<lambda> xs. \<phi> xs \<or> \<psi> xs"
hoelzl@58627
    37
hoelzl@58627
    38
abbreviation (input) AND (infix "aand" 60)
hoelzl@58627
    39
where "\<phi> aand \<psi> \<equiv> \<lambda> xs. \<phi> xs \<and> \<psi> xs"
hoelzl@58627
    40
hoelzl@58627
    41
abbreviation (input) "not \<phi> \<equiv> \<lambda> xs. \<not> \<phi> xs"
hoelzl@58627
    42
hoelzl@58627
    43
abbreviation (input) "true \<equiv> \<lambda> xs. True"
hoelzl@58627
    44
hoelzl@58627
    45
abbreviation (input) "false \<equiv> \<lambda> xs. False"
hoelzl@58627
    46
hoelzl@58627
    47
lemma impl_not_or: "\<phi> impl \<psi> = (not \<phi>) or \<psi>"
hoelzl@58627
    48
by blast
hoelzl@58627
    49
hoelzl@58627
    50
lemma not_or: "not (\<phi> or \<psi>) = (not \<phi>) aand (not \<psi>)"
hoelzl@58627
    51
by blast
hoelzl@58627
    52
hoelzl@58627
    53
lemma not_aand: "not (\<phi> aand \<psi>) = (not \<phi>) or (not \<psi>)"
hoelzl@58627
    54
by blast
hoelzl@58627
    55
hoelzl@58627
    56
lemma non_not[simp]: "not (not \<phi>) = \<phi>" by simp
hoelzl@58627
    57
hoelzl@58627
    58
(* Temporal (LTL) connectives: *)
hoelzl@58627
    59
fun holds where "holds P xs \<longleftrightarrow> P (shd xs)"
hoelzl@58627
    60
fun nxt where "nxt \<phi> xs = \<phi> (stl xs)"
hoelzl@58627
    61
hoelzl@58627
    62
inductive ev for \<phi> where
hoelzl@58627
    63
base: "\<phi> xs \<Longrightarrow> ev \<phi> xs"
hoelzl@58627
    64
|
hoelzl@58627
    65
step: "ev \<phi> (stl xs) \<Longrightarrow> ev \<phi> xs"
hoelzl@58627
    66
hoelzl@58627
    67
coinductive alw for \<phi> where
hoelzl@58627
    68
alw: "\<lbrakk>\<phi> xs; alw \<phi> (stl xs)\<rbrakk> \<Longrightarrow> alw \<phi> xs"
hoelzl@58627
    69
hoelzl@58627
    70
(* weak until: *)
hoelzl@58627
    71
coinductive UNTIL (infix "until" 60) for \<phi> \<psi> where
hoelzl@58627
    72
base: "\<psi> xs \<Longrightarrow> (\<phi> until \<psi>) xs"
hoelzl@58627
    73
|
hoelzl@58627
    74
step: "\<lbrakk>\<phi> xs; (\<phi> until \<psi>) (stl xs)\<rbrakk> \<Longrightarrow> (\<phi> until \<psi>) xs"
hoelzl@58627
    75
hoelzl@58627
    76
lemma holds_mono:
hoelzl@58627
    77
assumes holds: "holds P xs" and 0: "\<And> x. P x \<Longrightarrow> Q x"
hoelzl@58627
    78
shows "holds Q xs"
hoelzl@58627
    79
using assms by auto
hoelzl@58627
    80
hoelzl@58627
    81
lemma holds_aand:
hoelzl@58627
    82
"(holds P aand holds Q) steps \<longleftrightarrow> holds (\<lambda> step. P step \<and> Q step) steps" by auto
hoelzl@58627
    83
hoelzl@58627
    84
lemma nxt_mono:
hoelzl@58627
    85
assumes nxt: "nxt \<phi> xs" and 0: "\<And> xs. \<phi> xs \<Longrightarrow> \<psi> xs"
hoelzl@58627
    86
shows "nxt \<psi> xs"
hoelzl@58627
    87
using assms by auto
hoelzl@58627
    88
hoelzl@58627
    89
lemma ev_mono:
hoelzl@58627
    90
assumes ev: "ev \<phi> xs" and 0: "\<And> xs. \<phi> xs \<Longrightarrow> \<psi> xs"
hoelzl@58627
    91
shows "ev \<psi> xs"
hoelzl@58627
    92
using ev by induct (auto intro: ev.intros simp: 0)
hoelzl@58627
    93
hoelzl@58627
    94
lemma alw_mono:
hoelzl@58627
    95
assumes alw: "alw \<phi> xs" and 0: "\<And> xs. \<phi> xs \<Longrightarrow> \<psi> xs"
hoelzl@58627
    96
shows "alw \<psi> xs"
hoelzl@58627
    97
using alw by coinduct (auto elim: alw.cases simp: 0)
hoelzl@58627
    98
hoelzl@58627
    99
lemma until_monoL:
hoelzl@58627
   100
assumes until: "(\<phi>1 until \<psi>) xs" and 0: "\<And> xs. \<phi>1 xs \<Longrightarrow> \<phi>2 xs"
hoelzl@58627
   101
shows "(\<phi>2 until \<psi>) xs"
hoelzl@58627
   102
using until by coinduct (auto elim: UNTIL.cases simp: 0)
hoelzl@58627
   103
hoelzl@58627
   104
lemma until_monoR:
hoelzl@58627
   105
assumes until: "(\<phi> until \<psi>1) xs" and 0: "\<And> xs. \<psi>1 xs \<Longrightarrow> \<psi>2 xs"
hoelzl@58627
   106
shows "(\<phi> until \<psi>2) xs"
hoelzl@58627
   107
using until by coinduct (auto elim: UNTIL.cases simp: 0)
hoelzl@58627
   108
hoelzl@58627
   109
lemma until_mono:
hoelzl@58627
   110
assumes until: "(\<phi>1 until \<psi>1) xs" and
hoelzl@58627
   111
0: "\<And> xs. \<phi>1 xs \<Longrightarrow> \<phi>2 xs" "\<And> xs. \<psi>1 xs \<Longrightarrow> \<psi>2 xs"
hoelzl@58627
   112
shows "(\<phi>2 until \<psi>2) xs"
hoelzl@58627
   113
using until by coinduct (auto elim: UNTIL.cases simp: 0)
hoelzl@58627
   114
hoelzl@58627
   115
lemma until_false: "\<phi> until false = alw \<phi>"
hoelzl@58627
   116
proof-
hoelzl@58627
   117
  {fix xs assume "(\<phi> until false) xs" hence "alw \<phi> xs"
hoelzl@58627
   118
   apply coinduct by (auto elim: UNTIL.cases)
hoelzl@58627
   119
  }
hoelzl@58627
   120
  moreover
hoelzl@58627
   121
  {fix xs assume "alw \<phi> xs" hence "(\<phi> until false) xs"
hoelzl@58627
   122
   apply coinduct by (auto elim: alw.cases)
hoelzl@58627
   123
  }
hoelzl@58627
   124
  ultimately show ?thesis by blast
hoelzl@58627
   125
qed
hoelzl@58627
   126
hoelzl@58627
   127
lemma ev_nxt: "ev \<phi> = (\<phi> or nxt (ev \<phi>))"
hoelzl@58627
   128
apply(rule ext) by (metis ev.simps nxt.simps)
hoelzl@58627
   129
hoelzl@58627
   130
lemma alw_nxt: "alw \<phi> = (\<phi> aand nxt (alw \<phi>))"
hoelzl@58627
   131
apply(rule ext) by (metis alw.simps nxt.simps)
hoelzl@58627
   132
hoelzl@58627
   133
lemma ev_ev[simp]: "ev (ev \<phi>) = ev \<phi>"
hoelzl@58627
   134
proof-
hoelzl@58627
   135
  {fix xs
hoelzl@58627
   136
   assume "ev (ev \<phi>) xs" hence "ev \<phi> xs"
hoelzl@58627
   137
   by induct (auto intro: ev.intros)
hoelzl@58627
   138
  }
hoelzl@58627
   139
  thus ?thesis by (auto intro: ev.intros)
hoelzl@58627
   140
qed
hoelzl@58627
   141
hoelzl@58627
   142
lemma alw_alw[simp]: "alw (alw \<phi>) = alw \<phi>"
hoelzl@58627
   143
proof-
hoelzl@58627
   144
  {fix xs
hoelzl@58627
   145
   assume "alw \<phi> xs" hence "alw (alw \<phi>) xs"
hoelzl@58627
   146
   by coinduct (auto elim: alw.cases)
hoelzl@58627
   147
  }
hoelzl@58627
   148
  thus ?thesis by (auto elim: alw.cases)
hoelzl@58627
   149
qed
hoelzl@58627
   150
hoelzl@58627
   151
lemma ev_shift:
hoelzl@58627
   152
assumes "ev \<phi> xs"
hoelzl@58627
   153
shows "ev \<phi> (xl @- xs)"
hoelzl@58627
   154
using assms by (induct xl) (auto intro: ev.intros)
hoelzl@58627
   155
hoelzl@58627
   156
lemma ev_imp_shift:
hoelzl@58627
   157
assumes "ev \<phi> xs"  shows "\<exists> xl xs2. xs = xl @- xs2 \<and> \<phi> xs2"
hoelzl@58627
   158
using assms by induct (metis shift.simps(1), metis shift.simps(2) stream.collapse)+
hoelzl@58627
   159
hoelzl@58627
   160
lemma alw_ev_shift: "alw \<phi> xs1 \<Longrightarrow> ev (alw \<phi>) (xl @- xs1)"
hoelzl@58627
   161
by (auto intro: ev_shift ev.intros)
hoelzl@58627
   162
hoelzl@58627
   163
lemma alw_shift:
hoelzl@58627
   164
assumes "alw \<phi> (xl @- xs)"
hoelzl@58627
   165
shows "alw \<phi> xs"
hoelzl@58627
   166
using assms by (induct xl) (auto elim: alw.cases)
hoelzl@58627
   167
hoelzl@58627
   168
lemma ev_ex_nxt:
hoelzl@58627
   169
assumes "ev \<phi> xs"
hoelzl@58627
   170
shows "\<exists> n. (nxt ^^ n) \<phi> xs"
hoelzl@58627
   171
using assms proof induct
hoelzl@58627
   172
  case (base xs) thus ?case by (intro exI[of _ 0]) auto
hoelzl@58627
   173
next
hoelzl@58627
   174
  case (step xs)
hoelzl@58627
   175
  then obtain n where "(nxt ^^ n) \<phi> (stl xs)" by blast
hoelzl@58627
   176
  thus ?case by (intro exI[of _ "Suc n"]) (metis funpow.simps(2) nxt.simps o_def)
hoelzl@58627
   177
qed
hoelzl@58627
   178
hoelzl@58627
   179
lemma alw_sdrop:
hoelzl@58627
   180
assumes "alw \<phi> xs"  shows "alw \<phi> (sdrop n xs)"
hoelzl@58627
   181
by (metis alw_shift assms stake_sdrop)
hoelzl@58627
   182
hoelzl@58627
   183
lemma nxt_sdrop: "(nxt ^^ n) \<phi> xs \<longleftrightarrow> \<phi> (sdrop n xs)"
hoelzl@58627
   184
by (induct n arbitrary: xs) auto
hoelzl@58627
   185
hoelzl@58627
   186
definition "wait \<phi> xs \<equiv> LEAST n. (nxt ^^ n) \<phi> xs"
hoelzl@58627
   187
hoelzl@58627
   188
lemma nxt_wait:
hoelzl@58627
   189
assumes "ev \<phi> xs"  shows "(nxt ^^ (wait \<phi> xs)) \<phi> xs"
hoelzl@58627
   190
unfolding wait_def using ev_ex_nxt[OF assms] by(rule LeastI_ex)
hoelzl@58627
   191
hoelzl@58627
   192
lemma nxt_wait_least:
hoelzl@58627
   193
assumes ev: "ev \<phi> xs" and nxt: "(nxt ^^ n) \<phi> xs"  shows "wait \<phi> xs \<le> n"
hoelzl@58627
   194
unfolding wait_def using ev_ex_nxt[OF ev] by (metis Least_le nxt)
hoelzl@58627
   195
hoelzl@58627
   196
lemma sdrop_wait:
hoelzl@58627
   197
assumes "ev \<phi> xs"  shows "\<phi> (sdrop (wait \<phi> xs) xs)"
hoelzl@58627
   198
using nxt_wait[OF assms] unfolding nxt_sdrop .
hoelzl@58627
   199
hoelzl@58627
   200
lemma sdrop_wait_least:
hoelzl@58627
   201
assumes ev: "ev \<phi> xs" and nxt: "\<phi> (sdrop n xs)"  shows "wait \<phi> xs \<le> n"
hoelzl@58627
   202
using assms nxt_wait_least unfolding nxt_sdrop by auto
hoelzl@58627
   203
hoelzl@58627
   204
lemma nxt_ev: "(nxt ^^ n) \<phi> xs \<Longrightarrow> ev \<phi> xs"
hoelzl@58627
   205
by (induct n arbitrary: xs) (auto intro: ev.intros)
hoelzl@58627
   206
hoelzl@58627
   207
lemma not_ev: "not (ev \<phi>) = alw (not \<phi>)"
hoelzl@58627
   208
proof(rule ext, safe)
hoelzl@58627
   209
  fix xs assume "not (ev \<phi>) xs" thus "alw (not \<phi>) xs"
hoelzl@58627
   210
  by (coinduct) (auto intro: ev.intros)
hoelzl@58627
   211
next
hoelzl@58627
   212
  fix xs assume "ev \<phi> xs" and "alw (not \<phi>) xs" thus False
hoelzl@58627
   213
  by (induct) (auto elim: alw.cases)
hoelzl@58627
   214
qed
hoelzl@58627
   215
hoelzl@58627
   216
lemma not_alw: "not (alw \<phi>) = ev (not \<phi>)"
hoelzl@58627
   217
proof-
hoelzl@58627
   218
  have "not (alw \<phi>) = not (alw (not (not \<phi>)))" by simp
hoelzl@58627
   219
  also have "... = ev (not \<phi>)" unfolding not_ev[symmetric] by simp
hoelzl@58627
   220
  finally show ?thesis .
hoelzl@58627
   221
qed
hoelzl@58627
   222
hoelzl@58627
   223
lemma not_ev_not[simp]: "not (ev (not \<phi>)) = alw \<phi>"
hoelzl@58627
   224
unfolding not_ev by simp
hoelzl@58627
   225
hoelzl@58627
   226
lemma not_alw_not[simp]: "not (alw (not \<phi>)) = ev \<phi>"
hoelzl@58627
   227
unfolding not_alw by simp
hoelzl@58627
   228
hoelzl@58627
   229
lemma alw_ev_sdrop:
hoelzl@58627
   230
assumes "alw (ev \<phi>) (sdrop m xs)"
hoelzl@58627
   231
shows "alw (ev \<phi>) xs"
hoelzl@58627
   232
using assms
hoelzl@58627
   233
by coinduct (metis alw_nxt ev_shift funpow_swap1 nxt.simps nxt_sdrop stake_sdrop)
hoelzl@58627
   234
hoelzl@58627
   235
lemma ev_alw_imp_alw_ev:
hoelzl@58627
   236
assumes "ev (alw \<phi>) xs"  shows "alw (ev \<phi>) xs"
hoelzl@58627
   237
using assms apply induct
hoelzl@58627
   238
  apply (metis (full_types) alw_mono ev.base)
hoelzl@58627
   239
  by (metis alw alw_nxt ev.step)
hoelzl@58627
   240
hoelzl@58627
   241
lemma alw_aand: "alw (\<phi> aand \<psi>) = alw \<phi> aand alw \<psi>"
hoelzl@58627
   242
proof-
hoelzl@58627
   243
  {fix xs assume "alw (\<phi> aand \<psi>) xs" hence "(alw \<phi> aand alw \<psi>) xs"
hoelzl@58627
   244
   by (auto elim: alw_mono)
hoelzl@58627
   245
  }
hoelzl@58627
   246
  moreover
hoelzl@58627
   247
  {fix xs assume "(alw \<phi> aand alw \<psi>) xs" hence "alw (\<phi> aand \<psi>) xs"
hoelzl@58627
   248
   by coinduct (auto elim: alw.cases)
hoelzl@58627
   249
  }
hoelzl@58627
   250
  ultimately show ?thesis by blast
hoelzl@58627
   251
qed
hoelzl@58627
   252
hoelzl@58627
   253
lemma ev_or: "ev (\<phi> or \<psi>) = ev \<phi> or ev \<psi>"
hoelzl@58627
   254
proof-
hoelzl@58627
   255
  {fix xs assume "(ev \<phi> or ev \<psi>) xs" hence "ev (\<phi> or \<psi>) xs"
hoelzl@58627
   256
   by (auto elim: ev_mono)
hoelzl@58627
   257
  }
hoelzl@58627
   258
  moreover
hoelzl@58627
   259
  {fix xs assume "ev (\<phi> or \<psi>) xs" hence "(ev \<phi> or ev \<psi>) xs"
hoelzl@58627
   260
   by induct (auto intro: ev.intros)
hoelzl@58627
   261
  }
hoelzl@58627
   262
  ultimately show ?thesis by blast
hoelzl@58627
   263
qed
hoelzl@58627
   264
hoelzl@58627
   265
lemma ev_alw_aand:
hoelzl@58627
   266
assumes \<phi>: "ev (alw \<phi>) xs" and \<psi>: "ev (alw \<psi>) xs"
hoelzl@58627
   267
shows "ev (alw (\<phi> aand \<psi>)) xs"
hoelzl@58627
   268
proof-
hoelzl@58627
   269
  obtain xl xs1 where xs1: "xs = xl @- xs1" and \<phi>\<phi>: "alw \<phi> xs1"
hoelzl@58627
   270
  using \<phi> by (metis ev_imp_shift)
hoelzl@58627
   271
  moreover obtain yl ys1 where xs2: "xs = yl @- ys1" and \<psi>\<psi>: "alw \<psi> ys1"
hoelzl@58627
   272
  using \<psi> by (metis ev_imp_shift)
hoelzl@58627
   273
  ultimately have 0: "xl @- xs1 = yl @- ys1" by auto
hoelzl@58627
   274
  hence "prefixeq xl yl \<or> prefixeq yl xl" using shift_prefix_cases by auto
hoelzl@58627
   275
  thus ?thesis proof
hoelzl@58627
   276
    assume "prefixeq xl yl"
hoelzl@58627
   277
    then obtain yl1 where yl: "yl = xl @ yl1" by (elim prefixeqE)
hoelzl@58627
   278
    have xs1': "xs1 = yl1 @- ys1" using 0 unfolding yl by simp
hoelzl@58627
   279
    have "alw \<phi> ys1" using \<phi>\<phi> unfolding xs1' by (metis alw_shift)
hoelzl@58627
   280
    hence "alw (\<phi> aand \<psi>) ys1" using \<psi>\<psi> unfolding alw_aand by auto
hoelzl@58627
   281
    thus ?thesis unfolding xs2 by (auto intro: alw_ev_shift)
hoelzl@58627
   282
  next
hoelzl@58627
   283
    assume "prefixeq yl xl"
hoelzl@58627
   284
    then obtain xl1 where xl: "xl = yl @ xl1" by (elim prefixeqE)
hoelzl@58627
   285
    have ys1': "ys1 = xl1 @- xs1" using 0 unfolding xl by simp
hoelzl@58627
   286
    have "alw \<psi> xs1" using \<psi>\<psi> unfolding ys1' by (metis alw_shift)
hoelzl@58627
   287
    hence "alw (\<phi> aand \<psi>) xs1" using \<phi>\<phi> unfolding alw_aand by auto
hoelzl@58627
   288
    thus ?thesis unfolding xs1 by (auto intro: alw_ev_shift)
hoelzl@58627
   289
  qed
hoelzl@58627
   290
qed
hoelzl@58627
   291
hoelzl@58627
   292
lemma ev_alw_alw_impl:
hoelzl@58627
   293
assumes "ev (alw \<phi>) xs" and "alw (alw \<phi> impl ev \<psi>) xs"
hoelzl@58627
   294
shows "ev \<psi> xs"
hoelzl@58627
   295
using assms by induct (auto intro: ev.intros elim: alw.cases)
hoelzl@58627
   296
hoelzl@58627
   297
lemma ev_alw_stl[simp]: "ev (alw \<phi>) (stl x) \<longleftrightarrow> ev (alw \<phi>) x"
hoelzl@58627
   298
by (metis (full_types) alw_nxt ev_nxt nxt.simps)
hoelzl@58627
   299
hoelzl@58627
   300
lemma alw_alw_impl_ev:
hoelzl@58627
   301
"alw (alw \<phi> impl ev \<psi>) = (ev (alw \<phi>) impl alw (ev \<psi>))" (is "?A = ?B")
hoelzl@58627
   302
proof-
hoelzl@58627
   303
  {fix xs assume "?A xs \<and> ev (alw \<phi>) xs" hence "alw (ev \<psi>) xs"
hoelzl@58627
   304
   apply coinduct using ev_nxt by (auto elim: ev_alw_alw_impl alw.cases intro: ev.intros)
hoelzl@58627
   305
  }
hoelzl@58627
   306
  moreover
hoelzl@58627
   307
  {fix xs assume "?B xs" hence "?A xs"
hoelzl@58627
   308
   apply coinduct by (auto elim: alw.cases intro: ev.intros)
hoelzl@58627
   309
  }
hoelzl@58627
   310
  ultimately show ?thesis by blast
hoelzl@58627
   311
qed
hoelzl@58627
   312
hoelzl@58627
   313
lemma ev_alw_impl:
hoelzl@58627
   314
assumes "ev \<phi> xs" and "alw (\<phi> impl \<psi>) xs"  shows "ev \<psi> xs"
hoelzl@58627
   315
using assms by induct (auto intro: ev.intros elim: alw.cases)
hoelzl@58627
   316
hoelzl@58627
   317
lemma ev_alw_impl_ev:
hoelzl@58627
   318
assumes "ev \<phi> xs" and "alw (\<phi> impl ev \<psi>) xs"  shows "ev \<psi> xs"
hoelzl@58627
   319
using ev_alw_impl[OF assms] by simp
hoelzl@58627
   320
hoelzl@58627
   321
lemma alw_mp:
hoelzl@58627
   322
assumes "alw \<phi> xs" and "alw (\<phi> impl \<psi>) xs"
hoelzl@58627
   323
shows "alw \<psi> xs"
hoelzl@58627
   324
proof-
hoelzl@58627
   325
  {assume "alw \<phi> xs \<and> alw (\<phi> impl \<psi>) xs" hence ?thesis
hoelzl@58627
   326
   apply coinduct by (auto elim: alw.cases)
hoelzl@58627
   327
  }
hoelzl@58627
   328
  thus ?thesis using assms by auto
hoelzl@58627
   329
qed
hoelzl@58627
   330
hoelzl@58627
   331
lemma all_imp_alw:
hoelzl@58627
   332
assumes "\<And> xs. \<phi> xs"  shows "alw \<phi> xs"
hoelzl@58627
   333
proof-
hoelzl@58627
   334
  {assume "\<forall> xs. \<phi> xs"
hoelzl@58627
   335
   hence ?thesis by coinduct auto
hoelzl@58627
   336
  }
hoelzl@58627
   337
  thus ?thesis using assms by auto
hoelzl@58627
   338
qed
hoelzl@58627
   339
hoelzl@58627
   340
lemma alw_impl_ev_alw:
hoelzl@58627
   341
assumes "alw (\<phi> impl ev \<psi>) xs"
hoelzl@58627
   342
shows "alw (ev \<phi> impl ev \<psi>) xs"
hoelzl@58627
   343
using assms by coinduct (auto elim: alw.cases dest: ev_alw_impl intro: ev.intros)
hoelzl@58627
   344
hoelzl@58627
   345
lemma ev_holds_sset:
hoelzl@58627
   346
"ev (holds P) xs \<longleftrightarrow> (\<exists> x \<in> sset xs. P x)" (is "?L \<longleftrightarrow> ?R")
hoelzl@58627
   347
proof safe
hoelzl@58627
   348
  assume ?L thus ?R by induct (metis holds.simps stream.set_sel(1), metis stl_sset)
hoelzl@58627
   349
next
hoelzl@58627
   350
  fix x assume "x \<in> sset xs" "P x"
hoelzl@58627
   351
  thus ?L by (induct rule: sset_induct) (simp_all add: ev.base ev.step)
hoelzl@58627
   352
qed
hoelzl@58627
   353
hoelzl@58627
   354
(* LTL as a program logic: *)
hoelzl@58627
   355
lemma alw_invar:
hoelzl@58627
   356
assumes "\<phi> xs" and "alw (\<phi> impl nxt \<phi>) xs"
hoelzl@58627
   357
shows "alw \<phi> xs"
hoelzl@58627
   358
proof-
hoelzl@58627
   359
  {assume "\<phi> xs \<and> alw (\<phi> impl nxt \<phi>) xs" hence ?thesis
hoelzl@58627
   360
   apply coinduct by(auto elim: alw.cases)
hoelzl@58627
   361
  }
hoelzl@58627
   362
  thus ?thesis using assms by auto
hoelzl@58627
   363
qed
hoelzl@58627
   364
hoelzl@58627
   365
lemma variance:
hoelzl@58627
   366
assumes 1: "\<phi> xs" and 2: "alw (\<phi> impl (\<psi> or nxt \<phi>)) xs"
hoelzl@58627
   367
shows "(alw \<phi> or ev \<psi>) xs"
hoelzl@58627
   368
proof-
hoelzl@58627
   369
  {assume "\<not> ev \<psi> xs" hence "alw (not \<psi>) xs" unfolding not_ev[symmetric] .
hoelzl@58627
   370
   moreover have "alw (not \<psi> impl (\<phi> impl nxt \<phi>)) xs"
hoelzl@58627
   371
   using 2 by coinduct (auto elim: alw.cases)
hoelzl@58627
   372
   ultimately have "alw (\<phi> impl nxt \<phi>) xs" by(auto dest: alw_mp)
hoelzl@58627
   373
   with 1 have "alw \<phi> xs" by(rule alw_invar)
hoelzl@58627
   374
  }
hoelzl@58627
   375
  thus ?thesis by blast
hoelzl@58627
   376
qed
hoelzl@58627
   377
hoelzl@58627
   378
lemma ev_alw_imp_nxt:
hoelzl@58627
   379
assumes e: "ev \<phi> xs" and a: "alw (\<phi> impl (nxt \<phi>)) xs"
hoelzl@58627
   380
shows "ev (alw \<phi>) xs"
hoelzl@58627
   381
proof-
hoelzl@58627
   382
  obtain xl xs1 where xs: "xs = xl @- xs1" and \<phi>: "\<phi> xs1"
hoelzl@58627
   383
  using e by (metis ev_imp_shift)
hoelzl@58627
   384
  have "\<phi> xs1 \<and> alw (\<phi> impl (nxt \<phi>)) xs1" using a \<phi> unfolding xs by (metis alw_shift)
hoelzl@58627
   385
  hence "alw \<phi> xs1" by(coinduct xs1 rule: alw.coinduct) (auto elim: alw.cases)
hoelzl@58627
   386
  thus ?thesis unfolding xs by (auto intro: alw_ev_shift)
hoelzl@58627
   387
qed
hoelzl@58627
   388
hoelzl@58627
   389
hoelzl@58627
   390
hoelzl@58627
   391
end