Theory Logical_Characterization
section βΉLogical Characterization TheoremsβΊ
theory Logical_Characterization
imports Main af "Auxiliary/Preliminaries2"
begin
subsection βΉEventually True G-SubformulaeβΊ
fun π’β©Fβ©G :: "'a ltl β 'a set word β 'a ltl set"
where
"π’β©Fβ©G true w = {}"
| "π’β©Fβ©G (false) w = {}"
| "π’β©Fβ©G (p(a)) w = {}"
| "π’β©Fβ©G (np(a)) w = {}"
| "π’β©Fβ©G (Οβ©1 and Οβ©2) w = π’β©Fβ©G Οβ©1 w βͺ π’β©Fβ©G Οβ©2 w"
| "π’β©Fβ©G (Οβ©1 or Οβ©2) w = π’β©Fβ©G Οβ©1 w βͺ π’β©Fβ©G Οβ©2 w"
| "π’β©Fβ©G (F Ο) w = π’β©Fβ©G Ο w"
| "π’β©Fβ©G (G Ο) w = (if w β¨ F G Ο then {G Ο} βͺ π’β©Fβ©G Ο w else π’β©Fβ©G Ο w)"
| "π’β©Fβ©G (X Ο) w = π’β©Fβ©G Ο w"
| "π’β©Fβ©G (Ο U Ο) w = π’β©Fβ©G Ο w βͺ π’β©Fβ©G Ο w"
lemma π’β©Fβ©G_alt_def:
"π’β©Fβ©G Ο w = {G Ο | Ο. G Ο β βG Ο β§ w β¨ F (G Ο)}"
by (induction Ο arbitrary: w) (simp; blast)+
lemma π’β©Fβ©G_Only_G:
"Only_G (π’β©Fβ©G Ο w)"
by (induction Ο) auto
lemma π’β©Fβ©G_suffix[simp]:
"π’β©Fβ©G Ο (suffix i w) = π’β©Fβ©G Ο w"
unfolding π’β©Fβ©G_alt_def LTL_FG_suffix ..
subsection βΉEventually Provable and Almost All Eventually ProvableβΊ
abbreviation π
where
"π Ο π’ w i β‘ βj. π’ β¨β©P afβ©G Ο (w [i β j])"
definition almost_all_eventually_provable :: "'a ltl β 'a ltl set β 'a set word β bool" (βΉπβ©ββΊ)
where
"πβ©β Ο π’ w β‘ ββ©βi. π Ο π’ w i"
subsubsection βΉProof RulesβΊ
lemma almost_all_eventually_provable_monotonI[intro]:
"πβ©β Ο π’ w βΉ π’ β π’' βΉ πβ©β Ο π’' w"
unfolding almost_all_eventually_provable_def MOST_nat_le by blast
lemma almost_all_eventually_provable_restrict_to_G:
"πβ©β Ο π’ w βΉ Only_G π’ βΉ πβ©β Ο (π’ β© βG Ο) w"
proof -
assume "Only_G π’" and "πβ©β Ο π’ w"
moreover
hence "βΟ. π’ β¨β©P Ο = (π’ β© βG Ο) β¨β©P Ο"
using LTL_prop_entailment_restrict_to_propos propos_subset
unfolding G_nested_propos_alt_def by blast
ultimately
show ?thesis
unfolding almost_all_eventually_provable_def by force
qed
fun G_depth :: "'a ltl β nat"
where
"G_depth (Ο and Ο) = max (G_depth Ο) (G_depth Ο)"
| "G_depth (Ο or Ο) = max (G_depth Ο) (G_depth Ο)"
| "G_depth (F Ο) = G_depth Ο"
| "G_depth (G Ο) = G_depth Ο + 1"
| "G_depth (X Ο) = G_depth Ο"
| "G_depth (Ο U Ο) = max (G_depth Ο) (G_depth Ο)"
| "G_depth Ο = 0"
lemma almost_all_eventually_provable_restrict_to_G_depth:
assumes "πβ©β Ο π’ w"
assumes "Only_G π’"
shows "πβ©β Ο (π’ β© {Ο. G_depth Ο β€ G_depth Ο}) w"
proof -
{
fix Ο
have "π’ β¨β©P Ο = (π’ β© {Ο. G_depth Ο β€ G_depth Ο}) β¨β©P Ο"
by (induction Ο) (insert βΉOnly_G π’βΊ, auto)
}
note Unfold1 = this
{
fix w
{
fix Ο Ξ½
have "{Ο. G_depth Ο β€ G_depth (af_G_letter Ο Ξ½)} = {Ο. G_depth Ο β€ G_depth Ο}"
by (induction Ο) (unfold af_G_letter.simps G_depth.simps, simp_all, (metis le_max_iff_disj mem_Collect_eq)+)
}
hence "{Ο. G_depth Ο β€ G_depth (afβ©G Ο w)} = {Ο. G_depth Ο β€ G_depth Ο}"
by (induction w arbitrary: Ο rule: rev_induct) fastforce+
}
note Unfold2 = this
from assms(1) show ?thesis
unfolding almost_all_eventually_provable_def Unfold1 Unfold2 .
qed
lemma almost_all_eventually_provable_suffix:
"πβ©β Ο π’' w βΉ πβ©β Ο π’' (suffix i w)"
unfolding almost_all_eventually_provable_def MOST_nat_le
by (metis Nat.add_0_right subsequence_shift subsequence_prefix_suffix suffix_0 add.assoc diff_zero trans_le_add2)
subsubsection βΉThresholdβΊ
text βΉThe first index, such that the formula is eventually provable from this time onβΊ
fun threshold :: "'a ltl β 'a set word β 'a ltl set β nat option"
where
"threshold Ο w π’ = index (Ξ»j. π Ο π’ w j)"
lemma threshold_properties:
"threshold Ο w π’ = Some i βΉ 0 < i βΉ Β¬ π’ β¨β©P afβ©G Ο (w [(i - 1) β k])"
"threshold Ο w π’ = Some i βΉ j β₯ i βΉ βk. π’ β¨β©P afβ©G Ο (w [j β k])"
using index_properties unfolding threshold.simps by blast+
lemma threshold_suffix:
assumes "threshold Ο w π’ = Some k"
assumes "threshold Ο (suffix i w) π’ = Some k'"
shows "k β€ k' + i"
proof (rule ccontr)
assume "Β¬k β€ k' + i"
hence "k > k' + i"
by arith
then obtain j where "k = k' + i + Suc j"
by (metis Suc_diff_Suc le_Suc_eq le_add1 le_add_diff_inverse less_imp_Suc_add)
hence "0 < k" and "k' + i + Suc j - 1 = i + (k' + j)"
using βΉk > k' + iβΊ by arith+
show False
using threshold_properties(1)[OF assms(1) βΉ0 < kβΊ] threshold_properties(2)[OF assms(2), of "k' + j", OF le_add1]
unfolding subsequence_shift βΉk = k' + i + Suc jβΊ βΉk' + i + Suc j - 1 = i + (k' + j)βΊ by blast
qed
subsubsection βΉRelation to LTL semanticsβΊ
lemma ltl_implies_provable:
"w β¨ Ο βΉ π Ο (π’β©Fβ©G Ο w) w 0"
proof (induction Ο arbitrary: w)
case (LTLProp a)
hence "{} β¨β©P afβ©G (p(a)) (w [0 β 1])"
by (simp add: subsequence_def)
thus ?case
by blast
next
case (LTLPropNeg a)
hence "{} β¨β©P afβ©G (np(a)) (w [0 β 1])"
by (simp add: subsequence_def)
thus ?case
by blast
next
case (LTLAnd Οβ©1 Οβ©2)
obtain iβ©1 iβ©2 where "(π’β©Fβ©G Οβ©1 w) β¨β©P afβ©G Οβ©1 (w [0 β iβ©1])" and "(π’β©Fβ©G Οβ©2 w) β¨β©P afβ©G Οβ©2 (w [0 β iβ©2])"
using LTLAnd unfolding ltl_semantics.simps by blast
have "(π’β©Fβ©G Οβ©1 w) β¨β©P afβ©G Οβ©1 (w [0 β iβ©1 + iβ©2])" and "(π’β©Fβ©G Οβ©2 w) β¨β©P afβ©G Οβ©2 (w [0 β iβ©2 + iβ©1])"
using afβ©G_sat_core_generalized[OF π’β©Fβ©G_Only_G _ βΉ(π’β©Fβ©G Οβ©1 w) β¨β©P afβ©G Οβ©1 (w [0 β iβ©1])βΊ]
using afβ©G_sat_core_generalized[OF π’β©Fβ©G_Only_G _ βΉ(π’β©Fβ©G Οβ©2 w) β¨β©P afβ©G Οβ©2 (w [0 β iβ©2])βΊ]
by simp+
thus ?case
by (simp only: afβ©G_decompose add.commute) auto
next
case (LTLOr Οβ©1 Οβ©2)
thus ?case
unfolding afβ©G_decompose by (cases "w β¨ Οβ©1") force+
next
case (LTLNext Ο)
obtain i where "(π’β©Fβ©G Ο w) β¨β©P afβ©G Ο (suffix 1 w [0 β i])"
using LTLNext(1)[OF LTLNext(2)[unfolded ltl_semantics.simps]]
unfolding π’β©Fβ©G_suffix by blast
hence "(π’β©Fβ©G (X Ο) w) β¨β©P afβ©G (X Ο) (w [0 β 1 + i])"
unfolding subsequence_shift subsequence_append by (simp add: subsequence_def)
thus ?case
by blast
next
case (LTLFinal Ο)
then obtain i where "suffix i w β¨ Ο"
by auto
then obtain j where "π’β©Fβ©G Ο w β¨β©P afβ©G Ο (suffix i w [0 β j])"
using LTLFinal π’β©Fβ©G_suffix by blast
hence A: "π’β©Fβ©G Ο w β¨β©P afβ©G Ο (suffix i w [0 β Suc j])"
using afβ©G_sat_core_generalized[OF π’β©Fβ©G_Only_G, of j "Suc j", OF le_SucI] by blast
from afβ©G_keeps_F_and_S[OF _ A] have "π’β©Fβ©G Ο w β¨β©P afβ©G (F Ο) (w [0 β Suc (i + j)])"
unfolding subsequence_shift subsequence_append Suc_eq_plus1 by simp
thus ?case
using π’β©Fβ©G.simps(7) by blast
next
case (LTLUntil Ο Ο)
then obtain k where "suffix k w β¨ Ο" and "βj < k. suffix j w β¨ Ο"
by auto
thus ?case
proof (induction k arbitrary: w)
case 0
then obtain i where "π’β©Fβ©G Ο w β¨β©P afβ©G Ο (w [0 β i])"
using LTLUntil by (metis suffix_0)
hence "π’β©Fβ©G Ο w β¨β©P afβ©G Ο (w [0 β Suc i])"
using afβ©G_sat_core_generalized[OF π’β©Fβ©G_Only_G, of i "Suc i", OF le_SucI] by auto
hence "π’β©Fβ©G (Ο U Ο) w β¨β©P afβ©G (Ο U Ο) (w [0 β Suc i])"
unfolding afβ©G_subsequence_U ltl_prop_entailment.simps π’β©Fβ©G.simps by blast
thus ?case
by blast
next
case (Suc k)
hence "w β¨ Ο" and "suffix k (suffix 1 w) β¨ Ο" and "βj<k. suffix j (suffix 1 w) β¨ Ο"
unfolding suffix_0 suffix_suffix by (auto, metis Suc_less_eq)+
then obtain i where i_def: "π’β©Fβ©G (Ο U Ο) w β¨β©P afβ©G (Ο U Ο) (suffix 1 w [0 β i])"
using Suc(1)[of "suffix 1 w"] unfolding LTL_FG_suffix π’β©Fβ©G_alt_def by blast
obtain j where j_def: "π’β©Fβ©G Ο w β¨β©P afβ©G Ο (w [0 β j])"
using LTLUntil(1)[OF βΉw β¨ ΟβΊ] by auto
hence "π’β©Fβ©G (Ο U Ο) w β¨β©P afβ©G Ο (w [0 β j])"
by auto
hence "π’β©Fβ©G (Ο U Ο) w β¨β©P afβ©G Ο (w [0 β j + (i + 1)])"
by (blast intro: afβ©G_sat_core_generalized[OF π’β©Fβ©G_Only_G le_add1])
moreover
have "1 + (i + j) = j + (i + 1)"
by arith
have "π’β©Fβ©G (Ο U Ο) w β¨β©P afβ©G (Ο U Ο) (w [1 β j + (i + 1)])"
using afβ©G_sat_core_generalized[OF π’β©Fβ©G_Only_G le_add1 i_def, of j]
unfolding subsequence_shift π’β©Fβ©G_suffix βΉ1 + (i + j) = j + (i + 1)βΊ by simp
ultimately
have "π’β©Fβ©G (Ο U Ο) w β¨β©P afβ©G (Ο U Ο) (w [1 β Suc (j + i)]) and afβ©G Ο (w [0 β Suc (j + i)])"
by simp
hence "π’β©Fβ©G (Ο U Ο) w β¨β©P afβ©G (Ο U Ο) (w [0 β Suc (j + i)])"
unfolding afβ©G_subsequence_U ltl_prop_entailment.simps by blast
thus ?case
using afβ©G_subsequence_U ltl_prop_entailment.simps by blast
qed
qed simp+
lemma ltl_implies_provable_almost_all:
"w β¨ Ο βΉ ββ©βi. π’β©Fβ©G Ο w β¨β©P afβ©G Ο (w [0 β i])"
using ltl_implies_provable afβ©G_sat_core_generalized[OF π’β©Fβ©G_Only_G]
unfolding MOST_nat_le by metis
subsubsection βΉClosed SetsβΊ
abbreviation closed
where
"closed π’ w β‘ finite π’ β§ Only_G π’ β§ (βΟ. G Ο β π’ βΆ πβ©β Ο π’ w)"
lemma closed_FG:
assumes "closed π’ w"
assumes "G Ο β π’"
shows "w β¨ F G Ο"
proof -
have "finite π’" and "Only_G π’" and "(βΟ. G Ο β π’ βΉ πβ©β Ο π’ w)"
using assms by simp+
moreover
note βΉG Ο β π’βΊ
ultimately
show "w β¨ F G Ο"
proof (induction arbitrary: Ο rule: finite_ranking_induct[where f = G_depth])
case (insert x π’)
then obtain Ο' where "x = G Ο'"
by auto
{
fix Ο assume "G Ο β insert x π’" (is "_ β ?π’'")
hence "πβ©β Ο (?π’' β© {Ο'. G_depth Ο' β€ G_depth Ο}) w"
using insert(4-5) by (blast dest: almost_all_eventually_provable_restrict_to_G_depth)
moreover
have "G_depth Ο < G_depth x"
using insert(2) βΉG Ο β insert x π’βΊ βΉx = G Ο'βΊ by force
ultimately
have "πβ©β Ο π’ w"
by auto
}
hence "πβ©β Ο' π’ w" and "closed π’ w"
using insert βΉx = G Ο'βΊ by simp+
have "Only_G π’" and "Only_G (π’ βͺ βG Ο')" and "finite (π’ βͺ βG Ο')"
using G_nested_finite G_nested_propos_Only_G insert by blast+
then obtain kβ©1 where k1_def: "βΟ i. Ο β π’ βͺ βG Ο' βΉ suffix kβ©1 w β¨ Ο = suffix (kβ©1 + i) w β¨ Ο"
by (blast intro: ltl_G_stabilize)
hence "βΟ. G Ο β π’ βΉ w β¨ F (G Ο)"
using insert βΉclosed π’ wβΊ by simp
then obtain kβ©2 where k2_def: "βi β₯ kβ©2. βj. π Ο' π’ w i"
using βΉπβ©β Ο' π’ wβΊ unfolding almost_all_eventually_provable_def MOST_nat_le by blast
{
fix i
assume "i β₯ max kβ©1 kβ©2"
hence "i β₯ kβ©1" and "i β₯ kβ©2"
by simp+
then obtain j' where "π’ β¨β©P afβ©G Ο' (w [i β j'])"
using k2_def by blast
then obtain j where "π’ β¨β©P afβ©G Ο' (w [i β i + j])"
by (cases "i β€ j'") (blast dest: le_Suc_ex, metis subsequence_empty le_add_diff_inverse nat_le_linear)
moreover
have "βΟ. G Ο β π’ βΉ suffix kβ©1 w β¨ G Ο"
using ltl_G_stabilize_property[OF βΉfinite (π’ βͺ βG Ο')βΊ βΉOnly_G (π’ βͺ βG Ο')βΊ k1_def]
using βΉβΟ. G Ο β π’ βΉ w β¨ F (G Ο)βΊ by blast
hence "βΟ. G Ο β π’ βΉ suffix (i + j) w β¨ G Ο"
by (metis βΉi β₯ max kβ©1 kβ©2βΊ LTL_suffix_G suffix_suffix le_Suc_ex max.cobounded1)
hence "βΟ. Ο β π’ βΉ suffix (i + j) w β¨ Ο"
using βΉOnly_G π’βΊ by fast
ultimately
have Suffix: "suffix (i + j) w β¨ afβ©G Ο' (w [i β i + j])"
using ltl_models_equiv_prop_entailment by blast
obtain c where "i = kβ©1 + c"
using βΉi β₯ kβ©1βΊ unfolding le_iff_add by blast
hence Stable: "βΟ β βG Ο'. suffix i w β¨ Ο = suffix j (suffix i w) β¨ Ο"
using k1_def k1_def[of _ "c + j"] unfolding suffix_suffix add.assoc[symmetric] by blast
from Suffix have "suffix i w β¨ Ο'"
unfolding suffix_suffix subsequence_shift afβ©G_ltl_continuation_suffix[OF Stable] by simp
}
hence "w β¨ F G Ο'"
unfolding MOST_nat_le LTL_FG_almost_all_suffixes by blast
thus ?case
using insert using βΉβΟ. G Ο β π’ βΉ w β¨ F G ΟβΊ βΉx = G Ο'βΊ by auto
qed blast
qed
lemma closed_π’β©Fβ©G:
"closed (π’β©Fβ©G Ο w) w"
proof (induction Ο)
case (LTLGlobal Ο)
thus ?case
proof (cases "w β¨ F G Ο")
case True
hence "ββ©βi. suffix i w β¨ Ο"
using LTL_FG_almost_all_suffixes by blast
then obtain i where "βj β₯ i. suffix j w β¨ Ο"
unfolding MOST_nat_le by blast
{
fix k
assume "k β₯ i"
hence "suffix k w β¨ Ο"
using βΉβjβ₯i. suffix j w β¨ ΟβΊ by blast
hence "π Ο {G Ο |Ο. w β¨ F G Ο} (suffix k w) 0"
using LTL_FG_suffix
by (blast dest: ltl_implies_provable[unfolded π’β©Fβ©G_alt_def])
hence "π Ο {G Ο |Ο. w β¨ F G Ο} w k"
unfolding subsequence_shift by auto
}
hence "πβ©β Ο {G Ο | Ο. w β¨ F G Ο} w"
using almost_all_eventually_provable_def[of Ο _ w]
unfolding MOST_nat_le by auto
hence "πβ©β Ο (π’β©Fβ©G Ο w) w"
unfolding π’β©Fβ©G_alt_def
using almost_all_eventually_provable_restrict_to_G by blast
thus ?thesis
using LTLGlobal insert by auto
qed auto
qed auto
subsubsection βΉConjunction of Eventually Provable FormulasβΊ
definition β±
where
"β± Ο w π’ j = And (map (Ξ»i. afβ©G Ο (w [i β j])) [the (threshold Ο w π’) ..< Suc j])"
lemma almost_all_suffixes_model_β±:
assumes "closed π’ w"
assumes "G Ο β π’"
shows "ββ©βj. suffix j w β¨ evalβ©G π’ (β± Ο w π’ j)"
proof -
have "Only_G π’"
using assms(1) by simp
hence "π’ β {Ο. w β¨ F Ο}" and "πβ©β Ο π’ w"
using closed_FG[OF assms(1)] assms by auto
then obtain k where "threshold Ο w π’ = Some k"
by (simp add: almost_all_eventually_provable_def)
hence k_def: "k = the (threshold Ο w π’)"
by simp
moreover
have "finite (βG Ο βͺ π’)" and "Only_G (βG Ο βͺ π’)"
using assms(1) G_nested_finite unfolding G_nested_propos_alt_def by auto
then obtain l where S: "βj Ο. Ο β βG Ο βͺ π’ βΉ suffix l w β¨ Ο = suffix (l + j) w β¨ Ο"
using ltl_G_stabilize by metis
hence π’_sat:"βj Ο. G Ο β π’ βΉ suffix (l + j) w β¨ G Ο"
using ltl_G_stabilize_property βΉπ’ β {Ο. w β¨ F Ο}βΊ by blast
{
fix j
assume "l β€ j"
{
fix i
assume "k β€ i" "i β€ j"
then obtain j' where "j = i + j'"
by (blast dest: le_Suc_ex)
hence "βj β₯ i. π’ β¨β©P afβ©G Ο (w [i β j])"
using βΉπβ©β Ο π’ wβΊ unfolding almost_all_eventually_provable_def MOST_nat_le
by (metis βΉk β€ iβΊ βΉthreshold Ο w π’ = Some kβΊ threshold_properties(2) linear subsequence_empty)
then obtain j'' where "π’ β¨β©P afβ©G Ο (w [i β j''])" and "i β€ j''"
by (blast )
have "suffix j w β¨ evalβ©G π’ (afβ©G Ο (w [i β j]))"
proof (cases "j'' β€ j")
case True
hence "π’ β¨β©P afβ©G Ο (w [i β j])"
using afβ©G_sat_core_generalized[OF βΉOnly_G π’βΊ, of _ j' Ο "suffix i w"] le_Suc_ex[OF βΉi β€ j''βΊ] le_Suc_ex[OF βΉj'' β€ jβΊ]
by (metis add.right_neutral subsequence_shift βΉj = i + j'βΊ βΉπ’ β¨β©P afβ©G Ο (w [i β j''])βΊ nat_add_left_cancel_le )
hence "π’ β¨β©P evalβ©G π’ (afβ©G Ο (w [i β j]))"
unfolding evalβ©G_prop_entailment .
moreover
have "π’ β {Ο. suffix j w β¨ Ο}"
using π’_sat βΉl β€ jβΊ βΉOnly_G π’βΊ by (fast dest: le_Suc_ex)
ultimately
have "{Ο. suffix j w β¨ Ο} β¨β©P evalβ©G π’ (afβ©G Ο (w [i β j]))"
by blast
thus ?thesis
unfolding ltl_models_equiv_prop_entailment[symmetric] by simp
next
case False
hence "π’ β¨β©P evalβ©G π’ (afβ©G (afβ©G Ο (w [i β j])) (w [j β j'']))"
unfolding foldl_append[symmetric] evalβ©G_prop_entailment
by (metis le_iff_add βΉi β€ jβΊ map_append upt_add_eq_append nat_le_linear subsequence_def βΉπ’ β¨β©P afβ©G Ο (w [i β j''])βΊ)
hence "π’ β¨β©P afβ©G (evalβ©G π’ (afβ©G Ο (w [i β j]))) (w [j β j''])" (is "π’ β¨β©P ?afβ©G")
using afβ©G_evalβ©G[OF βΉOnly_G π’βΊ] by blast
moreover
have "l β€ j''"
using False βΉl β€ jβΊ by linarith
hence "π’ β {Ο. suffix j'' w β¨ Ο}"
using π’_sat βΉOnly_G π’βΊ by (fast dest: le_Suc_ex)
ultimately
have "suffix j'' w β¨ ?afβ©G"
using ltl_models_equiv_prop_entailment[symmetric] by blast
moreover
{
have "βΟ. Ο β βG Ο βͺ π’ βΉ suffix j w β¨ Ο = suffix j'' w β¨ Ο"
using S βΉl β€ jβΊ βΉl β€ j''βΊ by (metis le_add_diff_inverse)
moreover
have "βG (evalβ©G π’ (afβ©G Ο (w [i β j]))) β βG Ο" (is "?G β _")
using evalβ©G_G_nested by force
ultimately
have "βΟ. Ο β ?G βΉ suffix j w β¨ Ο = suffix j'' w β¨ Ο"
by auto
}
ultimately
show ?thesis
using afβ©G_ltl_continuation_suffix[of "evalβ©G π’ (afβ©G Ο (w [i β j]))" "suffix j w", unfolded suffix_suffix]
by (metis False le_Suc_ex nat_le_linear add_diff_cancel_left' subsequence_prefix_suffix)
qed
}
hence "suffix j w β¨ And (map (Ξ»i. evalβ©G π’ (afβ©G Ο (w [i β j]))) [k..<Suc j])"
unfolding And_semantics set_map set_upt image_def by force
hence "suffix j w β¨ evalβ©G π’ (And (map (Ξ»i. afβ©G Ο (w [i β j])) [k..<Suc j]))"
unfolding evalβ©G_And_map map_map comp_def .
}
thus ?thesis
unfolding β±_def And_semantics MOST_nat_le k_def[symmetric] by meson
qed
lemma almost_all_commutative'':
assumes "finite S"
assumes "Only_G S"
assumes "βx. G x β S βΉ ββ©βi. P x (i::nat)"
shows "ββ©βi. βx. G x β S βΆ P x i"
proof -
from assms have "(βx. x β S βΉ ββ©βi. P (theG x) (i::nat))"
by fastforce
with assms(1) have "ββ©βi. βx β S. P (theG x) i"
using almost_all_commutative' by force
thus ?thesis
using assms(2) unfolding MOST_nat_le by force
qed
lemma almost_all_suffixes_model_β±_generalized:
assumes "closed π’ w"
shows "ββ©βj. βΟ. G Ο β π’ βΆ suffix j w β¨ evalβ©G π’ (β± Ο w π’ j)"
using almost_all_suffixes_model_β±[OF assms] almost_all_commutative''[of π’] assms by fast
subsection βΉTechnical LemmasβΊ
lemma threshold_suffix_2:
assumes "threshold Ο w π’' = Some k"
assumes "k β€ l"
shows "threshold Ο (suffix l w) π’' = Some 0"
proof -
have "πβ©β Ο π’' w"
using βΉthreshold Ο w π’' = Some kβΊ option.distinct(1)
unfolding threshold.simps index.simps almost_all_eventually_provable_def by metis
hence "πβ©β Ο π’' (suffix l w)"
using almost_all_eventually_provable_suffix by blast
moreover
have "βi β₯ k. βj. π’' β¨β©P afβ©G Ο (w [i β j])"
using threshold_properties(2)[OF assms(1)] by blast
hence "βm. βj. π’' β¨β©P afβ©G Ο ((suffix l w) [m β j])"
unfolding subsequence_shift using βΉk β€ lβΊ βΉβi β₯ k. βj. π’' β¨β©P afβ©G Ο (w [i β j])βΊ
by (metis (mono_tags, opaque_lifting) leI less_imp_add_positive order_refl subsequence_empty trans_le_add1)
ultimately
show ?thesis
by simp
qed
lemma threshold_closed:
assumes "closed π’ w"
shows "βk. βΟ. G Ο β π’ βΆ threshold Ο (suffix k w) π’ = Some 0"
proof -
define k where "k = Max {the (threshold Ο w π’) | Ο. G Ο β π’}" (is "_ = Max ?S")
have "finite π’" and "Only_G π’" and "βΟ. G Ο β π’ βΉ πβ©β Ο π’ w"
using assms by blast+
hence "βΟ. G Ο β π’ βΉ βk. threshold Ο w π’ = Some k"
unfolding almost_all_eventually_provable_def by simp
moreover
have "?S = (Ξ»x. the (threshold (theG x) w π’)) ` π’"
unfolding image_def using βΉOnly_G π’βΊ ltl.sel(8) by metis
hence "finite ?S"
using βΉfinite π’βΊ finite_imageI by simp
hence "βΟ k'. G Ο β π’ βΉ threshold Ο w π’ = Some k' βΉ k' β€ k"
by (metis (mono_tags, lifting) CollectI Max_ge k_def option.sel)
ultimately
have "βΟ. G Ο β π’ βΉ threshold Ο (suffix k w) π’ = Some 0"
using threshold_suffix[of _ w π’ _ k 0] threshold_suffix_2 by blast
thus ?thesis
by blast
qed
lemma β±_drop:
assumes "πβ©β Ο π’' w"
assumes "S β¨β©P β± Ο w π’' (i + j)"
shows "S β¨β©P β± Ο (suffix i w) π’' j"
proof -
obtain k k' where k_def: "threshold Ο w π’' = Some k" and k'_def: "threshold Ο (suffix i w) π’' = Some k'"
using assms almost_all_eventually_provable_suffix
unfolding threshold.simps index.simps almost_all_eventually_provable_def by fastforce
hence k_def_2: "the (threshold Ο w π’') = k" and k'_def_2: "the (threshold Ο (suffix i w) π’') = k'"
by simp+
moreover
hence "k β€ i + j βΉ S β¨β©P Ο"
using βΉS β¨β©P β± Ο w π’' (i + j)βΊ unfolding β±_def And_semantics And_prop_entailment by (simp add: subsequence_def)
moreover
have "k' β€ j βΉ k β€ i + j"
using k_def k'_def threshold_suffix by fastforce
ultimately
have "the (threshold Ο (suffix i w) π’') β€ j βΉ S β¨β©P Ο"
by blast
moreover
{
fix pos
assume "k' β€ pos" and "pos β€ j"
have "k β€ i + pos"
by (metis threshold_suffix k_def k'_def βΉk' β€ posβΊ add.commute add_le_cancel_right order.trans)
hence "(i + pos) β set [k..<Suc (i + j)]"
using βΉpos β€ jβΊ by auto
hence "afβ©G Ο ((suffix i w) [pos β j]) β set (map (Ξ»ia. afβ©G Ο (subsequence w ia (i + j))) [k..<Suc (i + j)])"
unfolding subsequence_shift set_map by blast
hence "S β¨β©P afβ©G Ο ((suffix i w) [pos β j])"
using assms(2) unfolding β±_def And_prop_entailment k_def_2 by (cases "k β€ i + j") auto
}
ultimately
show ?thesis
unfolding β±_def And_prop_entailment k'_def_2 by auto
qed
subsection βΉMain ResultsβΊ
definition acceptβ©M
where
"acceptβ©M Ο π’ w β‘ (ββ©βj. βS. (βΟ. G Ο β π’ βΆ S β¨β©P G Ο β§ S β¨β©P evalβ©G π’ (β± Ο w π’ j)) βΆ S β¨β©P af Ο (w [0 β j]))"
lemma lemmaD:
assumes "w β¨ Ο"
assumes "βΟ. G Ο β π’β©Fβ©G Ο w βΉ threshold Ο w (π’β©Fβ©G Ο w) = Some 0"
shows "acceptβ©M Ο (π’β©Fβ©G Ο w) w"
proof -
obtain i where "π’β©Fβ©G Ο w β¨β©P afβ©G Ο (w [0 β i])"
using ltl_implies_provable[OF βΉw β¨ ΟβΊ] by metis
{
fix S j
assume assm1: "j β₯ i"
assume assm2: "βΟ. G Ο β π’β©Fβ©G Ο w βΉ S β¨β©P G Ο β§ S β¨β©P evalβ©G (π’β©Fβ©G Ο w) (β± Ο w (π’β©Fβ©G Ο w) j)"
moreover
{
have "π’β©Fβ©G Ο w β¨β©P afβ©G Ο (w [0 β j])"
using βΉπ’β©Fβ©G Ο w β¨β©P afβ©G Ο (w [0 β i])βΊ βΉj β₯ iβΊ
by (metis afβ©G_sat_core_generalized π’β©Fβ©G_Only_G)
moreover
have "π’β©Fβ©G Ο w β S"
using assm2 unfolding π’β©Fβ©G_alt_def by auto
ultimately
have "S β¨β©P evalβ©G (π’β©Fβ©G Ο w) (afβ©G Ο (w [0 β j]))"
using evalβ©G_prop_entailment by blast
}
moreover
{
fix Ο assume "G Ο β π’β©Fβ©G Ο w"
hence "the (threshold Ο w (π’β©Fβ©G Ο w)) = 0" and "S β¨β©P evalβ©G (π’β©Fβ©G Ο w) (β± Ο w (π’β©Fβ©G Ο w) j)"
using assms assm2 option.sel by metis+
hence "βi. i β€ j βΉ S β¨β©P evalβ©G (π’β©Fβ©G Ο w) (afβ©G Ο (w[i β j]))"
unfolding β±_def And_prop_entailment evalβ©G_And_map by auto
}
ultimately
have "S β¨β©P af Ο (w [0 β j])"
using afβ©G_implies_af_evalβ©G[of _ _ Ο] by presburger
}
thus ?thesis
unfolding acceptβ©M_def MOST_nat_le by meson
qed
theorem ltl_FG_logical_characterization:
"w β¨ F G Ο β· (βπ’ β βG (F G Ο). G Ο β π’ β§ closed π’ w)"
(is "?lhs β· ?rhs")
proof
assume ?lhs
hence "G Ο β π’β©Fβ©G (F G Ο) w" and "π’β©Fβ©G (F G Ο) w β βG (F G Ο)"
unfolding π’β©Fβ©G_alt_def by auto
thus ?rhs
using closed_π’β©Fβ©G by metis
qed (blast intro: closed_FG)
theorem ltl_logical_characterization:
"w β¨ Ο β· (βπ’ β βG Ο. acceptβ©M Ο π’ w β§ closed π’ w)"
(is "?lhs β· ?rhs")
proof
assume ?lhs
obtain k where k_def: "βΟ. G Ο β π’β©Fβ©G Ο w βΉ threshold Ο (suffix k w) (π’β©Fβ©G Ο w) = Some 0"
using threshold_closed[OF closed_π’β©Fβ©G] by blast
define w' where "w' = suffix k w"
define Ο' where "Ο' = af Ο (w[0 β k])"
from βΉ?lhsβΊ have "w' β¨ Ο'"
unfolding af_ltl_continuation_suffix[of w Ο k] w'_def Ο'_def .
have G_eq: "βG Ο' = βG Ο"
unfolding Ο'_def G_af_simp ..
have π’_eq: "π’β©Fβ©G Ο' w' = π’β©Fβ©G Ο w"
unfolding π’β©Fβ©G_alt_def w'_def Ο'_def G_af_simp LTL_FG_suffix ..
have Ο'_eq: "βj. af Ο' (w' [0 βj]) = af Ο (w [0 β k + j])"
unfolding Ο'_def w'_def foldl_append[symmetric] subsequence_shift
unfolding Nat.add_0_right by (metis subsequence_append)
have "acceptβ©M Ο' (π’β©Fβ©G Ο' w') w'"
using lemmaD[OF βΉw' β¨ Ο'βΊ] k_def
unfolding π’_eq w'_def[symmetric] by blast
then obtain j' where j'_def: "βj S. j β₯ j' βΉ
(βΟ. G Ο β π’β©Fβ©G Ο' w' βΆ S β¨β©P G Ο β§ S β¨β©P evalβ©G (π’β©Fβ©G Ο' w') (β± Ο w' (π’β©Fβ©G Ο' w') j)) βΉ S β¨β©P af Ο' (w' [0 β j])"
unfolding acceptβ©M_def MOST_nat_le by blast
{
fix j S
let ?af = "af Ο (w[0 β k + j' + j])"
assume "(βΟ. G Ο β (π’β©Fβ©G Ο' w') βΆ S β¨β©P G Ο β§ S β¨β©P evalβ©G (π’β©Fβ©G Ο' w') (β± Ο w (π’β©Fβ©G Ο' w') (k + j' + j)))"
moreover
{
fix Ο
assume "G Ο β π’β©Fβ©G Ο' w'" (is "_ β ?π’")
hence "πβ©β Ο ?π’ w"
unfolding π’_eq using closed_π’β©Fβ©G by blast
have "βS. S β¨β©P evalβ©G ?π’ (β± Ο w ?π’ (k + j' + j)) βΉ S β¨β©P evalβ©G ?π’ (β± Ο w' ?π’ (j' + j))"
using β±_drop[OF βΉπβ©β Ο (π’β©Fβ©G Ο' w') wβΊ, of _ k "j' + j"] evalβ©G_respectfulness(1)[unfolded ltl_prop_implies_def]
unfolding add.assoc w'_def by metis
moreover
assume "S β¨β©P evalβ©G ?π’ (β± Ο w ?π’ (k + j' + j))"
ultimately
have "S β¨β©P evalβ©G ?π’ (β± Ο w' ?π’ (j' + j))"
by simp
}
ultimately
have "S β¨β©P ?af"
using j'_def unfolding Ο'_eq add.assoc by simp
}
hence "acceptβ©M Ο (π’β©Fβ©G Ο w) w"
unfolding acceptβ©M_def MOST_nat_le π’_eq by (metis le_Suc_ex)
moreover
have "π’β©Fβ©G Ο w β βG Ο"
unfolding π’β©Fβ©G_alt_def by auto
ultimately
show ?rhs
by (metis closed_π’β©Fβ©G)
next
assume ?rhs
then obtain π’ where π’_prop: "π’ β βG Ο" "finite π’" "Only_G π’" "acceptβ©M Ο π’ w" "closed π’ w"
using π’_elements π’_finite by blast
then obtain i where "βΟ j. Ο β π’ βΉ suffix i w β¨ Ο = suffix (i + j) w β¨ Ο"
using ltl_G_stabilize by blast
hence i_def: "βΟ. G Ο β π’ βΉ suffix i w β¨ G Ο"
using ltl_G_stabilize_property[OF βΉfinite π’βΊ βΉOnly_G π’βΊ] π’_prop closed_FG[of π’] by blast
obtain j where j_def: "βj' S. j' β₯ j βΉ
(βΟ. G Ο β π’ βΆ S β¨β©P G Ο β§ S β¨β©P evalβ©G π’ (β± Ο w π’ j')) βΆ S β¨β©P af Ο (w [0 β j'])"
using βΉacceptβ©M Ο π’ wβΊ unfolding acceptβ©M_def MOST_nat_le by presburger
obtain j' where lemma19: "βj Ο. j β₯ j' βΉ G Ο β π’ βΉ suffix j w β¨ evalβ©G π’ (β± Ο w π’ j)"
using almost_all_suffixes_model_β±_generalized[OF βΉclosed π’ wβΊ] unfolding MOST_nat_le by blast
define k where "k = max (max i j) j'"
define w' where "w' = suffix k w"
define Ο' where "Ο' = af Ο (w[0 β k])"
define S where "S = {Ο. w' β¨ Ο}"
have "(βΟ. G Ο β π’ βΉ S β¨β©P G Ο β§ S β¨β©P evalβ©G π’ (β± Ο w π’ k)) βΉ S β¨β©P Ο'"
using j_def[of k S] unfolding Ο'_def k_def by fastforce
moreover
{
fix Ο
assume "G Ο β π’"
have "βj. i β€ j βΉ suffix i w β¨ G Ο βΉ suffix j w β¨ G Ο"
by (metis LTL_suffix_G le_Suc_ex suffix_suffix)
hence "w' β¨ G Ο"
unfolding w'_def k_def max_def
using i_def[OF βΉG Ο β π’βΊ] by simp
moreover
have "w' β¨ evalβ©G π’ (β± Ο w π’ k)"
using lemma19[OF _ βΉG Ο β π’βΊ, of k]
unfolding w'_def k_def by fastforce
ultimately
have "S β¨β©P G Ο" and "S β¨β©P evalβ©G π’ (β± Ο w π’ k)"
unfolding S_def ltl_models_equiv_prop_entailment[symmetric] by blast+
}
ultimately
have "S β¨β©P Ο'"
by simp
hence "w' β¨ Ο'"
using S_def ltl_models_equiv_prop_entailment by blast
thus ?lhs
using w'_def Ο'_def af_ltl_continuation_suffix by blast
qed
end