[STATEMENT]
lemma valid_eval_matchF_complete:
  assumes valid_before': "valid_matchF I t0 sub rho i w"
    and before_end: "reaches_on (w_run_t args) (w_tj w) (map fst rho') tj'''"
    "reaches_on (w_run_sub args) (w_sj w) (map snd rho') sj'''"
    "w_read_t args (w_ti w) = Some t" "w_read_t args tj''' = Some tm" "\<not>memR t tm I"
    and wf: "wf_regex r"
  shows "\<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and>
    valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define st where "st = w_st w"
[PROOF STATE]
proof (state)
this:
st = w_st w

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define ti where "ti = w_ti w"
[PROOF STATE]
proof (state)
this:
ti = w_ti w

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define si where "si = w_si w"
[PROOF STATE]
proof (state)
this:
si = w_si w

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define j where "j = w_j w"
[PROOF STATE]
proof (state)
this:
j = w_j w

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define tj where "tj = w_tj w"
[PROOF STATE]
proof (state)
this:
tj = w_tj w

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define sj where "sj = w_sj w"
[PROOF STATE]
proof (state)
this:
sj = w_sj w

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define s where "s = w_s w"
[PROOF STATE]
proof (state)
this:
s = w_s w

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define e where "e = w_e w"
[PROOF STATE]
proof (state)
this:
e = w_e w

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have valid_before: "rw t0 sub rho (i, ti, si, j, tj, sj)"
    "\<And>i j. i \<le> j \<Longrightarrow> j < length rho \<Longrightarrow> ts_at rho i \<le> ts_at rho j"
    "\<forall>q. mmap_lookup e q = sup_leadsto init step rho i j q"
    "valid_s init step st accept rho i i j s"
    "i = w_i w" "i \<le> j" "length rho = j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (rw t0 sub rho (i, ti, si, j, tj, sj) &&& (\<And>i j. \<lbrakk>i \<le> j; j < length rho\<rbrakk> \<Longrightarrow> ts_at rho i \<le> ts_at rho j) &&& \<forall>q. mmap_lookup e q = sup_leadsto init step rho i j q) &&& (valid_s init step st accept rho i i j s &&& i = w_i w) &&& i \<le> j &&& length rho = j
[PROOF STEP]
using valid_before'[unfolded valid_window_matchF_def] ti_def
      si_def j_def tj_def sj_def s_def e_def
[PROOF STATE]
proof (prove)
using this:
i = w_i w \<and> valid_window args t0 sub rho w \<and> rw t0 sub rho (w_i w, w_ti w, w_si w, w_j w, w_tj w, w_sj w) \<and> (\<forall>l\<in>{w_i w..<w_j w}. memR (ts_at rho i) (ts_at rho l) I)
ti = w_ti w
si = w_si w
j = w_j w
tj = w_tj w
sj = w_sj w
s = w_s w
e = w_e w

goal (1 subgoal):
 1. (rw t0 sub rho (i, ti, si, j, tj, sj) &&& (\<And>i j. \<lbrakk>i \<le> j; j < length rho\<rbrakk> \<Longrightarrow> ts_at rho i \<le> ts_at rho j) &&& \<forall>q. mmap_lookup e q = sup_leadsto init step rho i j q) &&& (valid_s init step st accept rho i i j s &&& i = w_i w) &&& i \<le> j &&& length rho = j
[PROOF STEP]
by (auto simp: valid_window_def Let_def init_def step_def st_def accept_def)
[PROOF STATE]
proof (state)
this:
rw t0 sub rho (i, ti, si, j, tj, sj)
\<lbrakk>?i3 \<le> ?j3; ?j3 < length rho\<rbrakk> \<Longrightarrow> ts_at rho ?i3 \<le> ts_at rho ?j3
\<forall>q. mmap_lookup e q = sup_leadsto init step rho i j q
valid_s init step st accept rho i i j s
i = w_i w
i \<le> j
length rho = j

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define rho'' where "rho'' = rho @ rho'"
[PROOF STATE]
proof (state)
this:
rho'' = rho @ rho'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have ij_le: "i \<le> j" "j = length rho"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> j &&& j = length rho
[PROOF STEP]
using valid_before
[PROOF STATE]
proof (prove)
using this:
rw t0 sub rho (i, ti, si, j, tj, sj)
\<lbrakk>?i3 \<le> ?j3; ?j3 < length rho\<rbrakk> \<Longrightarrow> ts_at rho ?i3 \<le> ts_at rho ?j3
\<forall>q. mmap_lookup e q = sup_leadsto init step rho i j q
valid_s init step st accept rho i i j s
i = w_i w
i \<le> j
length rho = j

goal (1 subgoal):
 1. i \<le> j &&& j = length rho
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<le> j
j = length rho

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have reach_tj: "reaches_on (w_run_t args) t0 (take j (map fst rho'')) tj"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reaches_on (w_run_t args) t0 (take j (map fst rho'')) tj
[PROOF STEP]
using valid_before(1) ij_le
[PROOF STATE]
proof (prove)
using this:
rw t0 sub rho (i, ti, si, j, tj, sj)
i \<le> j
j = length rho

goal (1 subgoal):
 1. reaches_on (w_run_t args) t0 (take j (map fst rho'')) tj
[PROOF STEP]
by (auto simp: take_map rho''_def simp del: reach_window.simps dest!: reach_window_run_tj)
[PROOF STATE]
proof (state)
this:
reaches_on (w_run_t args) t0 (take j (map fst rho'')) tj

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have reach_ti: "reaches_on (w_run_t args) t0 (take i (map fst rho'')) ti"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reaches_on (w_run_t args) t0 (take i (map fst rho'')) ti
[PROOF STEP]
using valid_before(1) ij_le
[PROOF STATE]
proof (prove)
using this:
rw t0 sub rho (i, ti, si, j, tj, sj)
i \<le> j
j = length rho

goal (1 subgoal):
 1. reaches_on (w_run_t args) t0 (take i (map fst rho'')) ti
[PROOF STEP]
by (auto simp: take_map rho''_def)
[PROOF STATE]
proof (state)
this:
reaches_on (w_run_t args) t0 (take i (map fst rho'')) ti

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have reach_si: "reaches_on (w_run_sub args) sub (take i (map snd rho'')) si"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reaches_on (w_run_sub args) sub (take i (map snd rho'')) si
[PROOF STEP]
using valid_before(1) ij_le
[PROOF STATE]
proof (prove)
using this:
rw t0 sub rho (i, ti, si, j, tj, sj)
i \<le> j
j = length rho

goal (1 subgoal):
 1. reaches_on (w_run_sub args) sub (take i (map snd rho'')) si
[PROOF STEP]
by (auto simp: take_map rho''_def)
[PROOF STATE]
proof (state)
this:
reaches_on (w_run_sub args) sub (take i (map snd rho'')) si

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have reach_sj: "reaches_on (w_run_sub args) sub (take j (map snd rho'')) sj"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reaches_on (w_run_sub args) sub (take j (map snd rho'')) sj
[PROOF STEP]
using valid_before(1) ij_le
[PROOF STATE]
proof (prove)
using this:
rw t0 sub rho (i, ti, si, j, tj, sj)
i \<le> j
j = length rho

goal (1 subgoal):
 1. reaches_on (w_run_sub args) sub (take j (map snd rho'')) sj
[PROOF STEP]
by (auto simp: take_map rho''_def simp del: reach_window.simps dest!: reach_window_run_sj)
[PROOF STATE]
proof (state)
this:
reaches_on (w_run_sub args) sub (take j (map snd rho'')) sj

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have reach_tj''': "reaches_on (w_run_t args) t0 (map fst rho'') tj'''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reaches_on (w_run_t args) t0 (map fst rho'') tj'''
[PROOF STEP]
using reaches_on_trans[OF reach_tj before_end(1)[folded tj_def]] ij_le(2)
[PROOF STATE]
proof (prove)
using this:
reaches_on (w_run_t args) t0 (take j (map fst rho'') @ map fst rho') tj'''
j = length rho

goal (1 subgoal):
 1. reaches_on (w_run_t args) t0 (map fst rho'') tj'''
[PROOF STEP]
by (auto simp del: map_append simp: rho''_def take_map drop_map map_append[symmetric])
[PROOF STATE]
proof (state)
this:
reaches_on (w_run_t args) t0 (map fst rho'') tj'''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have rho''_mono: "\<And>i j. i \<le> j \<Longrightarrow> j < length rho'' \<Longrightarrow> ts_at rho'' i \<le> ts_at rho'' j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i \<le> j; j < length rho''\<rbrakk> \<Longrightarrow> ts_at rho'' i \<le> ts_at rho'' j
[PROOF STEP]
using ts_at_mono[OF reach_tj''']
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i \<le> ?j; ?j < length rho''\<rbrakk> \<Longrightarrow> ts_at rho'' ?i \<le> ts_at rho'' ?j

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i \<le> j; j < length rho''\<rbrakk> \<Longrightarrow> ts_at rho'' i \<le> ts_at rho'' j
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i3 \<le> ?j3; ?j3 < length rho''\<rbrakk> \<Longrightarrow> ts_at rho'' ?i3 \<le> ts_at rho'' ?j3

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
obtain tm' where reach_tm: "reaches_on (w_run_t args) t0
    (map fst (rho'' @ [(tm, undefined)])) tm'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>tm'. reaches_on (w_run_t args) t0 (map fst (rho'' @ [(tm, undefined)])) tm' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using reaches_on_app[OF reach_tj'''] read_t_run[OF before_end(4)]
[PROOF STATE]
proof (prove)
using this:
w_run_t args tj''' = Some (?s'', ?v) \<Longrightarrow> reaches_on (w_run_t args) t0 (map fst rho'' @ [?v]) ?s''
\<exists>t'. w_run_t args tj''' = Some (t', tm)

goal (1 subgoal):
 1. (\<And>tm'. reaches_on (w_run_t args) t0 (map fst (rho'' @ [(tm, undefined)])) tm' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
reaches_on (w_run_t args) t0 (map fst (rho'' @ [(tm, undefined)])) tm'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have tj'''_eq: "\<And>tj_cur. reaches_on (w_run_t args) t0 (map fst rho'') tj_cur \<Longrightarrow>
    tj_cur = tj'''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>tj_cur. reaches_on (w_run_t args) t0 (map fst rho'') tj_cur \<Longrightarrow> tj_cur = tj'''
[PROOF STEP]
using reaches_on_inj[OF reach_tj''']
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>reaches_on (w_run_t args) t0 ?vs' ?t'; length (map fst rho'') = length ?vs'\<rbrakk> \<Longrightarrow> map fst rho'' = ?vs' \<and> tj''' = ?t'

goal (1 subgoal):
 1. \<And>tj_cur. reaches_on (w_run_t args) t0 (map fst rho'') tj_cur \<Longrightarrow> tj_cur = tj'''
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
reaches_on (w_run_t args) t0 (map fst rho'') ?tj_cur3 \<Longrightarrow> ?tj_cur3 = tj'''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have reach_sj''': "reaches_on (w_run_sub args) sub (map snd rho'') sj'''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reaches_on (w_run_sub args) sub (map snd rho'') sj'''
[PROOF STEP]
using reaches_on_trans[OF reach_sj before_end(2)[folded sj_def]] ij_le(2)
[PROOF STATE]
proof (prove)
using this:
reaches_on (w_run_sub args) sub (take j (map snd rho'') @ map snd rho') sj'''
j = length rho

goal (1 subgoal):
 1. reaches_on (w_run_sub args) sub (map snd rho'') sj'''
[PROOF STEP]
by (auto simp del: map_append simp: rho''_def take_map drop_map map_append[symmetric])
[PROOF STATE]
proof (state)
this:
reaches_on (w_run_sub args) sub (map snd rho'') sj'''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have sj'''_eq: "\<And>sj_cur. reaches_on (w_run_sub args) sub (map snd rho'') sj_cur \<Longrightarrow>
    sj_cur = sj'''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>sj_cur. reaches_on (w_run_sub args) sub (map snd rho'') sj_cur \<Longrightarrow> sj_cur = sj'''
[PROOF STEP]
using reaches_on_inj[OF reach_sj''']
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>reaches_on (w_run_sub args) sub ?vs' ?t'; length (map snd rho'') = length ?vs'\<rbrakk> \<Longrightarrow> map snd rho'' = ?vs' \<and> sj''' = ?t'

goal (1 subgoal):
 1. \<And>sj_cur. reaches_on (w_run_sub args) sub (map snd rho'') sj_cur \<Longrightarrow> sj_cur = sj'''
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
reaches_on (w_run_sub args) sub (map snd rho'') ?sj_cur3 \<Longrightarrow> ?sj_cur3 = sj'''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have reach_window_i: "rw t0 sub rho'' (i, ti, si, length rho'', tj''', sj''')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rw t0 sub rho'' (i, ti, si, length rho'', tj''', sj''')
[PROOF STEP]
using reach_windowI[OF reach_ti reach_si reach_tj''' reach_sj''' _ refl] ij_le
[PROOF STATE]
proof (prove)
using this:
i \<le> length rho'' \<Longrightarrow> rw t0 sub rho'' (i, ti, si, length rho'', tj''', sj''')
i \<le> j
j = length rho

goal (1 subgoal):
 1. rw t0 sub rho'' (i, ti, si, length rho'', tj''', sj''')
[PROOF STEP]
by (auto simp: rho''_def)
[PROOF STATE]
proof (state)
this:
rw t0 sub rho'' (i, ti, si, length rho'', tj''', sj''')

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have reach_window_j: "rw t0 sub rho'' (j, tj, sj, length rho'', tj''', sj''')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rw t0 sub rho'' (j, tj, sj, length rho'', tj''', sj''')
[PROOF STEP]
using reach_windowI[OF reach_tj reach_sj reach_tj''' reach_sj''' _ refl] ij_le
[PROOF STATE]
proof (prove)
using this:
j \<le> length rho'' \<Longrightarrow> rw t0 sub rho'' (j, tj, sj, length rho'', tj''', sj''')
i \<le> j
j = length rho

goal (1 subgoal):
 1. rw t0 sub rho'' (j, tj, sj, length rho'', tj''', sj''')
[PROOF STEP]
by (auto simp: rho''_def)
[PROOF STATE]
proof (state)
this:
rw t0 sub rho'' (j, tj, sj, length rho'', tj''', sj''')

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have t_def: "t = \<tau> \<sigma> i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t = \<tau> \<sigma> i
[PROOF STEP]
using valid_before(6) read_t_run[OF before_end(3)] reaches_on_app[OF reach_ti]
      ts_at_tau[where ?rho="take i rho'' @ [(t, undefined)]"]
[PROOF STATE]
proof (prove)
using this:
i \<le> j
\<exists>t'. w_run_t args (w_ti w) = Some (t', t)
w_run_t args ti = Some (?s'', ?v) \<Longrightarrow> reaches_on (w_run_t args) t0 (take i (map fst rho'') @ [?v]) ?s''
\<lbrakk>reaches_on (w_run_t args) t0 (map fst (take i rho'' @ [(t, undefined)])) ?t; ?i < length (take i rho'' @ [(t, undefined)])\<rbrakk> \<Longrightarrow> ts_at (take i rho'' @ [(t, undefined)]) ?i = \<tau> \<sigma> ?i

goal (1 subgoal):
 1. t = \<tau> \<sigma> i
[PROOF STEP]
by (fastforce simp: ti_def rho''_def valid_before(5,7) take_map ts_at_def nth_append)
[PROOF STATE]
proof (state)
this:
t = \<tau> \<sigma> i

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have t_tfin: "t \<in> tfin"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t \<in> tfin
[PROOF STEP]
using \<tau>_fin
[PROOF STATE]
proof (prove)
using this:
\<tau> ?\<sigma> ?i \<in> tfin

goal (1 subgoal):
 1. t \<in> tfin
[PROOF STEP]
by (auto simp: t_def)
[PROOF STATE]
proof (state)
this:
t \<in> tfin

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have i_lt_rho'': "i < length rho''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < length rho''
[PROOF STEP]
using ij_le before_end(3,4,5) reach_window_i memR_tfin_refl[OF t_tfin]
[PROOF STATE]
proof (prove)
using this:
i \<le> j
j = length rho
w_read_t args (w_ti w) = Some t
w_read_t args tj''' = Some tm
\<not> memR t tm I
rw t0 sub rho'' (i, ti, si, length rho'', tj''', sj''')
memR t t ?I

goal (1 subgoal):
 1. i < length rho''
[PROOF STEP]
by (cases "i = length rho''") (auto simp: rho''_def ti_def dest!: reaches_on_NilD)
[PROOF STATE]
proof (state)
this:
i < length rho''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
obtain ti''' si''' b where tbi_def: "w_run_t args ti = Some (ti''', t)"
    "w_run_sub args si = Some (si''', b)" "t = ts_at rho'' i" "b = bs_at rho'' i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>ti''' si''' b. \<lbrakk>w_run_t args ti = Some (ti''', t); w_run_sub args si = Some (si''', b); t = ts_at rho'' i; b = bs_at rho'' i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using reach_window_run_ti[OF reach_window_i i_lt_rho'']
      reach_window_run_si[OF reach_window_i i_lt_rho'']
      read_t_run[OF before_end(3), folded ti_def]
[PROOF STATE]
proof (prove)
using this:
\<exists>ti'. reaches_on (w_run_t args) t0 (take i (map fst rho'')) ti \<and> w_run_t args ti = Some (ti', ts_at rho'' i) \<and> reaches_on (w_run_t args) ti' (drop (Suc i) (map fst rho'')) tj'''
\<exists>si'. reaches_on (w_run_sub args) sub (take i (map snd rho'')) si \<and> w_run_sub args si = Some (si', bs_at rho'' i) \<and> reaches_on (w_run_sub args) si' (drop (Suc i) (map snd rho'')) sj'''
\<exists>t'. w_run_t args ti = Some (t', t)

goal (1 subgoal):
 1. (\<And>ti''' si''' b. \<lbrakk>w_run_t args ti = Some (ti''', t); w_run_sub args si = Some (si''', b); t = ts_at rho'' i; b = bs_at rho'' i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
w_run_t args ti = Some (ti''', t)
w_run_sub args si = Some (si''', b)
t = ts_at rho'' i
b = bs_at rho'' i

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
note before_end' = before_end(5)
[PROOF STATE]
proof (state)
this:
\<not> memR t tm I

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have read_ti: "w_read_t args ti = Some t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w_read_t args ti = Some t
[PROOF STEP]
using run_t_read[OF tbi_def(1)]
[PROOF STATE]
proof (prove)
using this:
w_read_t args ti = Some t

goal (1 subgoal):
 1. w_read_t args ti = Some t
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
w_read_t args ti = Some t

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have inv_before: "matchF_inv I t0 sub rho'' i ti si tj''' sj''' w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w
[PROOF STEP]
using valid_before' before_end(1,2,3) reach_window_j ij_le ti_def si_def j_def tj_def sj_def
[PROOF STATE]
proof (prove)
using this:
valid_matchF I t0 sub rho i w
reaches_on (w_run_t args) (w_tj w) (map fst rho') tj'''
reaches_on (w_run_sub args) (w_sj w) (map snd rho') sj'''
w_read_t args (w_ti w) = Some t
rw t0 sub rho'' (j, tj, sj, length rho'', tj''', sj''')
i \<le> j
j = length rho
ti = w_ti w
si = w_si w
j = w_j w
tj = w_tj w
sj = w_sj w

goal (1 subgoal):
 1. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w
[PROOF STEP]
unfolding matchF_loop_inv_def valid_window_matchF_def
[PROOF STATE]
proof (prove)
using this:
i = w_i w \<and> valid_window args t0 sub rho w \<and> rw t0 sub rho (w_i w, w_ti w, w_si w, w_j w, w_tj w, w_sj w) \<and> (\<forall>l\<in>{w_i w..<w_j w}. memR (ts_at rho i) (ts_at rho l) I)
reaches_on (w_run_t args) (w_tj w) (map fst rho') tj'''
reaches_on (w_run_sub args) (w_sj w) (map snd rho') sj'''
w_read_t args (w_ti w) = Some t
rw t0 sub rho'' (j, tj, sj, length rho'', tj''', sj''')
i \<le> j
j = length rho
ti = w_ti w
si = w_si w
j = w_j w
tj = w_tj w
sj = w_sj w

goal (1 subgoal):
 1. valid_window args t0 sub (take (w_j w) rho'') w \<and> w_i w = i \<and> w_ti w = ti \<and> w_si w = si \<and> rw t0 sub rho'' (w_j w, w_tj w, w_sj w, length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w..<w_j w}. memR (ts_at rho'' i) (ts_at rho'' l) I)
[PROOF STEP]
by (auto simp: rho''_def ts_at_def nth_append)
[PROOF STATE]
proof (state)
this:
matchF_inv I t0 sub rho'' i ti si tj''' sj''' w

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have i_j: "i \<le> j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> j
[PROOF STEP]
using valid_before
[PROOF STATE]
proof (prove)
using this:
rw t0 sub rho (i, ti, si, j, tj, sj)
\<lbrakk>?i3 \<le> ?j3; ?j3 < length rho\<rbrakk> \<Longrightarrow> ts_at rho ?i3 \<le> ts_at rho ?j3
\<forall>q. mmap_lookup e q = sup_leadsto init step rho i j q
valid_s init step st accept rho i i j s
i = w_i w
i \<le> j
length rho = j

goal (1 subgoal):
 1. i \<le> j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<le> j

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have loop: "pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)
[PROOF STEP]
proof (rule while_break_complete[of "matchF_inv I t0 sub rho'' i ti si tj''' sj'''", OF _ _ _ inv_before])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
fix w_cur :: "(bool iarray, nat set, 'd, 't, 'e) window"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
assume assms: "matchF_inv I t0 sub rho'' i ti si tj''' sj''' w_cur" "matchF_cond I t w_cur"
[PROOF STATE]
proof (state)
this:
matchF_inv I t0 sub rho'' i ti si tj''' sj''' w_cur
matchF_cond I t w_cur

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define j_cur where "j_cur = w_j w_cur"
[PROOF STATE]
proof (state)
this:
j_cur = w_j w_cur

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define tj_cur where "tj_cur = w_tj w_cur"
[PROOF STATE]
proof (state)
this:
tj_cur = w_tj w_cur

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define sj_cur where "sj_cur = w_sj w_cur"
[PROOF STATE]
proof (state)
this:
sj_cur = w_sj w_cur

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define s_cur where "s_cur = w_s w_cur"
[PROOF STATE]
proof (state)
this:
s_cur = w_s w_cur

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define e_cur where "e_cur = w_e w_cur"
[PROOF STATE]
proof (state)
this:
e_cur = w_e w_cur

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
have loop: "valid_window args t0 sub (take (w_j w_cur) rho'') w_cur"
      "rw t0 sub rho'' (j_cur, tj_cur, sj_cur, length rho'', tj''', sj''')"
      "\<And>l. l\<in>{w_i w_cur..<w_j w_cur} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_window args t0 sub (take (w_j w_cur) rho'') w_cur &&& rw t0 sub rho'' (j_cur, tj_cur, sj_cur, length rho'', tj''', sj''') &&& (\<And>l. l \<in> {w_i w_cur..<w_j w_cur} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I)
[PROOF STEP]
using j_cur_def tj_cur_def sj_cur_def s_cur_def e_cur_def
        assms(1)[unfolded matchF_loop_inv_def]
[PROOF STATE]
proof (prove)
using this:
j_cur = w_j w_cur
tj_cur = w_tj w_cur
sj_cur = w_sj w_cur
s_cur = w_s w_cur
e_cur = w_e w_cur
valid_window args t0 sub (take (w_j w_cur) rho'') w_cur \<and> w_i w_cur = i \<and> w_ti w_cur = ti \<and> w_si w_cur = si \<and> rw t0 sub rho'' (w_j w_cur, w_tj w_cur, w_sj w_cur, length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w_cur..<w_j w_cur}. memR (ts_at rho'' i) (ts_at rho'' l) I)

goal (1 subgoal):
 1. valid_window args t0 sub (take (w_j w_cur) rho'') w_cur &&& rw t0 sub rho'' (j_cur, tj_cur, sj_cur, length rho'', tj''', sj''') &&& (\<And>l. l \<in> {w_i w_cur..<w_j w_cur} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
valid_window args t0 sub (take (w_j w_cur) rho'') w_cur
rw t0 sub rho'' (j_cur, tj_cur, sj_cur, length rho'', tj''', sj''')
?l3 \<in> {w_i w_cur..<w_j w_cur} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
have j_cur_lt_rho'': "j_cur < length rho''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j_cur < length rho''
[PROOF STEP]
using assms tj'''_eq before_end(4,5)
[PROOF STATE]
proof (prove)
using this:
matchF_inv I t0 sub rho'' i ti si tj''' sj''' w_cur
matchF_cond I t w_cur
reaches_on (w_run_t args) t0 (map fst rho'') ?tj_cur3 \<Longrightarrow> ?tj_cur3 = tj'''
w_read_t args tj''' = Some tm
\<not> memR t tm I

goal (1 subgoal):
 1. j_cur < length rho''
[PROOF STEP]
unfolding matchF_loop_inv_def matchF_loop_cond_def
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w_cur) rho'') w_cur \<and> w_i w_cur = i \<and> w_ti w_cur = ti \<and> w_si w_cur = si \<and> rw t0 sub rho'' (w_j w_cur, w_tj w_cur, w_sj w_cur, length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w_cur..<w_j w_cur}. memR (ts_at rho'' i) (ts_at rho'' l) I)
case w_read_t args (w_tj w_cur) of None \<Rightarrow> False | Some t' \<Rightarrow> memR t t' I
reaches_on (w_run_t args) t0 (map fst rho'') ?tj_cur3 \<Longrightarrow> ?tj_cur3 = tj'''
w_read_t args tj''' = Some tm
\<not> memR t tm I

goal (1 subgoal):
 1. j_cur < length rho''
[PROOF STEP]
by (cases "j_cur = length rho''") (auto simp: j_cur_def split: option.splits)
[PROOF STATE]
proof (state)
this:
j_cur < length rho''

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
obtain tj_cur' sj_cur' x b_cur where tbi_cur_def: "w_run_t args tj_cur = Some (tj_cur', x)"
      "w_run_sub args sj_cur = Some (sj_cur', b_cur)"
      "x = ts_at rho'' j_cur" "b_cur = bs_at rho'' j_cur"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>tj_cur' x sj_cur' b_cur. \<lbrakk>w_run_t args tj_cur = Some (tj_cur', x); w_run_sub args sj_cur = Some (sj_cur', b_cur); x = ts_at rho'' j_cur; b_cur = bs_at rho'' j_cur\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using reach_window_run_ti[OF loop(2) j_cur_lt_rho'']
        reach_window_run_si[OF loop(2) j_cur_lt_rho'']
[PROOF STATE]
proof (prove)
using this:
\<exists>ti'. reaches_on (w_run_t args) t0 (take j_cur (map fst rho'')) tj_cur \<and> w_run_t args tj_cur = Some (ti', ts_at rho'' j_cur) \<and> reaches_on (w_run_t args) ti' (drop (Suc j_cur) (map fst rho'')) tj'''
\<exists>si'. reaches_on (w_run_sub args) sub (take j_cur (map snd rho'')) sj_cur \<and> w_run_sub args sj_cur = Some (si', bs_at rho'' j_cur) \<and> reaches_on (w_run_sub args) si' (drop (Suc j_cur) (map snd rho'')) sj'''

goal (1 subgoal):
 1. (\<And>tj_cur' x sj_cur' b_cur. \<lbrakk>w_run_t args tj_cur = Some (tj_cur', x); w_run_sub args sj_cur = Some (sj_cur', b_cur); x = ts_at rho'' j_cur; b_cur = bs_at rho'' j_cur\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
w_run_t args tj_cur = Some (tj_cur', x)
w_run_sub args sj_cur = Some (sj_cur', b_cur)
x = ts_at rho'' j_cur
b_cur = bs_at rho'' j_cur

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
note reach_window_j'_cur = reach_window_shift[OF loop(2) j_cur_lt_rho'' tbi_cur_def(1,2)]
[PROOF STATE]
proof (state)
this:
rw t0 sub rho'' (Suc j_cur, tj_cur', sj_cur', length rho'', tj''', sj''')

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
note tbi_cur_def' = tbi_cur_def(1,2)[unfolded tj_cur_def sj_cur_def]
[PROOF STATE]
proof (state)
this:
w_run_t args (w_tj w_cur) = Some (tj_cur', x)
w_run_sub args (w_sj w_cur) = Some (sj_cur', b_cur)

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
have mono: "\<And>t'. t' \<in> set (map fst (take (w_j w_cur) rho'')) \<Longrightarrow> t' \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>t'. t' \<in> set (map fst (take (w_j w_cur) rho'')) \<Longrightarrow> t' \<le> x
[PROOF STEP]
using rho''_mono[of _ j_cur] j_cur_lt_rho'' nat_less_le
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i3 \<le> j_cur; j_cur < length rho''\<rbrakk> \<Longrightarrow> ts_at rho'' ?i3 \<le> ts_at rho'' j_cur
j_cur < length rho''
(?m < ?n) = (?m \<le> ?n \<and> ?m \<noteq> ?n)

goal (1 subgoal):
 1. \<And>t'. t' \<in> set (map fst (take (w_j w_cur) rho'')) \<Longrightarrow> t' \<le> x
[PROOF STEP]
by (fastforce simp: tbi_cur_def(3) j_cur_def ts_at_def nth_append in_set_conv_nth
          split: list.splits)
[PROOF STATE]
proof (state)
this:
?t'3 \<in> set (map fst (take (w_j w_cur) rho'')) \<Longrightarrow> ?t'3 \<le> x

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
have take_unfold: "take (w_j w_cur) rho'' @ [(x, b_cur)] = (take (Suc (w_j w_cur)) rho'')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take (w_j w_cur) rho'' @ [(x, b_cur)] = take (Suc (w_j w_cur)) rho''
[PROOF STEP]
using j_cur_lt_rho''
[PROOF STATE]
proof (prove)
using this:
j_cur < length rho''

goal (1 subgoal):
 1. take (w_j w_cur) rho'' @ [(x, b_cur)] = take (Suc (w_j w_cur)) rho''
[PROOF STEP]
unfolding tbi_cur_def(3,4)
[PROOF STATE]
proof (prove)
using this:
j_cur < length rho''

goal (1 subgoal):
 1. take (w_j w_cur) rho'' @ [(ts_at rho'' j_cur, bs_at rho'' j_cur)] = take (Suc (w_j w_cur)) rho''
[PROOF STEP]
by (auto simp: ts_at_def bs_at_def j_cur_def take_Suc_conv_app_nth)
[PROOF STATE]
proof (state)
this:
take (w_j w_cur) rho'' @ [(x, b_cur)] = take (Suc (w_j w_cur)) rho''

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
obtain w_cur' where w_cur'_def: "adv_end args w_cur = Some w_cur'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>w_cur'. adv_end args w_cur = Some w_cur' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (fastforce simp: adv_end_def Let_def tj_cur_def[symmetric] sj_cur_def[symmetric] tbi_cur_def(1,2) split: prod.splits)
[PROOF STATE]
proof (state)
this:
adv_end args w_cur = Some w_cur'

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
have "\<And>l. l \<in>{w_i w_cur'..<w_j w_cur'} \<Longrightarrow>
      memR (ts_at rho'' i) (ts_at rho'' l) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. l \<in> {w_i w_cur'..<w_j w_cur'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
using loop(3) assms(2) w_cur'_def
[PROOF STATE]
proof (prove)
using this:
?l3 \<in> {w_i w_cur..<w_j w_cur} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
matchF_cond I t w_cur
adv_end args w_cur = Some w_cur'

goal (1 subgoal):
 1. \<And>l. l \<in> {w_i w_cur'..<w_j w_cur'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
unfolding adv_end_bounds[OF tbi_cur_def' w_cur'_def] matchF_loop_cond_def
        run_t_read[OF tbi_cur_def(1)[unfolded tj_cur_def]] tbi_cur_def(3) tbi_def(3)
[PROOF STATE]
proof (prove)
using this:
?l3 \<in> {w_i w_cur..<w_j w_cur} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
case Some (ts_at rho'' j_cur) of None \<Rightarrow> False | Some t' \<Rightarrow> memR (ts_at rho'' i) t' I
adv_end args w_cur = Some w_cur'

goal (1 subgoal):
 1. \<And>l. l \<in> {w_i w_cur..<Suc (w_j w_cur)} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
by (auto simp: j_cur_def elim: less_SucE)
[PROOF STATE]
proof (state)
this:
?l3 \<in> {w_i w_cur'..<w_j w_cur'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I

goal (3 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; matchF_cond I t s\<rbrakk> \<Longrightarrow> pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args s)
 2. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 3. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?l3 \<in> {w_i w_cur'..<w_j w_cur'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
[PROOF STEP]
show "pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args w_cur)"
[PROOF STATE]
proof (prove)
using this:
?l3 \<in> {w_i w_cur'..<w_j w_cur'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I

goal (1 subgoal):
 1. pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args w_cur)
[PROOF STEP]
using assms(1) reach_window_j'_cur valid_adv_end[OF loop(1) tbi_cur_def' mono]
        w_cur'_def adv_end_bounds[OF tbi_cur_def' w_cur'_def]
[PROOF STATE]
proof (prove)
using this:
?l3 \<in> {w_i w_cur'..<w_j w_cur'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
matchF_inv I t0 sub rho'' i ti si tj''' sj''' w_cur
rw t0 sub rho'' (Suc j_cur, tj_cur', sj_cur', length rho'', tj''', sj''')
(\<And>t'. t' \<in> set (map fst (take (w_j w_cur) rho'')) \<Longrightarrow> t' \<in> set (map fst (take (w_j w_cur) rho''))) \<Longrightarrow> case adv_end args w_cur of None \<Rightarrow> False | Some w' \<Rightarrow> valid_window args t0 sub (take (w_j w_cur) rho'' @ [(x, b_cur)]) w'
adv_end args w_cur = Some w_cur'
w_i w_cur' = w_i w_cur
w_ti w_cur' = w_ti w_cur
w_si w_cur' = w_si w_cur
w_j w_cur' = Suc (w_j w_cur)
w_tj w_cur' = tj_cur'
w_sj w_cur' = sj_cur'

goal (1 subgoal):
 1. pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args w_cur)
[PROOF STEP]
unfolding matchF_loop_inv_def j_cur_def take_unfold
[PROOF STATE]
proof (prove)
using this:
?l3 \<in> {w_i w_cur'..<w_j w_cur'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
valid_window args t0 sub (take (w_j w_cur) rho'') w_cur \<and> w_i w_cur = i \<and> w_ti w_cur = ti \<and> w_si w_cur = si \<and> rw t0 sub rho'' (w_j w_cur, w_tj w_cur, w_sj w_cur, length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w_cur..<w_j w_cur}. memR (ts_at rho'' i) (ts_at rho'' l) I)
rw t0 sub rho'' (Suc (w_j w_cur), tj_cur', sj_cur', length rho'', tj''', sj''')
(\<And>t'. t' \<in> set (map fst (take (w_j w_cur) rho'')) \<Longrightarrow> t' \<in> set (map fst (take (w_j w_cur) rho''))) \<Longrightarrow> case adv_end args w_cur of None \<Rightarrow> False | Some w' \<Rightarrow> valid_window args t0 sub (take (Suc (w_j w_cur)) rho'') w'
adv_end args w_cur = Some w_cur'
w_i w_cur' = w_i w_cur
w_ti w_cur' = w_ti w_cur
w_si w_cur' = w_si w_cur
w_j w_cur' = Suc (w_j w_cur)
w_tj w_cur' = tj_cur'
w_sj w_cur' = sj_cur'

goal (1 subgoal):
 1. pred_option' (\<lambda>w. valid_window args t0 sub (take (w_j w) rho'') w \<and> w_i w = i \<and> w_ti w = ti \<and> w_si w = si \<and> rw t0 sub rho'' (w_j w, w_tj w, w_sj w, length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w..<w_j w}. memR (ts_at rho'' i) (ts_at rho'' l) I)) (adv_end args w_cur)
[PROOF STEP]
by (auto simp: pred_option'_def)
[PROOF STATE]
proof (state)
this:
pred_option' (matchF_inv I t0 sub rho'' i ti si tj''' sj''') (adv_end args w_cur)

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
fix w1 w2
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
assume lassms: "matchF_inv I t0 sub rho'' i ti si tj''' sj''' w1" "matchF_cond I t w1"
        "Some w2 = adv_end args w1"
[PROOF STATE]
proof (state)
this:
matchF_inv I t0 sub rho'' i ti si tj''' sj''' w1
matchF_cond I t w1
Some w2 = adv_end args w1

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define j_cur where "j_cur = w_j w1"
[PROOF STATE]
proof (state)
this:
j_cur = w_j w1

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define tj_cur where "tj_cur = w_tj w1"
[PROOF STATE]
proof (state)
this:
tj_cur = w_tj w1

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define sj_cur where "sj_cur = w_sj w1"
[PROOF STATE]
proof (state)
this:
sj_cur = w_sj w1

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define s_cur where "s_cur = w_s w1"
[PROOF STATE]
proof (state)
this:
s_cur = w_s w1

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
define e_cur where "e_cur = w_e w1"
[PROOF STATE]
proof (state)
this:
e_cur = w_e w1

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
have loop: "valid_window args t0 sub (take (w_j w1) rho'') w1"
        "rw t0 sub rho'' (j_cur, tj_cur, sj_cur, length rho'', tj''', sj''')"
        "\<And>l. l\<in>{w_i w1..<w_j w1} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_window args t0 sub (take (w_j w1) rho'') w1 &&& rw t0 sub rho'' (j_cur, tj_cur, sj_cur, length rho'', tj''', sj''') &&& (\<And>l. l \<in> {w_i w1..<w_j w1} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I)
[PROOF STEP]
using j_cur_def tj_cur_def sj_cur_def s_cur_def e_cur_def
          lassms(1)[unfolded matchF_loop_inv_def]
[PROOF STATE]
proof (prove)
using this:
j_cur = w_j w1
tj_cur = w_tj w1
sj_cur = w_sj w1
s_cur = w_s w1
e_cur = w_e w1
valid_window args t0 sub (take (w_j w1) rho'') w1 \<and> w_i w1 = i \<and> w_ti w1 = ti \<and> w_si w1 = si \<and> rw t0 sub rho'' (w_j w1, w_tj w1, w_sj w1, length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w1..<w_j w1}. memR (ts_at rho'' i) (ts_at rho'' l) I)

goal (1 subgoal):
 1. valid_window args t0 sub (take (w_j w1) rho'') w1 &&& rw t0 sub rho'' (j_cur, tj_cur, sj_cur, length rho'', tj''', sj''') &&& (\<And>l. l \<in> {w_i w1..<w_j w1} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
valid_window args t0 sub (take (w_j w1) rho'') w1
rw t0 sub rho'' (j_cur, tj_cur, sj_cur, length rho'', tj''', sj''')
?l3 \<in> {w_i w1..<w_j w1} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
have j_cur_lt_rho'': "j_cur < length rho''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j_cur < length rho''
[PROOF STEP]
using lassms tj'''_eq ij_le before_end(4,5)
[PROOF STATE]
proof (prove)
using this:
matchF_inv I t0 sub rho'' i ti si tj''' sj''' w1
matchF_cond I t w1
Some w2 = adv_end args w1
reaches_on (w_run_t args) t0 (map fst rho'') ?tj_cur3 \<Longrightarrow> ?tj_cur3 = tj'''
i \<le> j
j = length rho
w_read_t args tj''' = Some tm
\<not> memR t tm I

goal (1 subgoal):
 1. j_cur < length rho''
[PROOF STEP]
unfolding matchF_loop_inv_def matchF_loop_cond_def
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w1) rho'') w1 \<and> w_i w1 = i \<and> w_ti w1 = ti \<and> w_si w1 = si \<and> rw t0 sub rho'' (w_j w1, w_tj w1, w_sj w1, length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w1..<w_j w1}. memR (ts_at rho'' i) (ts_at rho'' l) I)
case w_read_t args (w_tj w1) of None \<Rightarrow> False | Some t' \<Rightarrow> memR t t' I
Some w2 = adv_end args w1
reaches_on (w_run_t args) t0 (map fst rho'') ?tj_cur3 \<Longrightarrow> ?tj_cur3 = tj'''
i \<le> j
j = length rho
w_read_t args tj''' = Some tm
\<not> memR t tm I

goal (1 subgoal):
 1. j_cur < length rho''
[PROOF STEP]
by (cases "j_cur = length rho''") (auto simp: j_cur_def split: option.splits)
[PROOF STATE]
proof (state)
this:
j_cur < length rho''

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
obtain tj_cur' sj_cur' x b_cur where tbi_cur_def: "w_run_t args tj_cur = Some (tj_cur', x)"
        "w_run_sub args sj_cur = Some (sj_cur', b_cur)"
        "x = ts_at rho'' j_cur" "b_cur = bs_at rho'' j_cur"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>tj_cur' x sj_cur' b_cur. \<lbrakk>w_run_t args tj_cur = Some (tj_cur', x); w_run_sub args sj_cur = Some (sj_cur', b_cur); x = ts_at rho'' j_cur; b_cur = bs_at rho'' j_cur\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using reach_window_run_ti[OF loop(2) j_cur_lt_rho'']
          reach_window_run_si[OF loop(2) j_cur_lt_rho'']
[PROOF STATE]
proof (prove)
using this:
\<exists>ti'. reaches_on (w_run_t args) t0 (take j_cur (map fst rho'')) tj_cur \<and> w_run_t args tj_cur = Some (ti', ts_at rho'' j_cur) \<and> reaches_on (w_run_t args) ti' (drop (Suc j_cur) (map fst rho'')) tj'''
\<exists>si'. reaches_on (w_run_sub args) sub (take j_cur (map snd rho'')) sj_cur \<and> w_run_sub args sj_cur = Some (si', bs_at rho'' j_cur) \<and> reaches_on (w_run_sub args) si' (drop (Suc j_cur) (map snd rho'')) sj'''

goal (1 subgoal):
 1. (\<And>tj_cur' x sj_cur' b_cur. \<lbrakk>w_run_t args tj_cur = Some (tj_cur', x); w_run_sub args sj_cur = Some (sj_cur', b_cur); x = ts_at rho'' j_cur; b_cur = bs_at rho'' j_cur\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
w_run_t args tj_cur = Some (tj_cur', x)
w_run_sub args sj_cur = Some (sj_cur', b_cur)
x = ts_at rho'' j_cur
b_cur = bs_at rho'' j_cur

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
note tbi_cur_def' = tbi_cur_def(1,2)[unfolded tj_cur_def sj_cur_def]
[PROOF STATE]
proof (state)
this:
w_run_t args (w_tj w1) = Some (tj_cur', x)
w_run_sub args (w_sj w1) = Some (sj_cur', b_cur)

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
have "length rho'' - w_j w2 < length rho'' - w_j w1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length rho'' - w_j w2 < length rho'' - w_j w1
[PROOF STEP]
using j_cur_lt_rho'' adv_end_bounds[OF tbi_cur_def', folded lassms(3)]
[PROOF STATE]
proof (prove)
using this:
j_cur < length rho''
Some w2 = Some ?w' \<Longrightarrow> w_i ?w' = w_i w1
Some w2 = Some ?w' \<Longrightarrow> w_ti ?w' = w_ti w1
Some w2 = Some ?w' \<Longrightarrow> w_si ?w' = w_si w1
Some w2 = Some ?w' \<Longrightarrow> w_j ?w' = Suc (w_j w1)
Some w2 = Some ?w' \<Longrightarrow> w_tj ?w' = tj_cur'
Some w2 = Some ?w' \<Longrightarrow> w_sj ?w' = sj_cur'

goal (1 subgoal):
 1. length rho'' - w_j w2 < length rho'' - w_j w1
[PROOF STEP]
unfolding j_cur_def
[PROOF STATE]
proof (prove)
using this:
w_j w1 < length rho''
Some w2 = Some ?w' \<Longrightarrow> w_i ?w' = w_i w1
Some w2 = Some ?w' \<Longrightarrow> w_ti ?w' = w_ti w1
Some w2 = Some ?w' \<Longrightarrow> w_si ?w' = w_si w1
Some w2 = Some ?w' \<Longrightarrow> w_j ?w' = Suc (w_j w1)
Some w2 = Some ?w' \<Longrightarrow> w_tj ?w' = tj_cur'
Some w2 = Some ?w' \<Longrightarrow> w_sj ?w' = sj_cur'

goal (1 subgoal):
 1. length rho'' - w_j w2 < length rho'' - w_j w1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length rho'' - w_j w2 < length rho'' - w_j w1

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' ?w1.5; matchF_cond I t ?w1.5; Some ?w2.5 = adv_end args ?w1.5\<rbrakk> \<Longrightarrow> length rho'' - w_j ?w2.5 < length rho'' - w_j ?w1.5

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' ?w1.5; matchF_cond I t ?w1.5; Some ?w2.5 = adv_end args ?w1.5\<rbrakk> \<Longrightarrow> length rho'' - w_j ?w2.5 < length rho'' - w_j ?w1.5
[PROOF STEP]
have "{(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and>
      Some ta = adv_end args s} \<subseteq> measure (\<lambda>w. length rho'' - w_j w)"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' ?w1.5; matchF_cond I t ?w1.5; Some ?w2.5 = adv_end args ?w1.5\<rbrakk> \<Longrightarrow> length rho'' - w_j ?w2.5 < length rho'' - w_j ?w1.5

goal (1 subgoal):
 1. {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s} \<subseteq> measure (\<lambda>w. length rho'' - w_j w)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s} \<subseteq> measure (\<lambda>w. length rho'' - w_j w)

goal (2 subgoals):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
 2. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s} \<subseteq> measure (\<lambda>w. length rho'' - w_j w)
[PROOF STEP]
show "wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and>
      Some ta = adv_end args s}"
[PROOF STATE]
proof (prove)
using this:
{(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s} \<subseteq> measure (\<lambda>w. length rho'' - w_j w)

goal (1 subgoal):
 1. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
using wf_measure wf_subset
[PROOF STATE]
proof (prove)
using this:
{(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s} \<subseteq> measure (\<lambda>w. length rho'' - w_j w)
wf (measure ?f)
\<lbrakk>wf ?r; ?p \<subseteq> ?r\<rbrakk> \<Longrightarrow> wf ?p

goal (1 subgoal):
 1. wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
wf {(ta, s). matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> matchF_cond I t s \<and> Some ta = adv_end args s}

goal (1 subgoal):
 1. \<And>s. \<lbrakk>matchF_inv I t0 sub rho'' i ti si tj''' sj''' s; \<not> matchF_cond I t s\<rbrakk> \<Longrightarrow> matchF_inv I t0 sub rho'' i ti si tj''' sj''' s \<and> \<not> matchF_cond I t s
[PROOF STEP]
qed (auto simp add: inv_before)
[PROOF STATE]
proof (state)
this:
pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
obtain w' where w'_def: "while_break (matchF_cond I t) (adv_end args) w = Some w'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>w'. while_break (matchF_cond I t) (adv_end args) w = Some w' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using loop
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)

goal (1 subgoal):
 1. (\<And>w'. while_break (matchF_cond I t) (adv_end args) w = Some w' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: pred_option'_def split: option.splits)
[PROOF STATE]
proof (state)
this:
while_break (matchF_cond I t) (adv_end args) w = Some w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define w'' where adv_start_last: "w'' = adv_start args w'"
[PROOF STATE]
proof (state)
this:
w'' = adv_start args w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define st' where "st' = w_st w'"
[PROOF STATE]
proof (state)
this:
st' = w_st w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define i' where "i' = w_i w'"
[PROOF STATE]
proof (state)
this:
i' = w_i w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define ti' where "ti' = w_ti w'"
[PROOF STATE]
proof (state)
this:
ti' = w_ti w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define si' where "si' = w_si w'"
[PROOF STATE]
proof (state)
this:
si' = w_si w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define j' where "j' = w_j w'"
[PROOF STATE]
proof (state)
this:
j' = w_j w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define tj' where "tj' = w_tj w'"
[PROOF STATE]
proof (state)
this:
tj' = w_tj w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define sj' where "sj' = w_sj w'"
[PROOF STATE]
proof (state)
this:
sj' = w_sj w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define s' where "s' = w_s w'"
[PROOF STATE]
proof (state)
this:
s' = w_s w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define e' where "e' = w_e w'"
[PROOF STATE]
proof (state)
this:
e' = w_e w'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have valid_after: "valid_window args t0 sub (take (w_j w') rho'') w'"
    "rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')"
    "\<And>l. l\<in>{i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I"
    "i' = i" "ti' = ti" "si' = si"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (valid_window args t0 sub (take (w_j w') rho'') w' &&& rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''') &&& (\<And>l. l \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I)) &&& i' = i &&& ti' = ti &&& si' = si
[PROOF STEP]
using loop
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)

goal (1 subgoal):
 1. (valid_window args t0 sub (take (w_j w') rho'') w' &&& rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''') &&& (\<And>l. l \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I)) &&& i' = i &&& ti' = ti &&& si' = si
[PROOF STEP]
unfolding matchF_loop_inv_def w'_def i'_def ti'_def si'_def j'_def tj'_def sj'_def
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. (valid_window args t0 sub (take (w_j w') rho'') w' \<and> w_i w' = i \<and> w_ti w' = ti \<and> w_si w' = si \<and> rw t0 sub rho'' (w_j w', w_tj w', w_sj w', length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w'..<w_j w'}. memR (ts_at rho'' i) (ts_at rho'' l) I)) \<and> \<not> matchF_cond I t w') (Some w')

goal (1 subgoal):
 1. (valid_window args t0 sub (take (w_j w') rho'') w' &&& rw t0 sub rho'' (w_j w', w_tj w', w_sj w', length rho'', tj''', sj''') &&& (\<And>l. l \<in> {i..<w_j w'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I)) &&& w_i w' = i &&& w_ti w' = ti &&& w_si w' = si
[PROOF STEP]
by (auto simp: pred_option'_def)
[PROOF STATE]
proof (state)
this:
valid_window args t0 sub (take (w_j w') rho'') w'
rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')
?l3 \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
i' = i
ti' = ti
si' = si

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define i'' where "i'' = w_i w''"
[PROOF STATE]
proof (state)
this:
i'' = w_i w''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define j'' where "j'' = w_j w''"
[PROOF STATE]
proof (state)
this:
j'' = w_j w''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define tj'' where "tj'' = w_tj w''"
[PROOF STATE]
proof (state)
this:
tj'' = w_tj w''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
define sj'' where "sj'' = w_sj w''"
[PROOF STATE]
proof (state)
this:
sj'' = w_sj w''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have j'_le_rho'': "j' \<le> length rho''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j' \<le> length rho''
[PROOF STEP]
using loop
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)

goal (1 subgoal):
 1. j' \<le> length rho''
[PROOF STEP]
unfolding matchF_loop_inv_def valid_window_matchF_def w'_def j'_def
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. (valid_window args t0 sub (take (w_j w') rho'') w' \<and> w_i w' = i \<and> w_ti w' = ti \<and> w_si w' = si \<and> rw t0 sub rho'' (w_j w', w_tj w', w_sj w', length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w'..<w_j w'}. memR (ts_at rho'' i) (ts_at rho'' l) I)) \<and> \<not> matchF_cond I t w') (Some w')

goal (1 subgoal):
 1. w_j w' \<le> length rho''
[PROOF STEP]
by (auto simp: pred_option'_def)
[PROOF STATE]
proof (state)
this:
j' \<le> length rho''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
obtain te where tbj'_def: "w_read_t args tj' = Some te"
    "te = ts_at (rho'' @ [(tm, undefined)]) j'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>te. \<lbrakk>w_read_t args tj' = Some te; te = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof (cases "j' < length rho''")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<And>te. \<lbrakk>w_read_t args tj' = Some te; te = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis; j' < length rho''\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>te. \<lbrakk>w_read_t args tj' = Some te; te = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis; \<not> j' < length rho''\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
j' < length rho''

goal (2 subgoals):
 1. \<lbrakk>\<And>te. \<lbrakk>w_read_t args tj' = Some te; te = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis; j' < length rho''\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>te. \<lbrakk>w_read_t args tj' = Some te; te = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis; \<not> j' < length rho''\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. thesis
[PROOF STEP]
using reach_window_run_ti[OF valid_after(2) True] that True
[PROOF STATE]
proof (prove)
using this:
\<exists>ti'. reaches_on (w_run_t args) t0 (take j' (map fst rho'')) tj' \<and> w_run_t args tj' = Some (ti', ts_at rho'' j') \<and> reaches_on (w_run_t args) ti' (drop (Suc j') (map fst rho'')) tj'''
\<lbrakk>w_read_t args tj' = Some ?te3; ?te3 = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis
j' < length rho''

goal (1 subgoal):
 1. thesis
[PROOF STEP]
by (auto simp: ts_at_def nth_append dest!: run_t_read)
[PROOF STATE]
proof (state)
this:
thesis

goal (1 subgoal):
 1. \<lbrakk>\<And>te. \<lbrakk>w_read_t args tj' = Some te; te = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis; \<not> j' < length rho''\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>\<And>te. \<lbrakk>w_read_t args tj' = Some te; te = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis; \<not> j' < length rho''\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> j' < length rho''

goal (1 subgoal):
 1. \<lbrakk>\<And>te. \<lbrakk>w_read_t args tj' = Some te; te = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis; \<not> j' < length rho''\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> j' < length rho''
[PROOF STEP]
have "tj' = tj'''" "j' = length rho''"
[PROOF STATE]
proof (prove)
using this:
\<not> j' < length rho''

goal (1 subgoal):
 1. tj' = tj''' &&& j' = length rho''
[PROOF STEP]
using valid_after(2) j'_le_rho'' tj'''_eq
[PROOF STATE]
proof (prove)
using this:
\<not> j' < length rho''
rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')
j' \<le> length rho''
reaches_on (w_run_t args) t0 (map fst rho'') ?tj_cur3 \<Longrightarrow> ?tj_cur3 = tj'''

goal (1 subgoal):
 1. tj' = tj''' &&& j' = length rho''
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
tj' = tj'''
j' = length rho''

goal (1 subgoal):
 1. \<lbrakk>\<And>te. \<lbrakk>w_read_t args tj' = Some te; te = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis; \<not> j' < length rho''\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
tj' = tj'''
j' = length rho''
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
tj' = tj'''
j' = length rho''

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that before_end(4)
[PROOF STATE]
proof (prove)
using this:
tj' = tj'''
j' = length rho''
\<lbrakk>w_read_t args tj' = Some ?te3; ?te3 = ts_at (rho'' @ [(tm, undefined)]) j'\<rbrakk> \<Longrightarrow> thesis
w_read_t args tj''' = Some tm

goal (1 subgoal):
 1. thesis
[PROOF STEP]
by (auto simp: ts_at_def nth_append)
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
w_read_t args tj' = Some te
te = ts_at (rho'' @ [(tm, undefined)]) j'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have not_ets_te: "\<not>memR (ts_at rho'' i) te I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> memR (ts_at rho'' i) te I
[PROOF STEP]
using loop
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)

goal (1 subgoal):
 1. \<not> memR (ts_at rho'' i) te I
[PROOF STEP]
unfolding w'_def
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (Some w')

goal (1 subgoal):
 1. \<not> memR (ts_at rho'' i) te I
[PROOF STEP]
by (auto simp: pred_option'_def matchF_loop_cond_def tj'_def[symmetric] tbj'_def(1) tbi_def(3) split: option.splits)
[PROOF STATE]
proof (state)
this:
\<not> memR (ts_at rho'' i) te I

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have i'_set: "\<And>l. l \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I"
    "\<not>memR (ts_at rho'' i) (ts_at (rho'' @ [(tm, undefined)]) j') I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>l. l \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I) &&& \<not> memR (ts_at rho'' i) (ts_at (rho'' @ [(tm, undefined)]) j') I
[PROOF STEP]
using loop tbj'_def not_ets_te valid_after atLeastLessThan_iff
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)
w_read_t args tj' = Some te
te = ts_at (rho'' @ [(tm, undefined)]) j'
\<not> memR (ts_at rho'' i) te I
valid_window args t0 sub (take (w_j w') rho'') w'
rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')
?l3 \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
i' = i
ti' = ti
si' = si
(?i \<in> {?l..<?u}) = (?l \<le> ?i \<and> ?i < ?u)

goal (1 subgoal):
 1. (\<And>l. l \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I) &&& \<not> memR (ts_at rho'' i) (ts_at (rho'' @ [(tm, undefined)]) j') I
[PROOF STEP]
unfolding matchF_loop_inv_def matchF_loop_cond_def tbi_def(3)
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. (valid_window args t0 sub (take (w_j w') rho'') w' \<and> w_i w' = i \<and> w_ti w' = ti \<and> w_si w' = si \<and> rw t0 sub rho'' (w_j w', w_tj w', w_sj w', length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w'..<w_j w'}. memR (ts_at rho'' i) (ts_at rho'' l) I)) \<and> \<not> (case w_read_t args (w_tj w') of None \<Rightarrow> False | Some t' \<Rightarrow> memR (ts_at rho'' i) t' I)) (while_break (\<lambda>w. case w_read_t args (w_tj w) of None \<Rightarrow> False | Some t' \<Rightarrow> memR (ts_at rho'' i) t' I) (adv_end args) w)
w_read_t args tj' = Some te
te = ts_at (rho'' @ [(tm, undefined)]) j'
\<not> memR (ts_at rho'' i) te I
valid_window args t0 sub (take (w_j w') rho'') w'
rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')
?l3 \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
i' = i
ti' = ti
si' = si
(?i \<in> {?l..<?u}) = (?l \<le> ?i \<and> ?i < ?u)

goal (1 subgoal):
 1. (\<And>l. l \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' l) I) &&& \<not> memR (ts_at rho'' i) (ts_at (rho'' @ [(tm, undefined)]) j') I
[PROOF STEP]
by (auto simp: tbi_def tj'_def split: option.splits)
[PROOF STATE]
proof (state)
this:
?l3 \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
\<not> memR (ts_at rho'' i) (ts_at (rho'' @ [(tm, undefined)]) j') I

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have i_le_j': "i \<le> j'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> j'
[PROOF STEP]
using valid_after(1)
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w') rho'') w'

goal (1 subgoal):
 1. i \<le> j'
[PROOF STEP]
unfolding valid_after(4)[symmetric]
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w') rho'') w'

goal (1 subgoal):
 1. i' \<le> j'
[PROOF STEP]
by (auto simp: valid_window_def Let_def i'_def j'_def)
[PROOF STATE]
proof (state)
this:
i \<le> j'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have i_lt_j': "i < j'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < j'
[PROOF STEP]
using i_le_j' i'_set(2) i_lt_rho''
[PROOF STATE]
proof (prove)
using this:
i \<le> j'
\<not> memR (ts_at rho'' i) (ts_at (rho'' @ [(tm, undefined)]) j') I
i < length rho''

goal (1 subgoal):
 1. i < j'
[PROOF STEP]
using memR_tfin_refl[OF \<tau>_fin] ts_at_tau[OF reach_tj''', of j']
[PROOF STATE]
proof (prove)
using this:
i \<le> j'
\<not> memR (ts_at rho'' i) (ts_at (rho'' @ [(tm, undefined)]) j') I
i < length rho''
memR (\<tau> ?\<sigma>1 ?i1) (\<tau> ?\<sigma>1 ?i1) ?I
j' < length rho'' \<Longrightarrow> ts_at rho'' j' = \<tau> \<sigma> j'

goal (1 subgoal):
 1. i < j'
[PROOF STEP]
by (cases "i = j'") (auto simp: ts_at_def nth_append)
[PROOF STATE]
proof (state)
this:
i < j'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < j'
[PROOF STEP]
have i'_lt_j': "i' < j'"
[PROOF STATE]
proof (prove)
using this:
i < j'

goal (1 subgoal):
 1. i' < j'
[PROOF STEP]
unfolding valid_after
[PROOF STATE]
proof (prove)
using this:
i < j'

goal (1 subgoal):
 1. i < j'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i' < j'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have adv_last_bounds: "i'' = Suc i'" "w_ti w'' = ti'''" "w_si w'' = si'''" "j'' = j'"
    "tj'' = tj'" "sj'' = sj'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (i'' = Suc i' &&& w_ti w'' = ti''' &&& w_si w'' = si''') &&& j'' = j' &&& tj'' = tj' &&& sj'' = sj'
[PROOF STEP]
using valid_adv_start_bounds[OF valid_after(1) i'_lt_j'[unfolded i'_def j'_def]]
      valid_adv_start_bounds'[OF valid_after(1) tbi_def(1,2)[folded valid_after(5,6),
      unfolded ti'_def si'_def]]
[PROOF STATE]
proof (prove)
using this:
w_i (adv_start args w') = Suc (w_i w')
w_j (adv_start args w') = w_j w'
w_tj (adv_start args w') = w_tj w'
w_sj (adv_start args w') = w_sj w'
w_ti (adv_start args w') = ti'''
w_si (adv_start args w') = si'''

goal (1 subgoal):
 1. (i'' = Suc i' &&& w_ti w'' = ti''' &&& w_si w'' = si''') &&& j'' = j' &&& tj'' = tj' &&& sj'' = sj'
[PROOF STEP]
unfolding adv_start_last i'_def i''_def j'_def j''_def tj'_def tj''_def sj'_def sj''_def
[PROOF STATE]
proof (prove)
using this:
w_i (adv_start args w') = Suc (w_i w')
w_j (adv_start args w') = w_j w'
w_tj (adv_start args w') = w_tj w'
w_sj (adv_start args w') = w_sj w'
w_ti (adv_start args w') = ti'''
w_si (adv_start args w') = si'''

goal (1 subgoal):
 1. (w_i (adv_start args w') = Suc (w_i w') &&& w_ti (adv_start args w') = ti''' &&& w_si (adv_start args w') = si''') &&& w_j (adv_start args w') = w_j w' &&& w_tj (adv_start args w') = w_tj w' &&& w_sj (adv_start args w') = w_sj w'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i'' = Suc i'
w_ti w'' = ti'''
w_si w'' = si'''
j'' = j'
tj'' = tj'
sj'' = sj'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have i''_i: "i'' = i + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i'' = i + 1
[PROOF STEP]
using valid_after adv_last_bounds
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w') rho'') w'
rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')
?l3 \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
i' = i
ti' = ti
si' = si
i'' = Suc i'
w_ti w'' = ti'''
w_si w'' = si'''
j'' = j'
tj'' = tj'
sj'' = sj'

goal (1 subgoal):
 1. i'' = i + 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i'' = i + 1

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have i_le_j': "i \<le> j'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> j'
[PROOF STEP]
using valid_after i'_lt_j'
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w') rho'') w'
rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')
?l3 \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
i' = i
ti' = ti
si' = si
i' < j'

goal (1 subgoal):
 1. i \<le> j'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<le> j'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i \<le> j'
[PROOF STEP]
have i_le_rho: "i \<le> length rho''"
[PROOF STATE]
proof (prove)
using this:
i \<le> j'

goal (1 subgoal):
 1. i \<le> length rho''
[PROOF STEP]
using valid_after(2)
[PROOF STATE]
proof (prove)
using this:
i \<le> j'
rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')

goal (1 subgoal):
 1. i \<le> length rho''
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<le> length rho''

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have "valid_s init step st' accept (take j' rho'') i i j' s'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_s init step st' accept (take j' rho'') i i j' s'
[PROOF STEP]
using valid_after(1,4) i'_def
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w') rho'') w'
i' = i
i' = w_i w'

goal (1 subgoal):
 1. valid_s init step st' accept (take j' rho'') i i j' s'
[PROOF STEP]
by (auto simp: valid_window_def Let_def init_def step_def st'_def accept_def j'_def s'_def)
[PROOF STATE]
proof (state)
this:
valid_s init step st' accept (take j' rho'') i i j' s'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
note valid_s' = this[unfolded valid_s_def]
[PROOF STATE]
proof (state)
this:
(\<forall>q bs. case Mapping.lookup st' (q, bs) of None \<Rightarrow> True | Some v \<Rightarrow> step q bs = v) \<and> mmap_keys s' = {q. \<exists>l\<le>i. steps step (take j' rho'') init (l, i) = q} \<and> distinct (map fst s') \<and> (\<forall>q. case mmap_lookup s' q of None \<Rightarrow> True | Some (q', tstp) \<Rightarrow> steps step (take j' rho'') q (i, j') = q' \<and> tstp = sup_acc step accept (take j' rho'') q i j')

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have q0_in_keys: "{0} \<in> mmap_keys s'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0} \<in> mmap_keys s'
[PROOF STEP]
using valid_s' init_def steps_refl
[PROOF STATE]
proof (prove)
using this:
(\<forall>q bs. case Mapping.lookup st' (q, bs) of None \<Rightarrow> True | Some v \<Rightarrow> step q bs = v) \<and> mmap_keys s' = {q. \<exists>l\<le>i. steps step (take j' rho'') init (l, i) = q} \<and> distinct (map fst s') \<and> (\<forall>q. case mmap_lookup s' q of None \<Rightarrow> True | Some (q', tstp) \<Rightarrow> steps step (take j' rho'') q (i, j') = q' \<and> tstp = sup_acc step accept (take j' rho'') q i j')
init = {0}
steps ?step ?rho ?q (?i, ?i) = ?q

goal (1 subgoal):
 1. {0} \<in> mmap_keys s'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{0} \<in> mmap_keys s'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{0} \<in> mmap_keys s'
[PROOF STEP]
obtain q' tstp where lookup_s': "mmap_lookup s' {0} = Some (q', tstp)"
[PROOF STATE]
proof (prove)
using this:
{0} \<in> mmap_keys s'

goal (1 subgoal):
 1. (\<And>q' tstp. mmap_lookup s' {0} = Some (q', tstp) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto dest: Mapping_keys_dest)
[PROOF STATE]
proof (state)
this:
mmap_lookup s' {0} = Some (q', tstp)

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have lookup_sup_acc: "snd (the (mmap_lookup s' {0})) =
    sup_acc step accept (take j' rho'') {0} i j'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (the (mmap_lookup s' {0})) = sup_acc step accept (take j' rho'') {0} i j'
[PROOF STEP]
using conjunct2[OF valid_s'] lookup_s'
[PROOF STATE]
proof (prove)
using this:
mmap_keys s' = {q. \<exists>l\<le>i. steps step (take j' rho'') init (l, i) = q} \<and> distinct (map fst s') \<and> (\<forall>q. case mmap_lookup s' q of None \<Rightarrow> True | Some (q', tstp) \<Rightarrow> steps step (take j' rho'') q (i, j') = q' \<and> tstp = sup_acc step accept (take j' rho'') q i j')
mmap_lookup s' {0} = Some (q', tstp)

goal (1 subgoal):
 1. snd (the (mmap_lookup s' {0})) = sup_acc step accept (take j' rho'') {0} i j'
[PROOF STEP]
by auto (smt case_prodD option.simps(5))
[PROOF STATE]
proof (state)
this:
snd (the (mmap_lookup s' {0})) = sup_acc step accept (take j' rho'') {0} i j'

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have b_alt: "(case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False
    | Some tstp \<Rightarrow> memL t (fst tstp) I) \<longleftrightarrow> sat (MatchF I r) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I) = sat (MatchF I r) i
[PROOF STEP]
proof (rule iffI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I \<Longrightarrow> sat (MatchF I r) i
 2. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
assume assm: "case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False
      | Some tstp \<Rightarrow> memL t (fst tstp) I"
[PROOF STATE]
proof (state)
this:
case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I

goal (2 subgoals):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I \<Longrightarrow> sat (MatchF I r) i
 2. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
obtain ts tp where tstp_def:
      "sup_acc step accept (take j' rho'') {0} i j' = Some (ts, tp)"
      "memL (ts_at rho'' i) ts I"
[PROOF STATE]
proof (prove)
using this:
case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I

goal (1 subgoal):
 1. (\<And>ts tp. \<lbrakk>sup_acc step accept (take j' rho'') {0} i j' = Some (ts, tp); memL (ts_at rho'' i) ts I\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding lookup_sup_acc
[PROOF STATE]
proof (prove)
using this:
case sup_acc step accept (take j' rho'') {0} i j' of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I

goal (1 subgoal):
 1. (\<And>ts tp. \<lbrakk>sup_acc step accept (take j' rho'') {0} i j' = Some (ts, tp); memL (ts_at rho'' i) ts I\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: tbi_def split: option.splits)
[PROOF STATE]
proof (state)
this:
sup_acc step accept (take j' rho'') {0} i j' = Some (ts, tp)
memL (ts_at rho'' i) ts I

goal (2 subgoals):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I \<Longrightarrow> sat (MatchF I r) i
 2. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
sup_acc step accept (take j' rho'') {0} i j' = Some (ts, tp)
memL (ts_at rho'' i) ts I
[PROOF STEP]
have sup_acc_rho'': "sup_acc step accept rho'' {0} i j' = Some (ts, tp)"
[PROOF STATE]
proof (prove)
using this:
sup_acc step accept (take j' rho'') {0} i j' = Some (ts, tp)
memL (ts_at rho'' i) ts I

goal (1 subgoal):
 1. sup_acc step accept rho'' {0} i j' = Some (ts, tp)
[PROOF STEP]
using sup_acc_concat_cong[of j' "take j' rho''" step accept "drop j' rho''"] j'_le_rho''
[PROOF STATE]
proof (prove)
using this:
sup_acc step accept (take j' rho'') {0} i j' = Some (ts, tp)
memL (ts_at rho'' i) ts I
j' \<le> length (take j' rho'') \<Longrightarrow> sup_acc step accept (take j' rho'' @ drop j' rho'') ?q ?i j' = sup_acc step accept (take j' rho'') ?q ?i j'
j' \<le> length rho''

goal (1 subgoal):
 1. sup_acc step accept rho'' {0} i j' = Some (ts, tp)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sup_acc step accept rho'' {0} i j' = Some (ts, tp)

goal (2 subgoals):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I \<Longrightarrow> sat (MatchF I r) i
 2. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
have tp_props: "tp \<in> {i..<j'}" "acc step accept rho'' {0} (i, Suc tp)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tp \<in> {i..<j'} &&& wacc rho'' {0} (i, Suc tp)
[PROOF STEP]
using sup_acc_SomeE[OF sup_acc_rho'']
[PROOF STATE]
proof (prove)
using this:
tp \<in> {i..<j'} \<and> wacc rho'' {0} (i, Suc tp)

goal (1 subgoal):
 1. tp \<in> {i..<j'} &&& wacc rho'' {0} (i, Suc tp)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
tp \<in> {i..<j'}
wacc rho'' {0} (i, Suc tp)

goal (2 subgoals):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I \<Longrightarrow> sat (MatchF I r) i
 2. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
have ts_ts_at: "ts = ts_at rho'' tp"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ts = ts_at rho'' tp
[PROOF STEP]
using sup_acc_Some_ts[OF sup_acc_rho'']
[PROOF STATE]
proof (prove)
using this:
ts = ts_at rho'' tp

goal (1 subgoal):
 1. ts = ts_at rho'' tp
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
ts = ts_at rho'' tp

goal (2 subgoals):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I \<Longrightarrow> sat (MatchF I r) i
 2. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
have i_le_tp: "i \<le> Suc tp"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> Suc tp
[PROOF STEP]
using tp_props
[PROOF STATE]
proof (prove)
using this:
tp \<in> {i..<j'}
wacc rho'' {0} (i, Suc tp)

goal (1 subgoal):
 1. i \<le> Suc tp
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<le> Suc tp

goal (2 subgoals):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I \<Longrightarrow> sat (MatchF I r) i
 2. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
have "memR (ts_at rho'' i) (ts_at rho'' tp) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. memR (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
using i'_set(1)[OF tp_props(1)]
[PROOF STATE]
proof (prove)
using this:
memR (ts_at rho'' i) (ts_at rho'' tp) I

goal (1 subgoal):
 1. memR (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
memR (ts_at rho'' i) (ts_at rho'' tp) I

goal (2 subgoals):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I \<Longrightarrow> sat (MatchF I r) i
 2. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
memR (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
have "mem (ts_at rho'' i) (ts_at rho'' tp) I"
[PROOF STATE]
proof (prove)
using this:
memR (ts_at rho'' i) (ts_at rho'' tp) I

goal (1 subgoal):
 1. mem (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
using tstp_def(2)
[PROOF STATE]
proof (prove)
using this:
memR (ts_at rho'' i) (ts_at rho'' tp) I
memL (ts_at rho'' i) ts I

goal (1 subgoal):
 1. mem (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
unfolding ts_ts_at mem_def
[PROOF STATE]
proof (prove)
using this:
memR (ts_at rho'' i) (ts_at rho'' tp) I
memL (ts_at rho'' i) (ts_at rho'' tp) I

goal (1 subgoal):
 1. memL (ts_at rho'' i) (ts_at rho'' tp) I \<and> memR (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mem (ts_at rho'' i) (ts_at rho'' tp) I

goal (2 subgoals):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I \<Longrightarrow> sat (MatchF I r) i
 2. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
mem (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
show "sat (MatchF I r) i"
[PROOF STATE]
proof (prove)
using this:
mem (ts_at rho'' i) (ts_at rho'' tp) I

goal (1 subgoal):
 1. sat (MatchF I r) i
[PROOF STEP]
using i_le_tp acc_match[OF reach_sj''' i_le_tp _ wf] tp_props(2) ts_at_tau[OF reach_tj''']
        tp_props(1) j'_le_rho''
[PROOF STATE]
proof (prove)
using this:
mem (ts_at rho'' i) (ts_at rho'' tp) I
i \<le> Suc tp
Suc tp \<le> length rho'' \<Longrightarrow> wacc rho'' {0} (i, Suc tp) = ((i, Suc tp) \<in> match r)
wacc rho'' {0} (i, Suc tp)
?i < length rho'' \<Longrightarrow> ts_at rho'' ?i = \<tau> \<sigma> ?i
tp \<in> {i..<j'}
j' \<le> length rho''

goal (1 subgoal):
 1. sat (MatchF I r) i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sat (MatchF I r) i

goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
assume "sat (MatchF I r) i"
[PROOF STATE]
proof (state)
this:
sat (MatchF I r) i

goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
sat (MatchF I r) i
[PROOF STEP]
obtain l where l_def: "l \<ge> i" "mem (\<tau> \<sigma> i) (\<tau> \<sigma> l) I" "(i, Suc l) \<in> match r"
[PROOF STATE]
proof (prove)
using this:
sat (MatchF I r) i

goal (1 subgoal):
 1. (\<And>l. \<lbrakk>i \<le> l; mem (\<tau> \<sigma> i) (\<tau> \<sigma> l) I; (i, Suc l) \<in> match r\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<le> l
mem (\<tau> \<sigma> i) (\<tau> \<sigma> l) I
(i, Suc l) \<in> match r

goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
have l_lt_rho: "l < length rho''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l < length rho''
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> l < length rho'' \<Longrightarrow> False
[PROOF STEP]
assume contr: "\<not>l < length rho''"
[PROOF STATE]
proof (state)
this:
\<not> l < length rho''

goal (1 subgoal):
 1. \<not> l < length rho'' \<Longrightarrow> False
[PROOF STEP]
have "tm = ts_at (rho'' @ [(tm, undefined)]) (length rho'')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tm = ts_at (rho'' @ [(tm, undefined)]) (length rho'')
[PROOF STEP]
using i_le_rho
[PROOF STATE]
proof (prove)
using this:
i \<le> length rho''

goal (1 subgoal):
 1. tm = ts_at (rho'' @ [(tm, undefined)]) (length rho'')
[PROOF STEP]
by (auto simp add: ts_at_def rho''_def)
[PROOF STATE]
proof (state)
this:
tm = ts_at (rho'' @ [(tm, undefined)]) (length rho'')

goal (1 subgoal):
 1. \<not> l < length rho'' \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
tm = ts_at (rho'' @ [(tm, undefined)]) (length rho'')

goal (1 subgoal):
 1. \<not> l < length rho'' \<Longrightarrow> False
[PROOF STEP]
have "\<dots> \<le> \<tau> \<sigma> l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ts_at (rho'' @ [(tm, undefined)]) (length rho'') \<le> \<tau> \<sigma> l
[PROOF STEP]
using \<tau>_mono ts_at_tau[OF reach_tm] i_le_rho contr
[PROOF STATE]
proof (prove)
using this:
?i \<le> ?j \<Longrightarrow> \<tau> ?s ?i \<le> \<tau> ?s ?j
?i < length (rho'' @ [(tm, undefined)]) \<Longrightarrow> ts_at (rho'' @ [(tm, undefined)]) ?i = \<tau> \<sigma> ?i
i \<le> length rho''
\<not> l < length rho''

goal (1 subgoal):
 1. ts_at (rho'' @ [(tm, undefined)]) (length rho'') \<le> \<tau> \<sigma> l
[PROOF STEP]
by (metis One_nat_def Suc_eq_plus1 length_append lessI list.size(3)
            list.size(4) not_le_imp_less)
[PROOF STATE]
proof (state)
this:
ts_at (rho'' @ [(tm, undefined)]) (length rho'') \<le> \<tau> \<sigma> l

goal (1 subgoal):
 1. \<not> l < length rho'' \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
ts_at (rho'' @ [(tm, undefined)]) (length rho'') \<le> \<tau> \<sigma> l

goal (1 subgoal):
 1. \<not> l < length rho'' \<Longrightarrow> False
[PROOF STEP]
have "memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I
[PROOF STEP]
using l_def(2)
[PROOF STATE]
proof (prove)
using this:
mem (\<tau> \<sigma> i) (\<tau> \<sigma> l) I

goal (1 subgoal):
 1. memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I
[PROOF STEP]
unfolding mem_def
[PROOF STATE]
proof (prove)
using this:
memL (\<tau> \<sigma> i) (\<tau> \<sigma> l) I \<and> memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I

goal (1 subgoal):
 1. memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I

goal (1 subgoal):
 1. \<not> l < length rho'' \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
tm = ts_at (rho'' @ [(tm, undefined)]) (length rho'')
ts_at (rho'' @ [(tm, undefined)]) (length rho'') \<le> \<tau> \<sigma> l
memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I
[PROOF STEP]
have "memR (\<tau> \<sigma> i) tm I"
[PROOF STATE]
proof (prove)
using this:
tm = ts_at (rho'' @ [(tm, undefined)]) (length rho'')
ts_at (rho'' @ [(tm, undefined)]) (length rho'') \<le> \<tau> \<sigma> l
memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I

goal (1 subgoal):
 1. memR (\<tau> \<sigma> i) tm I
[PROOF STEP]
using memR_mono'
[PROOF STATE]
proof (prove)
using this:
tm = ts_at (rho'' @ [(tm, undefined)]) (length rho'')
ts_at (rho'' @ [(tm, undefined)]) (length rho'') \<le> \<tau> \<sigma> l
memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I
\<lbrakk>memR ?t ?t' ?I; ?t'' \<le> ?t'\<rbrakk> \<Longrightarrow> memR ?t ?t'' ?I

goal (1 subgoal):
 1. memR (\<tau> \<sigma> i) tm I
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
memR (\<tau> \<sigma> i) tm I

goal (1 subgoal):
 1. \<not> l < length rho'' \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
memR (\<tau> \<sigma> i) tm I
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
memR (\<tau> \<sigma> i) tm I

goal (1 subgoal):
 1. False
[PROOF STEP]
using before_end' ts_at_tau[OF reach_tj''' i_lt_rho''] tbi_def(3)
[PROOF STATE]
proof (prove)
using this:
memR (\<tau> \<sigma> i) tm I
\<not> memR t tm I
ts_at rho'' i = \<tau> \<sigma> i
t = ts_at rho'' i

goal (1 subgoal):
 1. False
[PROOF STEP]
by (auto simp: rho''_def)
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
l < length rho''

goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
have l_lt_j': "l < j'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l < j'
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> l < j' \<Longrightarrow> False
[PROOF STEP]
assume contr: "\<not>l < j'"
[PROOF STATE]
proof (state)
this:
\<not> l < j'

goal (1 subgoal):
 1. \<not> l < j' \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> l < j'
[PROOF STEP]
have ts_at_j'_l: "ts_at rho'' j' \<le> ts_at rho'' l"
[PROOF STATE]
proof (prove)
using this:
\<not> l < j'

goal (1 subgoal):
 1. ts_at rho'' j' \<le> ts_at rho'' l
[PROOF STEP]
using ts_at_mono[OF reach_tj'''] l_lt_rho
[PROOF STATE]
proof (prove)
using this:
\<not> l < j'
\<lbrakk>?i \<le> ?j; ?j < length rho''\<rbrakk> \<Longrightarrow> ts_at rho'' ?i \<le> ts_at rho'' ?j
l < length rho''

goal (1 subgoal):
 1. ts_at rho'' j' \<le> ts_at rho'' l
[PROOF STEP]
by (auto simp add: order.not_eq_order_implies_strict)
[PROOF STATE]
proof (state)
this:
ts_at rho'' j' \<le> ts_at rho'' l

goal (1 subgoal):
 1. \<not> l < j' \<Longrightarrow> False
[PROOF STEP]
have ts_at_l_iu: "memR (ts_at rho'' i) (ts_at rho'' l) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. memR (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
using l_def(2) ts_at_tau[OF reach_tj''' l_lt_rho] ts_at_tau[OF reach_tj''' i_lt_rho'']
[PROOF STATE]
proof (prove)
using this:
mem (\<tau> \<sigma> i) (\<tau> \<sigma> l) I
ts_at rho'' l = \<tau> \<sigma> l
ts_at rho'' i = \<tau> \<sigma> i

goal (1 subgoal):
 1. memR (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
unfolding mem_def
[PROOF STATE]
proof (prove)
using this:
memL (\<tau> \<sigma> i) (\<tau> \<sigma> l) I \<and> memR (\<tau> \<sigma> i) (\<tau> \<sigma> l) I
ts_at rho'' l = \<tau> \<sigma> l
ts_at rho'' i = \<tau> \<sigma> i

goal (1 subgoal):
 1. memR (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
memR (ts_at rho'' i) (ts_at rho'' l) I

goal (1 subgoal):
 1. \<not> l < j' \<Longrightarrow> False
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. False
[PROOF STEP]
using i'_set(2) ts_at_j'_l ts_at_l_iu contr l_lt_rho memR_mono'
[PROOF STATE]
proof (prove)
using this:
\<not> memR (ts_at rho'' i) (ts_at (rho'' @ [(tm, undefined)]) j') I
ts_at rho'' j' \<le> ts_at rho'' l
memR (ts_at rho'' i) (ts_at rho'' l) I
\<not> l < j'
l < length rho''
\<lbrakk>memR ?t ?t' ?I; ?t'' \<le> ?t'\<rbrakk> \<Longrightarrow> memR ?t ?t'' ?I

goal (1 subgoal):
 1. False
[PROOF STEP]
by (auto simp: ts_at_def nth_append split: if_splits)
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
l < j'

goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
have i_le_Suc_l: "i \<le> Suc l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> Suc l
[PROOF STEP]
using l_def(1)
[PROOF STATE]
proof (prove)
using this:
i \<le> l

goal (1 subgoal):
 1. i \<le> Suc l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<le> Suc l

goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
obtain tp where tstp_def: "sup_acc step accept rho'' {0} i j' = Some (ts_at rho'' tp, tp)"
      "l \<le> tp" "tp < j'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>tp. \<lbrakk>sup_acc step accept rho'' {0} i j' = Some (ts_at rho'' tp, tp); l \<le> tp; tp < j'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using l_def(1,3) l_lt_j' l_lt_rho
[PROOF STATE]
proof (prove)
using this:
i \<le> l
(i, Suc l) \<in> match r
l < j'
l < length rho''

goal (1 subgoal):
 1. (\<And>tp. \<lbrakk>sup_acc step accept rho'' {0} i j' = Some (ts_at rho'' tp, tp); l \<le> tp; tp < j'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (meson accept_match[OF reach_sj''' i_le_Suc_l _ wf, unfolded steps_is_run] sup_acc_SomeI[unfolded acc_is_accept, of step accept] acc_is_accept atLeastLessThan_iff less_eq_Suc_le)
[PROOF STATE]
proof (state)
this:
sup_acc step accept rho'' {0} i j' = Some (ts_at rho'' tp, tp)
l \<le> tp
tp < j'

goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
have "memL (ts_at rho'' i) (ts_at rho'' l) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. memL (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
using l_def(2)
[PROOF STATE]
proof (prove)
using this:
mem (\<tau> \<sigma> i) (\<tau> \<sigma> l) I

goal (1 subgoal):
 1. memL (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
unfolding ts_at_tau[OF reach_tj''' i_lt_rho'', symmetric]
        ts_at_tau[OF reach_tj''' l_lt_rho, symmetric] mem_def
[PROOF STATE]
proof (prove)
using this:
memL (ts_at rho'' i) (ts_at rho'' l) I \<and> memR (ts_at rho'' i) (ts_at rho'' l) I

goal (1 subgoal):
 1. memL (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
memL (ts_at rho'' i) (ts_at rho'' l) I

goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
memL (ts_at rho'' i) (ts_at rho'' l) I
[PROOF STEP]
have "memL (ts_at rho'' i) (ts_at rho'' tp) I"
[PROOF STATE]
proof (prove)
using this:
memL (ts_at rho'' i) (ts_at rho'' l) I

goal (1 subgoal):
 1. memL (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
using ts_at_mono[OF reach_tj''' tstp_def(2)] tstp_def(3) j'_le_rho'' memL_mono'
[PROOF STATE]
proof (prove)
using this:
memL (ts_at rho'' i) (ts_at rho'' l) I
tp < length rho'' \<Longrightarrow> ts_at rho'' l \<le> ts_at rho'' tp
tp < j'
j' \<le> length rho''
\<lbrakk>memL ?t ?t' ?I; ?t' \<le> ?t''\<rbrakk> \<Longrightarrow> memL ?t ?t'' ?I

goal (1 subgoal):
 1. memL (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
memL (ts_at rho'' i) (ts_at rho'' tp) I

goal (1 subgoal):
 1. sat (MatchF I r) i \<Longrightarrow> case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
memL (ts_at rho'' i) (ts_at rho'' tp) I
[PROOF STEP]
show "case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False
      | Some tstp \<Rightarrow> memL t (fst tstp) I"
[PROOF STATE]
proof (prove)
using this:
memL (ts_at rho'' i) (ts_at rho'' tp) I

goal (1 subgoal):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
using lookup_sup_acc tstp_def j'_le_rho''
        sup_acc_concat_cong[of j' "take j' rho''" step accept "drop j' rho''"]
[PROOF STATE]
proof (prove)
using this:
memL (ts_at rho'' i) (ts_at rho'' tp) I
snd (the (mmap_lookup s' {0})) = sup_acc step accept (take j' rho'') {0} i j'
sup_acc step accept rho'' {0} i j' = Some (ts_at rho'' tp, tp)
l \<le> tp
tp < j'
j' \<le> length rho''
j' \<le> length (take j' rho'') \<Longrightarrow> sup_acc step accept (take j' rho'' @ drop j' rho'') ?q ?i j' = sup_acc step accept (take j' rho'') ?q ?i j'

goal (1 subgoal):
 1. case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I
[PROOF STEP]
by (auto simp: tbi_def split: option.splits)
[PROOF STATE]
proof (state)
this:
case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(case snd (the (mmap_lookup s' {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I) = sat (MatchF I r) i

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have "valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
have "\<forall>l \<in> {i'..<j'}. memR (ts_at rho'' i') (ts_at rho'' l) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>l\<in>{i'..<j'}. memR (ts_at rho'' i') (ts_at rho'' l) I
[PROOF STEP]
using loop i'_def j'_def valid_after
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. matchF_inv I t0 sub rho'' i ti si tj''' sj''' w' \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)
i' = w_i w'
j' = w_j w'
valid_window args t0 sub (take (w_j w') rho'') w'
rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')
?l3 \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
i' = i
ti' = ti
si' = si

goal (1 subgoal):
 1. \<forall>l\<in>{i'..<j'}. memR (ts_at rho'' i') (ts_at rho'' l) I
[PROOF STEP]
unfolding matchF_loop_inv_def
[PROOF STATE]
proof (prove)
using this:
pred_option' (\<lambda>w'. (valid_window args t0 sub (take (w_j w') rho'') w' \<and> w_i w' = i \<and> w_ti w' = ti \<and> w_si w' = si \<and> rw t0 sub rho'' (w_j w', w_tj w', w_sj w', length rho'', tj''', sj''') \<and> (\<forall>l\<in>{w_i w'..<w_j w'}. memR (ts_at rho'' i) (ts_at rho'' l) I)) \<and> \<not> matchF_cond I t w') (while_break (matchF_cond I t) (adv_end args) w)
i' = w_i w'
j' = w_j w'
valid_window args t0 sub (take (w_j w') rho'') w'
rw t0 sub rho'' (j', tj', sj', length rho'', tj''', sj''')
?l3 \<in> {i..<j'} \<Longrightarrow> memR (ts_at rho'' i) (ts_at rho'' ?l3) I
i' = i
ti' = ti
si' = si

goal (1 subgoal):
 1. \<forall>l\<in>{i'..<j'}. memR (ts_at rho'' i') (ts_at rho'' l) I
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>l\<in>{i'..<j'}. memR (ts_at rho'' i') (ts_at rho'' l) I

goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>l\<in>{i'..<j'}. memR (ts_at rho'' i') (ts_at rho'' l) I
[PROOF STEP]
have "\<forall>l \<in> {i''..<j''}. memR (ts_at rho'' i'') ( ts_at rho'' l) I"
[PROOF STATE]
proof (prove)
using this:
\<forall>l\<in>{i'..<j'}. memR (ts_at rho'' i') (ts_at rho'' l) I

goal (1 subgoal):
 1. \<forall>l\<in>{i''..<j''}. memR (ts_at rho'' i'') (ts_at rho'' l) I
[PROOF STEP]
unfolding i''_i valid_after adv_last_bounds
[PROOF STATE]
proof (prove)
using this:
\<forall>l\<in>{i..<j'}. memR (ts_at rho'' i) (ts_at rho'' l) I

goal (1 subgoal):
 1. \<forall>l\<in>{i + 1..<j'}. memR (ts_at rho'' (i + 1)) (ts_at rho'' l) I
[PROOF STEP]
apply safe
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. \<lbrakk>\<forall>l\<in>{i..<j'}. memR (ts_at rho'' i) (ts_at rho'' l) I; l \<in> {i + 1..<j'}\<rbrakk> \<Longrightarrow> memR (ts_at rho'' (i + 1)) (ts_at rho'' l) I
[PROOF STEP]
subgoal for l
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>l\<in>{i..<j'}. memR (ts_at rho'' i) (ts_at rho'' l) I; l \<in> {i + 1..<j'}\<rbrakk> \<Longrightarrow> memR (ts_at rho'' (i + 1)) (ts_at rho'' l) I
[PROOF STEP]
apply (drule ballE[of _ _ l])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>l \<in> {i + 1..<j'}; memR (ts_at rho'' i) (ts_at rho'' l) I\<rbrakk> \<Longrightarrow> ?Q
 2. \<lbrakk>l \<in> {i + 1..<j'}; l \<notin> {i..<j'}\<rbrakk> \<Longrightarrow> ?Q
 3. \<lbrakk>l \<in> {i + 1..<j'}; ?Q\<rbrakk> \<Longrightarrow> memR (ts_at rho'' (i + 1)) (ts_at rho'' l) I
[PROOF STEP]
using ts_at_mono[OF reach_tj''', of i "Suc i"] j'_le_rho'' memR_mono
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>i \<le> Suc i; Suc i < length rho''\<rbrakk> \<Longrightarrow> ts_at rho'' i \<le> ts_at rho'' (Suc i)
j' \<le> length rho''
\<lbrakk>memR ?t ?t' ?I; ?t \<le> ?t''\<rbrakk> \<Longrightarrow> memR ?t'' ?t' ?I

goal (3 subgoals):
 1. \<lbrakk>l \<in> {i + 1..<j'}; memR (ts_at rho'' i) (ts_at rho'' l) I\<rbrakk> \<Longrightarrow> ?Q
 2. \<lbrakk>l \<in> {i + 1..<j'}; l \<notin> {i..<j'}\<rbrakk> \<Longrightarrow> ?Q
 3. \<lbrakk>l \<in> {i + 1..<j'}; ?Q\<rbrakk> \<Longrightarrow> memR (ts_at rho'' (i + 1)) (ts_at rho'' l) I
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<forall>l\<in>{i''..<j''}. memR (ts_at rho'' i'') (ts_at rho'' l) I

goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>l\<in>{i''..<j''}. memR (ts_at rho'' i'') (ts_at rho'' l) I

goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
have "rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')
[PROOF STEP]
have rw: "rw t0 sub (take j' rho'') (i', ti', si', j', tj', sj')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rw t0 sub (take j' rho'') (i', ti', si', j', tj', sj')
[PROOF STEP]
using valid_after(1)
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w') rho'') w'

goal (1 subgoal):
 1. rw t0 sub (take j' rho'') (i', ti', si', j', tj', sj')
[PROOF STEP]
by (auto simp: valid_window_def Let_def i'_def ti'_def si'_def j'_def tj'_def sj'_def)
[PROOF STATE]
proof (state)
this:
rw t0 sub (take j' rho'') (i', ti', si', j', tj', sj')

goal (1 subgoal):
 1. rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')
[PROOF STEP]
using reach_window_shift[OF rw i'_lt_j'
            tbi_def(1,2)[unfolded valid_after(5,6)[symmetric]]] adv_last_bounds
[PROOF STATE]
proof (prove)
using this:
rw t0 sub (take j' rho'') (Suc i', ti''', si''', j', tj', sj')
i'' = Suc i'
w_ti w'' = ti'''
w_si w'' = si'''
j'' = j'
tj'' = tj'
sj'' = sj'

goal (1 subgoal):
 1. rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')

goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')

goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
have "valid_window args t0 sub (take j' rho'') w''"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_window args t0 sub (take j' rho'') w''
[PROOF STEP]
using valid_adv_start[OF valid_after(1) i'_lt_j'[unfolded i'_def j'_def]]
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w') rho'') (adv_start args w')

goal (1 subgoal):
 1. valid_window args t0 sub (take j' rho'') w''
[PROOF STEP]
unfolding adv_start_last j'_def
[PROOF STATE]
proof (prove)
using this:
valid_window args t0 sub (take (w_j w') rho'') (adv_start args w')

goal (1 subgoal):
 1. valid_window args t0 sub (take (w_j w') rho'') (adv_start args w')
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
valid_window args t0 sub (take j' rho'') w''

goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>l\<in>{i''..<j''}. memR (ts_at rho'' i'') (ts_at rho'' l) I
rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')
valid_window args t0 sub (take j' rho'') w''
[PROOF STEP]
show "valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')"
[PROOF STATE]
proof (prove)
using this:
\<forall>l\<in>{i''..<j''}. memR (ts_at rho'' i'') (ts_at rho'' l) I
rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')
valid_window args t0 sub (take j' rho'') w''

goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
using j'_le_rho''
[PROOF STATE]
proof (prove)
using this:
\<forall>l\<in>{i''..<j''}. memR (ts_at rho'' i'') (ts_at rho'' l) I
rw t0 sub (take j'' rho'') (i'', ti''', si''', j'', tj'', sj'')
valid_window args t0 sub (take j' rho'') w''
j' \<le> length rho''

goal (1 subgoal):
 1. valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
[PROOF STEP]
unfolding valid_window_matchF_def adv_last_bounds adv_start_last[symmetric] i''_def[symmetric]
        j'_def j''_def[symmetric] tj'_def tj''_def[symmetric] sj'_def sj''_def[symmetric]
[PROOF STATE]
proof (prove)
using this:
\<forall>l\<in>{Suc i'..<w_j w'}. memR (ts_at rho'' (Suc i')) (ts_at rho'' l) I
rw t0 sub (take (w_j w') rho'') (Suc i', ti''', si''', w_j w', w_tj w', w_sj w')
valid_window args t0 sub (take (w_j w') rho'') w''
w_j w' \<le> length rho''

goal (1 subgoal):
 1. Suc i' = Suc i' \<and> valid_window args t0 sub (take (w_j w') rho'') w'' \<and> rw t0 sub (take (w_j w') rho'') (Suc i', ti''', si''', w_j w', w_tj w', w_sj w') \<and> (\<forall>l\<in>{Suc i'..<w_j w'}. memR (ts_at (take (w_j w') rho'') (Suc i')) (ts_at (take (w_j w') rho'') l) I)
[PROOF STEP]
by (auto simp: ts_at_def)
[PROOF STATE]
proof (state)
this:
valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
have "eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w'')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w'')
[PROOF STEP]
unfolding j''_def adv_start_last[symmetric] adv_last_bounds valid_after rho''_def
      eval_matchF.simps run_t_read[OF tbi_def(1)[unfolded ti_def]]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case Some t of None \<Rightarrow> None | Some t \<Rightarrow> case while_break (matchF_cond I t) (adv_end args) w of None \<Rightarrow> None | Some w' \<Rightarrow> case w_read_t args (w_tj w') of None \<Rightarrow> None | Some t' \<Rightarrow> let \<beta> = case snd (the (mmap_lookup (w_s w') {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I in Some ((t, \<beta>), adv_start args w')) = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w'')
[PROOF STEP]
using tbj'_def[unfolded tj'_def] not_ets_te[folded tbi_def(3)]
      b_alt[unfolded s'_def] t_def adv_start_last w'_def
[PROOF STATE]
proof (prove)
using this:
w_read_t args (w_tj w') = Some te
te = ts_at (rho'' @ [(tm, undefined)]) j'
\<not> memR t te I
(case snd (the (mmap_lookup (w_s w') {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I) = sat (MatchF I r) i
t = \<tau> \<sigma> i
w'' = adv_start args w'
while_break (matchF_cond I t) (adv_end args) w = Some w'

goal (1 subgoal):
 1. (case Some t of None \<Rightarrow> None | Some t \<Rightarrow> case while_break (matchF_cond I t) (adv_end args) w of None \<Rightarrow> None | Some w' \<Rightarrow> case w_read_t args (w_tj w') of None \<Rightarrow> None | Some t' \<Rightarrow> let \<beta> = case snd (the (mmap_lookup (w_s w') {0})) of None \<Rightarrow> False | Some tstp \<Rightarrow> memL t (fst tstp) I in Some ((t, \<beta>), adv_start args w')) = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w'')
[PROOF STEP]
by (auto simp only: Let_def split: option.splits if_splits)
[PROOF STATE]
proof (state)
this:
eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w'')

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w'')
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
valid_matchF I t0 sub (take j'' rho'') i'' (adv_start args w')
eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w'')

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
unfolding j''_def adv_start_last[symmetric] adv_last_bounds valid_after rho''_def
[PROOF STATE]
proof (prove)
using this:
valid_matchF I t0 sub (take (w_j w'') (rho @ rho')) (Suc i) w''
eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w'')

goal (1 subgoal):
 1. \<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>w'. eval_mF I w = Some ((\<tau> \<sigma> i, sat (MatchF I r) i), w') \<and> valid_matchF I t0 sub (take (w_j w') (rho @ rho')) (Suc i) w'

goal:
No subgoals!
[PROOF STEP]
qed