src/HOL/Library/Linear_Temporal_Logic_on_Streams.thy
author wenzelm
Mon, 06 Jul 2015 22:06:02 +0200
changeset 60678 17ba2df56dee
parent 60500 903bb1495239
child 61239 dd949db0ade8
permissions -rw-r--r--
tuned proofs;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58627
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
     1
(*  Title:      HOL/Library/Linear_Temporal_Logic_on_Streams.thy
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
     2
    Author:     Andrei Popescu, TU Muenchen
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
     3
    Author:     Dmitriy Traytel, TU Muenchen
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
     4
*)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
     5
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59000
diff changeset
     6
section \<open>Linear Temporal Logic on Streams\<close>
58627
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
     7
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
     8
theory Linear_Temporal_Logic_on_Streams
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
     9
  imports Stream Sublist Extended_Nat Infinite_Set
58627
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    10
begin
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    11
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59000
diff changeset
    12
section\<open>Preliminaries\<close>
58627
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    13
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    14
lemma shift_prefix:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    15
assumes "xl @- xs = yl @- ys" and "length xl \<le> length yl"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    16
shows "prefixeq xl yl"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    17
using assms proof(induct xl arbitrary: yl xs ys)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    18
  case (Cons x xl yl xs ys)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    19
  thus ?case by (cases yl) auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    20
qed auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    21
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    22
lemma shift_prefix_cases:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    23
assumes "xl @- xs = yl @- ys"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    24
shows "prefixeq xl yl \<or> prefixeq yl xl"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    25
using shift_prefix[OF assms] apply(cases "length xl \<le> length yl")
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    26
by (metis, metis assms nat_le_linear shift_prefix)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    27
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    28
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59000
diff changeset
    29
section\<open>Linear temporal logic\<close>
58627
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    30
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    31
(* Propositional connectives: *)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    32
abbreviation (input) IMPL (infix "impl" 60)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    33
where "\<phi> impl \<psi> \<equiv> \<lambda> xs. \<phi> xs \<longrightarrow> \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    34
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    35
abbreviation (input) OR (infix "or" 60)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    36
where "\<phi> or \<psi> \<equiv> \<lambda> xs. \<phi> xs \<or> \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    37
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    38
abbreviation (input) AND (infix "aand" 60)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    39
where "\<phi> aand \<psi> \<equiv> \<lambda> xs. \<phi> xs \<and> \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    40
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    41
abbreviation (input) "not \<phi> \<equiv> \<lambda> xs. \<not> \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    42
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    43
abbreviation (input) "true \<equiv> \<lambda> xs. True"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    44
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    45
abbreviation (input) "false \<equiv> \<lambda> xs. False"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    46
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    47
lemma impl_not_or: "\<phi> impl \<psi> = (not \<phi>) or \<psi>"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    48
by blast
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    49
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    50
lemma not_or: "not (\<phi> or \<psi>) = (not \<phi>) aand (not \<psi>)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    51
by blast
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    52
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    53
lemma not_aand: "not (\<phi> aand \<psi>) = (not \<phi>) or (not \<psi>)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    54
by blast
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    55
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    56
lemma non_not[simp]: "not (not \<phi>) = \<phi>" by simp
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    57
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    58
(* Temporal (LTL) connectives: *)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    59
fun holds where "holds P xs \<longleftrightarrow> P (shd xs)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    60
fun nxt where "nxt \<phi> xs = \<phi> (stl xs)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    61
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    62
definition "HLD s = holds (\<lambda>x. x \<in> s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    63
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    64
abbreviation HLD_nxt (infixr "\<cdot>" 65) where
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    65
  "s \<cdot> P \<equiv> HLD s aand nxt P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    66
58627
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    67
inductive ev for \<phi> where
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    68
base: "\<phi> xs \<Longrightarrow> ev \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    69
|
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    70
step: "ev \<phi> (stl xs) \<Longrightarrow> ev \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    71
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    72
coinductive alw for \<phi> where
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    73
alw: "\<lbrakk>\<phi> xs; alw \<phi> (stl xs)\<rbrakk> \<Longrightarrow> alw \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    74
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    75
(* weak until: *)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    76
coinductive UNTIL (infix "until" 60) for \<phi> \<psi> where
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    77
base: "\<psi> xs \<Longrightarrow> (\<phi> until \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    78
|
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    79
step: "\<lbrakk>\<phi> xs; (\<phi> until \<psi>) (stl xs)\<rbrakk> \<Longrightarrow> (\<phi> until \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    80
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    81
lemma holds_mono:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    82
assumes holds: "holds P xs" and 0: "\<And> x. P x \<Longrightarrow> Q x"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    83
shows "holds Q xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    84
using assms by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    85
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    86
lemma holds_aand:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    87
"(holds P aand holds Q) steps \<longleftrightarrow> holds (\<lambda> step. P step \<and> Q step) steps" by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    88
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    89
lemma HLD_iff: "HLD s \<omega> \<longleftrightarrow> shd \<omega> \<in> s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    90
  by (simp add: HLD_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    91
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    92
lemma HLD_Stream[simp]: "HLD X (x ## \<omega>) \<longleftrightarrow> x \<in> X"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    93
  by (simp add: HLD_iff)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
    94
58627
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    95
lemma nxt_mono:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    96
assumes nxt: "nxt \<phi> xs" and 0: "\<And> xs. \<phi> xs \<Longrightarrow> \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    97
shows "nxt \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    98
using assms by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
    99
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   100
declare ev.intros[intro]
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   101
declare alw.cases[elim]
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   102
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   103
lemma ev_induct_strong[consumes 1, case_names base step]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   104
  "ev \<phi> x \<Longrightarrow> (\<And>xs. \<phi> xs \<Longrightarrow> P xs) \<Longrightarrow> (\<And>xs. ev \<phi> (stl xs) \<Longrightarrow> \<not> \<phi> xs \<Longrightarrow> P (stl xs) \<Longrightarrow> P xs) \<Longrightarrow> P x"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   105
  by (induct rule: ev.induct) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   106
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   107
lemma alw_coinduct[consumes 1, case_names alw stl]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   108
  "X x \<Longrightarrow> (\<And>x. X x \<Longrightarrow> \<phi> x) \<Longrightarrow> (\<And>x. X x \<Longrightarrow> \<not> alw \<phi> (stl x) \<Longrightarrow> X (stl x)) \<Longrightarrow> alw \<phi> x"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   109
  using alw.coinduct[of X x \<phi>] by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   110
58627
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   111
lemma ev_mono:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   112
assumes ev: "ev \<phi> xs" and 0: "\<And> xs. \<phi> xs \<Longrightarrow> \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   113
shows "ev \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   114
using ev by induct (auto intro: ev.intros simp: 0)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   115
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   116
lemma alw_mono:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   117
assumes alw: "alw \<phi> xs" and 0: "\<And> xs. \<phi> xs \<Longrightarrow> \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   118
shows "alw \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   119
using alw by coinduct (auto elim: alw.cases simp: 0)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   120
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   121
lemma until_monoL:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   122
assumes until: "(\<phi>1 until \<psi>) xs" and 0: "\<And> xs. \<phi>1 xs \<Longrightarrow> \<phi>2 xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   123
shows "(\<phi>2 until \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   124
using until by coinduct (auto elim: UNTIL.cases simp: 0)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   125
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   126
lemma until_monoR:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   127
assumes until: "(\<phi> until \<psi>1) xs" and 0: "\<And> xs. \<psi>1 xs \<Longrightarrow> \<psi>2 xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   128
shows "(\<phi> until \<psi>2) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   129
using until by coinduct (auto elim: UNTIL.cases simp: 0)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   130
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   131
lemma until_mono:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   132
assumes until: "(\<phi>1 until \<psi>1) xs" and
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   133
0: "\<And> xs. \<phi>1 xs \<Longrightarrow> \<phi>2 xs" "\<And> xs. \<psi>1 xs \<Longrightarrow> \<psi>2 xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   134
shows "(\<phi>2 until \<psi>2) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   135
using until by coinduct (auto elim: UNTIL.cases simp: 0)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   136
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   137
lemma until_false: "\<phi> until false = alw \<phi>"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   138
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   139
  {fix xs assume "(\<phi> until false) xs" hence "alw \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   140
   apply coinduct by (auto elim: UNTIL.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   141
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   142
  moreover
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   143
  {fix xs assume "alw \<phi> xs" hence "(\<phi> until false) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   144
   apply coinduct by (auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   145
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   146
  ultimately show ?thesis by blast
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   147
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   148
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   149
lemma ev_nxt: "ev \<phi> = (\<phi> or nxt (ev \<phi>))"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   150
apply(rule ext) by (metis ev.simps nxt.simps)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   151
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   152
lemma alw_nxt: "alw \<phi> = (\<phi> aand nxt (alw \<phi>))"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   153
apply(rule ext) by (metis alw.simps nxt.simps)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   154
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   155
lemma ev_ev[simp]: "ev (ev \<phi>) = ev \<phi>"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   156
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   157
  {fix xs
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   158
   assume "ev (ev \<phi>) xs" hence "ev \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   159
   by induct (auto intro: ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   160
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   161
  thus ?thesis by (auto intro: ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   162
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   163
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   164
lemma alw_alw[simp]: "alw (alw \<phi>) = alw \<phi>"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   165
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   166
  {fix xs
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   167
   assume "alw \<phi> xs" hence "alw (alw \<phi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   168
   by coinduct (auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   169
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   170
  thus ?thesis by (auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   171
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   172
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   173
lemma ev_shift:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   174
assumes "ev \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   175
shows "ev \<phi> (xl @- xs)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   176
using assms by (induct xl) (auto intro: ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   177
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   178
lemma ev_imp_shift:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   179
assumes "ev \<phi> xs"  shows "\<exists> xl xs2. xs = xl @- xs2 \<and> \<phi> xs2"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   180
using assms by induct (metis shift.simps(1), metis shift.simps(2) stream.collapse)+
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   181
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   182
lemma alw_ev_shift: "alw \<phi> xs1 \<Longrightarrow> ev (alw \<phi>) (xl @- xs1)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   183
by (auto intro: ev_shift ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   184
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   185
lemma alw_shift:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   186
assumes "alw \<phi> (xl @- xs)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   187
shows "alw \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   188
using assms by (induct xl) (auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   189
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   190
lemma ev_ex_nxt:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   191
assumes "ev \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   192
shows "\<exists> n. (nxt ^^ n) \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   193
using assms proof induct
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   194
  case (base xs) thus ?case by (intro exI[of _ 0]) auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   195
next
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   196
  case (step xs)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   197
  then obtain n where "(nxt ^^ n) \<phi> (stl xs)" by blast
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   198
  thus ?case by (intro exI[of _ "Suc n"]) (metis funpow.simps(2) nxt.simps o_def)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   199
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   200
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   201
lemma alw_sdrop:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   202
assumes "alw \<phi> xs"  shows "alw \<phi> (sdrop n xs)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   203
by (metis alw_shift assms stake_sdrop)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   204
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   205
lemma nxt_sdrop: "(nxt ^^ n) \<phi> xs \<longleftrightarrow> \<phi> (sdrop n xs)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   206
by (induct n arbitrary: xs) auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   207
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   208
definition "wait \<phi> xs \<equiv> LEAST n. (nxt ^^ n) \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   209
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   210
lemma nxt_wait:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   211
assumes "ev \<phi> xs"  shows "(nxt ^^ (wait \<phi> xs)) \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   212
unfolding wait_def using ev_ex_nxt[OF assms] by(rule LeastI_ex)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   213
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   214
lemma nxt_wait_least:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   215
assumes ev: "ev \<phi> xs" and nxt: "(nxt ^^ n) \<phi> xs"  shows "wait \<phi> xs \<le> n"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   216
unfolding wait_def using ev_ex_nxt[OF ev] by (metis Least_le nxt)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   217
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   218
lemma sdrop_wait:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   219
assumes "ev \<phi> xs"  shows "\<phi> (sdrop (wait \<phi> xs) xs)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   220
using nxt_wait[OF assms] unfolding nxt_sdrop .
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   221
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   222
lemma sdrop_wait_least:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   223
assumes ev: "ev \<phi> xs" and nxt: "\<phi> (sdrop n xs)"  shows "wait \<phi> xs \<le> n"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   224
using assms nxt_wait_least unfolding nxt_sdrop by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   225
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   226
lemma nxt_ev: "(nxt ^^ n) \<phi> xs \<Longrightarrow> ev \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   227
by (induct n arbitrary: xs) (auto intro: ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   228
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   229
lemma not_ev: "not (ev \<phi>) = alw (not \<phi>)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   230
proof(rule ext, safe)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   231
  fix xs assume "not (ev \<phi>) xs" thus "alw (not \<phi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   232
  by (coinduct) (auto intro: ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   233
next
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   234
  fix xs assume "ev \<phi> xs" and "alw (not \<phi>) xs" thus False
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   235
  by (induct) (auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   236
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   237
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   238
lemma not_alw: "not (alw \<phi>) = ev (not \<phi>)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   239
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   240
  have "not (alw \<phi>) = not (alw (not (not \<phi>)))" by simp
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   241
  also have "... = ev (not \<phi>)" unfolding not_ev[symmetric] by simp
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   242
  finally show ?thesis .
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   243
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   244
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   245
lemma not_ev_not[simp]: "not (ev (not \<phi>)) = alw \<phi>"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   246
unfolding not_ev by simp
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   247
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   248
lemma not_alw_not[simp]: "not (alw (not \<phi>)) = ev \<phi>"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   249
unfolding not_alw by simp
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   250
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   251
lemma alw_ev_sdrop:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   252
assumes "alw (ev \<phi>) (sdrop m xs)"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   253
shows "alw (ev \<phi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   254
using assms
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   255
by coinduct (metis alw_nxt ev_shift funpow_swap1 nxt.simps nxt_sdrop stake_sdrop)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   256
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   257
lemma ev_alw_imp_alw_ev:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   258
assumes "ev (alw \<phi>) xs"  shows "alw (ev \<phi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   259
using assms apply induct
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   260
  apply (metis (full_types) alw_mono ev.base)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   261
  by (metis alw alw_nxt ev.step)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   262
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   263
lemma alw_aand: "alw (\<phi> aand \<psi>) = alw \<phi> aand alw \<psi>"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   264
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   265
  {fix xs assume "alw (\<phi> aand \<psi>) xs" hence "(alw \<phi> aand alw \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   266
   by (auto elim: alw_mono)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   267
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   268
  moreover
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   269
  {fix xs assume "(alw \<phi> aand alw \<psi>) xs" hence "alw (\<phi> aand \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   270
   by coinduct (auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   271
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   272
  ultimately show ?thesis by blast
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   273
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   274
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   275
lemma ev_or: "ev (\<phi> or \<psi>) = ev \<phi> or ev \<psi>"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   276
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   277
  {fix xs assume "(ev \<phi> or ev \<psi>) xs" hence "ev (\<phi> or \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   278
   by (auto elim: ev_mono)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   279
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   280
  moreover
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   281
  {fix xs assume "ev (\<phi> or \<psi>) xs" hence "(ev \<phi> or ev \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   282
   by induct (auto intro: ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   283
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   284
  ultimately show ?thesis by blast
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   285
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   286
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   287
lemma ev_alw_aand:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   288
assumes \<phi>: "ev (alw \<phi>) xs" and \<psi>: "ev (alw \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   289
shows "ev (alw (\<phi> aand \<psi>)) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   290
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   291
  obtain xl xs1 where xs1: "xs = xl @- xs1" and \<phi>\<phi>: "alw \<phi> xs1"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   292
  using \<phi> by (metis ev_imp_shift)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   293
  moreover obtain yl ys1 where xs2: "xs = yl @- ys1" and \<psi>\<psi>: "alw \<psi> ys1"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   294
  using \<psi> by (metis ev_imp_shift)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   295
  ultimately have 0: "xl @- xs1 = yl @- ys1" by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   296
  hence "prefixeq xl yl \<or> prefixeq yl xl" using shift_prefix_cases by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   297
  thus ?thesis proof
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   298
    assume "prefixeq xl yl"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   299
    then obtain yl1 where yl: "yl = xl @ yl1" by (elim prefixeqE)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   300
    have xs1': "xs1 = yl1 @- ys1" using 0 unfolding yl by simp
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   301
    have "alw \<phi> ys1" using \<phi>\<phi> unfolding xs1' by (metis alw_shift)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   302
    hence "alw (\<phi> aand \<psi>) ys1" using \<psi>\<psi> unfolding alw_aand by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   303
    thus ?thesis unfolding xs2 by (auto intro: alw_ev_shift)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   304
  next
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   305
    assume "prefixeq yl xl"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   306
    then obtain xl1 where xl: "xl = yl @ xl1" by (elim prefixeqE)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   307
    have ys1': "ys1 = xl1 @- xs1" using 0 unfolding xl by simp
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   308
    have "alw \<psi> xs1" using \<psi>\<psi> unfolding ys1' by (metis alw_shift)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   309
    hence "alw (\<phi> aand \<psi>) xs1" using \<phi>\<phi> unfolding alw_aand by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   310
    thus ?thesis unfolding xs1 by (auto intro: alw_ev_shift)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   311
  qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   312
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   313
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   314
lemma ev_alw_alw_impl:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   315
assumes "ev (alw \<phi>) xs" and "alw (alw \<phi> impl ev \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   316
shows "ev \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   317
using assms by induct (auto intro: ev.intros elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   318
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   319
lemma ev_alw_stl[simp]: "ev (alw \<phi>) (stl x) \<longleftrightarrow> ev (alw \<phi>) x"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   320
by (metis (full_types) alw_nxt ev_nxt nxt.simps)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   321
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   322
lemma alw_alw_impl_ev:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   323
"alw (alw \<phi> impl ev \<psi>) = (ev (alw \<phi>) impl alw (ev \<psi>))" (is "?A = ?B")
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   324
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   325
  {fix xs assume "?A xs \<and> ev (alw \<phi>) xs" hence "alw (ev \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   326
   apply coinduct using ev_nxt by (auto elim: ev_alw_alw_impl alw.cases intro: ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   327
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   328
  moreover
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   329
  {fix xs assume "?B xs" hence "?A xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   330
   apply coinduct by (auto elim: alw.cases intro: ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   331
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   332
  ultimately show ?thesis by blast
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   333
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   334
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   335
lemma ev_alw_impl:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   336
assumes "ev \<phi> xs" and "alw (\<phi> impl \<psi>) xs"  shows "ev \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   337
using assms by induct (auto intro: ev.intros elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   338
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   339
lemma ev_alw_impl_ev:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   340
assumes "ev \<phi> xs" and "alw (\<phi> impl ev \<psi>) xs"  shows "ev \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   341
using ev_alw_impl[OF assms] by simp
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   342
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   343
lemma alw_mp:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   344
assumes "alw \<phi> xs" and "alw (\<phi> impl \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   345
shows "alw \<psi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   346
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   347
  {assume "alw \<phi> xs \<and> alw (\<phi> impl \<psi>) xs" hence ?thesis
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   348
   apply coinduct by (auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   349
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   350
  thus ?thesis using assms by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   351
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   352
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   353
lemma all_imp_alw:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   354
assumes "\<And> xs. \<phi> xs"  shows "alw \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   355
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   356
  {assume "\<forall> xs. \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   357
   hence ?thesis by coinduct auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   358
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   359
  thus ?thesis using assms by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   360
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   361
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   362
lemma alw_impl_ev_alw:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   363
assumes "alw (\<phi> impl ev \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   364
shows "alw (ev \<phi> impl ev \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   365
using assms by coinduct (auto elim: alw.cases dest: ev_alw_impl intro: ev.intros)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   366
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   367
lemma ev_holds_sset:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   368
"ev (holds P) xs \<longleftrightarrow> (\<exists> x \<in> sset xs. P x)" (is "?L \<longleftrightarrow> ?R")
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   369
proof safe
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   370
  assume ?L thus ?R by induct (metis holds.simps stream.set_sel(1), metis stl_sset)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   371
next
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   372
  fix x assume "x \<in> sset xs" "P x"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   373
  thus ?L by (induct rule: sset_induct) (simp_all add: ev.base ev.step)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   374
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   375
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   376
(* LTL as a program logic: *)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   377
lemma alw_invar:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   378
assumes "\<phi> xs" and "alw (\<phi> impl nxt \<phi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   379
shows "alw \<phi> xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   380
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   381
  {assume "\<phi> xs \<and> alw (\<phi> impl nxt \<phi>) xs" hence ?thesis
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   382
   apply coinduct by(auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   383
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   384
  thus ?thesis using assms by auto
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   385
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   386
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   387
lemma variance:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   388
assumes 1: "\<phi> xs" and 2: "alw (\<phi> impl (\<psi> or nxt \<phi>)) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   389
shows "(alw \<phi> or ev \<psi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   390
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   391
  {assume "\<not> ev \<psi> xs" hence "alw (not \<psi>) xs" unfolding not_ev[symmetric] .
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   392
   moreover have "alw (not \<psi> impl (\<phi> impl nxt \<phi>)) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   393
   using 2 by coinduct (auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   394
   ultimately have "alw (\<phi> impl nxt \<phi>) xs" by(auto dest: alw_mp)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   395
   with 1 have "alw \<phi> xs" by(rule alw_invar)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   396
  }
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   397
  thus ?thesis by blast
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   398
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   399
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   400
lemma ev_alw_imp_nxt:
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   401
assumes e: "ev \<phi> xs" and a: "alw (\<phi> impl (nxt \<phi>)) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   402
shows "ev (alw \<phi>) xs"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   403
proof-
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   404
  obtain xl xs1 where xs: "xs = xl @- xs1" and \<phi>: "\<phi> xs1"
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   405
  using e by (metis ev_imp_shift)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   406
  have "\<phi> xs1 \<and> alw (\<phi> impl (nxt \<phi>)) xs1" using a \<phi> unfolding xs by (metis alw_shift)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   407
  hence "alw \<phi> xs1" by(coinduct xs1 rule: alw.coinduct) (auto elim: alw.cases)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   408
  thus ?thesis unfolding xs by (auto intro: alw_ev_shift)
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   409
qed
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   410
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   411
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   412
inductive ev_at :: "('a stream \<Rightarrow> bool) \<Rightarrow> nat \<Rightarrow> 'a stream \<Rightarrow> bool" for P :: "'a stream \<Rightarrow> bool" where
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   413
  base: "P \<omega> \<Longrightarrow> ev_at P 0 \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   414
| step:"\<not> P \<omega> \<Longrightarrow> ev_at P n (stl \<omega>) \<Longrightarrow> ev_at P (Suc n) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   415
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   416
inductive_simps ev_at_0[simp]: "ev_at P 0 \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   417
inductive_simps ev_at_Suc[simp]: "ev_at P (Suc n) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   418
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   419
lemma ev_at_imp_snth: "ev_at P n \<omega> \<Longrightarrow> P (sdrop n \<omega>)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   420
  by (induction n arbitrary: \<omega>) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   421
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   422
lemma ev_at_HLD_imp_snth: "ev_at (HLD X) n \<omega> \<Longrightarrow> \<omega> !! n \<in> X"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   423
  by (auto dest!: ev_at_imp_snth simp: HLD_iff)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   424
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   425
lemma ev_at_HLD_single_imp_snth: "ev_at (HLD {x}) n \<omega> \<Longrightarrow> \<omega> !! n = x"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   426
  by (drule ev_at_HLD_imp_snth) simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   427
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   428
lemma ev_at_unique: "ev_at P n \<omega> \<Longrightarrow> ev_at P m \<omega> \<Longrightarrow> n = m"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   429
proof (induction arbitrary: m rule: ev_at.induct)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   430
  case (base \<omega>) then show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   431
    by (simp add: ev_at.simps[of _ _ \<omega>])
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   432
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   433
  case (step \<omega> n) from step.prems step.hyps step.IH[of "m - 1"] show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   434
    by (auto simp add: ev_at.simps[of _ _ \<omega>])
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   435
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   436
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   437
lemma ev_iff_ev_at: "ev P \<omega> \<longleftrightarrow> (\<exists>n. ev_at P n \<omega>)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   438
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   439
  assume "ev P \<omega>" then show "\<exists>n. ev_at P n \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   440
    by (induction rule: ev_induct_strong) (auto intro: ev_at.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   441
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   442
  assume "\<exists>n. ev_at P n \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   443
  then obtain n where "ev_at P n \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   444
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   445
  then show "ev P \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   446
    by induction auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   447
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   448
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   449
lemma ev_at_shift: "ev_at (HLD X) i (stake (Suc i) \<omega> @- \<omega>' :: 's stream) \<longleftrightarrow> ev_at (HLD X) i \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   450
  by (induction i arbitrary: \<omega>) (auto simp: HLD_iff)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   451
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   452
lemma ev_iff_ev_at_unqiue: "ev P \<omega> \<longleftrightarrow> (\<exists>!n. ev_at P n \<omega>)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   453
  by (auto intro: ev_at_unique simp: ev_iff_ev_at)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   454
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   455
lemma alw_HLD_iff_streams: "alw (HLD X) \<omega> \<longleftrightarrow> \<omega> \<in> streams X"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   456
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   457
  assume "alw (HLD X) \<omega>" then show "\<omega> \<in> streams X"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   458
  proof (coinduction arbitrary: \<omega>)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   459
    case (streams \<omega>) then show ?case by (cases \<omega>) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   460
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   461
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   462
  assume "\<omega> \<in> streams X" then show "alw (HLD X) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   463
  proof (coinduction arbitrary: \<omega>)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   464
    case (alw \<omega>) then show ?case by (cases \<omega>) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   465
  qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   466
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   467
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   468
lemma not_HLD: "not (HLD X) = HLD (- X)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   469
  by (auto simp: HLD_iff)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   470
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   471
lemma not_alw_iff: "\<not> (alw P \<omega>) \<longleftrightarrow> ev (not P) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   472
  using not_alw[of P] by (simp add: fun_eq_iff)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   473
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   474
lemma not_ev_iff: "\<not> (ev P \<omega>) \<longleftrightarrow> alw (not P) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   475
  using not_alw_iff[of "not P" \<omega>, symmetric]  by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   476
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   477
lemma ev_Stream: "ev P (x ## s) \<longleftrightarrow> P (x ## s) \<or> ev P s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   478
  by (auto elim: ev.cases)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   479
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   480
lemma alw_ev_imp_ev_alw:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   481
  assumes "alw (ev P) \<omega>" shows "ev (P aand alw (ev P)) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   482
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   483
  have "ev P \<omega>" using assms by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   484
  from this assms show ?thesis
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   485
    by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   486
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   487
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   488
lemma ev_False: "ev (\<lambda>x. False) \<omega> \<longleftrightarrow> False"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   489
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   490
  assume "ev (\<lambda>x. False) \<omega>" then show False
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   491
    by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   492
qed auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   493
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   494
lemma alw_False: "alw (\<lambda>x. False) \<omega> \<longleftrightarrow> False"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   495
  by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   496
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   497
lemma ev_iff_sdrop: "ev P \<omega> \<longleftrightarrow> (\<exists>m. P (sdrop m \<omega>))"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   498
proof safe
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   499
  assume "ev P \<omega>" then show "\<exists>m. P (sdrop m \<omega>)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   500
    by (induct rule: ev_induct_strong) (auto intro: exI[of _ 0] exI[of _ "Suc n" for n])
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   501
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   502
  fix m assume "P (sdrop m \<omega>)" then show "ev P \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   503
    by (induct m arbitrary: \<omega>) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   504
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   505
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   506
lemma alw_iff_sdrop: "alw P \<omega> \<longleftrightarrow> (\<forall>m. P (sdrop m \<omega>))"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   507
proof safe
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   508
  fix m assume "alw P \<omega>" then show "P (sdrop m \<omega>)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   509
    by (induct m arbitrary: \<omega>) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   510
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   511
  assume "\<forall>m. P (sdrop m \<omega>)" then show "alw P \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   512
    by (coinduction arbitrary: \<omega>) (auto elim: allE[of _ 0] allE[of _ "Suc n" for n])
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   513
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   514
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   515
lemma infinite_iff_alw_ev: "infinite {m. P (sdrop m \<omega>)} \<longleftrightarrow> alw (ev P) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   516
  unfolding infinite_nat_iff_unbounded_le alw_iff_sdrop ev_iff_sdrop
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   517
  by simp (metis le_Suc_ex le_add1)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   518
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   519
lemma alw_inv:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   520
  assumes stl: "\<And>s. f (stl s) = stl (f s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   521
  shows "alw P (f s) \<longleftrightarrow> alw (\<lambda>x. P (f x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   522
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   523
  assume "alw P (f s)" then show "alw (\<lambda>x. P (f x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   524
    by (coinduction arbitrary: s rule: alw_coinduct)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   525
       (auto simp: stl)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   526
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   527
  assume "alw (\<lambda>x. P (f x)) s" then show "alw P (f s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   528
    by (coinduction arbitrary: s rule: alw_coinduct) (auto simp: stl[symmetric])
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   529
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   530
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   531
lemma ev_inv:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   532
  assumes stl: "\<And>s. f (stl s) = stl (f s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   533
  shows "ev P (f s) \<longleftrightarrow> ev (\<lambda>x. P (f x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   534
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   535
  assume "ev P (f s)" then show "ev (\<lambda>x. P (f x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   536
    by (induction "f s" arbitrary: s) (auto simp: stl)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   537
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   538
  assume "ev (\<lambda>x. P (f x)) s" then show "ev P (f s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   539
    by induction (auto simp: stl[symmetric])
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   540
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   541
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   542
lemma alw_smap: "alw P (smap f s) \<longleftrightarrow> alw (\<lambda>x. P (smap f x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   543
  by (rule alw_inv) simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   544
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   545
lemma ev_smap: "ev P (smap f s) \<longleftrightarrow> ev (\<lambda>x. P (smap f x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   546
  by (rule ev_inv) simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   547
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   548
lemma alw_cong:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   549
  assumes P: "alw P \<omega>" and eq: "\<And>\<omega>. P \<omega> \<Longrightarrow> Q1 \<omega> \<longleftrightarrow> Q2 \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   550
  shows "alw Q1 \<omega> \<longleftrightarrow> alw Q2 \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   551
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   552
  from eq have "(alw P aand Q1) = (alw P aand Q2)" by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   553
  then have "alw (alw P aand Q1) \<omega> = alw (alw P aand Q2) \<omega>" by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   554
  with P show "alw Q1 \<omega> \<longleftrightarrow> alw Q2 \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   555
    by (simp add: alw_aand)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   556
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   557
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   558
lemma ev_cong:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   559
  assumes P: "alw P \<omega>" and eq: "\<And>\<omega>. P \<omega> \<Longrightarrow> Q1 \<omega> \<longleftrightarrow> Q2 \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   560
  shows "ev Q1 \<omega> \<longleftrightarrow> ev Q2 \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   561
proof -
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   562
  from P have "alw (\<lambda>xs. Q1 xs \<longrightarrow> Q2 xs) \<omega>" by (rule alw_mono) (simp add: eq)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   563
  moreover from P have "alw (\<lambda>xs. Q2 xs \<longrightarrow> Q1 xs) \<omega>" by (rule alw_mono) (simp add: eq)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   564
  moreover note ev_alw_impl[of Q1 \<omega> Q2] ev_alw_impl[of Q2 \<omega> Q1]
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   565
  ultimately show "ev Q1 \<omega> \<longleftrightarrow> ev Q2 \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   566
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   567
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   568
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   569
lemma alwD: "alw P x \<Longrightarrow> P x"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   570
  by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   571
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   572
lemma alw_alwD: "alw P \<omega> \<Longrightarrow> alw (alw P) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   573
  by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   574
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   575
lemma alw_ev_stl: "alw (ev P) (stl \<omega>) \<longleftrightarrow> alw (ev P) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   576
  by (auto intro: alw.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   577
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   578
lemma holds_Stream: "holds P (x ## s) \<longleftrightarrow> P x"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   579
  by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   580
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   581
lemma holds_eq1[simp]: "holds (op = x) = HLD {x}"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   582
  by rule (auto simp: HLD_iff)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   583
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   584
lemma holds_eq2[simp]: "holds (\<lambda>y. y = x) = HLD {x}"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   585
  by rule (auto simp: HLD_iff)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   586
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   587
lemma not_holds_eq[simp]: "holds (- op = x) = not (HLD {x})"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   588
  by rule (auto simp: HLD_iff)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   589
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59000
diff changeset
   590
text \<open>Strong until\<close>
59000
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   591
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   592
inductive suntil (infix "suntil" 60) for \<phi> \<psi> where
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   593
  base: "\<psi> \<omega> \<Longrightarrow> (\<phi> suntil \<psi>) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   594
| step: "\<phi> \<omega> \<Longrightarrow> (\<phi> suntil \<psi>) (stl \<omega>) \<Longrightarrow> (\<phi> suntil \<psi>) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   595
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   596
inductive_simps suntil_Stream: "(\<phi> suntil \<psi>) (x ## s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   597
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   598
lemma suntil_induct_strong[consumes 1, case_names base step]:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   599
  "(\<phi> suntil \<psi>) x \<Longrightarrow>
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   600
    (\<And>\<omega>. \<psi> \<omega> \<Longrightarrow> P \<omega>) \<Longrightarrow>
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   601
    (\<And>\<omega>. \<phi> \<omega> \<Longrightarrow> \<not> \<psi> \<omega> \<Longrightarrow> (\<phi> suntil \<psi>) (stl \<omega>) \<Longrightarrow> P (stl \<omega>) \<Longrightarrow> P \<omega>) \<Longrightarrow> P x"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   602
  using suntil.induct[of \<phi> \<psi> x P] by blast
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   603
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   604
lemma ev_suntil: "(\<phi> suntil \<psi>) \<omega> \<Longrightarrow> ev \<psi> \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   605
  by (induct rule: suntil.induct) (auto intro: ev.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   606
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   607
lemma suntil_inv:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   608
  assumes stl: "\<And>s. f (stl s) = stl (f s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   609
  shows "(P suntil Q) (f s) \<longleftrightarrow> ((\<lambda>x. P (f x)) suntil (\<lambda>x. Q (f x))) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   610
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   611
  assume "(P suntil Q) (f s)" then show "((\<lambda>x. P (f x)) suntil (\<lambda>x. Q (f x))) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   612
    by (induction "f s" arbitrary: s) (auto simp: stl intro: suntil.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   613
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   614
  assume "((\<lambda>x. P (f x)) suntil (\<lambda>x. Q (f x))) s" then show "(P suntil Q) (f s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   615
    by induction (auto simp: stl[symmetric] intro: suntil.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   616
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   617
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   618
lemma suntil_smap: "(P suntil Q) (smap f s) \<longleftrightarrow> ((\<lambda>x. P (smap f x)) suntil (\<lambda>x. Q (smap f x))) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   619
  by (rule suntil_inv) simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   620
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   621
lemma hld_smap: "HLD x (smap f s) = holds (\<lambda>y. f y \<in> x) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   622
  by (simp add: HLD_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   623
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   624
lemma suntil_mono:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   625
  assumes eq: "\<And>\<omega>. P \<omega> \<Longrightarrow> Q1 \<omega> \<Longrightarrow> Q2 \<omega>" "\<And>\<omega>. P \<omega> \<Longrightarrow> R1 \<omega> \<Longrightarrow> R2 \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   626
  assumes *: "(Q1 suntil R1) \<omega>" "alw P \<omega>" shows "(Q2 suntil R2) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   627
  using * by induct (auto intro: eq suntil.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   628
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   629
lemma suntil_cong:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   630
  "alw P \<omega> \<Longrightarrow> (\<And>\<omega>. P \<omega> \<Longrightarrow> Q1 \<omega> \<longleftrightarrow> Q2 \<omega>) \<Longrightarrow> (\<And>\<omega>. P \<omega> \<Longrightarrow> R1 \<omega> \<longleftrightarrow> R2 \<omega>) \<Longrightarrow>
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   631
    (Q1 suntil R1) \<omega> \<longleftrightarrow> (Q2 suntil R2) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   632
  using suntil_mono[of P Q1 Q2 R1 R2 \<omega>] suntil_mono[of P Q2 Q1 R2 R1 \<omega>] by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   633
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   634
lemma ev_suntil_iff: "ev (P suntil Q) \<omega> \<longleftrightarrow> ev Q \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   635
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   636
  assume "ev (P suntil Q) \<omega>" then show "ev Q \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   637
   by induct (auto dest: ev_suntil)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   638
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   639
  assume "ev Q \<omega>" then show "ev (P suntil Q) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   640
    by induct (auto intro: suntil.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   641
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   642
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   643
lemma true_suntil: "((\<lambda>_. True) suntil P) = ev P"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   644
  by (simp add: suntil_def ev_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   645
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   646
lemma suntil_lfp: "(\<phi> suntil \<psi>) = lfp (\<lambda>P s. \<psi> s \<or> (\<phi> s \<and> P (stl s)))"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   647
  by (simp add: suntil_def)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   648
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   649
lemma sfilter_P[simp]: "P (shd s) \<Longrightarrow> sfilter P s = shd s ## sfilter P (stl s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   650
  using sfilter_Stream[of P "shd s" "stl s"] by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   651
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   652
lemma sfilter_not_P[simp]: "\<not> P (shd s) \<Longrightarrow> sfilter P s = sfilter P (stl s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   653
  using sfilter_Stream[of P "shd s" "stl s"] by simp
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   654
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   655
lemma sfilter_eq: 
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   656
  assumes "ev (holds P) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   657
  shows "sfilter P s = x ## s' \<longleftrightarrow>
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   658
    P x \<and> (not (holds P) suntil (HLD {x} aand nxt (\<lambda>s. sfilter P s = s'))) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   659
  using assms
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   660
  by (induct rule: ev_induct_strong)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   661
     (auto simp add: HLD_iff intro: suntil.intros elim: suntil.cases)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   662
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   663
lemma sfilter_streams:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   664
  "alw (ev (holds P)) \<omega> \<Longrightarrow> \<omega> \<in> streams A \<Longrightarrow> sfilter P \<omega> \<in> streams {x\<in>A. P x}"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   665
proof (coinduction arbitrary: \<omega>)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   666
  case (streams \<omega>)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   667
  then have "ev (holds P) \<omega>" by blast
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   668
  from this streams show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   669
    by (induct rule: ev_induct_strong) (auto elim: streamsE)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   670
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   671
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   672
lemma alw_sfilter:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   673
  assumes *: "alw (ev (holds P)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   674
  shows "alw Q (sfilter P s) \<longleftrightarrow> alw (\<lambda>x. Q (sfilter P x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   675
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   676
  assume "alw Q (sfilter P s)" with * show "alw (\<lambda>x. Q (sfilter P x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   677
  proof (coinduction arbitrary: s rule: alw_coinduct)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   678
    case (stl s) 
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   679
    then have "ev (holds P) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   680
      by blast
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   681
    from this stl show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   682
      by (induct rule: ev_induct_strong) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   683
  qed auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   684
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   685
  assume "alw (\<lambda>x. Q (sfilter P x)) s" with * show "alw Q (sfilter P s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   686
  proof (coinduction arbitrary: s rule: alw_coinduct)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   687
    case (stl s) 
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   688
    then have "ev (holds P) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   689
      by blast
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   690
    from this stl show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   691
      by (induct rule: ev_induct_strong) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   692
  qed auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   693
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   694
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   695
lemma ev_sfilter:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   696
  assumes *: "alw (ev (holds P)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   697
  shows "ev Q (sfilter P s) \<longleftrightarrow> ev (\<lambda>x. Q (sfilter P x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   698
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   699
  assume "ev Q (sfilter P s)" from this * show "ev (\<lambda>x. Q (sfilter P x)) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   700
  proof (induction "sfilter P s" arbitrary: s rule: ev_induct_strong)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   701
    case (step s)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   702
    then have "ev (holds P) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   703
      by blast
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   704
    from this step show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   705
      by (induct rule: ev_induct_strong) auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   706
  qed auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   707
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   708
  assume "ev (\<lambda>x. Q (sfilter P x)) s" then show "ev Q (sfilter P s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   709
  proof (induction rule: ev_induct_strong)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   710
    case (step s) then show ?case
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   711
      by (cases "P (shd s)") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   712
  qed auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   713
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   714
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   715
lemma holds_sfilter:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   716
  assumes "ev (holds Q) s" shows "holds P (sfilter Q s) \<longleftrightarrow> (not (holds Q) suntil (holds (Q aand P))) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   717
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   718
  assume "holds P (sfilter Q s)" with assms show "(not (holds Q) suntil (holds (Q aand P))) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   719
    by (induct rule: ev_induct_strong) (auto intro: suntil.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   720
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   721
  assume "(not (holds Q) suntil (holds (Q aand P))) s" then show "holds P (sfilter Q s)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   722
    by induct auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   723
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   724
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   725
lemma suntil_aand_nxt:
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   726
  "(\<phi> suntil (\<phi> aand nxt \<psi>)) \<omega> \<longleftrightarrow> (\<phi> aand nxt (\<phi> suntil \<psi>)) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   727
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   728
  assume "(\<phi> suntil (\<phi> aand nxt \<psi>)) \<omega>" then show "(\<phi> aand nxt (\<phi> suntil \<psi>)) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   729
    by induction (auto intro: suntil.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   730
next
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   731
  assume "(\<phi> aand nxt (\<phi> suntil \<psi>)) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   732
  then have "(\<phi> suntil \<psi>) (stl \<omega>)" "\<phi> \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   733
    by auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   734
  then show "(\<phi> suntil (\<phi> aand nxt \<psi>)) \<omega>"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   735
    by (induction "stl \<omega>" arbitrary: \<omega>)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   736
       (auto elim: suntil.cases intro: suntil.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   737
qed
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   738
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   739
lemma alw_sconst: "alw P (sconst x) \<longleftrightarrow> P (sconst x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   740
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   741
  assume "P (sconst x)" then show "alw P (sconst x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   742
    by coinduction auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   743
qed auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   744
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   745
lemma ev_sconst: "ev P (sconst x) \<longleftrightarrow> P (sconst x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   746
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   747
  assume "ev P (sconst x)" then show "P (sconst x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   748
    by (induction "sconst x") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   749
qed auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   750
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   751
lemma suntil_sconst: "(\<phi> suntil \<psi>) (sconst x) \<longleftrightarrow> \<psi> (sconst x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   752
proof
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   753
  assume "(\<phi> suntil \<psi>) (sconst x)" then show "\<psi> (sconst x)"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   754
    by (induction "sconst x") auto
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   755
qed (auto intro: suntil.intros)
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   756
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   757
lemma hld_smap': "HLD x (smap f s) = HLD (f -` x) s"
6eb0725503fc import general theorems from AFP/Markov_Models
hoelzl
parents: 58881
diff changeset
   758
  by (simp add: HLD_def)
58627
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   759
1329679abb2d add Linear Temporal Logic on Streams
hoelzl
parents:
diff changeset
   760
end