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‹In this section, we provide a formulation of LTL with explicit syntactic sugar deeply embedded.
This formalization serves as a reference semantics.›
definition"pw_eq_on S w w' ≡∀i. w i ∩ S = w' i ∩ S"
lemma 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
lemma 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)
lemma pw_eq_on_subset: "S ⊆ S' ==> pw_eq_on S' w w' ==> pw_eq_on S w w'" by (auto simp add: pw_eq_on_def)
lemma ltlc_eq_on_aux: "pw_eq_on (atoms_ltlc φ) w w' ==> w ⊨c φ ==> w' ⊨c φ" proof (induction φ arbitrary: w w') case Until_ltlc thus ?case by simp (meson Un_upper1 Un_upper2 pw_eq_on_subset pw_eq_on_suffix) next case Release_ltlc thus ?case by simp (metis Un_upper1 pw_eq_on_subset pw_eq_on_suffix sup_commute) next case WeakUntil_ltlc thus ?case by simp (meson pw_eq_on_subset pw_eq_on_suffix sup.cobounded1 sup_ge2) next case StrongRelease_ltlc thus ?case by simp (metis Un_upper1 pw_eq_on_subset pw_eq_on_suffix pw_eq_on_sym sup_ge2) next case (And_ltlc φ ψ) thus ?case by simp (meson Un_upper1 inf_sup_ord(4) pw_eq_on_subset) next case (Or_ltlc φ ψ) thus ?case by simp (meson Un_upper2 pw_eq_on_subset sup_ge1) next case (Implies_ltlc φ ψ) thus ?case by simp (meson Un_upper1 Un_upper2 pw_eq_on_subset[of "atoms_ltlc _""atoms_ltlc φ ∪ atoms_ltlc ψ"] pw_eq_on_sym) qed (auto simp add: pw_eq_on_def; metis suffix_nth)+
lemma ltlc_eq_on: "pw_eq_on (atoms_ltlc φ) w w' ==> w ⊨c φ ⟷ w' ⊨c φ" using ltlc_eq_on_aux pw_eq_on_sym by blast
lemma suffix_comp: "(λi. f (suffix k w i)) = suffix k (f o w)" by auto
lemma suffix_range: "∪(range ξ) ⊆ APs ==>∪(range (suffix k ξ)) ⊆ APs" by auto
lemma 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) proof (induction φ arbitrary: w) case (Prop_ltlc x) thus ?caseusing assms(1) by (simp add: SUP_le_iff inj_on_image_mem_iff) next case (Next_ltlc φ) show ?case using Next_ltlc(1)[of "suffix 1 w", unfolded suffix_comp comp_def] Next_ltlc(2,3) applysimp 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) next case (Final_ltlc φ) thus ?case using Final_ltlc(1)[of "suffix _ _", unfolded suffix_comp comp_def, OF suffix_range] by fastforce next case (Global_ltlc) thus ?case using Global_ltlc(1)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] byfastforce next case (Until_ltlc) thus ?case using Until_ltlc(1,2)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] by fastforce next case (Release_ltlc) thus ?case using Release_ltlc(1,2)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] by fastforce next case (WeakUntil_ltlc) thus ?case using WeakUntil_ltlc(1,2)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] by fastforce next case (StrongRelease_ltlc) thus ?case using StrongRelease_ltlc(1,2)[of "suffix _ w", unfolded suffix_comp comp_def, OF suffix_range] by fastforce qed simp+
definition"map_props f APs ≡ {i. ∃p∈APs. f p = Some i}"
lemma map_semantics_ltlc: assumes INJ: "inj_on f (dom f)"and DOM: "atoms_ltlc φ ⊆ dom f" shows"ξ ⊨c φ ⟷ (map_props f o ξ) ⊨c map_ltlc (the o f) φ" proof - let ?ξr = "λi. ξ i ∩ atoms_ltlc φ" let ?ξr' = "λi. ξ i ∩ dom f"
have1: "∪(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) note2 = inj_on_subset[OF this DOM]
have3: "(λ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 alsofrom map_semantics_ltlc_aux[OF 21 subset_refl] have"…⟷ (λi. (the o f) ` ?ξr i) ⊨c map_ltlc (the o f) φ" . alsohave"…⟷ (λ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) alsonote3 finallyshow ?thesis . qed
lemma map_semantics_ltlc_inv: assumes INJ: "inj_on f (dom f)"and DOM: "atoms_ltlc φ ⊆ dom f" shows"ξ ⊨c map_ltlc (the o f) φ ⟷ (λi. (the o f) -` ξ i) ⊨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)
subsection‹LTL in Negation Normal Form›
text‹We define a type of LTL formula in negation normal form (NNF).›
lemma next_until_distrib: "w ⊨n Xn (φ Un ψ) ⟷ w ⊨n (Xn φ) Un (Xn ψ)" by auto
lemma next_release_distrib: "w ⊨n Xn (φ Rn ψ) ⟷ w ⊨n (Xn φ) Rn (Xn ψ)" by auto
lemma next_weak_until_distrib: "w ⊨n Xn (φ Wn ψ) ⟷ w ⊨n (Xn φ) Wn (Xn ψ)" by auto
lemma next_strong_release_distrib: "w ⊨n Xn (φ Mn ψ) ⟷ w ⊨n (Xn φ) Mn (Xn ψ)" by auto
subsubsection‹Nested operators›
lemma finally_until[simp]: "w ⊨n Fn (φ Un ψ) ⟷ w ⊨n Fn ψ" by auto force
lemma globally_release[simp]: "w ⊨n Gn (φ Rn ψ) ⟷ w ⊨n Gn ψ" by auto force
lemma globally_weak_until[simp]: "w ⊨n Gn (φ Wn ψ) ⟷ w ⊨n Gn (φ orn ψ)" by auto force
lemma finally_strong_release[simp]: "w ⊨n Fn (φ Mn ψ) ⟷ w ⊨n Fn (φ andn ψ)" by auto force
subsubsection‹Weak and strong operators›
lemma ltln_weak_strong: "w ⊨n φ Wn ψ ⟷ w ⊨n (Gn φ) orn (φ Un ψ)" "w ⊨n φ Rn ψ ⟷ w ⊨n (Gn ψ) orn (φ Mn ψ)" proof 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 φ)"
thenshow"suffix i w ⊨n φ" by (induction i rule: less_induct) force next fix i k assume"∀j≤i. ¬ suffix j w ⊨n ψ" and"suffix k w ⊨n ψ" and"∀j<k. suffix j w ⊨n φ"
thenshow"suffix i w ⊨n φ" by (cases "i < k") simp_all next 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 ψ)"
thenshow"suffix i w ⊨n ψ" by (induction i rule: less_induct) force next fix i k assume"∀j<i. ¬ suffix j w ⊨n φ" and"suffix k w ⊨n φ" and"∀j≤k. suffix j w ⊨n ψ"
thenshow"suffix i w ⊨n ψ" by (cases "i ≤ k") simp_all qed
lemma ltln_strong_weak: "w ⊨n φ Un ψ ⟷ w ⊨n (Fn ψ) andn (φ Wn ψ)" "w ⊨n φ Mn ψ ⟷ w ⊨n (Fn φ) andn (φ Rn ψ)" by (metis ltln_weak_strong notn.simps(1,5,8-11) notn_semantics)+
lemma ltln_strong_to_weak: "w ⊨n φ Un ψ ==> w ⊨n φ Wn ψ" "w ⊨n φ Mn ψ ==> w ⊨n φ Rn ψ" using ltln_weak_strong by simp_all blast+
lemma ltln_weak_to_strong: "[w ⊨n φ Wn ψ; ¬ w ⊨n Gn φ]==> w ⊨n φ Un ψ" "[w ⊨n φ Wn ψ; w ⊨n Fn ψ]==> w ⊨n φ Un ψ" "[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
lemma ltln_StrongRelease_to_Until: "w ⊨n φ Mn ψ ⟷ w ⊨n ψ Un (φ andn ψ)" using order.order_iff_strict by auto
lemma ltln_Release_to_WeakUntil: "w ⊨n φ Rn ψ ⟷ w ⊨n ψ Wn (φ andn ψ)" by (meson ltln_StrongRelease_to_Until ltln_weak_strong semantics_ltln.simps(6))
lemma ltln_WeakUntil_to_Release: "w ⊨n φ Wn ψ ⟷ w ⊨n ψ Rn (φ orn ψ)" by (metis ltln_StrongRelease_to_Until notn.simps(6,9,10) notn_semantics)
lemma ltln_Until_to_StrongRelease: "w ⊨n φ Un ψ ⟷ w ⊨n ψ Mn (φ orn ψ)" by (metis ltln_Release_to_WeakUntil notn.simps(6,8,11) notn_semantics)
subsubsection‹GF and FG semantics›
lemma GF_suffix: "suffix i w ⊨n Gn (Fn ψ) ⟷ w ⊨n Gn (Fn ψ)" by auto (metis ab_semigroup_add_class.add_ac(1) add.left_commute)
lemma FG_suffix: "suffix i w ⊨n Fn (Gn ψ) ⟷ w ⊨n Fn (Gn ψ)" by (auto simp: algebra_simps) (metis add.commute add.left_commute)
lemma GF_Inf_many: "w ⊨n Gn (Fn φ) ⟷ (∃\<infinity> i. suffix i w ⊨n φ)" unfolding INFM_nat_le by simp (blast dest: le_Suc_ex intro: le_add1)
lemma FG_Alm_all: "w ⊨n Fn (Gn φ) ⟷ (∀\<infinity> i. suffix i w ⊨n φ)" unfolding MOST_nat_le by simp (blast dest: le_Suc_ex intro: le_add1)
(* 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: "(∃\<infinity>i::nat. P i) ⟷ (∃\<infinity>i. P (i + j))" using MOST_nat_add not_MOST not_INFM by blast
lemma FG_suffix_G: "w ⊨n Fn (Gn φ) ==>∀\<infinity>i. suffix i w ⊨n Gn φ" proof - assume"w ⊨n Fn (Gn φ)" thenhave"w ⊨n Fn (Gn (Gn φ))" by (meson globally_release semantics_ltln.simps(8)) thenshow"∀\<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_nat proof standard+ fix i :: nat assume"suffix i w ⊨n Gn (Fn ψ)" thenshow"suffix i w ⊨n Fn ψ" 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 ⊨n ψ" 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 (Fn ψ)" proof (cases "w ⊨n Gn (Fn ψ)") case False thenhave"¬ (∃\<infinity>i. suffix i w ⊨n ψ)" unfolding GF_Inf_many by simp thenhave"finite {i. suffix i w ⊨n ψ}" by (simp add: INFM_iff_infinite) thenhave"∀i>Max {i. suffix i w ⊨n ψ}. ¬ suffix i w ⊨n ψ" using Max_ge not_le by auto thenshow ?thesis using j_suffix j_max by blast qed force qed
lemma Alm_all_FG_G: "∀\<infinity>i. suffix i w ⊨n Fn (Gn ψ) ⟷ suffix i w ⊨n Gn ψ" unfolding MOST_nat proof standard+ fix i :: nat assume"suffix i w ⊨n Gn ψ" thenshow"suffix i w ⊨n Fn (Gn ψ)" unfolding FG_Alm_all INFM_nat by fastforce next fix i :: nat assume suffix: "suffix i w ⊨n Fn (Gn ψ)" assume max: "i > Max {i. ¬ suffix i w ⊨n Gn ψ}"
with suffix have"∀\<infinity>j. suffix (i + j) w ⊨n Gn ψ" using FG_suffix_G[of "suffix i w"] suffix_suffix by fastforce thenhave"¬ (∃\<infinity>j. ¬ suffix j w ⊨n Gn ψ)" using MOST_nat_add[of "λi. suffix i w ⊨n Gn ψ" i] by (simp add: algebra_simps) thenhave"finite {i. ¬ suffix i w ⊨n Gn ψ}" by (simp add: INFM_iff_infinite)
with max show"suffix i w ⊨n Gn ψ" using Max_ge leD by blast qed
subsubsection‹Expansion›
lemma ltln_expand_Until: "ξ ⊨n φ Un ψ ⟷ (ξ ⊨n ψ orn (φ andn (Xn (φ Un ψ))))"
(is"?lhs = ?rhs") proof assume ?lhs thenobtain 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 "ξ ⊨n ψ") 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: "ξ ⊨n φ Rn ψ ⟷ (ξ ⊨n ψ andn (φ orn (Xn (φ Rn ψ))))"
(is"?lhs = ?rhs") proof assume ?lhs thus ?rhs using less_Suc_eq_0_disj by force next assume ?rhs
{ fix i assume"¬ suffix i ξ ⊨n ψ" thenhave"∃j<i. suffix j ξ ⊨n φ" using‹?rhs›by (cases i) force+
}
{ fix i assume"¬ suffix i ξ ⊨n φ" thenhave"∃j≤i. suffix j ξ ⊨n ψ" using‹?rhs›by (cases i) force+
}
thus ?lhs by auto qed
lemma ltln_expand_StrongRelease: "ξ ⊨n φ Mn ψ ⟷ (ξ ⊨n ψ andn (φ orn (Xn (φ Mn ψ))))"
(is"?lhs = ?rhs") proof assume ?lhs thenobtain 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 "ξ ⊨n φ") case True thus ?lhs using‹?rhs› ltln_expand_WeakUntil by fastforce next case False thus ?lhs by (metis ‹?rhs› ltln_expand_WeakUntil notn.simps(5,6,7,11) notn_semantics) qed qed
lemma ltln_Release_alterdef: "w ⊨n φ Rn ψ ⟷ w ⊨n (Gn ψ) orn (ψ Un (φ andn ψ))" 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.›
text‹We define the syntax and semantics of propositional linear-time
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.›
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.