Theory Flat_Aux_SLA
subsubsection "Flat Aux via Sloped-Language Automaton"
theory Flat_Aux_SLA
imports Flat_Aux
begin
lemma InfiniteDescentI:"(⋀nds. alw (holds2 edge) nds ⟹ Ex (descentIpath nds)) ⟹ InfiniteDescent"
unfolding SLA_Criterion Paut⇩R_lang Rst_correct[symmetric]
using ipath_def Taut⇩R_lang_in by auto
lemma "InfiniteDescent"
proof(rule InfiniteDescentI)
fix x
assume "alw (holds2 edge) x"
hence edge_always:"⋀i. edge (x !! i) (x !! Suc i)"
and Node_always:"⋀i. (x !! i) ∈ Node"
using alw_nodes
unfolding alw_holds2_iff_snth alw_holdsS_iff_snth by auto
have flat_trans_is_aux:"⋀i. x !! i = Flat ⟹ stl x !! i = Aux"
subgoal for i using edge_always[of i] by (auto) .
define Pss::"node stream ⇒ nat ⇒ nat" where
"Pss = (λx n. (if x !! n = Flat then 0 else 1))"
define Ps where Ps:"Ps = fToStream (Pss x)"
note Ps_defs = Ps[unfolded Pss_def fToStream_def]
show "Ex (descentIpath x)"
proof(cases "infs (λx. x = Flat) x")
case True
show ?thesis
apply(rule exI[of _ Ps], unfold descentIpath_iff_snth)
apply(rule exI[of _ 0], intro conjI allI impI)
subgoal for j apply(cases "x !! j")
subgoal apply(cases "x !! Suc j")
using edge_always[of j] by (auto simp: RR_defs Ps_defs)
by(cases "x !! Suc j",auto simp: RR_defs Ps_defs)
using True flat_trans_is_aux unfolding alw_ev_holds_iff_snth
by(auto simp: RR_defs Ps_defs)
next
case False
then consider (alw_aux) "alw (holds (λx. x = Aux)) x"
| (some_flat) "∃i. ∀k > i. (x !! i) = Flat ∧ (x !! k) = Aux"
apply-by(drule fins_imp, auto)
thus ?thesis proof(cases)
case alw_aux
hence alw_aux:"⋀i. x !! i = Aux" unfolding alw_holds_iff_snth by auto
also have alw_aux':"⋀i. stl x !! i = Aux" subgoal for i using calculation[of "Suc i"] by auto .
show ?thesis
apply(rule exI[of _ "sconst 0"], unfold descentIpath_iff_snth)
apply(rule exI[of _ 0], intro conjI allI impI)
using alw_aux alw_aux' by auto
next
case some_flat
then obtain i where i:"∀n>i. x !! n = Aux" "x !! i = Flat" by blast
hence always_aux:"⋀j. j≥Suc 0 ⟹ x !! (i + j) = Aux"
"⋀j. j≥Suc 0 ⟹ stl x !! (i + j) = Aux"
by (auto,metis less_add_Suc1 stl_Suc_eq)
have flat_aux_not_i_le:
"⋀j. x !! j = Flat ⟹ x !! Suc j = Aux ⟹ j ≠ i ⟹ Suc j < i ∧ j < i"
by (metis Suc_lessI i(1,2) linorder_neqE_nat node.simps(2))
have aux_flat_not_i_le:
"⋀j. x !! j = Aux ⟹ x !! Suc j = Flat ⟹ j < i"
by (metis i(1) node.simps(2) not_less_eq)
have aux_ngr:"⋀j. x !! j = Aux ⟹ x !! Suc j = Aux ⟹ ¬ i < j ⟹ Suc j < i ∧ j < i"
by (metis Suc_lessI i(2) linorder_neqE_nat node.distinct(1))
define newPs where newPs:"newPs = stake i Ps @- sconst 0"
note newPs_defs = newPs[unfolded Ps_defs]
hence always_1:"⋀j. j≥Suc 0 ⟹ newPs !! (i + j) = 0"
"⋀j. j≥Suc 0 ⟹ stl newPs !! (i + j) = 0" by auto
also have newPs_le:"⋀j. j < i ⟹ newPs !! j = (stake i Ps) ! j"
by (simp add: newPs)
have newPs_gr:"⋀j. i < j ⟹ newPs !! j = 0" unfolding newPs by auto
show ?thesis
apply(rule exI[of _ newPs], unfold descentIpath_iff_snth)
apply(rule exI[of _ "Suc 0"], intro conjI allI impI)
subgoal for j apply(cases "x !! j")
subgoal apply(cases "x !! Suc j")
subgoal using edge_always[of j] by auto
apply(cases "j = i")
subgoal by (auto simp: RR_defs newPs_defs)
apply(frule flat_aux_not_i_le[of j], safe)
apply(frule newPs_le[of j], frule newPs_le[of "Suc j"])
using nth_map_upt by (auto simp: RR_defs Ps_defs)
subgoal apply(cases "x !! Suc j")
subgoal apply(frule aux_flat_not_i_le, safe)
apply(frule newPs_le[of j], drule Suc_disj)
apply (erule disjE, frule newPs_le[of "Suc j"])
subgoal using nth_map_upt by (auto simp: RR_defs Ps_defs)
subgoal by (auto simp: RR_defs newPs_defs) .
apply(cases "i<j")
subgoal using newPs_gr newPs_gr[of "Suc j"] by auto
subgoal apply(frule aux_ngr, safe)
apply(frule newPs_le[of j], frule newPs_le[of "Suc j"])
using nth_map_upt by (auto simp: RR_defs Ps_defs) . .
subgoal for j apply(rule exI[of _ "i + j"]) using always_aux always_1 by (auto simp: RR_defs) .
qed
qed
qed
end