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