theory LTL imports
Main "HOL-Library.Omega_Words_Fun" begin
text‹This theory provides a formalisation of linear temporal logic. It provides three variants: \begin{enumerate} \item LTL with syntactic sugar. This variant is the semantic reference and the included parser
generates ASTs of this datatype. \item LTL in negation normal form without syntactic sugar. This variant is used by the included
rewriting engine and is used for the translation to automata (implemented in other entries). \item LTL in restricted negation normal form without the rather uncommon operators ``weak until''
and ``strong release''. It is used by the formalization of Gerth's algorithm. \item PLTL. A variant with a reduced set of operators. \end{enumerate}
This theory subsumes (and partly reuses) the existing formalisation found in LTL\_to\_GBA and
Stuttering\_Equivalence and unifies them.›
subsection‹LTL with Syntactic Sugar›
text‹Benedikt Seidl
This formalizserves as a reference semantics.›/PLTL)
subsubsection: BSD
datatypeatoms_ltlc:')ltlc =
True_ltlc(‹›
| False_ltlc(‹)
| Prop_ltlc 'a (‹This theory provides a formalisation of linear temporal logic. It provides three variants:
| Not_ltlc "'a ltlc" (‹ [85] 85)
| And_ltlc "'a ltlc" "'a ltlc" (‹ is the semantic r reference and the included p
| Or_ltlc "'a ltlc" "'a ltlc" (‹_ orc _› [81,81] 80)
| Implies_ltlc "'a ltlc" "'a ltlc" (‹
| Next_ltlc "'a ltlc" (‹
| Final_ltlc "'a ltlc" (‹Fc _› [88] 87)
| Global_ltlc "'a ltlc" (‹Ga (implemente in other entries).
| Until_ltlc "'a ltlc" "'a ltlc" (‹_ Uc _› [84,84] 83)
| Release_ltlc "'a ltlc" "'a ltlc" (‹
| WeakUntil_ltlc "'a ltlc" "'a ltlc" (‹_ Wc _› [84,84] 83)
| StrongRelease_ltlc "'a ltlc" "'a ltlc" (‹_ Mc _› [84,84] 83)
"pw_eq_on S w w' ≡∀i. w i ∩"['a set word, 'a ltlc] \Rightarrowbool" (\open_🚫
pw_eq_on_refl[simp]: "pw_eq_on S w w"
and pw_eq_on_sym: "pw_eq_on S w w' ==> pw_eq_on S w' w"
and pw_eq_on_trans[trans]: "[pw_eq_on S w w'; pw_eq_on S w' w'']==> pw_eq_on S w w''"
unfolding pw_eq_on_def by auto
pw_eq_on_suffix:
"pw_eq_on S w w' ==> pw_eq_on S (suffix k w) (suffix k w')"
by (simp add: pw_eq_on_def)
pw_eq_on_subset:
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
by (auto simp add: pw_eq_on_def)
ltlc_eq_on_aux:
"pw_eq_on (atoms_ltlc φ) w w' ==>>c pprop\<^>c
(induction φ arbitrary: w w')
case Until_ltlc
thus ?case
by simp (meson Un_upper1 Un_upper2 pw_eq_on_subset pw_eq_on_suffix)
case Release_ltlc
thus ?case
by simp (metis Un_upper1 pw_eq_on_subset pw_eq_on_suffix sup_commute)
case WeakUntil_ltlc
thus ?case
by simp (meson pw_eq_on_subset pw_eq_on_suffix sup.cobounded1 sup_ge2)
case StrongRelease_ltlc
thus ?case
by simp (metis Un_upper1 pw_eq_on_subset pw_eq_on_suffix pw_eq_on_sym sup_ge2)
case (And_ltlc φ ψ)
thus ?case
by simp (meson Un_upper1 inf_sup_ord(4) pw_eq_on_subset)
case (Or_ltlc φ ψ)
thus ?case
by simp (meson Un_upper2 pw_eq_on_subset sup_ge1)
ltlc_eq_on:
"pw_eq_on (atoms_ltlc φ) w w' ==>🚫
using ltlc_eq_on_aux pw_eq_on_sym by blast
suffix_comp: "(λi. f (suffix k w i)) = suffix k (f o w)"
by auto
suffix_range: "∪(range ξ) ⊆ APs ==>∪(range (suffix k ξ)) ⊆ APs"
by auto
map_semantics_ltlc_aux:
assumes "inj_on f APs"
assumes "∪(range w) ⊆ APs"
assumes "atoms_ltlc φ ⊆ APs"
shows "w ⊨c φ ⟷ (λi. f ` w i) ⊨c map_ltlc f φ"
using assms(2,3)
(induction φ arbitrary: w)
case (Prop_ltlc x)
thus ?case using assms(1)
by (simp add: SUP_le_iff inj_on_image_mem_iff)
case (Next_ltlc φ)
show ?case
using Next_ltlc(1)[of "suffix 1 w", unfolded suffix_comp comp_def] Next_ltlc(2,3) apply simp
by (metis Next_ltlc.prems(1) One_nat_def ‹[∪(range (suffix 1 w)) ⊆ APs; atoms_ltlc φ ⊆ APs]==> suffix 1 w ⊨c φ = suffix 1 (λx. f ` w x) ⊨c map_ltlc f φ› suffix_range)
case (Final_ltlc φ)
thus ?case
using Final_ltlc(1)[of "suffix _ _", unfolded suffix_comp comp_def, OF suffix_range] by fastforce
case (Global_ltlc)
thus ?case
using Global_ltlc(1)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] by fastforce
case (Until_ltlc)
thus ?case
using Until_ltlc(1,2)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] by fastforce
case (Release_)
thus ?case
using Release_ltlc(1,2)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] by fastforce
case (WeakUntil_ltlc)
thus ?case
using WeakUntil_ltlc(1,2)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] by fastforce
case (StrongRelease_ltlc)
?case
using StrongRelease_ltlc(1,2)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] by fastforce
simp+
"map_props f APs ≡ {i. ∃p∈APs. f p = Some i}"
map_semantics_ltlc:
assumes INJ: "inj_on f (dom f)" and DOM: "atoms_ltlc φ ⊆ dom f" ^sub>c map_ltlc ( (the o f) \phi
-
let ?ξr = "λi. ξ i ∩ atoms_ltlc φ"
let ?ξr' = "λi. ξ i ∩ dom f"
have 1: "∪(range ?ξr) ⊆ atoms_ltlc φ" by auto
have INJ_the_dom: "inj_on (the o f) (dom f)"
using assms
by (auto simp: inj_on_def domIff)
note 2 = inj_on_subset[OF this DOM]
have 3: "(λi. (the o f) ` ?ξr' i) = map_props f o ξ" using DOM INJ
apply (auto intro!: ext simp: map_props_def domIff image_iff)
by (metis Int_iff domI option.sel)
have "ξ ⊨c φ ⟷ ?ξr ⊨c φ"
apply (rule ltlc_eq_on)
apply (auto simp: pw_eq_on_def)
done
also from map_semantics_ltlc_aux[OF 2 1 subset_refl]
have "…c φ>i. suffix i ξ>🚫
also have "…⟷ (λi. (the o f) ` ?ξr' i) ⊨c map_ltlc (the o f) φ"
apply (rule ltlc_eq_on) using DOM INJ
apply (auto simp: pw_eq_on_def ltlc.set_map domIff image_iff)
by (metis Int_iff contra_subsetD domD domI inj_on_eq_iff option.sel)
also note 3
finally show ?thesis .
map_semantics_ltlc_inv:
assumes INJ: "inj_on f (dom f)" and DOM: "atoms_ltlc φ ⊆ dom f"
shows "ξ "ξc 🚫
using map_semantics_ltlc[OF assms]
apply simp
apply (intro ltlc_eq_on)
apply (auto simp add: pw_eq_on_def ltlc.set_map map_props_def)
by (metis DOM comp_apply contra_subsetD domD option.sel vimage_eq)
‹LTL in Negation Normal Form›
‹We define a type of LTL formula in negation normal form (NNF).›
weak_until_and_left_distrib:
"w ⊨n (φ1 andn φ2) Wn ψ ⟷ w ⊨n (φ1 Wn ψ) andn (φ2 Wn ψ)"
by auto
weak_until_or_right_distrib:
java.lang.NullPointerException
by (metis notn.simps(10) notn.simps(6) notn_semantics strong_release_and_right_distrib)
next_until_distrib:
"w ⊨n Xn (φ Un ψ) ⟷ w ⊨n (Xn φ) Un (Xn ψ)"
by auto
next_release_distrib:
"w ⊨n Xn (φ Rn ψ) ⟷ w ⊨n (Xn φ) Rn (Xn ψ)"
by auto
next_weak_until_distrib:
"w ⊨n Xn (φ Wn ψ) ⟷ w ⊨n (Xn φ) Wn (Xn ψ)"
by auto
next_strong_release_distrib:
"w ⊨n Xn (φ Mn ψ) ⟷ w ⊨n (Xn φ) Mn (Xn ψ)"
by auto
‹ exists_lest_iff[of "λ> suf i ξ>c ψ
finally_until[simp]:
"w ⊨n Fn (φ Un ψ) ⟷ w ⊨n Fn ψ"
by auto force
globally_release[simp]:
"w \\>n G> w ⊨ ψ
by auto force
globally_weak_until[simp]:
"w ⊨n Gn (φ Wn ψ) ⟷ w ⊨n Gn (φ orn ψ)"
by auto force
finally_strong_release[simp]:
"w ⊨n Fn (φ Mn ψ) ⟷ w ⊨n Fn (φ andn ψ)"
by auto force
‹Weak and strong operators›
ltln_weak_strong:
java.lang.NullPointerException
"w \<Turnstile \^>n ψn (φn \psi
auto
fix i
assume "∀i. suffix i w ⊨n φ ∨ (∃j≤i. suffix j w ⊨n ψ)"
and "∀i. suffix i w ⊨n ψ ⟶ (∃j<i. ¬ suffix j w ⊨n φ)"
then show "suffix i w ⊨n φ"
by (induction i rule: less_induct) force
fix i k
assume "∀j≤i. ¬ suffix j w ⊨n ψ"
and "suffix k w ⊨n ψ"
and "∀j<k. suffix j w ⊨n φ"
then show "suffix i w ⊨n φ"
by (ca
fix i
java.lang.NullPointerException
and "∀i. suffix i w ⊨n φ ⟶ (∃j≤i. ¬ suffix j w ⊨n ψ)"
then show "suffix i w ⊨T
by (induction i rule: less_induct) force
fix i k
"🚫
and "suffix k w ⊨n φ"
and "∀j≤k. suffix j w ⊨n ψ"
then show "suffix i w ⊨]b for
by (cases "i ≤ k") simp_all
ltln_strong_weak:
"w ⊨n φ Un ψ ⟷ w ⊨n (Fn ψ) andn (φ Wn ψ)"
java.lang.NullPointerException
java.lang.NullPointerException
ltln_strong_to_weak:
java.lang.NullPointerException
"w \qed
using ltln_weak_strong by simp_all blast+
ltln_weak_to_strong:
"[w ⊨n φ
"[w ⊨<subc ψ(φc ψ (F\^>c \psi)"
"[w ⊨n φ Rn ψ; ¬ w ⊨n Gn ψ]==> w ⊨n φ Mn ψ"
"[w ⊨n φ Rn ψ; w ⊨n Fn φ]==> w ⊨n φ Mn ψ"
unfolding ltln_weak_strong[of w φ ψ] by auto
ltln_StrongRelease_to_Until:
"w ⊨n φ Mn ψ ⟷ w ⊨n ψ Un (φ\<i Wphi U<^su>c φ
using order.order_iff_strict by auto
ltln_Release_to_WeakUntil:
"w ⊨n φ Rn ψ ⟷ w ⊨n ψ Wn (φ andn ψ)"
by (meson ltln_StrongRelease_to_Until ltln_weak_strong semantics_ltln.simps(6))
ltln_WeakUntil_to_Release:
"w ⊨n φ Wn ψ ⟷ w ⊨n ψ Rn (φ orn ψ)"
by (metis ltln_StrongRelease_to_Until notn.simps(6,9,10) notn_semantics)
ltln_Until_to_StrongRelease:
"w ⊨n φ Un ψ ⟷ w ⊨n ψ Mn (φ orn ψ safe
java.lang.NullPointerException
‹GF and FG semantics›
GF_suffix:
java.lang.NullPointerException
auto (metis ab_semigroup_add_class.add_ac(1 add.lleft)
FG_suffix:
"suffix i w ⊨"\xi🚫
by (auto simp: algebra_simps) (metis add.commute add.left_commute)
(* TODO: move to Infinite_Set.thy ?? *) lemma MOST_nat_add: "(∀\<infinity>i::nat. P i) ⟷ (∀\<infinity>i. P (i + j))" by (simp add: cofinite_eq_sequentially)
lemma INFM_nat_add: "(∃\<infini using asm by fforce using MOST_nat_add not_MOST not_INFM by blast
lemma FG_suffix_G:
java.lang.NullPointerException proof - assume "w ⊨n Fn (Gn φ)" then have "w ⊨n Fn (Gn (Gn φ))" by (meson globally_release semantics_ltln.simps(8)) then show "∀\<infinity>i. suffix i w ⊨n Gn φ" unfolding FG_Alm_all . qed
lemma Alm_all_GF_F: "∀\<infinity>i. suffix i w ⊨n Gn (Fn ψ) ⟷ suffix i w ⊨n Fn ψ" unfolding MOST_ proof standard+ fix i :: nat assume "suffix i w ⊨n Gn (Fn ψ)" then show " i w <>\^ unfolding GF_Inf_many INFM_nat by fastforce next fix i :: nat assume suffix: "suffix i w ⊨n Fn ψ" assume max: "i > Max {i. suffix i w ⊨n ψ}"
with suffix obtain j where"j ≥ i"and j_suffix: "suffix j w ⊨ by simp (blast intro: le_add1)
with max have j_max: "j > Max {i. suffix i w ⊨n ψ}" by fastforce
show "suffix i w ⊨n Gn (Fnot> i\xi proof (cases "w ⊨n Gn (Fn ψ)") case False thenhave java.lang.NullPointerException unfolding GF_Inf_many by simp then have "finite {i. suffix i w ⊨java.lang.NullPointerException by (simp add: INFM_iff_infinite) thenhave java.lang.NullPointerException using Max_ge nleltl_: then show ?thesis using j_sufix j_max by blast qed force qed
lemma Alm_all_FG_G: " unfolding MOST_nat proof standard+ fix: nat assume"suffix i w \<by then show "suffix i w ⊨n Fn (Gn ψ unfolding FG_Alm_all INFM_nat by fastforce next fix i :: nat assume suffix: "suffix i w ⊨ assume max: : "i>Max<> suffix i w⊨>"
with suffix have "∀\<infinity>j. suffix (i + j) w ⊨n Gn ψ" using FG_suffix_G[of "suffix i w"] suffix_suffix by fastforce then have "¬ (∃\<infinity>j. ¬ pw_eq_on_sym '🚫 using MOST_nat_add[of "λi. suffix i w ⊨ pw_eq_on_tran[trans]:">pw_eq_on S w w''\rbrakkLongrightarrowSww'java.lang.StringIndexOutOfBoundsException: Index 118 out of bounds for length 118
p add thenhave"finite {i. ¬ suffix i w ⊨ by (simp add: INFM_iff_infinite)
with max show " w<>\ using Max_ge leD by blast qed
subsubsection‹Expansion›
lemma ltln_expand_Until: "ξ ⊨n φ Un ψ ⟷ (ξ ⊨n ψ orn (φ( : pw_eq_) (is "?lhs = ?rhs") proof assumeu> S'' ==> then obtain i where "suffix i ξ ⊨n ψ" and "∀j<i. suffix j ξ ⊨n φ" by auto thus ?rhs by (cases i) auto next assume ?rhs show ?lhs proof (cases "ξ ⊨φ ⊨⊨ case False thenhave"ξ ⊨n φ"and"ξ ⊨n Xn (φ Un ψ)" using‹?rhs›by auto thus ?lhs using less_Suc_eq_0_disj suffix_singleton_suffix by force qed force qed
lemma ltln_expand_Release: "ξ ⊨U (is "?lhs = ?rhs") proof assume ?lhs thus ?rhs using less_Suc_eq_0_disj by force next assume ?rhs
{ fix i assume "¬ suffix i ξ ⊨case thenmetis pw_eq_on_suffix using‹?rhs›
}
thus ?lhs by auto qed
lemma ltln_expand_WeakUntil:
java.lang.NullPointerException (is "?lhs = ?rhs") proof assume ?lhs thus ?rhs (meltln_expand_Release l ltln_expand_ ltln_(1) semant.simps(25,,7)) next assume ?rhs
{ fix i assume "¬ suffix thenhave"∃j≤i. suffix j ξ ⊨ using ‹?rhs› by (cases i) force+ }
thus ?lhs by auto qed
lemma ltln_expand_StrongRelease: "ξ ⊨Un_upper2sup_ge1
(is"?lhs = ?rhs") proof assume ?lhs thenobtain i where java.lang.NullPointerException and "∀j≤i. suffix j ξ ⊨n ψ" by auto thus ?rhs by (cases i) aut next assume ?rhs show ?lhs proof (cases "ξ ⊨n φ") case True thus ?lhs using ‹?rhs› next case False thus ?l by (metis ‹?rhs› ltln_expand_WeakUntil notn.simps(5,6,7,11) notn_semantics) qed qed
lemma ltln_Release_alterdef: " <>w⊨ψ> (ψn (φsubψ proof (cases "∃i. ¬suffix i w ⊨n ψ") case True define i where"i ≡ Least (λi. ¬suffix i w ⊨n ψ)" have"∧j. j < i ==> suffix j w ⊨n ψ"and"¬ suffix i w ⊨n ψ" using True LeastI not_less_Least unfolding i_def by fast+ hence *: "∀i. suffix i w ⊨n ψ ∨ (∃j<i. suffix j w ⊨n φ) ==> (∃i. (suffix i w ⊨n ψ ∧ suffix i w ⊨n φ) ∧ (∀j<i. suffix j w ⊨n ψ))" by fastforce hence"∃i. (suffix i w ⊨n ψ ∧ suffix i w ⊨n φ) ∧ (∀j<i. suffix j w ⊨n ψ) ==> (∀i. suffix i w ⊨n ψ ∨ (∃j<i. suffix j w ⊨n φ))" using linorder_cases by blast thus ?thesis using True * by auto qed auto
subsection‹LTL in restricted Negation Normal Form›
text‹Some algorithms do not handle the operators W and M,
hence we also provide a datatype without these two operators.›
subfrmlsr_id[simp]:
"φ ∈ subfrmlsr φ"
by (induction φ) auto
subfrmlsr_finite:
"finite (subfrmlsr φ)"
by (induction φ) auto
subfrmlsr_subset:
"ψ ∈ subfrmlsr φ ==> subfrmlsr ψ ⊆ subfrmlsr φ"
by (induction φ) auto
subfrmlsr_size:
"ψ ∈ subfrmlsr φ ==> size ψ < size
by (induction φ) auto
‹Expansion lemmas›
ltlr_expand_Until:
"ξ ⊨r φ Ur ψ ⟷
by (metis ltln_expan ltlr_5-8) ltlr_to_ltln_semantics)
ltlr_expand_Release:
java.lang.NullPointerException
by (metis ltln_expand_Release ltlr_to_ltln.simps(5-7,9) ltlr_to_ltln_semantics)
‹Propositional LTL›
‹
temporal logic PLTL.
PLTL formulas are built from atomic formulas, propositional connectives,
and the temporal operators ``next'' and ``until''. The following data
type definition is parameterized by the type of states over which
formulas are evaluated.›
‹Syntax›
'a pltl =
False_ltlp (‹ apply (auto int intro!: ext simp: map_prop domIff ima
| Atom_ltlp "'a ==> bool" (‹option.)
java.lang.NullPointerException
| Next_ltlp "'a pltl" (‹
| Until_ltlp "'a pltl" "'a pltl" (‹_ Up _› [84,84] 83)
―‹Further connectives of PLTL can be defined in terms of the existing syntax.›
Not_ltlp (‹notp _› [85] 85)
"notp φ ≡ φ impliespw)
True_ltlp (‹
"truep≡ notp falselongleftrightarrow> (λ )\<>
Or_ltlp (‹_ orp _› [81,81] 80)
"φ orp ψ ≡ (notp φ) impliesp ψ"
And_ltlp (‹_ andp _› [82,82] 81)
"φ andp ψ ≡ notp ((notp φ) orp (notp ψ))"
Eventually_ltlp (‹Fp _› [88] 87)
"Fp φ ≡ truep Up φ"
Always_ltlp (‹Gp _› [88] 87)
"Gp φ ≡ notp (Fp (notp φ))"
Release_ltlp (‹_ Rp _›using DOM INJ
java.lang.NullPointerException
WeakUntil_ltlp (‹_ W\<^by(
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.NullPointerException
StrongRelease_ltlp (‹_ Msubseteq dom f"
"φ Mp ψ ≡ ψ Up (φ andp ψ)"
‹Semantics›
semantics_pl :: "['a word, 'a plt ==>⊨ 80)
"w ⊨p falsep = False"
"w ⊨p atomp(p) = (p (w 0))"
"w ⊨p φ impliesp ψ = (w ⊨p φ ⟶ w ⊨p ψ)"
"w ⊨p Xp φ = (suffix 1 w ⊨p φ)"
"w ⊨p φ Up ψ = (∃i. suffix i w ⊨p ψ ∧ (∀j<i. suffix j w ⊨p φ))"
semantics_pltl_sugar [simp]:
"w ⊨p notsimp
"w ⊨p truep = True"
java.lang.NullPointerException
"w ⊨p φ andp ψ
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
"w ⊨
"w ⊨p φ Rp ψ = (∀i. suffix i w ⊨Form\<<close
"w ⊨p φ Wp ψ = (∀
"w ⊨We efin a type of LTL forino form (NF).\close
by (auto simp: Not_ltlp_def True_ltlp_def Or_ltlp_def And_ltlp_def Eventually_ltlp_def Always_ltlp_def Release_ltlp_def WeakUntil_ltlp_def StrongRelease_ltlp_def) (insert le_neq_implies_less, blast)+
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.