section {*FUNCTION\_\_DPDA\_to\_CFG\_OPT*}
theory
  FUNCTION__DPDA_to_CFG_OPT

imports
  PRJ_12_04_06_02__ENTRY

begin

definition l2_dom :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> ('state, 'stack) DT_l2_l3_nonterminals set"
  where
    "l2_dom G \<equiv>
  {cons_l2 q A | q A. q \<in> epda_states G \<and> A \<in> epda_gamma G}"

definition all_state_stack_str2 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph"
  where
    "all_state_stack_str2 G k \<equiv>
  {cons_tuple2 (Some(cons_tuple2 q1 (take k s1))) (Some(cons_tuple2 q2 (take k s2))) | q1 s1 q2 s2.
   q1 \<in> epda_states G
   \<and> q2 \<in> epda_states G
   \<and> set s1 \<subseteq> epda_gamma G
   \<and> set s2 \<subseteq> epda_gamma G
  }\<union>{cons_tuple2 None (Some(cons_tuple2 q2 (take k s2))) | q2 s2.
   q2 \<in> epda_states G
   \<and> set s2 \<subseteq> epda_gamma G
  }"

definition all_state_stack_str3 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list, nat option) DT_tuple3 option DT_graph"
  where
    "all_state_stack_str3 G k \<equiv>
  {cons_tuple2 (Some (cons_tuple3 q1 s1 n1)) (Some (cons_tuple3 q2 s2 n2)) | q1 s1 n1 q2 s2 n2.
  cons_tuple2 (Some (cons_tuple2 q1 s1)) (Some (cons_tuple2 q2 s2)) \<in> all_state_stack_str2 G k
  \<and> n1 \<in> {None}\<union>{Some n| n. n\<le>k}
  \<and> n2 \<in> {None}\<union>{Some n| n. n\<le>k}
  }\<union>
  {cons_tuple2 None (Some (cons_tuple3 q2 s2 n2)) | q2 s2 n2.
  cons_tuple2 None (Some (cons_tuple2 q2 s2)) \<in> all_state_stack_str2 G k
  \<and> n2 \<in> {None}\<union>{Some n| n. n\<le>k}}"

lemma F_SDPDA_TO_CFG_OPT__step_closure__l2_init_in_all_state_stack_str3_simp: "
  valid_epda G
  \<Longrightarrow> S \<subseteq> F_EPDA_AIA__codom G k
  \<Longrightarrow> k>0
  \<Longrightarrow> A \<in> epda_gamma G
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__l2_init G A S \<subseteq> all_state_stack_str3 G k"
  apply(simp add: F_EPDA_AIA__fp_valid_input_def F_SDPDA_TO_CFG_OPT__step_closure__l2_init_def all_state_stack_str3_def)
  apply(clarsimp)
  apply(rename_tac q w v)(*strict*)
  apply(simp add: all_state_stack_str2_def)
  apply(subgoal_tac "cons_tuple2 q w \<in> F_EPDA_AIA__codom G k")
   apply(rename_tac q w v)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac q w v)(*strict*)
  apply(thin_tac "S \<subseteq> X" for X)
  apply(thin_tac "X \<in> S" for X)
  apply(simp add: F_EPDA_AIA__codom_def)
  apply(erule disjE)
   apply(rename_tac q w v)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_start_def)
   apply(clarsimp)
   apply(rename_tac q w)(*strict*)
   apply(simp add: valid_epda_def)
   apply(clarsimp)
   apply(erule disjE)
    apply(rename_tac q w)(*strict*)
    apply(clarsimp)
    apply(simp add: prefix_def)
    apply(clarsimp)
    apply(erule_tac x="[epda_box G]" in allE)
    apply(clarsimp)
   apply(rename_tac q w)(*strict*)
   apply(clarsimp)
  apply(rename_tac q w v)(*strict*)
  apply(clarsimp)
  apply(rename_tac q)(*strict*)
  apply(erule disjE)
   apply(rename_tac q)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_start_def)
  apply(rename_tac q)(*strict*)
  apply(clarsimp)
  apply(rename_tac q s)(*strict*)
  apply(simp add: valid_epda_def)
  apply(clarsimp)
  apply(erule_tac x="[A]" in allE)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__l2_approx_in_CFG: "
  valid_simple_dpda G
  \<Longrightarrow> 0<k
  \<Longrightarrow> ReachS = F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}
  \<Longrightarrow> CL = (%x. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp (F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G x ReachS) k))
  \<Longrightarrow> cons_l2 q A \<in> F_SDPDA_TO_CFG_OPT__l2_approx G k ReachS CL
  \<Longrightarrow> q \<in> epda_states G \<and> A \<in> epda_gamma G"
  apply(simp add: F_SDPDA_TO_CFG_OPT__l2_approx_def F_SDPDA_TO_CFG_OPT__l2_approx_1_def)
  apply(clarsimp)
  apply(rename_tac w n q' w' n')(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac w n q' w' n')(*strict*)
   prefer 2
   apply(rule_tac G="G" and k="k" and E="{F_EPDA_AIA__fp_start G k}" in F_EPDA_AIA__fp_preserves_F_EPDA_AIA__fp_valid_input)
   apply(rule F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
  apply(rename_tac w n q' w' n')(*strict*)
  apply(rule propSym)
  apply(rule context_conjI)
   apply(rename_tac w n q' w' n')(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__pushed_symbols_def)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(clarsimp)
   apply(erule disjE)
    apply(rename_tac w n q' w' n')(*strict*)
    apply(force)
   apply(rename_tac w n q' w' n')(*strict*)
   apply(clarsimp)
   apply(rename_tac w n q' w' n' y e)(*strict*)
   apply(erule_tac x="e" in ballE)
    apply(rename_tac w n q' w' n' y e)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac w n q' w' n' y e)(*strict*)
   apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_step_label_def)
   apply(force)
  apply(rename_tac w n q' w' n')(*strict*)
  apply(thin_tac "cons_tuple2 (Some (cons_tuple3 q w n)) (Some (cons_tuple3 q' w' n'))
       \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
           (F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G A (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
             k)")
  apply(subgoal_tac "cons_tuple2 None (Some (cons_tuple3 q w n)) \<in> all_state_stack_str3 G k")
   apply(rename_tac w n q' w' n')(*strict*)
   apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
   apply(rename_tac w n q' n')(*strict*)
   apply(clarsimp)
  apply(rename_tac w n q' w' n')(*strict*)
  apply(rule_tac A="F_SDPDA_TO_CFG_OPT__step_closure__l2_init G A (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k})" in set_mp)
   apply(rename_tac w n q' w' n')(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac w n q' w' n')(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l2_init_in_all_state_stack_str3_simp)
     apply(rename_tac w n q' w' n')(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac w n q' w' n')(*strict*)
    apply(simp add: F_EPDA_AIA__fp_valid_input_def)
   apply(rename_tac w n q' w' n')(*strict*)
   apply(force)
  apply(rename_tac w n q' w' n')(*strict*)
  apply(force)
  done

definition l3_dom :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> ('state, 'stack) DT_l2_l3_nonterminals set"
  where
    "l3_dom G \<equiv>
  {cons_l3 q A q' | q A q'. q \<in> epda_states G \<and> q' \<in> epda_states G \<and> A \<in> epda_gamma G}"

lemma finite_l2_dom: "
  valid_epda G
  \<Longrightarrow> finite (l2_dom G)"
  apply(simp add: l2_dom_def)
  apply(rule_tac t="{cons_l2 q A |q A. q \<in> epda_states G \<and> A \<in> epda_gamma G}" and s="(%(q,A). cons_l2 q A)`(epda_states G \<times> epda_gamma G)" in ssubst)
   apply(force)
  apply(rule finite_imageI)
  apply(simp add: valid_epda_def)
  done

definition reach_k_access_closure1 :: "
  ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph"
  where
    "reach_k_access_closure1 E \<equiv>
   E
   \<union> {cons_tuple2 x z | x y z. cons_tuple2 x y \<in> E \<and> cons_tuple2 y z \<in> E}"

function (domintros) reach_k_access_closure :: "
  ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph"
  where
    "reach_k_access_closure E =
  (if reach_k_access_closure1 E = E
  then E
  else reach_k_access_closure (reach_k_access_closure1 E))"
   apply(rename_tac P x)(*strict*)
   apply(force)
  apply(rename_tac E Ea)(*strict*)
  apply(force)
  done

definition reach_k_loop1 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph"
  where
    "reach_k_loop1 G k E \<equiv>
  E \<union>
  {cons_tuple2 (Some (cons_tuple2 q1 s1)) (Some (cons_tuple2 q2 s2)) | c q1 s1 q2 s2 w1 w2 x.
   cons_tuple2 c (Some (cons_tuple2 q1 s1)) \<in> E
   \<and> \<lparr>edge_src = q1, edge_event = x, edge_pop = w1, edge_push = w2, edge_trg = q2\<rparr> \<in> epda_delta G
   \<and> (w1 \<sqsubseteq> s1 \<or> s1 \<sqsubseteq> w1)
   \<and> s2 = take k (w2 @ (drop (length w1) s1))}"

function (domintros) reach_k :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph"
  where
    "reach_k G k E  =
  (if reach_k_loop1 G k E = E
  then E
  else reach_k G k (reach_k_loop1 G k E))"
   apply(rename_tac P x)(*strict*)
   apply(force)
  apply(rename_tac G k E Ga ka Ea)(*strict*)
  apply(force)
  done

definition reach_k_initial :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> (('state, 'stack list) DT_tuple2 option, ('state, 'stack list) DT_tuple2 option) DT_tuple2"
  where
    "reach_k_initial G k \<equiv>
  cons_tuple2 None (Some (cons_tuple2 (epda_initial G) (take k [epda_box G])))"

definition all_state_stack_str4 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list, nat option) DT_tuple3 option DT_graph"
  where
    "all_state_stack_str4 G k \<equiv>
  all_state_stack_str3 G k \<union> {cons_tuple2 None None}"

definition F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST :: "
  'a DT_graph
  \<Rightarrow> bool"
  where
    "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E \<equiv>
  finite E"

definition F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_EXTRA_01 :: "
  'a DT_graph
  \<Rightarrow> bool"
  where
    "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_EXTRA_01 N \<equiv>
  True"

definition F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_EXTRA_02 :: "
  'a DT_graph
  \<Rightarrow> bool"
  where
    "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_EXTRA_02 N \<equiv>
  finite N"

definition F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER :: "
  'a DT_graph
  \<Rightarrow> bool"
  where
    "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<equiv>
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_EXTRA_01 N
  \<and> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_EXTRA_02 N"

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER_AT_START: "
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N"
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER_def)
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_EXTRA_01_def F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_EXTRA_02_def reach_k_initial_def)
  done

definition max_data :: "
  'a DT_graph
  \<Rightarrow> 'a DT_graph"
  where "max_data E \<equiv>
  {cons_tuple2 x y | x y.
  {x, y} \<subseteq> sel_tuple2_1 ` E \<union> sel_tuple2_2 ` E}"

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_preserves_finite: "
  finite E
  \<Longrightarrow> finite (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E)"
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def)
  apply(rule conjI)
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule_tac h="%e. cons_tuple2 (sel_tuple2_1 e) (sel_tuple2_1 e)" and F="E" in finite_imageI)
    apply(force)
   apply(rule_tac B="((\<lambda>e. cons_tuple2 (sel_tuple2_1 e) (sel_tuple2_1 e)) ` E)" in finite_subset)
    prefer 2
    apply(force)
   apply(clarsimp)
   apply(rename_tac xa y)(*strict*)
   apply(force)
  apply(rule conjI)
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule_tac h="%e. cons_tuple2 (sel_tuple2_2 e) (sel_tuple2_2 e)" and F="E" in finite_imageI)
    apply(force)
   apply(rule_tac B="((\<lambda>e. cons_tuple2 (sel_tuple2_2 e) (sel_tuple2_2 e)) ` E)" in finite_subset)
    prefer 2
    apply(force)
   apply(clarsimp)
   apply(rename_tac xa y)(*strict*)
   apply(force)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac h="%(e1,e2). cons_tuple2 (sel_tuple2_1 e1) (sel_tuple2_2 e2)" and F="E\<times>E" in finite_imageI)
   apply(force)
  apply(rule_tac B="((%(e1,e2). cons_tuple2 (sel_tuple2_1 e1) (sel_tuple2_2 e2)) ` (E\<times>E))" in finite_subset)
   prefer 2
   apply(force)
  apply(clarsimp)
  apply(rename_tac xa y z)(*strict*)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termLem: "
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E \<Longrightarrow>
   F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E)"
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
  apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_preserves_finite)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_preserves_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST: "
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N)"
  apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termLem)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_mono: "
  E \<subseteq> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E"
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_contained_in_max_data: "
  finite E
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E \<subseteq> max_data E"
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def max_data_def)
  apply(rule conjI)
   apply(force)
  apply(rule conjI)
   apply(force)
  apply(rule conjI)
   apply(force)
  apply(force)
  done

lemma max_data_preserves_finite: "
  finite E
  \<Longrightarrow> finite (max_data E)"
  apply(simp add: max_data_def)
  apply(rule_tac B="((%(x,y). cons_tuple2 x y) ` ((sel_tuple2_1 ` E \<union> sel_tuple2_2 ` E)\<times>(sel_tuple2_1 ` E \<union> sel_tuple2_2 ` E)))" in finite_subset)
   prefer 2
   apply(force)
  apply(clarsimp)
  apply(rename_tac xa y)(*strict*)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termLem2: "
         F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST  E \<Longrightarrow>
       F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E \<noteq> E \<Longrightarrow>
       card (max_data E - F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E)
       < card (max_data E - E)"
  apply(rule Finite_Set.psubset_card_mono)
   prefer 2
   apply(rule rev_subset)
    prefer 3
    apply(rule_tac
      B = "max_data E"
      in Finite_Set.finite_subset)
     apply(force)
    prefer 2
    apply(subgoal_tac "E\<subseteq> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one  E")
     apply(blast)
    apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_mono)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_contained_in_max_data)
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
  apply(rule max_data_preserves_finite)
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
  done

lemma max_data_equal_under_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one: "
  max_data (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E) = max_data E"
  apply(rule antisym)
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def max_data_def)
   apply(clarsimp)
   apply(rename_tac xa y)(*strict*)
   apply(erule disjE)+
     apply(rename_tac xa y)(*strict*)
     apply(clarsimp)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
       apply(rename_tac x xb)(*strict*)
       apply(clarsimp)
      apply(rename_tac x xb)(*strict*)
      apply(erule disjE)+
       apply(rename_tac x xb)(*strict*)
       apply(clarsimp)
       apply(rename_tac x xa y)(*strict*)
       apply(force)
      apply(rename_tac x xb)(*strict*)
      apply(erule disjE)+
       apply(rename_tac x xb)(*strict*)
       apply(clarsimp)
       apply(rename_tac x xa y)(*strict*)
       apply(force)
      apply(rename_tac x xb)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
       apply(rename_tac x xb)(*strict*)
       apply(clarsimp)
       apply(rename_tac xb xa y)(*strict*)
       apply(force)
      apply(rename_tac x xb)(*strict*)
      apply(erule disjE)+
       apply(rename_tac x xb)(*strict*)
       apply(clarsimp)
       apply(rename_tac xb xa y)(*strict*)
       apply(force)
      apply(rename_tac x xb)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
       apply(rename_tac x xb)(*strict*)
       apply(clarsimp)
       apply(rename_tac xa xc y ya)(*strict*)
       apply(force)
      apply(rename_tac x xb)(*strict*)
      apply(erule disjE)+
       apply(rename_tac x xb)(*strict*)
       apply(clarsimp)
       apply(rename_tac xa xc y ya)(*strict*)
       apply(force)
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xc y z ya)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
       apply(rename_tac x xb)(*strict*)
       apply(clarsimp)
       apply(rename_tac xa xc y ya)(*strict*)
       apply(force)
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xc y z ya)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
       apply(rename_tac x xb)(*strict*)
       apply(clarsimp)
       apply(rename_tac xa xc y ya)(*strict*)
       apply(force)
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xc y ya z)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xc y ya z)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa xc y ya z za)(*strict*)
     apply(force)
    apply(rename_tac xa y)(*strict*)
    apply(clarsimp)
    apply(rename_tac x xb)(*strict*)
    apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac x xa y)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac x xa y)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(clarsimp)
     apply(rename_tac x xa y z)(*strict*)
     apply(force)
    apply(rename_tac x xb)(*strict*)
    apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xb xa y)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xb xa y)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(clarsimp)
     apply(rename_tac xb xa y z)(*strict*)
     apply(force)
    apply(rename_tac x xb)(*strict*)
    apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xc y ya)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xc y ya)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa xc y z ya)(*strict*)
     apply(force)
    apply(rename_tac x xb)(*strict*)
    apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xc y ya)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa xc y z ya)(*strict*)
     apply(force)
    apply(rename_tac x xb)(*strict*)
    apply(erule disjE)+
      apply(rename_tac x xb)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xc y ya)(*strict*)
      apply(force)
     apply(rename_tac x xb)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa xc y ya z)(*strict*)
     apply(force)
    apply(rename_tac x xb)(*strict*)
    apply(clarsimp)
    apply(rename_tac xb xa y z)(*strict*)
    apply(erule disjE)+
     apply(rename_tac xb xa y z)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa y z x ya)(*strict*)
     apply(force)
    apply(rename_tac xb xa y z)(*strict*)
    apply(clarsimp)
    apply(rename_tac xa y z x ya za)(*strict*)
    apply(force)
   apply(rename_tac xa y)(*strict*)
   apply(clarsimp)
   apply(rename_tac y x)(*strict*)
   apply(erule disjE)+
     apply(rename_tac y x)(*strict*)
     apply(clarsimp)
     apply(rename_tac x xa)(*strict*)
     apply(erule disjE)+
      apply(rename_tac x xa)(*strict*)
      apply(clarsimp)
     apply(rename_tac x xa)(*strict*)
     apply(erule disjE)+
      apply(rename_tac x xa)(*strict*)
      apply(clarsimp)
      apply(rename_tac x xb y)(*strict*)
      apply(force)
     apply(rename_tac x xa)(*strict*)
     apply(erule disjE)+
      apply(rename_tac x xa)(*strict*)
      apply(clarsimp)
      apply(rename_tac x xb y)(*strict*)
      apply(force)
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac x xb y z)(*strict*)
     apply(force)
    apply(rename_tac y x)(*strict*)
    apply(clarsimp)
    apply(rename_tac x xa)(*strict*)
    apply(erule disjE)+
      apply(rename_tac x xa)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xb y)(*strict*)
      apply(force)
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa xb y)(*strict*)
     apply(erule disjE)+
      apply(rename_tac xa xb y)(*strict*)
      apply(clarsimp)
      apply(rename_tac xb y x ya)(*strict*)
      apply(force)
     apply(rename_tac xa xb y)(*strict*)
     apply(erule disjE)+
      apply(rename_tac xa xb y)(*strict*)
      apply(clarsimp)
      apply(rename_tac xb y x ya)(*strict*)
      apply(force)
     apply(rename_tac xa xb y)(*strict*)
     apply(clarsimp)
     apply(rename_tac xb y x ya z)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(erule disjE)+
      apply(rename_tac x xa)(*strict*)
      apply(clarsimp)
      apply(rename_tac xa xb y)(*strict*)
      apply(force)
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa xb y z)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(erule disjE)+
      apply(rename_tac x xa)(*strict*)
      apply(clarsimp)
      apply(rename_tac xb xc y ya)(*strict*)
      apply(force)
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa xb y)(*strict*)
     apply(erule disjE)+
      apply(rename_tac xa xb y)(*strict*)
      apply(clarsimp)
      apply(rename_tac xb y x ya)(*strict*)
      apply(force)
     apply(rename_tac xa xb y)(*strict*)
     apply(clarsimp)
     apply(rename_tac xb y x ya z)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(clarsimp)
    apply(rename_tac xa xb y z)(*strict*)
    apply(erule disjE)+
     apply(rename_tac xa xb y z)(*strict*)
     apply(clarsimp)
     apply(rename_tac xb y z x ya)(*strict*)
     apply(force)
    apply(rename_tac xa xb y z)(*strict*)
    apply(erule disjE)+
     apply(rename_tac xa xb y z)(*strict*)
     apply(clarsimp)
     apply(rename_tac xb y z x ya)(*strict*)
     apply(force)
    apply(rename_tac xa xb y z)(*strict*)
    apply(clarsimp)
    apply(rename_tac xb y z x ya za)(*strict*)
    apply(force)
   apply(rename_tac y x)(*strict*)
   apply(clarsimp)
   apply(rename_tac x xa)(*strict*)
   apply(erule disjE)+
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
    apply(rename_tac x xa)(*strict*)
    apply(erule disjE)+
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac x xb y)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(clarsimp)
    apply(erule disjE)+
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac x xb y)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(clarsimp)
    apply(rename_tac x xb y z)(*strict*)
    apply(force)
   apply(rename_tac x xa)(*strict*)
   apply(erule disjE)+
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa xb y)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(clarsimp)
    apply(erule disjE)+
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa xb y)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(clarsimp)
    apply(rename_tac xa xb y z)(*strict*)
    apply(force)
   apply(rename_tac x xa)(*strict*)
   apply(erule disjE)+
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac xb xc y ya)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(clarsimp)
    apply(rename_tac xa xb y)(*strict*)
    apply(erule disjE)+
     apply(rename_tac xa xb y)(*strict*)
     apply(clarsimp)
     apply(rename_tac xb y x ya)(*strict*)
     apply(force)
    apply(rename_tac xa xb y)(*strict*)
    apply(clarsimp)
    apply(rename_tac xb y x ya z)(*strict*)
    apply(force)
   apply(rename_tac x xa)(*strict*)
   apply(erule disjE)+
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac xb xc y ya)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(clarsimp)
    apply(rename_tac xb xc y z ya)(*strict*)
    apply(force)
   apply(rename_tac x xa)(*strict*)
   apply(erule disjE)+
     apply(rename_tac x xa)(*strict*)
     apply(clarsimp)
     apply(rename_tac xb xc y ya)(*strict*)
     apply(force)
    apply(rename_tac x xa)(*strict*)
    apply(clarsimp)
    apply(rename_tac xb xc y ya z)(*strict*)
    apply(force)
   apply(rename_tac x xa)(*strict*)
   apply(clarsimp)
   apply(rename_tac xa xb y z)(*strict*)
   apply(erule disjE)+
    apply(rename_tac xa xb y z)(*strict*)
    apply(clarsimp)
    apply(rename_tac xb y z x ya)(*strict*)
    apply(force)
   apply(rename_tac xa xb y z)(*strict*)
   apply(clarsimp)
   apply(rename_tac xb y z x ya za)(*strict*)
   apply(force)
  apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(simp add: max_data_def F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def)
  apply(clarsimp)
  apply(rename_tac xa y)(*strict*)
  apply(force)
  done
declare max_data_equal_under_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one [simp add]

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_TRANSFER_TRANSFERS_ALL: "
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N)
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N)"
  apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER_AT_START)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termination: "
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_dom E"
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>E. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E"
      and RECURSIVE_COND = "\<lambda>E. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one  E\<noteq>E"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>E. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E"
      and MEASURE = "\<lambda>E. card (max_data E - E)"
      in partial_termination_wf)
      apply(auto)
       apply(rename_tac EA x)(*strict*)
       apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E")
       apply(rename_tac EA x)
       apply(rename_tac EA x)(*strict*)
       apply(thin_tac "x \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one EA")
       apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one EA)")
        apply(rename_tac EA x)(*strict*)
        apply(blast)
       apply(rename_tac EA x)(*strict*)
       apply(thin_tac "\<not> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one EA)")
       apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termLem)
       apply(blast)
      apply(rename_tac EA x)(*strict*)
      apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E")
      apply(rename_tac EA x)
      apply(rename_tac EA x)(*strict*)
      apply(thin_tac "x \<in> EA")
      apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one EA)")
       apply(rename_tac EA x)(*strict*)
       apply(blast)
      apply(rename_tac EA x)(*strict*)
      apply(thin_tac "\<not> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one EA)")
      apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termLem)
      apply(blast)
     apply(rename_tac EA x)(*strict*)
     apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E")
     apply(rename_tac EA x)
     apply(rename_tac EA x)(*strict*)
     apply(case_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one EA = EA")
      apply(rename_tac EA x)(*strict*)
      apply(force)
     apply(rename_tac EA x)(*strict*)
     apply(thin_tac "x \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one EA")
     apply(subgoal_tac "card (max_data EA - F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one EA) < card (max_data EA - EA)")
      apply(rename_tac EA x)(*strict*)
      apply(blast)
     apply(rename_tac E x)(*strict*)
     apply(thin_tac "\<not> card (max_data E - F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one  E) < card (max_data E - E)")
     apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termLem2)
      apply(rename_tac E x)(*strict*)
      apply(blast)
     apply(rename_tac E x)(*strict*)
     apply(force)
    apply(rename_tac EA x)(*strict*)
    apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E")
    apply(rename_tac E x)
    apply(rename_tac E x)(*strict*)
    apply(subgoal_tac "E \<subseteq> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E")
     apply(rename_tac E x)(*strict*)
     prefer 2
     apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_mono)
    apply(rename_tac E x)(*strict*)
    apply(blast)
   apply(rename_tac b)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp.domintros)
    apply(rename_tac b x)(*strict*)
    apply(force,force)
  apply(rename_tac x)(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp.domintros)
   apply(rename_tac x xa)(*strict*)
   apply(force,force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_idemp2: "
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N = F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp  (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N)"
  apply(rule_tac
      t = "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N"
      in ssubst)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp.psimps)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termination)
   apply(blast)
  apply(simp add: Let_def)
  apply(clarsimp)
  apply(rule_tac
      t = "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N"
      in ssubst)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp.psimps)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termination)
   apply(blast)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_Meta_Lift_prime: "
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N
  \<Longrightarrow> (\<And>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N) \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<Longrightarrow> P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one  N) (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N) \<Longrightarrow> P N (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N) )
  \<Longrightarrow> (\<And>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N = N \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<Longrightarrow> P N (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N) )
  \<Longrightarrow> P N (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N)"
  apply(subgoal_tac "(\<lambda>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<longrightarrow> (P N (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N))) N")
   apply(erule impE)
    prefer 2
    apply(blast)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER_AT_START)
   apply(blast)
  apply(subgoal_tac "(\<lambda>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<longrightarrow> (P N (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N))) N")
   apply(blast)
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>E. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E"
      and RECURSIVE_COND = "\<lambda>E. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one  E\<noteq>E"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>E. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E"
      and MEASURE = "\<lambda>E. card (max_data E - E)"
      and TERM_FUN = "(\<lambda>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<longrightarrow> (P N (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N)))"
      and y = "N"
      in partial_termination_wf)
      apply(rule allI)
      apply(rename_tac x)(*strict*)
      apply(clarify)
      apply(rename_tac x)(*strict*)
      apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N")
      apply(rename_tac N)
      apply(rename_tac N)(*strict*)
      apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_preserves_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST)
      apply(blast)
     apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N")
     apply(clarsimp)
     apply(rename_tac x)(*strict*)
     apply(rename_tac N)
     apply(rename_tac N)(*strict*)
     apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termLem2)
      apply(rename_tac N)(*strict*)
      apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
     apply(rename_tac N)(*strict*)
     apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
    apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
   prefer 2
   apply(clarsimp)
  apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N")
  apply(rename_tac N)
  apply(rename_tac N)(*strict*)
  apply(erule impE)
   apply(rename_tac N)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_TRANSFER_TRANSFERS_ALL)
     apply(rename_tac N)(*strict*)
     apply(blast)
    apply(rename_tac N)(*strict*)
    apply(blast)
   apply(rename_tac N)(*strict*)
   apply(blast)
  apply(rename_tac N)(*strict*)
  apply(subgoal_tac "P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N) (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N)")
   apply(rename_tac N)(*strict*)
   apply(thin_tac "P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N) (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp  (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N))")
   prefer 2
   apply(rule_tac
      t="F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N"
      and s="F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N)"
      in ssubst)
    apply(rename_tac N)(*strict*)
    apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_idemp2)
    apply(force)
   apply(rename_tac N)(*strict*)
   apply(force)
  apply(rename_tac N)(*strict*)
  apply(force)
  done

definition all_state_stack_str :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph"
  where
    "all_state_stack_str G k \<equiv>
  {cons_tuple2 (Some(cons_tuple2 q1 (take k s1))) (Some(cons_tuple2 q2 (take k s2))) | q1 s1 q2 s2.
   q1 \<in> epda_states G
   \<and> q2 \<in> epda_states G
   \<and> set s1 \<subseteq> epda_gamma G
   \<and> set s2 \<subseteq> epda_gamma G
  }\<union>{reach_k_initial G k}"

definition reach_k_EXTRA_01 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "reach_k_EXTRA_01 G k N \<equiv>
  reach_k_initial G k \<in> N"

definition reach_k_EXTRA_02 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "reach_k_EXTRA_02 G k N \<equiv>
  N \<subseteq> all_state_stack_str G k"

definition reach_k_TRANSFER :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "reach_k_TRANSFER G k N \<equiv>
  reach_k_EXTRA_01 G k N
  \<and> reach_k_EXTRA_02 G k N"

definition reach_k_one_step_contained :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> nat set
  \<Rightarrow> bool"
  where
    "reach_k_one_step_contained G k E N \<equiv>
  (\<forall>d i e1 c1 e2 c2 j.
  epdaH.derivation_initial G d
  \<longrightarrow> d i = Some (pair e1 c1)
  \<longrightarrow> j\<in> N
  \<longrightarrow> d (Suc i+j) = Some (pair (Some e2) c2)
  \<longrightarrow> (\<exists>w1 w2. cons_tuple2 (Some(cons_tuple2 (epdaH_conf_state c1) (take k w1))) (Some(cons_tuple2 (epdaH_conf_state c2) (take k w2))) \<in> E \<and> prefix w1 (epdaH_conf_stack c1) \<and> prefix w2 (epdaH_conf_stack c2)))"

definition SpecOutput_reach_k :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "SpecOutput_reach_k G k E \<equiv>
  reach_k_TRANSFER G k E
  \<and> reach_k_one_step_contained G k E {0}"

definition reach_k_all_prestate :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "reach_k_all_prestate G k E \<equiv>
  \<forall>y z.
  cons_tuple2 y z \<in> E - {reach_k_initial G k}
  \<longrightarrow> (\<exists>x. cons_tuple2 x y \<in> E)"

definition reach_k_TERM_ARGS_TEST :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "reach_k_TERM_ARGS_TEST G k E \<equiv>
  valid_epda G
  \<and> reach_k_initial G k \<in> E
  \<and> E \<subseteq> all_state_stack_str G k
  \<and> reach_k_all_prestate G k E"

lemma finite_all_state_stack_str3: "
 valid_epda G
 \<Longrightarrow> finite (all_state_stack_str3 G k)"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac h="%(q1,s1,n1,q2,s2,n2). cons_tuple2 (Some (cons_tuple3 q1 s1 n1)) (Some(cons_tuple3 q2 s2 n2))" and F="(epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> ({None}\<union>{Some n| n. n\<le>k}) \<times> epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> ({None}\<union>{Some n| n. n\<le>k}))" in finite_imageI)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
    apply(rule wordsUpToLengthFinite2)
    apply(force)
   apply(rule finite_cartesian_product)
    apply(force)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
    apply(rule wordsUpToLengthFinite2)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(force)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac h="%(q2,s2,n2). cons_tuple2 (None) (Some(cons_tuple3 q2 s2 n2))" and F="(epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> ({None}\<union>{Some n| n. n\<le>k}))" in finite_imageI)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
    apply(rule wordsUpToLengthFinite2)
    apply(force)
   apply(force)
  apply(rule_tac
      s="((%(q1,s1,n1,q2,s2,n2). cons_tuple2 (Some (cons_tuple3 q1 s1 n1)) (Some(cons_tuple3 q2 s2 n2))) `
      ((epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> ({None}\<union>{Some n| n. n\<le>k}) \<times> epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> ({None}\<union>{Some n| n. n\<le>k})))) \<union> ((%(q2,s2,n2). cons_tuple2 (None) (Some(cons_tuple3 q2 s2 n2))) ` (epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> ({None}\<union>{Some n| n. n\<le>k})))"
      and t="all_state_stack_str3 G k"
      in ssubst)
   prefer 2
   apply(rule_tac t="finite X" for X in ssubst)
    apply(rule finite_Un)
   apply(rule conjI)
    apply(force)
   apply(force)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(simp add: all_state_stack_str3_def)
  apply(rule_tac f="%a b. a \<union> b" in arg_cong2)
   apply(rule antisym)
    apply(clarsimp)
    apply(rename_tac q1 s1 n1 q2 s2 n2)(*strict*)
    apply(rule inMap)
    apply(rule_tac x="(q1,take k s1,n1,q2,take k s2,n2)" in bexI)
     apply(rename_tac q1 s1 n1 q2 s2 n2)(*strict*)
     apply(clarsimp)
     apply(simp add: all_state_stack_str2_def)
     apply(force)
    apply(rename_tac q1 s1 n1 q2 s2 n2)(*strict*)
    apply(clarsimp)
    apply(simp add: all_state_stack_str2_def)
    apply(force)
   apply(simp add: all_state_stack_str2_def)
   apply(force)
  apply(rule antisym)
   apply(clarsimp)
   apply(rename_tac q2 s2 n2)(*strict*)
   apply(rule inMap)
   apply(rule_tac x="(q2,take k s2,n2)" in bexI)
    apply(rename_tac q2 s2 n2)(*strict*)
    apply(clarsimp)
    apply(simp add: all_state_stack_str2_def)
    apply(clarsimp)
   apply(rename_tac q2 s2 n2)(*strict*)
   apply(simp add: all_state_stack_str2_def)
   apply(clarsimp)
   apply(rename_tac q2 n2 s2a)(*strict*)
   apply(force)
  apply(clarsimp)
  apply(rename_tac a b w)(*strict*)
  apply(simp add: all_state_stack_str2_def)
  apply(force)
  done

lemma finite_all_state_stack_str4: "
  valid_epda G
  \<Longrightarrow> finite (all_state_stack_str4 G k)"
  apply(subgoal_tac "finite (all_state_stack_str3 G k)")
   prefer 2
   apply(rule finite_all_state_stack_str3)
   apply(force)
  apply(simp add: all_state_stack_str4_def)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_preserves_all_state_stack_str4: "
  valid_epda G
  \<Longrightarrow> k>0
  \<Longrightarrow> E \<subseteq> all_state_stack_str4 G k
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp E \<subseteq> all_state_stack_str4 G k"
  apply(subgoal_tac "E \<subseteq> all_state_stack_str4 G k
  \<longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp E \<subseteq> all_state_stack_str4 G k")
   apply(force)
  apply(rule_tac N="E" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_Meta_Lift_prime)
    apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def SpecOutput_reach_k_def reach_k_TRANSFER_def reach_k_EXTRA_01_def reach_k_EXTRA_02_def)
    apply(rule_tac B="all_state_stack_str4 G k" in finite_subset)
     apply(force)
    apply(rule finite_all_state_stack_str4)
    apply(force)
   apply(rename_tac N)(*strict*)
   apply(rule impI)
   apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N \<subseteq> all_state_stack_str4 G k")
    apply(rename_tac N)(*strict*)
    apply(force)
   apply(rename_tac N)(*strict*)
   apply(thin_tac "E \<subseteq> all_state_stack_str4 G k")
   apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N)")
   apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N")
   apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N")
   apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N \<subseteq> all_state_stack_str4 G k \<longrightarrow>
         F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N \<subseteq> all_state_stack_str4 G k")
   apply(clarsimp)
   apply(rename_tac N x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def)
   apply(erule disjE)
    apply(rename_tac N x)(*strict*)
    apply(force)
   apply(rename_tac N x)(*strict*)
   apply(erule disjE)
    apply(rename_tac N x)(*strict*)
    apply(clarsimp)
    apply(rename_tac N xa y)(*strict*)
    apply(subgoal_tac "cons_tuple2 xa y \<in> all_state_stack_str4 G k")
     apply(rename_tac N xa y)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac N xa y)(*strict*)
    apply(thin_tac "N \<subseteq> X" for X)
    apply(thin_tac "X \<in> N" for X)
    apply(simp add: all_state_stack_str4_def all_state_stack_str3_def all_state_stack_str2_def)
    apply(rename_tac xa y)(*strict*)
    apply(case_tac xa)
     apply(rename_tac xa y)(*strict*)
     apply(clarsimp)
    apply(rename_tac xa y a)(*strict*)
    apply(clarsimp)
    apply(rename_tac q1 n1 q2 n2 s1a s2a)(*strict*)
    apply(force)
   apply(rename_tac N x)(*strict*)
   apply(erule disjE)
    apply(rename_tac N x)(*strict*)
    apply(clarsimp)
    apply(rename_tac N xa y)(*strict*)
    apply(subgoal_tac "cons_tuple2 xa y \<in> all_state_stack_str4 G k")
     apply(rename_tac N xa y)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac N xa y)(*strict*)
    apply(thin_tac "N \<subseteq> X" for X)
    apply(thin_tac "X \<in> N" for X)
    apply(simp add: all_state_stack_str4_def all_state_stack_str3_def all_state_stack_str2_def)
    apply(rename_tac xa y)(*strict*)
    apply(case_tac y)
     apply(rename_tac xa y)(*strict*)
     apply(clarsimp)
    apply(rename_tac xa y a)(*strict*)
    apply(clarsimp)
    apply(rename_tac xa a)(*strict*)
    apply(force)
   apply(rename_tac N x)(*strict*)
   apply(clarsimp)
   apply(rename_tac N xa y z)(*strict*)
   apply(subgoal_tac "cons_tuple2 xa y \<in> all_state_stack_str4 G k")
    apply(rename_tac N xa y z)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac N xa y z)(*strict*)
   apply(subgoal_tac "cons_tuple2 y z \<in> all_state_stack_str4 G k")
    apply(rename_tac N xa y z)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac N xa y z)(*strict*)
   apply(thin_tac "N \<subseteq> X" for X)
   apply(thin_tac "X \<in> N" for X)
   apply(thin_tac "X \<in> N" for X)
   apply(simp add: all_state_stack_str4_def all_state_stack_str3_def all_state_stack_str2_def)
   apply(rename_tac xa y z)(*strict*)
   apply(case_tac xa)
    apply(rename_tac xa y z)(*strict*)
    prefer 2
    apply(rename_tac xa y z a)(*strict*)
    apply(clarsimp)
    apply(rename_tac q1 n1 q2 n2 s1a s2a q2a n2a s1 s2b)(*strict*)
    apply(force)
   apply(rename_tac xa y z)(*strict*)
   apply(clarsimp)
   apply(rename_tac y z)(*strict*)
   apply(force)
  apply(rename_tac N)(*strict*)
  apply(rule_tac x="N" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp.pelims)
    apply(rename_tac N)(*strict*)
    apply(force)
   apply(rename_tac N)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termination)
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
  apply(rename_tac N S)(*strict*)
  apply(force)
  done

definition F_SDPDA_TO_CFG_OPT__step_closure__fp_EXTRA_01 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list, nat option) DT_tuple3 option DT_graph
  \<Rightarrow> bool"
  where
    "F_SDPDA_TO_CFG_OPT__step_closure__fp_EXTRA_01 G k N \<equiv>
  True"

definition F_SDPDA_TO_CFG_OPT__step_closure__fp_EXTRA_02 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list, nat option) DT_tuple3 option DT_graph
  \<Rightarrow> bool"
  where
    "F_SDPDA_TO_CFG_OPT__step_closure__fp_EXTRA_02 G k N \<equiv>
  N \<subseteq> all_state_stack_str3 G k"

definition F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list, nat option) DT_tuple3 option DT_graph
  \<Rightarrow> bool"
  where
    "F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER G k N \<equiv>
  F_SDPDA_TO_CFG_OPT__step_closure__fp_EXTRA_01 G k N
  \<and> F_SDPDA_TO_CFG_OPT__step_closure__fp_EXTRA_02 G k N"

definition F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list, nat option) DT_tuple3 option DT_graph
  \<Rightarrow> bool"
  where
    "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k S \<equiv>
  valid_epda G
  \<and> k>0
  \<and> S \<subseteq> all_state_stack_str3 G k"

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER_AT_START: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER G k N"
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER_def)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def F_SDPDA_TO_CFG_OPT__step_closure__fp_EXTRA_01_def F_SDPDA_TO_CFG_OPT__step_closure__fp_EXTRA_02_def reach_k_initial_def)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_termLem: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k E \<Longrightarrow>
   F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k)"
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
  apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(force)
  apply(rename_tac x)(*strict*)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__read__exists__greater_than_0_def)
   apply(clarsimp)
   apply(rename_tac xa q r X w q' n)(*strict*)
   apply(subgoal_tac "SSX \<in> all_state_stack_str3 G k" for SSX)
    apply(rename_tac xa q r X w q' n)(*strict*)
    prefer 2
    apply(rule_tac A="E" in set_mp)
     apply(rename_tac xa q r X w q' n)(*strict*)
     apply(force)
    apply(rename_tac xa q r X w q' n)(*strict*)
    apply(force)
   apply(rename_tac xa q r X w q' n)(*strict*)
   apply(thin_tac "X \<in> E" for X)
   apply(thin_tac "E \<subseteq> X" for X)
   apply(subgoal_tac "valid_epda_step_label G SSX" for SSX)
    apply(rename_tac xa q r X w q' n)(*strict*)
    prefer 2
    apply(simp add: valid_epda_def)
    apply(force)
   apply(rename_tac xa q r X w q' n)(*strict*)
   apply(thin_tac "X \<in> epda_delta G" for X)
   apply(simp add: valid_epda_step_label_def)
   apply(clarsimp)
   apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
   apply(erule disjE)
    apply(rename_tac xa q r X w q' n)(*strict*)
    apply(clarsimp)
    apply(rename_tac q r X w q' n q1 n1 s1a s2)(*strict*)
    apply(force)
   apply(rename_tac xa q r X w q' n)(*strict*)
   apply(force)
  apply(rename_tac x)(*strict*)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__read__not_exists__none_def)
   apply(clarsimp)
   apply(rename_tac xa q r X q')(*strict*)
   apply(subgoal_tac "SSX \<in> all_state_stack_str3 G k" for SSX)
    apply(rename_tac xa q r X q')(*strict*)
    prefer 2
    apply(rule_tac A="E" in set_mp)
     apply(rename_tac xa q r X q')(*strict*)
     apply(force)
    apply(rename_tac xa q r X q')(*strict*)
    apply(force)
   apply(rename_tac xa q r X q')(*strict*)
   apply(thin_tac "X \<in> E" for X)
   apply(thin_tac "E \<subseteq> X" for X)
   apply(subgoal_tac "valid_epda_step_label G SSX" for SSX)
    apply(rename_tac xa q r X q')(*strict*)
    prefer 2
    apply(simp add: valid_epda_def)
    apply(force)
   apply(rename_tac xa q r X q')(*strict*)
   apply(thin_tac "X \<in> epda_delta G" for X)
   apply(simp add: valid_epda_step_label_def)
   apply(clarsimp)
   apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
   apply(rule_tac x="[]" in exI)
   apply(clarsimp)
   apply(rule_tac x="[X]" in exI)
   apply(clarsimp)
   apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_def)
   apply(clarsimp)
   apply(rename_tac xa q r X q' a)(*strict*)
   apply(erule disjE)
    apply(rename_tac xa q r X q' a)(*strict*)
    apply(erule disjE)
     apply(rename_tac xa q r X q' a)(*strict*)
     apply(clarsimp)
    apply(rename_tac xa q r X q' a)(*strict*)
    apply(clarsimp)
   apply(rename_tac xa q r X q' a)(*strict*)
   apply(force)
  apply(rename_tac x)(*strict*)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__greater_than_0_def)
   apply(clarsimp)
   apply(rename_tac xa q q' X w n)(*strict*)
   apply(subgoal_tac "SSX \<in> all_state_stack_str3 G k" for SSX)
    apply(rename_tac xa q q' X w n)(*strict*)
    prefer 2
    apply(rule_tac A="E" in set_mp)
     apply(rename_tac xa q q' X w n)(*strict*)
     apply(force)
    apply(rename_tac xa q q' X w n)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X w n)(*strict*)
   apply(thin_tac "X \<in> E" for X)
   apply(thin_tac "E \<subseteq> X" for X)
   apply(subgoal_tac "valid_epda_step_label G SSX" for SSX)
    apply(rename_tac xa q q' X w n)(*strict*)
    prefer 2
    apply(simp add: valid_epda_def)
    apply(force)
   apply(rename_tac xa q q' X w n)(*strict*)
   apply(thin_tac "X
       \<in> epda_delta G" for X)
   apply(simp add: valid_epda_step_label_def)
   apply(clarsimp)
   apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
   apply(erule disjE)
    apply(rename_tac xa q q' X w n)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' X w n q1 n1 s1a s2)(*strict*)
    apply(rule_tac x="X#w" in exI)
    apply(clarsimp)
    apply(case_tac s2)
     apply(rename_tac q q' X w n q1 n1 s1a s2)(*strict*)
     apply(force)
    apply(rename_tac q q' X w n q1 n1 s1a s2 a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' X w n q1 n1 s1a a list)(*strict*)
    apply(case_tac k)
     apply(rename_tac q q' X w n q1 n1 s1a a list)(*strict*)
     apply(force)
    apply(rename_tac q q' X w n q1 n1 s1a a list nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' n q1 n1 s1a a list nat)(*strict*)
    apply(rule_tac x="take nat list" in exI)
    apply(clarsimp)
    apply(subgoal_tac "min (Suc nat) nat = nat")
     apply(rename_tac q q' n q1 n1 s1a a list nat)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac q q' n q1 n1 s1a a list nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' n q1 n1 s1a a list nat x)(*strict*)
    apply (metis set_take_subset2 subsetD)
   apply(rename_tac xa q q' X w n)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X w n s2)(*strict*)
   apply(rule_tac x="X#w" in exI)
   apply(clarsimp)
   apply(case_tac s2)
    apply(rename_tac q q' X w n s2)(*strict*)
    apply(force)
   apply(rename_tac q q' X w n s2 a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X w n a list)(*strict*)
   apply(case_tac k)
    apply(rename_tac q q' X w n a list)(*strict*)
    apply(force)
   apply(rename_tac q q' X w n a list nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' n a list nat)(*strict*)
   apply(rule_tac x="take nat list" in exI)
   apply(clarsimp)
   apply(subgoal_tac "min (Suc nat) nat = nat")
    apply(rename_tac q q' n a list nat)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac q q' n a list nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' n a list nat x)(*strict*)
   apply (metis set_take_subset2 subsetD)
  apply(rename_tac x)(*strict*)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__none_def)
   apply(clarsimp)
   apply(rename_tac xa q q' X w)(*strict*)
   apply(subgoal_tac "SSX \<in> all_state_stack_str3 G k" for SSX)
    apply(rename_tac xa q q' X w)(*strict*)
    prefer 2
    apply(rule_tac A="E" in set_mp)
     apply(rename_tac xa q q' X w)(*strict*)
     apply(force)
    apply(rename_tac xa q q' X w)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X w)(*strict*)
   apply(thin_tac "X \<in> E" for X)
   apply(thin_tac "E \<subseteq> X" for X)
   apply(subgoal_tac "valid_epda_step_label G SSX" for SSX)
    apply(rename_tac xa q q' X w)(*strict*)
    prefer 2
    apply(simp add: valid_epda_def)
    apply(force)
   apply(rename_tac xa q q' X w)(*strict*)
   apply(thin_tac "X
       \<in> epda_delta G" for X)
   apply(simp add: valid_epda_step_label_def)
   apply(clarsimp)
   apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
   apply(case_tac k)
    apply(rename_tac xa q q' X w)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X w nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac k)
   apply(rename_tac xa q q' X w k)(*strict*)
   apply(erule disjE)
    apply(rename_tac xa q q' X w k)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' X w k q1 n1 s1a s2)(*strict*)
    apply(case_tac s2)
     apply(rename_tac q q' X w k q1 n1 s1a s2)(*strict*)
     apply(force)
    apply(rename_tac q q' X w k q1 n1 s1a s2 a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' k q1 n1 s1a a list)(*strict*)
    apply(rename_tac X s2)
    apply(rename_tac q q' k q1 n1 s1a X s2)(*strict*)
    apply(rule_tac x="X # take k s2 " in exI)
    apply(clarsimp)
    apply(rule_tac x="take k s2" in exI)
    apply(clarsimp)
    apply(subgoal_tac "min (Suc k) k =k")
     apply(rename_tac q q' k q1 n1 s1a X s2)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac q q' k q1 n1 s1a X s2)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' k q1 n1 s1a X s2 x)(*strict*)
    apply (metis set_take_subset2 subsetD)
   apply(rename_tac xa q q' X w k)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X w k s2)(*strict*)
   apply(case_tac s2)
    apply(rename_tac q q' X w k s2)(*strict*)
    apply(force)
   apply(rename_tac q q' X w k s2 a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' k a list)(*strict*)
   apply(rename_tac X s2)
   apply(rename_tac q q' k X s2)(*strict*)
   apply(rule_tac x="X # take k s2 " in exI)
   apply(clarsimp)
   apply(rule_tac x="take k s2" in exI)
   apply(clarsimp)
   apply(subgoal_tac "min (Suc k) k =k")
    apply(rename_tac q q' k X s2)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac q q' k X s2)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' k X s2 x)(*strict*)
   apply (metis set_take_subset2 subsetD)
  apply(rename_tac x)(*strict*)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__not_exists__none_def)
   apply(clarsimp)
   apply(rename_tac xa q q' X)(*strict*)
   apply(subgoal_tac "SSX \<in> all_state_stack_str3 G k" for SSX)
    apply(rename_tac xa q q' X)(*strict*)
    prefer 2
    apply(rule_tac A="E" in set_mp)
     apply(rename_tac xa q q' X)(*strict*)
     apply(force)
    apply(rename_tac xa q q' X)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X)(*strict*)
   apply(thin_tac "X \<in> E" for X)
   apply(thin_tac "E \<subseteq> X" for X)
   apply(subgoal_tac "valid_epda_step_label G SSX" for SSX)
    apply(rename_tac xa q q' X)(*strict*)
    prefer 2
    apply(simp add: valid_epda_def)
    apply(force)
   apply(rename_tac xa q q' X)(*strict*)
   apply(thin_tac "X
       \<in> epda_delta G" for X)
   apply(simp add: valid_epda_step_label_def)
   apply(clarsimp)
   apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
   apply(case_tac k)
    apply(rename_tac xa q q' X)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac k)
   apply(rename_tac xa q q' X k)(*strict*)
   apply(rule_tac x="[]" in exI)
   apply(clarsimp)
   apply(rule_tac x="[]" in exI)
   apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__none_def)
   apply(clarsimp)
   apply(rename_tac xa q q' X Y w)(*strict*)
   apply(subgoal_tac "SSX \<in> all_state_stack_str3 G k" for SSX)
    apply(rename_tac xa q q' X Y w)(*strict*)
    prefer 2
    apply(rule_tac A="E" in set_mp)
     apply(rename_tac xa q q' X Y w)(*strict*)
     apply(force)
    apply(rename_tac xa q q' X Y w)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X Y w)(*strict*)
   apply(thin_tac "X \<in> E" for X)
   apply(thin_tac "E \<subseteq> X" for X)
   apply(subgoal_tac "valid_epda_step_label G SSX" for SSX)
    apply(rename_tac xa q q' X Y w)(*strict*)
    prefer 2
    apply(simp add: valid_epda_def)
    apply(force)
   apply(rename_tac xa q q' X Y w)(*strict*)
   apply(thin_tac "X
       \<in> epda_delta G" for X)
   apply(simp add: valid_epda_step_label_def)
   apply(clarsimp)
   apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
   apply(case_tac k)
    apply(rename_tac xa q q' X Y w)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X Y w nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac k)
   apply(rename_tac xa q q' X Y w k)(*strict*)
   apply(erule disjE)
    apply(rename_tac xa q q' X Y w k)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' X Y w k q1 n1 s1a s2)(*strict*)
    apply(case_tac s2)
     apply(rename_tac q q' X Y w k q1 n1 s1a s2)(*strict*)
     apply(force)
    apply(rename_tac q q' X Y w k q1 n1 s1a s2 a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' X k q1 n1 s1a a list)(*strict*)
    apply(rename_tac X s2)
    apply(rename_tac q q' Xa k q1 n1 s1a X s2)(*strict*)
    apply(rule_tac x="X # s2 " in exI)
    apply(clarsimp)
    apply(subgoal_tac "min k (Suc k) =k")
     apply(rename_tac q q' Xa k q1 n1 s1a X s2)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac q q' Xa k q1 n1 s1a X s2)(*strict*)
    apply(clarsimp)
    apply(rule_tac x="Xa#X#s2" in exI)
    apply(clarsimp)
    apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_def)
    apply(clarsimp)
    apply(rename_tac q q' Xa k q1 n1 s1a X s2 a aa)(*strict*)
    apply(erule disjE)
     apply(rename_tac q q' Xa k q1 n1 s1a X s2 a aa)(*strict*)
     apply(erule disjE)
      apply(rename_tac q q' Xa k q1 n1 s1a X s2 a aa)(*strict*)
      apply(erule disjE)
       apply(rename_tac q q' Xa k q1 n1 s1a X s2 a aa)(*strict*)
       apply(clarsimp)
      apply(rename_tac q q' Xa k q1 n1 s1a X s2 a aa)(*strict*)
      apply(clarsimp)
     apply(rename_tac q q' Xa k q1 n1 s1a X s2 a aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac q q' Xa k q1 n1 s1a X s2 a aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' Xa k q1 s1a X s2 a aa n)(*strict*)
    apply(erule disjE)
     apply(rename_tac q q' Xa k q1 s1a X s2 a aa n)(*strict*)
     apply(erule disjE)
      apply(rename_tac q q' Xa k q1 s1a X s2 a aa n)(*strict*)
      apply(clarsimp)
     apply(rename_tac q q' Xa k q1 s1a X s2 a aa n)(*strict*)
     apply(clarsimp)
    apply(rename_tac q q' Xa k q1 s1a X s2 a aa n)(*strict*)
    apply(clarsimp)
   apply(rename_tac xa q q' X Y w k)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X Y w k s2)(*strict*)
   apply(case_tac s2)
    apply(rename_tac q q' X Y w k s2)(*strict*)
    apply(force)
   apply(rename_tac q q' X Y w k s2 a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X k a list)(*strict*)
   apply(rename_tac X s2)
   apply(rename_tac q q' Xa k X s2)(*strict*)
   apply(rule_tac x="X # s2 " in exI)
   apply(clarsimp)
   apply(subgoal_tac "min k (Suc k) =k")
    apply(rename_tac q q' Xa k X s2)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac q q' Xa k X s2)(*strict*)
   apply(clarsimp)
   apply(rule_tac x="Xa#X#s2" in exI)
   apply(clarsimp)
   apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_def)
   apply(clarsimp)
   apply(rename_tac q q' Xa k X s2 a aa)(*strict*)
   apply(erule disjE)
    apply(rename_tac q q' Xa k X s2 a aa)(*strict*)
    apply(erule disjE)
     apply(rename_tac q q' Xa k X s2 a aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac q q' Xa k X s2 a aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac q q' Xa k X s2 a aa)(*strict*)
   apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__not_exists__none_def)
   apply(clarsimp)
   apply(rename_tac xa q q' X Y)(*strict*)
   apply(subgoal_tac "SSX \<in> all_state_stack_str3 G k" for SSX)
    apply(rename_tac xa q q' X Y)(*strict*)
    prefer 2
    apply(rule_tac A="E" in set_mp)
     apply(rename_tac xa q q' X Y)(*strict*)
     apply(force)
    apply(rename_tac xa q q' X Y)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X Y)(*strict*)
   apply(thin_tac "X \<in> E" for X)
   apply(thin_tac "E \<subseteq> X" for X)
   apply(subgoal_tac "valid_epda_step_label G SSX" for SSX)
    apply(rename_tac xa q q' X Y)(*strict*)
    prefer 2
    apply(simp add: valid_epda_def)
    apply(force)
   apply(rename_tac xa q q' X Y)(*strict*)
   apply(thin_tac "X
       \<in> epda_delta G" for X)
   apply(simp add: valid_epda_step_label_def)
   apply(clarsimp)
   apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
   apply(case_tac k)
    apply(rename_tac xa q q' X Y)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X Y nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac k)
   apply(rename_tac xa q q' X Y k)(*strict*)
   apply(erule disjE)
    apply(rename_tac xa q q' X Y k)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' X Y k q1 n1 s1a s2)(*strict*)
    apply(rule_tac x="[]" in exI)
    apply(clarsimp)
    apply(rule_tac x="[X,Y]" in exI)
    apply(clarsimp)
    apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_def)
    apply(clarsimp)
    apply(rename_tac q q' X Y k q1 n1 s1a s2 a aa)(*strict*)
    apply(erule disjE)
     apply(rename_tac q q' X Y k q1 n1 s1a s2 a aa)(*strict*)
     apply(erule disjE)
      apply(rename_tac q q' X Y k q1 n1 s1a s2 a aa)(*strict*)
      apply(erule disjE)
       apply(rename_tac q q' X Y k q1 n1 s1a s2 a aa)(*strict*)
       apply(clarsimp)
      apply(rename_tac q q' X Y k q1 n1 s1a s2 a aa)(*strict*)
      apply(clarsimp)
     apply(rename_tac q q' X Y k q1 n1 s1a s2 a aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac q q' X Y k q1 n1 s1a s2 a aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' X Y k q1 s1a s2 a aa n)(*strict*)
    apply(erule disjE)
     apply(rename_tac q q' X Y k q1 s1a s2 a aa n)(*strict*)
     apply(erule disjE)
      apply(rename_tac q q' X Y k q1 s1a s2 a aa n)(*strict*)
      apply(clarsimp)
     apply(rename_tac q q' X Y k q1 s1a s2 a aa n)(*strict*)
     apply(clarsimp)
    apply(rename_tac q q' X Y k q1 s1a s2 a aa n)(*strict*)
    apply(clarsimp)
   apply(rename_tac xa q q' X Y k)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X Y k s2)(*strict*)
   apply(rule_tac x="[]" in exI)
   apply(clarsimp)
   apply(rule_tac x="[X,Y]" in exI)
   apply(clarsimp)
   apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_def)
   apply(clarsimp)
   apply(rename_tac q q' X Y k s2 a aa)(*strict*)
   apply(erule disjE)
    apply(rename_tac q q' X Y k s2 a aa)(*strict*)
    apply(erule disjE)
     apply(rename_tac q q' X Y k s2 a aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac q q' X Y k s2 a aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac q q' X Y k s2 a aa)(*strict*)
   apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__less_than_k_def)
   apply(clarsimp)
   apply(rename_tac xa q q' X Y w n)(*strict*)
   apply(subgoal_tac "SSX \<in> all_state_stack_str3 G k" for SSX)
    apply(rename_tac xa q q' X Y w n)(*strict*)
    prefer 2
    apply(rule_tac A="E" in set_mp)
     apply(rename_tac xa q q' X Y w n)(*strict*)
     apply(force)
    apply(rename_tac xa q q' X Y w n)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X Y w n)(*strict*)
   apply(thin_tac "X \<in> E" for X)
   apply(thin_tac "E \<subseteq> X" for X)
   apply(subgoal_tac "valid_epda_step_label G SSX" for SSX)
    apply(rename_tac xa q q' X Y w n)(*strict*)
    prefer 2
    apply(simp add: valid_epda_def)
    apply(force)
   apply(rename_tac xa q q' X Y w n)(*strict*)
   apply(thin_tac "X
       \<in> epda_delta G" for X)
   apply(simp add: valid_epda_step_label_def)
   apply(clarsimp)
   apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
   apply(case_tac k)
    apply(rename_tac xa q q' X Y w n)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X Y w n nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac k)
   apply(rename_tac xa q q' X Y w n k)(*strict*)
   apply(erule disjE)
    apply(rename_tac xa q q' X Y w n k)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' X Y w n k q1 n1 s1a s2)(*strict*)
    apply(subgoal_tac "min k (Suc k) =k")
     apply(rename_tac q q' X Y w n k q1 n1 s1a s2)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac q q' X Y w n k q1 n1 s1a s2)(*strict*)
    apply(clarsimp)
    apply(case_tac s2)
     apply(rename_tac q q' X Y w n k q1 n1 s1a s2)(*strict*)
     apply(force)
    apply(rename_tac q q' X Y w n k q1 n1 s1a s2 a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac q q' X n k q1 n1 s1a a list)(*strict*)
    apply(rename_tac X s2)
    apply(rename_tac q q' Xa n k q1 n1 s1a X s2)(*strict*)
    apply(rule_tac x="X # take k s2 " in exI)
    apply(clarsimp)
    apply(rule_tac x="Xa # X # s2 " in exI)
    apply(clarsimp)
    apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_def)
    apply(clarsimp)
    apply(rename_tac q q' Xa n k q1 n1 s1a X s2 a aa)(*strict*)
    apply (metis Diff_iff in_set_takeD insert_subset set_simps(2) subsetI subset_trans)
   apply(rename_tac xa q q' X Y w n k)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X Y w n k s2)(*strict*)
   apply(subgoal_tac "min k (Suc k) =k")
    apply(rename_tac q q' X Y w n k s2)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac q q' X Y w n k s2)(*strict*)
   apply(clarsimp)
   apply(case_tac s2)
    apply(rename_tac q q' X Y w n k s2)(*strict*)
    apply(force)
   apply(rename_tac q q' X Y w n k s2 a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X n k a list)(*strict*)
   apply(rename_tac X s2)
   apply(rename_tac q q' Xa n k X s2)(*strict*)
   apply(rule_tac x="X # take k s2 " in exI)
   apply(clarsimp)
   apply(rule_tac x="Xa # X # s2 " in exI)
   apply(clarsimp)
   apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_def)
   apply(clarsimp)
   apply(rename_tac q q' Xa n k X s2 a aa)(*strict*)
   apply (metis Diff_iff in_set_takeD insert_subset set_simps(2) subsetI subset_trans)
  apply(rename_tac x)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__k_def)
  apply(clarsimp)
  apply(rename_tac xa q q' X Y w n)(*strict*)
  apply(subgoal_tac "SSX \<in> all_state_stack_str3 G SSY" for SSX SSY)
   apply(rename_tac xa q q' X Y w n)(*strict*)
   prefer 2
   apply(rule_tac A="E" in set_mp)
    apply(rename_tac xa q q' X Y w n)(*strict*)
    apply(force)
   apply(rename_tac xa q q' X Y w n)(*strict*)
   apply(force)
  apply(rename_tac xa q q' X Y w n)(*strict*)
  apply(thin_tac "X \<in> E" for X)
  apply(thin_tac "E \<subseteq> X" for X)
  apply(subgoal_tac "valid_epda_step_label G SSX" for SSX)
   apply(rename_tac xa q q' X Y w n)(*strict*)
   prefer 2
   apply(simp add: valid_epda_def)
   apply(force)
  apply(rename_tac xa q q' X Y w n)(*strict*)
  apply(thin_tac "X
      \<in> epda_delta G" for X)
  apply(simp add: valid_epda_step_label_def)
  apply(clarsimp)
  apply(simp add: all_state_stack_str3_def all_state_stack_str2_def)
  apply(erule disjE)
   apply(rename_tac xa q q' X Y w n)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X Y w n q1 n1 s1a s2)(*strict*)
   apply(case_tac s2)
    apply(rename_tac q q' X Y w n q1 n1 s1a s2)(*strict*)
    apply(force)
   apply(rename_tac q q' X Y w n q1 n1 s1a s2 a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac q q' X n q1 n1 s1a a list)(*strict*)
   apply(rename_tac X s2)
   apply(rename_tac q q' Xa n q1 n1 s1a X s2)(*strict*)
   apply(rule_tac x="X # take n s2 " in exI)
   apply(clarsimp)
   apply(subgoal_tac "min n (Suc n) =n")
    apply(rename_tac q q' Xa n q1 n1 s1a X s2)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac q q' Xa n q1 n1 s1a X s2)(*strict*)
   apply(clarsimp)
   apply(rule_tac x="Xa # X # s2 " in exI)
   apply(clarsimp)
   apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_def)
   apply(clarsimp)
   apply(rename_tac q q' Xa n q1 n1 s1a X s2 a aa)(*strict*)
   apply (metis Diff_iff in_set_takeD insert_subset set_simps(2) subsetI subset_trans)
  apply(rename_tac xa q q' X Y w n)(*strict*)
  apply(clarsimp)
  apply(rename_tac q q' X Y w n s2)(*strict*)
  apply(case_tac s2)
   apply(rename_tac q q' X Y w n s2)(*strict*)
   apply(force)
  apply(rename_tac q q' X Y w n s2 a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac q q' X n a list)(*strict*)
  apply(rename_tac X s2)
  apply(rename_tac q q' Xa n X s2)(*strict*)
  apply(rule_tac x="X # take n s2 " in exI)
  apply(clarsimp)
  apply(subgoal_tac "min n (Suc n) =n")
   apply(rename_tac q q' Xa n X s2)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac q q' Xa n X s2)(*strict*)
  apply(clarsimp)
  apply(rule_tac x="Xa # X # s2 " in exI)
  apply(clarsimp)
  apply(simp add: may_terminated_by_def append_language_def kleene_star_def valid_epda_def)
  apply(clarsimp)
  apply(rename_tac q q' Xa n X s2 a aa)(*strict*)
  apply (metis Diff_iff in_set_takeD insert_subset set_simps(2) subsetI subset_trans)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_one_preserves_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k)"
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termLem)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_one_mono: "
  E \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k"
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_termLem2: "
         F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k E \<Longrightarrow>
       F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k \<noteq> E \<Longrightarrow>
       card (all_state_stack_str3 G k - F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k)
       < card (all_state_stack_str3 G k - E)"
  apply(rule Finite_Set.psubset_card_mono)
   prefer 2
   apply(rule rev_subset)
    prefer 3
    apply(rule_tac
      B = "all_state_stack_str3 G k"
      in Finite_Set.finite_subset)
     apply(force)
    prefer 2
    apply(subgoal_tac "E\<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k")
     apply(blast)
    apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_one_mono)
   prefer 2
   apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k)")
    prefer 2
    apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termLem)
    apply(blast)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
  apply(rule finite_all_state_stack_str3)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_one_TRANSFER_TRANSFERS_ALL: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k)
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER G k N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k)"
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER_AT_START)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_termination: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k E
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_dom (G,E,k)"
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>E. F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k E"
      and RECURSIVE_COND = "\<lambda>E. F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k\<noteq>E"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>E. F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k"
      and MEASURE = "\<lambda>E. card (all_state_stack_str3 G k - E)"
      in partial_termination_wf)
      apply(auto)
       apply(rename_tac EA x)(*strict*)
       apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k E")
       apply(rename_tac EA x)
       apply(rename_tac EA x)(*strict*)
       apply(thin_tac "x \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G EA k")
       apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G EA k)")
        apply(rename_tac EA x)(*strict*)
        apply(blast)
       apply(rename_tac EA x)(*strict*)
       apply(thin_tac "\<not> F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G EA k)")
       apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termLem)
       apply(blast)
      apply(rename_tac EA x)(*strict*)
      apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k E")
      apply(rename_tac EA x)
      apply(rename_tac EA x)(*strict*)
      apply(thin_tac "x \<in> EA")
      apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G EA k)")
       apply(rename_tac EA x)(*strict*)
       apply(blast)
      apply(rename_tac EA x)(*strict*)
      apply(thin_tac "\<not> F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G EA k)")
      apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termLem)
      apply(blast)
     apply(rename_tac EA x)(*strict*)
     apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k E")
     apply(rename_tac EA x)
     apply(rename_tac EA x)(*strict*)
     apply(case_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_one G EA k = EA")
      apply(rename_tac EA x)(*strict*)
      apply(force)
     apply(rename_tac EA x)(*strict*)
     apply(thin_tac "x \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G EA k")
     apply(subgoal_tac "card (all_state_stack_str3 G k - F_SDPDA_TO_CFG_OPT__step_closure__fp_one G EA k) < card (all_state_stack_str3 G k - EA)")
      apply(rename_tac EA x)(*strict*)
      apply(blast)
     apply(rename_tac E x)(*strict*)
     apply(thin_tac "\<not> card (all_state_stack_str3 G k - F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k) < card (all_state_stack_str3 G k - E)")
     apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termLem2)
      apply(rename_tac E x)(*strict*)
      apply(blast)
     apply(rename_tac E x)(*strict*)
     apply(force)
    apply(rename_tac EA x)(*strict*)
    apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k E")
    apply(rename_tac E x)
    apply(rename_tac E x)(*strict*)
    apply(subgoal_tac "E \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k")
     apply(rename_tac E x)(*strict*)
     prefer 2
     apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_one_mono)
    apply(rename_tac E x)(*strict*)
    apply(blast)
   apply(rename_tac b)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp.domintros)
    apply(rename_tac b xa)(*strict*)
    apply(force)
   apply(rename_tac b xa)(*strict*)
   apply(force)
  apply(rename_tac x)(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp.domintros)
   apply(rename_tac x xa)(*strict*)
   apply(force)
  apply(rename_tac x xa)(*strict*)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_F_SDPDA_TO_CFG_OPT__step_closure__fp_one_idemp2: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp G N k = F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k) k"
  apply(rule_tac
      t = "F_SDPDA_TO_CFG_OPT__step_closure__fp G N k"
      in ssubst)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp.psimps)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termination)
   apply(blast)
  apply(simp add: Let_def)
  apply(clarsimp)
  apply(rule_tac
      t = "F_SDPDA_TO_CFG_OPT__step_closure__fp G N k"
      in ssubst)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp.psimps)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termination)
   apply(blast)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_Meta_Lift_prime: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N
  \<Longrightarrow> (\<And>G k N. F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k) \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER G k N \<Longrightarrow> P G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k) (F_SDPDA_TO_CFG_OPT__step_closure__fp G N k) \<Longrightarrow> P G k N (F_SDPDA_TO_CFG_OPT__step_closure__fp G N k) )
  \<Longrightarrow> (\<And>G k N. F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k = N \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER G k N \<Longrightarrow> P G k N (F_SDPDA_TO_CFG_OPT__step_closure__fp G N k) )
  \<Longrightarrow> P G k N (F_SDPDA_TO_CFG_OPT__step_closure__fp G N k)"
  apply(subgoal_tac "(\<lambda>N. F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER G k N \<longrightarrow> (P G k N (F_SDPDA_TO_CFG_OPT__step_closure__fp G N k))) N")
   apply(erule impE)
    prefer 2
    apply(blast)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER_AT_START)
   apply(blast)
  apply(subgoal_tac "(\<lambda>N. F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER G k N \<longrightarrow> (P G k N (F_SDPDA_TO_CFG_OPT__step_closure__fp G N k))) N")
   apply(blast)
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>E. F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k E"
      and RECURSIVE_COND = "\<lambda>E. F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k\<noteq>E"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>E. F_SDPDA_TO_CFG_OPT__step_closure__fp_one G E k"
      and MEASURE = "\<lambda>E. card (all_state_stack_str3 G k - E)"
      and TERM_FUN = "(\<lambda>N. F_SDPDA_TO_CFG_OPT__step_closure__fp_TRANSFER G k N \<longrightarrow> (P G k N (F_SDPDA_TO_CFG_OPT__step_closure__fp G N k)))"
      and y = "N"
      in partial_termination_wf)
      apply(rule allI)
      apply(rename_tac x)(*strict*)
      apply(clarify)
      apply(rename_tac x)(*strict*)
      apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N")
      apply(rename_tac N)
      apply(rename_tac N)(*strict*)
      apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_one_preserves_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST)
      apply(blast)
     apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N")
     apply(clarsimp)
     apply(rename_tac x)(*strict*)
     apply(rename_tac N)
     apply(rename_tac N)(*strict*)
     apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termLem2)
      apply(rename_tac N)(*strict*)
      apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
     apply(rename_tac N)(*strict*)
     apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
   prefer 2
   apply(clarsimp)
  apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k N")
  apply(rename_tac N)
  apply(rename_tac N)(*strict*)
  apply(erule impE)
   apply(rename_tac N)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_one_TRANSFER_TRANSFERS_ALL)
     apply(rename_tac N)(*strict*)
     apply(blast)
    apply(rename_tac N)(*strict*)
    apply(blast)
   apply(rename_tac N)(*strict*)
   apply(blast)
  apply(rename_tac N)(*strict*)
  apply(subgoal_tac "P G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k) (F_SDPDA_TO_CFG_OPT__step_closure__fp G N k)")
   apply(rename_tac N)(*strict*)
   apply(thin_tac "P G k (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k) (F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k) k)")
   prefer 2
   apply(rule_tac
      t="F_SDPDA_TO_CFG_OPT__step_closure__fp G N k"
      and s="F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__fp_one G N k) k"
      in ssubst)
    apply(rename_tac N)(*strict*)
    apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_F_SDPDA_TO_CFG_OPT__step_closure__fp_one_idemp2)
    apply(force)
   apply(rename_tac N)(*strict*)
   apply(force)
  apply(rename_tac N)(*strict*)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_preserves_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k S
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__fp G S k)"
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_Meta_Lift_prime)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(clarsimp)
  apply(rename_tac Ga ka N)(*strict*)
  apply(rule_tac ?x.0="Ga" in F_SDPDA_TO_CFG_OPT__step_closure__fp.pelims)
    apply(rename_tac Ga ka N)(*strict*)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termination)
   apply(force)
  apply(rename_tac Ga ka N Gaa Sa kaa)(*strict*)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__l3_init_in_all_state_stack_str3_simp: "
  valid_epda G
  \<Longrightarrow> S \<subseteq> F_EPDA_AIA__codom G k
  \<Longrightarrow> k>0
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__l3_init G A S \<subseteq> all_state_stack_str3 G k"
  apply(simp add: F_EPDA_AIA__fp_valid_input_def F_SDPDA_TO_CFG_OPT__step_closure__l3_init_def all_state_stack_str3_def)
  apply(clarsimp)
  apply(rename_tac q w)(*strict*)
  apply(simp add: all_state_stack_str2_def)
  apply(subgoal_tac "cons_tuple2 q (A # w) \<in> F_EPDA_AIA__codom G k")
   apply(rename_tac q w)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac q w)(*strict*)
  apply(thin_tac "S \<subseteq> X" for X)
  apply(thin_tac "X \<in> S" for X)
  apply(simp add: F_EPDA_AIA__codom_def)
  apply(erule disjE)
   apply(rename_tac q w)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_start_def)
   apply(clarsimp)
   apply(simp add: valid_epda_def)
   apply(erule_tac x="[epda_box G]" in allE)
   apply(clarsimp)
  apply(rename_tac q w)(*strict*)
  apply(clarsimp)
  done

lemma all_state_stack_str2_map_to_F_EPDA_AIA__codom: "
  S \<subseteq> all_state_stack_str2 G k
  \<Longrightarrow> (the \<circ> sel_tuple2_2) ` S \<subseteq> F_EPDA_AIA__codom G k"
  apply(simp add: all_state_stack_str2_def F_EPDA_AIA__codom_def)
  apply(clarsimp)
  apply(rename_tac xa)(*strict*)
  apply(force)
  done

definition reach_k_access_closure_TERM_ARGS_TEST :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "reach_k_access_closure_TERM_ARGS_TEST G k E \<equiv>
  valid_epda G
  \<and> reach_k_initial G k \<in> E
  \<and> E \<subseteq> all_state_stack_str2 G k
  \<and> reach_k_one_step_contained G k E {0}"

definition reach_k_access_closure_EXTRA_01 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "reach_k_access_closure_EXTRA_01 G k N \<equiv>
  True"

definition reach_k_access_closure_EXTRA_02 :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "reach_k_access_closure_EXTRA_02 G k N \<equiv>
  N \<subseteq> all_state_stack_str2 G k"

definition reach_k_access_closure_TRANSFER :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> bool"
  where
    "reach_k_access_closure_TRANSFER G k N \<equiv>
  reach_k_access_closure_EXTRA_01 G k N
  \<and> reach_k_access_closure_EXTRA_02 G k N"

lemma reach_k_access_closure_TRANSFER_AT_START: "
  reach_k_access_closure_TERM_ARGS_TEST G k N
  \<Longrightarrow> reach_k_access_closure_TRANSFER G k N"
  apply(simp add: reach_k_access_closure_TRANSFER_def)
  apply(simp add: reach_k_access_closure_TERM_ARGS_TEST_def reach_k_access_closure_EXTRA_01_def reach_k_access_closure_EXTRA_02_def reach_k_initial_def)
  done

lemma reach_k_access_closure1_intro1: "
  x \<in> E
  \<Longrightarrow> x \<in> reach_k_access_closure1 E"
  apply(simp add: reach_k_access_closure1_def)
  done

lemma reach_k_access_closure1_preserves_all_state_stack_str: "
  valid_epda G
  \<Longrightarrow> E \<subseteq> all_state_stack_str2 G k
  \<Longrightarrow> reach_k_access_closure1 E \<subseteq> all_state_stack_str2 G k"
  apply(simp add: all_state_stack_str2_def)
  apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(simp add: reach_k_access_closure1_def all_state_stack_str_def all_state_stack_str2_def)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(subgoal_tac "x \<in> insert (reach_k_initial G k)
             {cons_tuple2 (Some (cons_tuple2 q1 (take k s1)))
               (Some (cons_tuple2 q2 (take k s2))) |
              q1 s1 q2 s2.
              q1 \<in> epda_states G \<and>
              q2 \<in> epda_states G \<and>
              set s1 \<subseteq> epda_gamma G \<and> set s2 \<subseteq> epda_gamma G}")
    apply(rename_tac x)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac x)(*strict*)
   apply(thin_tac "x \<in> E" for x)
   apply(thin_tac "E \<subseteq> x" for x)
   apply(clarsimp)
   apply(simp add: reach_k_initial_def valid_epda_def)
   apply(force)
  apply(rename_tac x)(*strict*)
  apply(clarsimp)
  apply(rename_tac xa y z)(*strict*)
  apply(subgoal_tac "cons_tuple2 xa y \<in> {cons_tuple2 (Some (cons_tuple2 q1 (take k s1)))
              (Some (cons_tuple2 q2 (take k s2))) |
             q1 s1 q2 s2.
             q1 \<in> epda_states G \<and>
             q2 \<in> epda_states G \<and>
             set s1 \<subseteq> epda_gamma G \<and> set s2 \<subseteq> epda_gamma G} \<union>
            {cons_tuple2 None (Some (cons_tuple2 q2 (take k s2))) |q2 s2.
             q2 \<in> epda_states G \<and> set s2 \<subseteq> epda_gamma G}")
   apply(rename_tac xa y z)(*strict*)
   prefer 2
   apply(blast)
  apply(rename_tac xa y z)(*strict*)
  apply(subgoal_tac "cons_tuple2 y z \<in> {cons_tuple2 (Some (cons_tuple2 q1 (take k s1)))
              (Some (cons_tuple2 q2 (take k s2))) |
             q1 s1 q2 s2.
             q1 \<in> epda_states G \<and>
             q2 \<in> epda_states G \<and>
             set s1 \<subseteq> epda_gamma G \<and> set s2 \<subseteq> epda_gamma G} \<union>
            {cons_tuple2 None (Some (cons_tuple2 q2 (take k s2))) |q2 s2.
             q2 \<in> epda_states G \<and> set s2 \<subseteq> epda_gamma G}")
   apply(rename_tac xa y z)(*strict*)
   prefer 2
   apply(blast)
  apply(rename_tac xa y z)(*strict*)
  apply(thin_tac "x \<in> E" for x)
  apply(thin_tac "x \<in> E" for x)
  apply(thin_tac "E \<subseteq> x" for x)
  apply(clarsimp)
  apply(erule disjE)
   apply(rename_tac xa y z)(*strict*)
   apply(erule disjE)
    apply(rename_tac xa y z)(*strict*)
    apply(clarsimp)
    apply(rename_tac q1 s1 s1a q2 s2 q2a s2a)(*strict*)
    apply(force)
   apply(rename_tac xa y z)(*strict*)
   apply(simp add: reach_k_initial_def)
  apply(rename_tac xa y z)(*strict*)
  apply(clarsimp)
  done

lemma reach_k_one_step_contained_closed_under_extension: "
  reach_k_one_step_contained G k E N
  \<Longrightarrow> E \<subseteq> E'
  \<Longrightarrow> reach_k_one_step_contained G k E' N"
  apply(simp add: reach_k_one_step_contained_def)
  apply(clarsimp)
  apply(rename_tac d i e1 c1 e2 c2 j)(*strict*)
  apply(erule_tac x="d" in allE)
  apply(clarsimp)
  apply(erule_tac x="i" in allE)
  apply(clarsimp)
  apply(erule_tac x="e2" in allE)
  apply(erule_tac x="c2" in allE)
  apply(erule_tac x="j" in allE)
  apply(clarsimp)
  apply(rename_tac d i e1 c1 e2 c2 j w1 w2)(*strict*)
  apply(rule_tac x="w1" in exI)
  apply(rule_tac x="w2" in exI)
  apply(clarsimp)
  apply(force)
  done

lemma reach_k_access_closure_termLem: "
  reach_k_access_closure_TERM_ARGS_TEST G k E \<Longrightarrow>
   reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure1 E)"
  apply(simp add: reach_k_access_closure_TERM_ARGS_TEST_def reach_k_initial_def)
  apply(clarsimp)
  apply(rule conjI)
   apply(rule reach_k_access_closure1_intro1)
   apply(force)
  apply(rule conjI)
   apply(rule reach_k_access_closure1_preserves_all_state_stack_str)
    apply(force)
   apply(force)
  apply(rule reach_k_one_step_contained_closed_under_extension)
   apply(force)
  apply(simp add: reach_k_access_closure1_def)
  done

lemma reach_k_access_closure1_preserves_reach_k_access_closure_TERM_ARGS_TEST: "
  reach_k_access_closure_TERM_ARGS_TEST G k N
  \<Longrightarrow> reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure1 N)"
  apply(rule reach_k_access_closure_termLem)
  apply(force)
  done

lemma reach_k_access_closure1_mono: "
  E \<subseteq> reach_k_access_closure1 E"
  apply(simp add: reach_k_access_closure1_def)
  done

lemma reach_k_access_closure1_TRANSFER_TRANSFERS_ALL: "
  reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure1 N)
  \<Longrightarrow> reach_k_access_closure_TERM_ARGS_TEST G k N
  \<Longrightarrow> reach_k_access_closure_TRANSFER G k N
  \<Longrightarrow> reach_k_access_closure_TRANSFER G k (reach_k_access_closure1 N)"
  apply(rule reach_k_access_closure_TRANSFER_AT_START)
  apply(force)
  done

lemma finite_all_state_stack_str2: "
  valid_epda G
  \<Longrightarrow> finite (all_state_stack_str2 G k)"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac h="%(q1,s1,q2,s2). cons_tuple2 (Some (cons_tuple2 q1 s1)) (Some(cons_tuple2 q2 s2))" and F="(epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G})" in finite_imageI)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
    apply(rule wordsUpToLengthFinite2)
    apply(force)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(rule wordsUpToLengthFinite2)
   apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac h="%(q1,s1,q2,s2). cons_tuple2 (None) (Some(cons_tuple2 q2 s2))" and F="(epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G})" in finite_imageI)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
    apply(rule wordsUpToLengthFinite2)
    apply(force)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(rule wordsUpToLengthFinite2)
   apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
  apply(rule_tac
      s="((\<lambda>(q1, s1, q2, s2).
          cons_tuple2 (Some (cons_tuple2 q1 s1)) (Some (cons_tuple2 q2 s2))) `
      (epda_states G \<times>
       {take k w |w. set w \<subseteq> epda_gamma G} \<times>
       epda_states G \<times> {take k w |w. set w \<subseteq> epda_gamma G})) \<union> ((\<lambda>(q1, s1, q2, s2). cons_tuple2 None (Some (cons_tuple2 q2 s2))) `
      (epda_states G \<times>
       {take k w |w. set w \<subseteq> epda_gamma G} \<times>
       epda_states G \<times> {take k w |w. set w \<subseteq> epda_gamma G}))"
      and t="all_state_stack_str2 G k"
      in ssubst)
   prefer 2
   apply(rule_tac t="finite
     ((\<lambda>(q1, s1, q2, s2).
          cons_tuple2 (Some (cons_tuple2 q1 s1)) (Some (cons_tuple2 q2 s2))) `
      (epda_states G \<times>
       {take k w |w. set w \<subseteq> epda_gamma G} \<times>
       epda_states G \<times> {take k w |w. set w \<subseteq> epda_gamma G}) \<union>
      (\<lambda>(q1, s1, q2, s2). cons_tuple2 None (Some (cons_tuple2 q2 s2))) `
      (epda_states G \<times>
       {take k w |w. set w \<subseteq> epda_gamma G} \<times>
       epda_states G \<times> {take k w |w. set w \<subseteq> epda_gamma G}))" in ssubst)
    apply(rule finite_Un)
   apply(rule conjI)
    apply(simp (no_asm))
   apply(simp (no_asm))
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(simp add: all_state_stack_str2_def)
  apply(rule_tac f="%a b. a \<union> b" in arg_cong2)
   apply(rule antisym)
    apply(clarsimp)
    apply(rename_tac q1 s1 q2 s2)(*strict*)
    apply(rule inMap)
    apply(rule_tac x="(q1,take k s1,q2,take k s2)" in bexI)
     apply(rename_tac q1 s1 q2 s2)(*strict*)
     apply(clarsimp)
    apply(rename_tac q1 s1 q2 s2)(*strict*)
    apply(force)
   apply(clarsimp)
   apply(rename_tac a ab w wa)(*strict*)
   apply(force)
  apply(rule antisym)
   apply(clarsimp)
   apply(rename_tac q2 s2)(*strict*)
   apply(rule inMap)
   apply(rule_tac x="(q2,take k s2,q2,take k s2)" in bexI)
    apply(rename_tac q2 s2)(*strict*)
    apply(clarsimp)
   apply(rename_tac q2 s2)(*strict*)
   apply(force)
  apply(clarsimp)
  apply(rename_tac a ab w wa)(*strict*)
  apply(force)
  done

lemma reach_k_access_closure_termLem2: "
  reach_k_access_closure_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_access_closure1 E \<noteq> E
  \<Longrightarrow> card (all_state_stack_str2 G k - reach_k_access_closure1 E) < card (all_state_stack_str2 G k - E)"
  apply(rule Finite_Set.psubset_card_mono)
   prefer 2
   apply(rule rev_subset)
    prefer 3
    apply(rule_tac
      B = "all_state_stack_str2 G k"
      in Finite_Set.finite_subset)
     apply(force)
    prefer 2
    apply(subgoal_tac "E\<subseteq> reach_k_access_closure1  E")
     apply(blast)
    apply(rule reach_k_access_closure1_mono)
   prefer 2
   apply(subgoal_tac "reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure1 E)")
    prefer 2
    apply(rule reach_k_access_closure_termLem)
    apply(blast)
   apply(simp add: reach_k_access_closure_TERM_ARGS_TEST_def)
  apply(rule finite_all_state_stack_str2)
  apply(simp add: reach_k_access_closure_TERM_ARGS_TEST_def)
  done

lemma reach_k_access_closure_Meta_Lift: "
  reach_k_access_closure_TERM_ARGS_TEST G k N
  \<Longrightarrow> (\<And>N. reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure1 N) \<Longrightarrow> reach_k_access_closure_TERM_ARGS_TEST G k N \<Longrightarrow> reach_k_access_closure_TRANSFER G k N \<Longrightarrow> P G k (reach_k_access_closure (reach_k_access_closure1 N)) \<Longrightarrow> P G k (reach_k_access_closure N))
  \<Longrightarrow> (\<And>N. reach_k_access_closure1 N = N \<Longrightarrow> reach_k_access_closure_TERM_ARGS_TEST G k N \<Longrightarrow> reach_k_access_closure_TRANSFER G k N \<Longrightarrow> P G k (reach_k_access_closure N))
  \<Longrightarrow> P G k (reach_k_access_closure N)"
  apply(subgoal_tac "(\<lambda>N. reach_k_access_closure_TRANSFER G k N \<longrightarrow> (P G k (reach_k_access_closure N))) N")
   apply(erule impE)
    prefer 2
    apply(blast)
   apply(rule reach_k_access_closure_TRANSFER_AT_START)
   apply(blast)
  apply(subgoal_tac "(\<lambda>N. reach_k_access_closure_TRANSFER G k N \<longrightarrow> (P G k (reach_k_access_closure N))) N")
   apply(blast)
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>E. reach_k_access_closure_TERM_ARGS_TEST G k E"
      and RECURSIVE_COND = "\<lambda>E. reach_k_access_closure1  E\<noteq>E"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>E. reach_k_access_closure1 E"
      and MEASURE = "\<lambda>E. card (all_state_stack_str2 G k - E)"
      and TERM_FUN = "(\<lambda>N. reach_k_access_closure_TRANSFER G k N \<longrightarrow> (P G k (reach_k_access_closure N)))"
      and y = "N"
      in partial_termination_wf)
      apply(rule allI)
      apply(rename_tac x)(*strict*)
      apply(clarify)
      apply(rename_tac b)(*strict*)
      apply(thin_tac "reach_k_access_closure_TERM_ARGS_TEST G k N")
      apply(rename_tac N)
      apply(rename_tac N)(*strict*)
      apply(rule reach_k_access_closure1_preserves_reach_k_access_closure_TERM_ARGS_TEST)
      apply(blast)
     apply(thin_tac "reach_k_access_closure_TERM_ARGS_TEST G k N")
     apply(clarsimp)
     apply(rename_tac b)(*strict*)
     apply(rename_tac N)
     apply(rename_tac N)(*strict*)
     apply(rule reach_k_access_closure_termLem2)
      apply(rename_tac N)(*strict*)
      apply(simp add: reach_k_access_closure_TERM_ARGS_TEST_def)
     apply(rename_tac N)(*strict*)
     apply(simp add: reach_k_access_closure_TERM_ARGS_TEST_def)
    apply(simp add: reach_k_access_closure_TERM_ARGS_TEST_def)
   prefer 2
   apply(clarsimp)
  apply(clarsimp)
  apply(rename_tac b)(*strict*)
  apply(erule impE)
   apply(rename_tac b)(*strict*)
   apply(rule reach_k_access_closure1_TRANSFER_TRANSFERS_ALL)
     apply(rename_tac b)(*strict*)
     apply(blast)+
  done

lemma reach_k_access_closure_termination: "
  reach_k_access_closure_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_access_closure_dom E"
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>E. reach_k_access_closure_TERM_ARGS_TEST G k E"
      and RECURSIVE_COND = "\<lambda>E. reach_k_access_closure1  E\<noteq>E"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>E. reach_k_access_closure1 E"
      and MEASURE = "\<lambda>E. card (all_state_stack_str2 G k - E)"
      in partial_termination_wf)
      apply(auto)
       apply(rename_tac EA x)(*strict*)
       apply(thin_tac "reach_k_access_closure_TERM_ARGS_TEST G k E")
       apply(rename_tac EA x)
       apply(rename_tac EA x)(*strict*)
       apply(thin_tac "x \<in> reach_k_access_closure1 EA")
       apply(subgoal_tac "reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure1 EA)")
        apply(rename_tac EA x)(*strict*)
        apply(blast)
       apply(rename_tac EA x)(*strict*)
       apply(thin_tac "\<not> reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure1 EA)")
       apply(rule reach_k_access_closure_termLem)
       apply(blast)
      apply(rename_tac EA x)(*strict*)
      apply(thin_tac "reach_k_access_closure_TERM_ARGS_TEST G k E")
      apply(rename_tac EA x)
      apply(rename_tac EA x)(*strict*)
      apply(thin_tac "x \<in> EA")
      apply(subgoal_tac "reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure1 EA)")
       apply(rename_tac EA x)(*strict*)
       apply(blast)
      apply(rename_tac EA x)(*strict*)
      apply(thin_tac "\<not> reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure1 EA)")
      apply(rule reach_k_access_closure_termLem)
      apply(blast)
     apply(rename_tac EA x)(*strict*)
     apply(thin_tac "reach_k_access_closure_TERM_ARGS_TEST G k E")
     apply(rename_tac EA x)
     apply(rename_tac EA x)(*strict*)
     apply(case_tac "reach_k_access_closure1 EA = EA")
      apply(rename_tac EA x)(*strict*)
      apply(force)
     apply(rename_tac EA x)(*strict*)
     apply(thin_tac "x \<in> reach_k_access_closure1 EA")
     apply(subgoal_tac "card (all_state_stack_str2 G k - reach_k_access_closure1 EA) < card (all_state_stack_str2 G k - EA)")
      apply(rename_tac EA x)(*strict*)
      apply(blast)
     apply(rename_tac E x)(*strict*)
     apply(thin_tac "\<not> card (all_state_stack_str2 G k - reach_k_access_closure1  E) < card (all_state_stack_str2 G k - E)")
     apply(rule reach_k_access_closure_termLem2)
      apply(rename_tac E x)(*strict*)
      apply(blast)
     apply(rename_tac E x)(*strict*)
     apply(force)
    apply(rename_tac EA x)(*strict*)
    apply(thin_tac "reach_k_access_closure_TERM_ARGS_TEST G k E")
    apply(rename_tac E x)
    apply(rename_tac E x)(*strict*)
    apply(subgoal_tac "E \<subseteq> reach_k_access_closure1 E")
     apply(rename_tac E x)(*strict*)
     prefer 2
     apply(rule reach_k_access_closure1_mono)
    apply(rename_tac E x)(*strict*)
    apply(blast)
   apply(rename_tac b)(*strict*)
   apply(rule reach_k_access_closure.domintros)
    apply(rename_tac b x)(*strict*)
    apply(force,force)
  apply(rename_tac x)(*strict*)
  apply(rule reach_k_access_closure.domintros)
   apply(rename_tac x xa)(*strict*)
   apply(force,force)
  done

lemma reach_k_access_closure_reach_k_access_closure1_idemp2: "
  reach_k_access_closure_TERM_ARGS_TEST G k N
  \<Longrightarrow> reach_k_access_closure N = reach_k_access_closure  (reach_k_access_closure1 N)"
  apply(rule_tac
      t = "reach_k_access_closure N"
      and s = "(if reach_k_access_closure1 N = N then N else reach_k_access_closure (reach_k_access_closure1  N))"
      in ssubst)
   apply(rule reach_k_access_closure.psimps)
   apply(rule reach_k_access_closure_termination)
   apply(blast)
  apply(clarsimp)
  apply(rule_tac
      t = "reach_k_access_closure N"
      and s = "(if reach_k_access_closure1 N = N then N else reach_k_access_closure (reach_k_access_closure1  N))"
      in ssubst)
   apply(rule reach_k_access_closure.psimps)
   apply(rule reach_k_access_closure_termination)
   apply(blast)
  apply(clarsimp)
  done

lemma reach_k_access_closure_preserves_reach_k_access_closure_TERM_ARGS_TEST: "
  reach_k_access_closure_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_access_closure_TERM_ARGS_TEST G k (reach_k_access_closure E)"
  apply(rule_tac G="G" and k="k" and N="E" in reach_k_access_closure_Meta_Lift)
    apply(simp add: reach_k_access_closure_TERM_ARGS_TEST_def SpecOutput_reach_k_def reach_k_TRANSFER_def reach_k_EXTRA_01_def reach_k_EXTRA_02_def)
   apply(rename_tac N)(*strict*)
   apply (metis reach_k_access_closure_reach_k_access_closure1_idemp2)
  apply(rename_tac N)(*strict*)
  apply (metis reach_k_access_closure.psimps reach_k_access_closure_termination)
  done

lemma reach_k_TRANSFER_AT_START: "
  reach_k_TERM_ARGS_TEST G k N
  \<Longrightarrow> reach_k_TRANSFER G k N"
  apply(simp add: reach_k_TRANSFER_def)
  apply(simp add: reach_k_TERM_ARGS_TEST_def reach_k_EXTRA_01_def reach_k_EXTRA_02_def reach_k_initial_def)
  done

lemma reach_k_termLem: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k E)"
  apply(simp add: reach_k_TERM_ARGS_TEST_def reach_k_loop1_def valid_epda_def reach_k_loop1_def reach_k_initial_def)
  apply(clarsimp)
  apply(rule conjI)
   apply(clarsimp)
   apply(rename_tac c q1 s1 q2 w1 w2 xa)(*strict*)
   apply(subgoal_tac "cons_tuple2 (c) (Some (cons_tuple2 q1 s1)) \<in> all_state_stack_str G k")
    apply(rename_tac c q1 s1 q2 w1 w2 xa)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac c q1 s1 q2 w1 w2 xa)(*strict*)
   apply(thin_tac " E \<subseteq> all_state_stack_str G k")
   apply(thin_tac "cons_tuple2
        c
        (Some (cons_tuple2 q1 s1))
       \<in> E")
   apply(simp add: all_state_stack_str_def)
   apply(erule_tac x="\<lparr>edge_src = q1, edge_event = xa, edge_pop = w1, edge_push = w2,
          edge_trg = q2\<rparr>" in ballE)
    apply(rename_tac c q1 s1 q2 w1 w2 xa)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac c q1 s1 q2 w1 w2 xa)(*strict*)
   apply(simp add: valid_epda_step_label_def may_terminated_by_def reach_k_initial_def)
   apply(clarsimp)
   apply(erule_tac P="c = None \<and> q1 = epda_initial G \<and> s1 = take k [epda_box G]" in disjE)
    apply(rename_tac c q1 s1 q2 w1 w2 xa)(*strict*)
    apply(clarsimp)
    apply(rename_tac q2 w1 w2 xa)(*strict*)
    apply(rule_tac x="[epda_box G]" in exI)
    apply(clarsimp)
    apply(simp add: append_language_def kleene_star_def)
    apply(clarsimp)
    apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
    apply(rule_tac x="take k w2 @
             take (k - length w2) (drop (length w1) (take k [epda_box G]))" in exI)
    apply(clarsimp)
    apply(subgoal_tac "X" for X)
     apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
     prefer 2
     apply(rule_tac a="(length w2)" and b="k" in min_alt)
    apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
    apply(erule_tac P="min (length w2) k = length w2 \<and> length w2 \<le> k" in disjE)
     apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
     apply(rule conjI)
      apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
      apply(clarsimp)
     apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
     apply(rule conjI)
      apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
      apply(rule set_take_subset2)
      apply(force)
     apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
     apply(rule set_take_subset2)
     apply(case_tac k)
      apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
      apply(clarsimp)
     apply(rename_tac q2 w1 w2 xa a aa nat)(*strict*)
     apply(clarsimp)
     apply(rename_tac q2 w1 w2 xa a aa nat x)(*strict*)
     apply(case_tac w1)
      apply(rename_tac q2 w1 w2 xa a aa nat x)(*strict*)
      apply(clarsimp)
     apply(rename_tac q2 w1 w2 xa a aa nat x ab list)(*strict*)
     apply(clarsimp)
    apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
    apply(rule conjI)
     apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
    apply(rule conjI)
     apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
     apply(rule set_take_subset2)
     apply(force)
    apply(rename_tac q2 w1 w2 xa a aa)(*strict*)
    apply(force)
   apply(rename_tac c q1 s1 q2 w1 w2 xa)(*strict*)
   apply(clarsimp)
   apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
   apply(rule_tac x="s2" in exI)
   apply(clarsimp)
   apply(rule_tac x="take k w2 @
             take (k - length w2) (drop (length w1) (take k s2))" in exI)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
    apply(case_tac "min (length w2) k = length w2")
     apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
     apply(clarsimp)
    apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
    apply(subgoal_tac "min (length w2) k = k")
     apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
    apply(clarsimp)
   apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
   apply(rule conjI)
    apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
    apply(rule set_take_subset2)
    apply(simp add: append_language_def kleene_star_def)
    apply(clarsimp)
    apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2 x a aa)(*strict*)
    apply(erule_tac P="w2 = aa @ [epda_box G] " in disjE)
     apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2 x a aa)(*strict*)
     apply(clarsimp)
     apply(rename_tac q1 q2 w1 xa q1a s1a s2 x a aa)(*strict*)
     apply(erule disjE)
      apply(rename_tac q1 q2 w1 xa q1a s1a s2 x a aa)(*strict*)
      apply(force)
     apply(rename_tac q1 q2 w1 xa q1a s1a s2 x a aa)(*strict*)
     apply(blast)
    apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2 x a aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac q1 q2 w1 xa q1a s1a s2 x a aa)(*strict*)
    apply(blast)
   apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
   apply(rule set_take_subset2)
   apply(rule_tac subset_trans)
    apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
    apply(rule set_drop_subset)
   apply(rename_tac q1 q2 w1 w2 xa q1a s1a s2)(*strict*)
   apply(rule set_take_subset2)
   apply(force)
  apply(simp add: reach_k_all_prestate_def)
  apply(clarsimp)
  apply(rename_tac y z)(*strict*)
  apply(erule disjE)
   apply(rename_tac y z)(*strict*)
   apply(erule_tac x="y" in allE)
   apply(erule impE)
    apply(rename_tac y z)(*strict*)
    apply(force)
   apply(rename_tac y z)(*strict*)
   apply(clarsimp)
   apply(rename_tac y z x)(*strict*)
   apply(force)
  apply(rename_tac y z)(*strict*)
  apply(clarsimp)
  apply(rename_tac c q1 s1 q2 w1 w2 x)(*strict*)
  apply(force)
  done

lemma reach_k_loop1_preserves_reach_k_TERM_ARGS_TEST: "
  reach_k_TERM_ARGS_TEST G k N
  \<Longrightarrow> reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k N)"
  apply(case_tac "reach_k_loop1 G k N = N")
   apply(clarsimp)
  apply(rule reach_k_termLem)
  apply(auto)
  done

lemma reach_k_loop1_mono: "
  E \<subseteq> reach_k_loop1 G k E"
  apply(simp add: reach_k_loop1_def)
  done

lemma insert_arg_cong: "
  A = B
  \<Longrightarrow> insert x A = insert x B"
  apply(force)
  done

lemma finite_all_state_stack_str: "
  valid_epda G
  \<Longrightarrow> finite (all_state_stack_str G k)"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac h="%(q1,s1,q2,s2). cons_tuple2 (Some (cons_tuple2 q1 s1)) (Some(cons_tuple2 q2 s2))" and F="(epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G})" in finite_imageI)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
    apply(rule wordsUpToLengthFinite2)
    apply(force)
   apply(rule finite_cartesian_product)
    apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
   apply(rule wordsUpToLengthFinite2)
   apply(simp add: reach_k_TERM_ARGS_TEST_def valid_epda_def)
  apply(rule_tac
      s="(%(q1,s1,q2,s2). cons_tuple2 (Some (cons_tuple2 q1 s1)) (Some (cons_tuple2 q2 s2))) ` (epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G}) \<union> {reach_k_initial G k}"
      and t="all_state_stack_str G k"
      in ssubst)
   prefer 2
   apply(rule_tac t="finite ((%(q1,s1,q2,s2). cons_tuple2 (Some (cons_tuple2 q1 s1)) (Some (cons_tuple2 q2 s2))) ` (epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G} \<times> epda_states G \<times> {take k w| w. set w \<subseteq> epda_gamma G}) \<union> {reach_k_initial G k})" in ssubst)
    apply(rule finite_Un)
   apply(rule conjI)
    apply(simp (no_asm))
   apply(simp (no_asm))
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(simp add: all_state_stack_str_def)
  apply(rule insert_arg_cong)
  apply(rule antisym)
   apply(clarsimp)
   apply(rename_tac q1 s1 q2 s2)(*strict*)
   apply(rule inMap)
   apply(rule_tac x="(q1,take k s1,q2,take k s2)" in bexI)
    apply(rename_tac q1 s1 q2 s2)(*strict*)
    apply(clarsimp)
   apply(rename_tac q1 s1 q2 s2)(*strict*)
   apply(force)
  apply(clarsimp)
  apply(rename_tac a ab w wa)(*strict*)
  apply(force)
  done

lemma reach_k_termLem2: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_loop1 G k E \<noteq> E
  \<Longrightarrow> card (all_state_stack_str G k - reach_k_loop1 G k E) < card (all_state_stack_str G k - E)"
  apply(rule Finite_Set.psubset_card_mono)
   prefer 2
   apply(rule rev_subset)
    prefer 3
    apply(rule_tac
      B = "all_state_stack_str G k"
      in Finite_Set.finite_subset)
     apply(force)
    prefer 2
    apply(subgoal_tac "E\<subseteq> reach_k_loop1 G k E")
     apply(blast)
    apply(rule reach_k_loop1_mono)
   prefer 2
   apply(subgoal_tac "reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k E)")
    prefer 2
    apply(rule reach_k_termLem)
    apply(blast)
   apply(simp add: reach_k_TERM_ARGS_TEST_def)
  apply(rule finite_all_state_stack_str)
  apply(simp add: reach_k_TERM_ARGS_TEST_def)
  done

lemma reach_k_loop1_TRANSFER_TRANSFERS_ALL: "
  reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k N)
  \<Longrightarrow> reach_k_TERM_ARGS_TEST G k N
  \<Longrightarrow> reach_k_TRANSFER G k N
  \<Longrightarrow> reach_k_TRANSFER G k (reach_k_loop1 G k N)"
  apply(rule reach_k_TRANSFER_AT_START)
  apply(force)
  done

lemma reach_k_Meta_Lift: "
  reach_k_TERM_ARGS_TEST G k N
  \<Longrightarrow> (\<And>G k N. reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k N) \<Longrightarrow> reach_k_TERM_ARGS_TEST G k N \<Longrightarrow> reach_k_TRANSFER G k N \<Longrightarrow> P G k (reach_k G k (reach_k_loop1 G k N)) \<Longrightarrow> P G k (reach_k G k N))
  \<Longrightarrow> (\<And>G k N. reach_k_loop1 G k N = N \<Longrightarrow> reach_k_TERM_ARGS_TEST G k N \<Longrightarrow> reach_k_TRANSFER G k N \<Longrightarrow> P G k (reach_k G k N))
  \<Longrightarrow> P G k (reach_k G k N)"
  apply(subgoal_tac "(\<lambda>G k N. reach_k_TRANSFER G k N \<longrightarrow> (P G k (reach_k G k N))) G k N")
   apply(erule impE)
    prefer 2
    apply(blast)
   apply(rule reach_k_TRANSFER_AT_START)
   apply(blast)
  apply(subgoal_tac "(\<lambda>(G,k,N). reach_k_TRANSFER G k N \<longrightarrow> (P G k (reach_k G k N))) (G,k,N)")
   apply(blast)
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>(G,k,N). reach_k_TERM_ARGS_TEST G k N"
      and RECURSIVE_COND = "\<lambda>(G,k,N). reach_k_loop1 G k N\<noteq>N"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>(G,k,N). (G,k,reach_k_loop1 G k N)"
      and MEASURE = "\<lambda>(G,k,S). card (((all_state_stack_str G k))-S)"
      and TERM_FUN = "(\<lambda>(G,k,N). reach_k_TRANSFER G k N \<longrightarrow> (P G k (reach_k G k N)))"
      and y = "(G,k,N)"
      in partial_termination_wf)
      apply(rule allI)
      apply(rename_tac x)(*strict*)
      apply(clarify)
      apply(rename_tac a aa b)(*strict*)
      apply(thin_tac "reach_k_TERM_ARGS_TEST G k N")
      apply(rename_tac G k N)
      apply(rename_tac G k N)(*strict*)
      apply(rule reach_k_loop1_preserves_reach_k_TERM_ARGS_TEST)
      apply(blast)
     apply(thin_tac "reach_k_TERM_ARGS_TEST G k N")
     apply(clarsimp)
     apply(rename_tac a aa b)(*strict*)
     apply(rename_tac G k N)
     apply(rename_tac G k N)(*strict*)
     apply(rule reach_k_termLem2)
      apply(rename_tac G k N)(*strict*)
      apply(simp add: reach_k_TERM_ARGS_TEST_def)
     apply(rename_tac G k N)(*strict*)
     apply(simp add: reach_k_TERM_ARGS_TEST_def)
    apply(simp add: reach_k_TERM_ARGS_TEST_def)
   prefer 2
   apply(clarsimp)
  apply(clarsimp)
  apply(rename_tac a aa b)(*strict*)
  apply(erule impE)
   apply(rename_tac a aa b)(*strict*)
   apply(rule reach_k_loop1_TRANSFER_TRANSFERS_ALL)
     apply(rename_tac a aa b)(*strict*)
     apply(blast)+
  done

lemma reach_k_termination: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_dom (G, k, E)"
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>(G,k,E). reach_k_TERM_ARGS_TEST G k E"
      and RECURSIVE_COND = "\<lambda>(G,k,E). reach_k_loop1 G k E\<noteq>E"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>(G,k,E). (G,k,reach_k_loop1 G k E)"
      and MEASURE = "\<lambda>(G,k,E). card (all_state_stack_str G k - E)"
      in partial_termination_wf)
      apply(auto)
       apply(rename_tac a aa b x)(*strict*)
       apply(thin_tac "reach_k_TERM_ARGS_TEST G k E")
       apply(rename_tac G k E x)
       apply(rename_tac G k E x)(*strict*)
       apply(thin_tac "x \<in> reach_k_loop1 G k E")
       apply(subgoal_tac "reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k E)")
        apply(rename_tac G k E x)(*strict*)
        apply(blast)
       apply(rename_tac G k E x)(*strict*)
       apply(thin_tac "\<not> reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k E)")
       apply(rule reach_k_termLem)
       apply(blast)
      apply(rename_tac a aa b x)(*strict*)
      apply(thin_tac "reach_k_TERM_ARGS_TEST G k E")
      apply(rename_tac G k E x)
      apply(rename_tac G k E x)(*strict*)
      apply(thin_tac "x \<in> E")
      apply(subgoal_tac "reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k E)")
       apply(rename_tac G k E x)(*strict*)
       apply(blast)
      apply(rename_tac G k E x)(*strict*)
      apply(thin_tac "\<not> reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k E)")
      apply(rule reach_k_termLem)
      apply(blast)
     apply(rename_tac a aa b x)(*strict*)
     apply(thin_tac "reach_k_TERM_ARGS_TEST G k E")
     apply(rename_tac G k E x)
     apply(rename_tac G k E x)(*strict*)
     apply(case_tac "reach_k_loop1 G k E = E")
      apply(rename_tac G k E x)(*strict*)
      apply(force)
     apply(rename_tac G k E x)(*strict*)
     apply(thin_tac "x \<in> reach_k_loop1 G k E")
     apply(subgoal_tac "card (all_state_stack_str G k - reach_k_loop1 G k E) < card (all_state_stack_str G k - E)")
      apply(rename_tac G k E x)(*strict*)
      apply(blast)
     apply(rename_tac G k E x)(*strict*)
     apply(thin_tac "\<not> card (all_state_stack_str G k - reach_k_loop1 G k E) < card (all_state_stack_str G k - E)")
     apply(rule reach_k_termLem2)
      apply(rename_tac G k E x)(*strict*)
      apply(blast)
     apply(rename_tac G k E x)(*strict*)
     apply(force)
    apply(rename_tac a aa b x)(*strict*)
    apply(thin_tac "reach_k_TERM_ARGS_TEST G k E")
    apply(rename_tac G k E x)
    apply(rename_tac G k E x)(*strict*)
    apply(subgoal_tac "E \<subseteq> reach_k_loop1 G k E")
     apply(rename_tac G k E x)(*strict*)
     prefer 2
     apply(rule reach_k_loop1_mono)
    apply(rename_tac G k E x)(*strict*)
    apply(blast)
   apply(rename_tac a aa b)(*strict*)
   apply(rule reach_k.domintros)
    apply(rename_tac a aa b x)(*strict*)
    apply(force,force)
  apply(rename_tac a aa b)(*strict*)
  apply(rule reach_k.domintros)
   apply(rename_tac a aa b x)(*strict*)
   apply(force,force)
  done

lemma reach_k_reach_k_loop1_idemp2: "
  reach_k_TERM_ARGS_TEST G k N
  \<Longrightarrow> reach_k G k N = reach_k G k (reach_k_loop1 G k N)"
  apply(rule_tac
      t = "reach_k G k N"
      and s = "(if reach_k_loop1 G k N = N then N else reach_k G k (reach_k_loop1 G k N))"
      in ssubst)
   apply(rule reach_k.psimps)
   apply(rule reach_k_termination)
   apply(blast)
  apply(clarsimp)
  apply(rule_tac
      t = "reach_k G k N"
      and s = "(if reach_k_loop1 G k N = N then N else reach_k G k (reach_k_loop1 G k N))"
      in ssubst)
   apply(rule reach_k.psimps)
   apply(rule reach_k_termination)
   apply(blast)
  apply(clarsimp)
  done

theorem reach_k_preserves_reach_k_TERM_ARGS_TEST: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_TERM_ARGS_TEST G k (reach_k G k E)"
  apply(rule reach_k_Meta_Lift)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(rule_tac t="(reach_k Ga ka N)"  and s="(reach_k Ga ka (reach_k_loop1 Ga ka N))" in ssubst)
    apply(rename_tac Ga ka N)(*strict*)
    apply(rule reach_k_reach_k_loop1_idemp2)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(force)
  apply(rename_tac Ga ka N)(*strict*)
  apply(rule_tac ?x.0="Ga" and ?xa.0="ka" and ?xb.0="N" in reach_k.pelims)
    apply(rename_tac Ga ka N)(*strict*)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(rule reach_k_termination)
   apply(force)
  apply(rename_tac Ga ka N Gaa kaa Ea)(*strict*)
  apply(clarsimp)
  done

lemma reach_k_initial_in_all_state_stack_str: "
  valid_epda G
  \<Longrightarrow> reach_k_initial G k \<in> all_state_stack_str G k"
  apply(simp add: reach_k_initial_def all_state_stack_str_def)
  done

lemma reach_k_TERM_ARGS_TEST_with_reach_k_initial: "
  valid_epda G
  \<Longrightarrow> reach_k_TERM_ARGS_TEST G k {reach_k_initial G k}"
  apply(simp add: reach_k_TERM_ARGS_TEST_def)
  apply(rule conjI)
   apply(rule reach_k_initial_in_all_state_stack_str)
   apply(force)
  apply(simp add: reach_k_all_prestate_def)
  done

lemma all_state_stack_str_in_all_state_stack_str2: "
  valid_epda G
  \<Longrightarrow> all_state_stack_str G k \<subseteq> all_state_stack_str2 G k"
  apply(simp add: all_state_stack_str_def all_state_stack_str2_def reach_k_initial_def)
  apply(rule_tac x="[epda_box G]" in exI)
  apply(clarsimp)
  apply(simp add: valid_epda_def)
  done

lemma reach_k_loop1_intro2: "
  cons_tuple2 c (Some(cons_tuple2 q1 s1)) \<in> E
  \<Longrightarrow> \<lparr>edge_src = q1, edge_event = x, edge_pop = w1, edge_push = w2, edge_trg = q2\<rparr> \<in> epda_delta G
  \<Longrightarrow> s2 = take k (w2 @ (drop (length w1) s1))
  \<Longrightarrow> prefix w1 s1 \<or> prefix s1 w1
  \<Longrightarrow> cons_tuple2 (Some(cons_tuple2 q1 s1)) (Some(cons_tuple2 q2 s2)) \<in> reach_k_loop1 G k E"
  apply(simp add: reach_k_loop1_def)
  apply(force)
  done

lemma append_take_drop_id2: "
  take k w1 @ take (k - length w1) w2 @ drop k w1 @ drop (k - length w1) w2 @ w3 = w1 @ w2 @ w3"
  apply(case_tac "k-length w1")
   apply(clarsimp)
  apply(rename_tac nat)(*strict*)
  apply(clarsimp)
  done

lemma reach_k_some_tuple_reachable_hlp3: "
  take (min (k - length pu1) (k - (length pu2 + length ca))) cc = take (k - length pu1) (drop (length pu2 + length ca - (min (length pu2) k + min (length ca) (k - length pu2))) (take (k - (length pu2 + length ca)) cc))"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac a="(k - length pu1)" and b="(k - (length pu2 + length ca))" in min_alt)
  apply(erule disjE)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule_tac a="length pu2" and b="k" in min_alt)
   apply(erule disjE)
    apply(clarsimp)
    apply(subgoal_tac "X" for X)
     prefer 2
     apply(rule_tac a="length ca" and b="k-length pu2" in min_alt)
    apply(erule disjE)
     apply(clarsimp)
    apply(clarsimp)
   apply(clarsimp)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac a="length ca" and b="k-length pu2" in min_alt)
  apply(erule disjE)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule_tac a="length pu2" and b="k" in min_alt)
   apply(erule disjE)
    apply(clarsimp)
   apply(clarsimp)
  apply(clarsimp)
  done

lemma take_prefix_append: "
  take n x \<sqsubseteq> x @ y"
  apply(simp add: prefix_def)
  apply(rule_tac x="drop n x @ y" in exI)
  apply(force)
  done

lemma take_prefix_append_context: "
  w @ take n x \<sqsubseteq> w @ x"
  apply(simp add: prefix_def)
  apply(rule_tac x="drop n x" in exI)
  apply(force)
  done

lemma append_take_drop_id3: "
  pu2 @ ca \<sqsubseteq> take k pu2 @ take (k - length pu2) ca @ take (k - (length pu2 + length ca)) cc \<or> take k pu2 @ take (k - length pu2) ca @ take (k - (length pu2 + length ca)) cc \<sqsubseteq> pu2 @ ca"
  apply(case_tac "k-length pu2")
   apply(clarsimp)
   apply(simp add: take_prefix_append)
  apply(rename_tac nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "k=Suc nat+length pu2")
   apply(rename_tac nat)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac nat)(*strict*)
  apply(clarsimp)
  apply(case_tac "Suc nat - length ca")
   apply(rename_tac nat)(*strict*)
   apply(clarsimp)
   apply(simp add: take_prefix_append_context)
  apply(rename_tac nat nata)(*strict*)
  apply(clarsimp)
  apply(simp add: prefix_def)
  done

lemma take_prefix: "
 take k x \<sqsubseteq> x"
  apply(simp add: prefix_def)
  apply(rule_tac x="drop k x" in exI)
   apply(force)
  done

lemma append_take_drop_id4: "
  po1 \<sqsubseteq> take k po1 @ take (k - length po1) cb \<or> take k po1 @ take (k - length po1) cb \<sqsubseteq> po1"
  apply(case_tac "k-length po1")
   apply(clarsimp)
   apply(simp add: take_prefix)
  apply(rename_tac nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "k=Suc nat+length po1")
   apply(rename_tac nat)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac nat)(*strict*)
  apply(clarsimp)
  apply(simp add: prefix_def)
  done

lemmas append_take_drop =
  append_take_drop_id4
  append_take_drop_id3
  append_take_drop_id2
  append_take_drop_id
  take_is_prefix
  take_prefix_append
  take_prefix_append_context

lemma reach_k_some_tuple_reachable_hlp2: "
  reach_k_loop1 G k E = E
  \<Longrightarrow> reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_TRANSFER G k E
  \<Longrightarrow> reach_k G k E = E
  \<Longrightarrow> reach_k_dom (G, k, E)
  \<Longrightarrow> epdaH.derivation_initial G d
  \<Longrightarrow> d i = Some (pair e1 c1)
  \<Longrightarrow> d (Suc i) = Some (pair (Some e2) c2)
  \<Longrightarrow> \<exists>w1 w2. cons_tuple2 (Some (cons_tuple2 (epdaH_conf_state c1) (take k w1))) (Some (cons_tuple2 (epdaH_conf_state c2) (take k w2))) \<in> E \<and> prefix w1 (epdaH_conf_stack c1) \<and> prefix w2 (epdaH_conf_stack c2)"
  apply(induct i arbitrary: e1 c1 e2 c2)
   apply(rename_tac e1 c1 e2 c2)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac e1 c1 e2 c2)(*strict*)
    prefer 2
    apply(rule_tac
      d="d" and
      n="0" and
      m="Suc 0"
      in epdaH.step_detail_before_some_position)
      apply(rename_tac e1 c1 e2 c2)(*strict*)
      apply(rule epdaH.derivation_initial_is_derivation)
      apply(force)
     apply(rename_tac e1 c1 e2 c2)(*strict*)
     apply(force)
    apply(rename_tac e1 c1 e2 c2)(*strict*)
    apply(force)
   apply(rename_tac e1 c1 e2 c2)(*strict*)
   apply(clarsimp)
   apply(simp add: epdaH_step_relation_def)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 w)(*strict*)
   apply(case_tac c1)
   apply(rename_tac e1 c1 e2 c2 w epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
   apply(case_tac c2)
   apply(rename_tac e1 c1 e2 c2 w epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka epdaH_conf_stateaa epdaH_conf_historyaa epdaH_conf_stackaa)(*strict*)
   apply(case_tac e2)
   apply(rename_tac e1 c1 e2 c2 w epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka epdaH_conf_stateaa epdaH_conf_historyaa epdaH_conf_stackaa edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
   apply(rename_tac q1 h1 s1 q2 h2 s2 qs r po pu qt)
   apply(rename_tac e1 c1 e2 c2 w q1 h1 s1 q2 h2 s2 qs r po pu qt)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs r po pu qt)(*strict*)
   apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def reach_k_TRANSFER_def reach_k_EXTRA_01_def reach_k_initial_def)
   apply(clarsimp)
   apply(rename_tac w r po pu qt)(*strict*)
   apply(rule_tac x="[epda_box G]" in exI)
   apply(case_tac po)
    apply(rename_tac w r po pu qt)(*strict*)
    apply(clarsimp)
    apply(rename_tac r pu qt)(*strict*)
    apply(rule_tac x="pu@[epda_box G]" in exI)
    apply(simp add: prefix_def)
    apply(rule_tac t="E" and s="reach_k_loop1 G k E" in ssubst)
     apply(rename_tac r pu qt)(*strict*)
     apply(force)
    apply(rename_tac r pu qt)(*strict*)
    apply(rule reach_k_loop1_intro2)
       apply(rename_tac r pu qt)(*strict*)
       apply(force)
      apply(rename_tac r pu qt)(*strict*)
      apply(force)
     apply(rename_tac r pu qt)(*strict*)
     prefer 2
     apply(simp add: prefix_def)
    apply(rename_tac r pu qt)(*strict*)
    apply(clarsimp)
    apply(rule_tac t="min (k - length pu) k" and s="(k - length pu)" in ssubst)
     apply(rename_tac r pu qt)(*strict*)
     apply(force)
    apply(rename_tac r pu qt)(*strict*)
    apply(blast)
   apply(rename_tac w r po pu qt a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac r pu qt)(*strict*)
   apply(rule_tac x="pu" in exI)
   apply(simp add: prefix_def)
   apply(rule_tac t="E" and s="reach_k_loop1 G k E" in ssubst)
    apply(rename_tac r pu qt)(*strict*)
    apply(force)
   apply(rename_tac r pu qt)(*strict*)
   apply(rule reach_k_loop1_intro2)
      apply(rename_tac r pu qt)(*strict*)
      apply(force)
     apply(rename_tac r pu qt)(*strict*)
     apply(force)
    apply(rename_tac r pu qt)(*strict*)
    apply(force)
   apply(rename_tac r pu qt)(*strict*)
   apply(clarsimp)
   apply(simp add: prefix_def)
   apply(case_tac k)
    apply(rename_tac r pu qt)(*strict*)
    apply(force)
   apply(rename_tac r pu qt nat)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 e2 c2)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac i e1 c1 e2 c2)(*strict*)
   prefer 2
   apply(rule_tac
      d="d" and
      n="i" and
      m="Suc i"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac i e1 c1 e2 c2)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac i e1 c1 e2 c2)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 e2 c2)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 e2 c2)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac i e1 c1 e2 c2)(*strict*)
   prefer 2
   apply(rule_tac
      d="d" and
      n="Suc i" and
      m="Suc (Suc i)"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac i e1 c1 e2 c2)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac i e1 c1 e2 c2)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 e2 c2)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 e2 c2)(*strict*)
  apply(erule exE)+
  apply(rename_tac i e1 c1 e2 c2 e1a e1b e2a e2b c1a c1b c2a c2b)(*strict*)
  apply(clarsimp)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a)(*strict*)
  apply(erule_tac x="e1a" in meta_allE)
  apply(clarsimp)
  apply(erule_tac x="c1a" in meta_allE)
  apply(clarsimp)
  apply(erule_tac x="e2a" in meta_allE)
  apply(clarsimp)
  apply(erule_tac x="c1" in meta_allE)
  apply(clarsimp)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2)(*strict*)
  apply(simp add: epdaH_step_relation_def)
  apply(clarsimp)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa)(*strict*)
  apply(case_tac c1a)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac q1 h1 s1)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa q1 h1 s1)(*strict*)
  apply(case_tac c1)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa q1 h1 s1 epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac q2 h2 s2)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa q1 h1 s1 q2 h2 s2)(*strict*)
  apply(case_tac c2)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa q1 h1 s1 q2 h2 s2 epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac q3 h3 s3)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa q1 h1 s1 q2 h2 s2 q3 h3 s3)(*strict*)
  apply(case_tac e2)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa q1 h1 s1 q2 h2 s2 q3 h3 s3 edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac qs1 r1 po1 pu1 qt1)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa q1 h1 s1 q2 h2 s2 q3 h3 s3 qs1 r1 po1 pu1 qt1)(*strict*)
  apply(case_tac e2a)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa q1 h1 s1 q2 h2 s2 q3 h3 s3 qs1 r1 po1 pu1 qt1 edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac qs2 r2 po2 pu2 qt2)
  apply(rename_tac i c1 e2 c2 e1a e2a c1a w1 w2 w wa q1 h1 s1 q2 h2 s2 q3 h3 s3 qs1 r1 po1 pu1 qt1 qs2 r2 po2 pu2 qt2)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1a w1 w2 w wa h1 r1 po1 pu1 qt1 qs2 r2 po2 pu2 qt2)(*strict*)
  apply(thin_tac "d x = y" for x y)
  apply(thin_tac "d x = y" for x y)
  apply(thin_tac "d x = y" for x y)
  apply(thin_tac "w1 \<sqsubseteq> po2 @ wa")
  apply(rule_tac x="w2" in exI)
  apply(subgoal_tac "prefix pu2 po1 \<or> SSX" for SSX)
   apply(rename_tac i e1a w1 w2 w wa h1 r1 po1 pu1 qt1 qs2 r2 po2 pu2 qt2)(*strict*)
   prefer 2
   apply(rule mutual_prefix_prefix)
   apply(force)
  apply(rename_tac i e1a w1 w2 w wa h1 r1 po1 pu1 qt1 qs2 r2 po2 pu2 qt2)(*strict*)
  apply(erule disjE)
   apply(rename_tac i e1a w1 w2 w wa h1 r1 po1 pu1 qt1 qs2 r2 po2 pu2 qt2)(*strict*)
   apply(simp add: prefix_def)
   apply(rename_tac w1 w2 w wa r1 po1 pu1 qt1 qs2 r2 po2 pu2 qt2)(*strict*)
   apply(clarsimp)
   apply(rename_tac w1 w2 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca)(*strict*)
   apply(subgoal_tac "prefix w2 pu2 \<or> SSX" for SSX)
    apply(rename_tac w1 w2 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca)(*strict*)
    prefer 2
    apply(rule mutual_prefix_prefix)
    apply(force)
   apply(rename_tac w1 w2 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca)(*strict*)
   apply(erule disjE)
    apply(rename_tac w1 w2 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca)(*strict*)
    apply(simp add: prefix_def)
    apply(clarsimp)
    apply(rename_tac w1 w2 w r1 pu1 qt1 qs2 r2 po2 qt2 ca cb)(*strict*)
    apply(rule_tac x="pu1" in exI)
    apply(clarsimp)
    apply(rename_tac w1 w2 r1 pu1 qt1 qs2 r2 po2 qt2 ca cb)(*strict*)
    apply(rule_tac t="E" and s="reach_k_loop1 G k E" in ssubst)
     apply(rename_tac w1 w2 r1 pu1 qt1 qs2 r2 po2 qt2 ca cb)(*strict*)
     apply(force)
    apply(rename_tac w1 w2 r1 pu1 qt1 qs2 r2 po2 qt2 ca cb)(*strict*)
    apply(rule reach_k_loop1_intro2)
       apply(rename_tac w1 w2 r1 pu1 qt1 qs2 r2 po2 qt2 ca cb)(*strict*)
       apply(force)
      apply(rename_tac w1 w2 r1 pu1 qt1 qs2 r2 po2 qt2 ca cb)(*strict*)
      apply(force)
     apply(rename_tac w1 w2 r1 pu1 qt1 qs2 r2 po2 qt2 ca cb)(*strict*)
     apply(force)
    apply(rename_tac w1 w2 r1 pu1 qt1 qs2 r2 po2 qt2 ca cb)(*strict*)
    apply(rule disjI2)
    apply(simp add: prefix_def)
    apply(rule_tac x="drop k w2@cb@ca" in exI)
    apply(force)
   apply(rename_tac w1 w2 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca)(*strict*)
   apply(simp add: prefix_def)
   apply(clarsimp)
   apply(rename_tac w1 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cb)(*strict*)
   apply(subgoal_tac "prefix cb ca \<or> SSX" for SSX)
    apply(rename_tac w1 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cb)(*strict*)
    prefer 2
    apply(rule mutual_prefix_prefix)
    apply(force)
   apply(rename_tac w1 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cb)(*strict*)
   apply(erule disjE)
    apply(rename_tac w1 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cb)(*strict*)
    apply(simp add: prefix_def)
    apply(clarsimp)
    apply(rename_tac w1 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 cb cc)(*strict*)
    apply(rule_tac x="pu1" in exI)
    apply(clarsimp)
    apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 cb cc)(*strict*)
    apply(rule_tac t="E" and s="reach_k_loop1 G k E" in ssubst)
     apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 cb cc)(*strict*)
     apply(force)
    apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 cb cc)(*strict*)
    apply(rule reach_k_loop1_intro2)
       apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 cb cc)(*strict*)
       apply(force)
      apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 cb cc)(*strict*)
      apply(force)
     apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 cb cc)(*strict*)
     apply(force)
    apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 cb cc)(*strict*)
    apply(rule disjI2)
    apply(simp add: prefix_def)
    apply(rule_tac x="drop k pu2@drop (k - length pu2) cb@cc" in exI)
    apply(rule append_take_drop_id2)
   apply(rename_tac w1 w r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cb)(*strict*)
   apply(simp add: prefix_def)
   apply(clarsimp)
   apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cc)(*strict*)
   apply(rule_tac x="pu1@take (k - (length pu2 + length ca)) cc" in exI)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cc)(*strict*)
    prefer 2
    apply(rule_tac x="drop (k - (length pu2 + length ca)) cc@c" in exI)
    apply(force)
   apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cc)(*strict*)
   apply(rule_tac t="E" and s="reach_k_loop1 G k E" in ssubst)
    apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cc)(*strict*)
    apply(force)
   apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cc)(*strict*)
   apply(rule reach_k_loop1_intro2)
      apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cc)(*strict*)
      apply(force)
     apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cc)(*strict*)
     apply(force)
    apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cc)(*strict*)
    apply(clarsimp)
    apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 ca cc)(*strict*)
    apply(rule reach_k_some_tuple_reachable_hlp3)
   apply(rename_tac w1 r1 pu1 qt1 qs2 r2 po2 pu2 qt2 c ca cc)(*strict*)
   apply(rule append_take_drop_id3)
  apply(rename_tac i e1a w1 w2 w wa h1 r1 po1 pu1 qt1 qs2 r2 po2 pu2 qt2)(*strict*)
  apply(simp add: prefix_def)
  apply(rename_tac w1 w2 w wa r1 po1 pu1 qt1 qs2 r2 po2 pu2 qt2)(*strict*)
  apply(thin_tac "\<lparr>edge_src = qs2, edge_event = r2, edge_pop = po2,
          edge_push = pu2, edge_trg = qt2\<rparr>
       \<in> epda_delta G")
  apply(clarsimp)
  apply(rename_tac w1 w2 wa r1 po1 pu1 qt1 qs2 qt2 c ca)(*strict*)
  apply(subgoal_tac "prefix w2 po1 \<or> SSX" for SSX)
   apply(rename_tac w1 w2 wa r1 po1 pu1 qt1 qs2 qt2 c ca)(*strict*)
   prefer 2
   apply(rule mutual_prefix_prefix)
   apply(force)
  apply(rename_tac w1 w2 wa r1 po1 pu1 qt1 qs2 qt2 c ca)(*strict*)
  apply(erule disjE)
   apply(rename_tac w1 w2 wa r1 po1 pu1 qt1 qs2 qt2 c ca)(*strict*)
   apply(simp add: prefix_def)
   apply(clarsimp)
   apply(rename_tac w1 w2 wa r1 pu1 qt1 qs2 qt2 ca cb)(*strict*)
   apply(rule_tac x="pu1" in exI)
   apply(clarsimp)
   apply(rename_tac w1 w2 r1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(rule_tac t="E" and s="reach_k_loop1 G k E" in ssubst)
    apply(rename_tac w1 w2 r1 pu1 qt1 qs2 qt2 cb)(*strict*)
    apply(force)
   apply(rename_tac w1 w2 r1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(rule reach_k_loop1_intro2)
      apply(rename_tac w1 w2 r1 pu1 qt1 qs2 qt2 cb)(*strict*)
      apply(force)
     apply(rename_tac w1 w2 r1 pu1 qt1 qs2 qt2 cb)(*strict*)
     apply(force)
    apply(rename_tac w1 w2 r1 pu1 qt1 qs2 qt2 cb)(*strict*)
    apply(force)
   apply(rename_tac w1 w2 r1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(rule disjI2)
   apply(simp add: take_prefix_append)
  apply(rename_tac w1 w2 wa r1 po1 pu1 qt1 qs2 qt2 c ca)(*strict*)
  apply(simp add: prefix_def)
  apply(clarsimp)
  apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 c ca cb)(*strict*)
  apply(subgoal_tac "prefix cb ca \<or> SSX" for SSX)
   apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 c ca cb)(*strict*)
   prefer 2
   apply(rule mutual_prefix_prefix)
   apply(force)
  apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 c ca cb)(*strict*)
  apply(erule disjE)
   apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 c ca cb)(*strict*)
   apply(simp add: prefix_def)
   apply(clarsimp)
   apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 cb cc)(*strict*)
   apply(rule_tac x="pu1@take (k - length po1) cb" in exI)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 cb cc)(*strict*)
    prefer 2
    apply(rule_tac x="drop (k - length po1) cb @ cc @ wa" in exI)
    apply(force)
   apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 cb cc)(*strict*)
   apply(rule_tac t="E" and s="reach_k_loop1 G k E" in ssubst)
    apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 cb cc)(*strict*)
    apply(force)
   apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 cb cc)(*strict*)
   apply(rule reach_k_loop1_intro2)
      apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 cb cc)(*strict*)
      apply(force)
     apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 cb cc)(*strict*)
     apply(force)
    apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 cb cc)(*strict*)
    prefer 2
    apply(simp add: append_take_drop)
   apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 cb cc)(*strict*)
   apply(clarsimp)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
    prefer 2
    apply(rule_tac a="length cb" and b="(k - (length po1))" in min_alt)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(erule disjE)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
    apply(clarsimp)
    apply(subgoal_tac "X" for X)
     apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
     prefer 2
     apply(rule_tac a="length po1" and b="k" in min_alt)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
    apply(erule disjE)
     apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
     apply(clarsimp)
     apply(subgoal_tac "X" for X)
      apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
      prefer 2
      apply(rule_tac a="(k - (length pu1))" and b="(k - (length po1))" in min_alt)
     apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
     apply(erule disjE)
      apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
      apply(clarsimp)
     apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
     apply(force)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
    apply(clarsimp)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
    prefer 2
    apply(rule_tac a="length po1" and b="k" in min_alt)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(erule disjE)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
    apply(clarsimp)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
    prefer 2
    apply(rule_tac a="(k - (length pu1))" and b="(k - (length po1))" in min_alt)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(erule disjE)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
    apply(clarsimp)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 cb)(*strict*)
   apply(force)
  apply(rename_tac w1 wa r1 po1 pu1 qt1 qs2 qt2 c ca cb)(*strict*)
  apply(simp add: prefix_def)
  apply(clarsimp)
  apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
   prefer 2
   apply(rule_tac a="length po1" and b="k" in min_alt)
  apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
  apply(erule disjE)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
   prefer 2
   apply(clarsimp)
   apply(rule_tac x="pu1" in exI)
   apply(clarsimp)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2)(*strict*)
   apply(rule_tac t="E" and s="reach_k_loop1 G k E" in ssubst)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2)(*strict*)
    apply(force)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2)(*strict*)
   apply(rule reach_k_loop1_intro2)
      apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2)(*strict*)
      apply(force)
     apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2)(*strict*)
     apply(force)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2)(*strict*)
    apply(force)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2)(*strict*)
   apply(rule disjI2)
   apply(simp add: append_take_drop)
  apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
  apply(clarsimp)
  apply(thin_tac "min (length po1) k = length po1")
  apply(rule_tac x="pu1@take (k - length po1) ca @
           take (k - (length po1 + length ca)) cc" in exI)
  apply(clarsimp)
  apply(rule conjI)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
   prefer 2
   apply(rule_tac x="drop (k-length po1) (ca@cc) @ c" in exI)
   apply(rule_tac t="take (k - length po1) ca @
       take (k - (length po1 + length ca)) cc @
       drop (k - length po1) (ca @ cc) @ c" and s="(take (k - length po1) (ca @
       cc) @
       drop (k - length po1) (ca @ cc)) @ c" in ssubst)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
    apply(simp (no_asm))
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
   apply(rule_tac t="(take (k - length po1) (ca @
       cc) @
       drop (k - length po1) (ca @ cc))" and s="ca@cc" in ssubst)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
    apply(rule append_take_drop_id)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
   apply(force)
  apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
  apply(rule_tac t="E" and s="reach_k_loop1 G k E" in ssubst)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
   apply(force)
  apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
  apply(rule reach_k_loop1_intro2)
     apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
     apply(force)
    apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
    apply(force)
   apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
   apply(force)
  apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 c ca cc)(*strict*)
  apply(rule disjI1)
  apply(clarsimp)
  apply(rename_tac w1 r1 po1 pu1 qt1 qs2 qt2 ca cc)(*strict*)
  apply(simp add: prefix_def)
  done

lemma reach_k_some_tuple_reachable_hlp1: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> \<forall>d i e1 c1 e2 c2. epdaH.derivation_initial G d \<longrightarrow> d i = Some (pair e1 c1) \<longrightarrow> d (Suc i) = Some (pair (Some e2) c2) \<longrightarrow> (\<exists>w1 w2. cons_tuple2 (Some (cons_tuple2 (epdaH_conf_state c1) (take k w1))) (Some (cons_tuple2 (epdaH_conf_state c2) (take k w2))) \<in> reach_k G k E \<and> prefix w1 (epdaH_conf_stack c1) \<and> prefix w2 (epdaH_conf_stack c2))"
  apply(rule reach_k_Meta_Lift)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(rule_tac t="(reach_k Ga ka N)"  and s="(reach_k Ga ka (reach_k_loop1 Ga ka N))" in ssubst)
    apply(rename_tac Ga ka N)(*strict*)
    apply(rule reach_k_reach_k_loop1_idemp2)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(force)
  apply(rename_tac Ga ka N)(*strict*)
  apply(rule_tac ?x.0="Ga" and ?xa.0="ka" and ?xb.0="N" in reach_k.pelims)
    apply(rename_tac Ga ka N)(*strict*)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(rule reach_k_termination)
   apply(force)
  apply(rename_tac Ga ka N Gaa kaa Ea)(*strict*)
  apply(clarsimp)
  apply(rename_tac Ga ka Ea d i e1 c1 e2 c2)(*strict*)
  apply(thin_tac "X" for X)
  apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
   prefer 2
   apply(rule_tac i="i" in reach_k_some_tuple_reachable_hlp2)
          apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
          apply(force)
         apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
         apply(force)
        apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
        apply(force)
       apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
       apply(force)
      apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
      apply(force)
     apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
     apply(force)
    apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
    apply(force)
   apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
   apply(force)
  apply(rename_tac Ga ka E d i e1 c1 e2 c2)(*strict*)
  apply(force)
  done

theorem reach_k_some_tuple_reachable: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> epdaH.derivation_initial G d
  \<Longrightarrow> d i = Some (pair e1 c1)
  \<Longrightarrow> d (Suc i) = Some (pair (Some e2) c2)
  \<Longrightarrow> \<exists>w1 w2. cons_tuple2 (Some (cons_tuple2 (epdaH_conf_state c1) (take k w1))) (Some (cons_tuple2 (epdaH_conf_state c2) (take k w2))) \<in> reach_k G k E \<and> prefix w1 (epdaH_conf_stack c1) \<and> prefix w2 (epdaH_conf_stack c2)"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule reach_k_some_tuple_reachable_hlp1)
   apply(force)
  apply(force)
  done

theorem reach_k_enforces_reach_k_one_step_contained: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_one_step_contained G k (reach_k G k E) {0}"
  apply(simp add: reach_k_one_step_contained_def)
  apply(clarsimp)
  apply(rename_tac d i e1 c1 e2 c2)(*strict*)
  apply(rule_tac reach_k_some_tuple_reachable)
     apply(rename_tac d i e1 c1 e2 c2)(*strict*)
     apply(force)
    apply(rename_tac d i e1 c1 e2 c2)(*strict*)
    apply(force)
   apply(rename_tac d i e1 c1 e2 c2)(*strict*)
   apply(force)
  apply(rename_tac d i e1 c1 e2 c2)(*strict*)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__l3_approx_in_CFG1: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> cons_l3 q1 A q2 \<in> F_SDPDA_TO_CFG_OPT__l3_approx_1 G k xb ((the \<circ> sel_tuple2_2) ` reach_k_access_closure (reach_k G k {reach_k_initial G k})) (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp (F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb ((the \<circ> sel_tuple2_2) ` reach_k_access_closure (reach_k G k {reach_k_initial G k}))) k))
  \<Longrightarrow> xb \<in> F_SDPDA_TO_CFG_OPT__pushed_symbols G
  \<Longrightarrow> q2 \<in> epda_states G \<and> q1 \<in> epda_states G \<and> A \<in> epda_gamma G"
  apply(simp add: F_SDPDA_TO_CFG_OPT__l3_approx_1_def)
  apply(clarsimp)
  apply(rename_tac SE w n w' n')(*strict*)
  apply(thin_tac "cons_tuple2 None SE
       \<in> F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb
           ((the \<circ> sel_tuple2_2) `
            reach_k_access_closure (reach_k G k {reach_k_initial G k}))")
  apply(thin_tac "
       cons_tuple2 SE (Some (cons_tuple3 q1 w n))
       \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
           (F_SDPDA_TO_CFG_OPT__step_closure__fp G
             (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb
               ((the \<circ> sel_tuple2_2) `
                reach_k_access_closure (reach_k G k {reach_k_initial G k})))
             k)")
  apply(thin_tac "w = [] \<or> [A] \<sqsubseteq> w")
  apply(subgoal_tac "X" for X)
   apply(rename_tac SE w n w' n')(*strict*)
   prefer 2
   apply(rule_tac E="(F_SDPDA_TO_CFG_OPT__step_closure__fp G
             (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb
               ((the \<circ> sel_tuple2_2) `
                reach_k_access_closure (reach_k G k {reach_k_initial G k})))
             k)" and G="G" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_preserves_all_state_stack_str4)
     apply(rename_tac SE w n w' n')(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac SE w n w' n')(*strict*)
    apply(force)
   apply(rename_tac SE w n w' n')(*strict*)
   apply(rule_tac B="all_state_stack_str3 G k" in subset_trans)
    apply(rename_tac SE w n w' n')(*strict*)
    prefer 2
    apply(simp add: all_state_stack_str4_def)
    apply(rename_tac w n w' n')(*strict*)
    apply(force)
   apply(rename_tac SE w n w' n')(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac SE w n w' n')(*strict*)
    prefer 2
    apply(rule_tac G="G" and k="k" and S="(F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb
          ((the \<circ> sel_tuple2_2) `
           reach_k_access_closure (reach_k G k {reach_k_initial G k})))" in F_SDPDA_TO_CFG_OPT__step_closure__fp_preserves_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST)
    prefer 2
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
   apply(rename_tac SE w n w' n')(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
   apply(rename_tac w n w' n')(*strict*)
   apply(rule conjI)
    apply(rename_tac w n w' n')(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(rename_tac w n w' n')(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l3_init_in_all_state_stack_str3_simp)
     apply(rename_tac w n w' n')(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac w n w' n')(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac w n w' n')(*strict*)
   apply(rule all_state_stack_str2_map_to_F_EPDA_AIA__codom)
   apply(subgoal_tac "X" for X)
    apply(rename_tac w n w' n')(*strict*)
    prefer 2
    apply(rule_tac G="G" and k="k" and E="(reach_k G k {reach_k_initial G k})" in reach_k_access_closure_preserves_reach_k_access_closure_TERM_ARGS_TEST)
    prefer 2
    apply(simp add: reach_k_access_closure_TERM_ARGS_TEST_def)
   apply(rename_tac w n w' n')(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac w n w' n')(*strict*)
    prefer 2
    apply(rule_tac G="G" and k="k" and E="{reach_k_initial G k}" in reach_k_preserves_reach_k_TERM_ARGS_TEST)
    apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(rename_tac w n w' n')(*strict*)
   apply(simp add: reach_k_TERM_ARGS_TEST_def reach_k_access_closure_TERM_ARGS_TEST_def)
   apply(rule conjI)
    apply(rename_tac w n w' n')(*strict*)
    apply(rule_tac B="all_state_stack_str G k" in subset_trans)
     apply(rename_tac w n w' n')(*strict*)
     apply(force)
    apply(rename_tac w n w' n')(*strict*)
    apply (metis all_state_stack_str_in_all_state_stack_str2)
   apply(rename_tac w n w' n')(*strict*)
   apply(rule reach_k_enforces_reach_k_one_step_contained)
   apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
  apply(rename_tac SE w n w' n')(*strict*)
  apply(subgoal_tac "cons_tuple2 (Some (cons_tuple3 q1 w n)) (Some (cons_tuple3 q2 w' n')) \<in> all_state_stack_str4 G k")
   apply(rename_tac SE w n w' n')(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac SE w n w' n')(*strict*)
  apply(thin_tac "cons_tuple2 (Some (cons_tuple3 q1 w n)) (Some (cons_tuple3 q2 w' n'))
       \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
           (F_SDPDA_TO_CFG_OPT__step_closure__fp G
             (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb
               ((the \<circ> sel_tuple2_2) `
                reach_k_access_closure (reach_k G k {reach_k_initial G k})))
             k)")
  apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
        (F_SDPDA_TO_CFG_OPT__step_closure__fp G
          (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb
            ((the \<circ> sel_tuple2_2) `
             reach_k_access_closure (reach_k G k {reach_k_initial G k})))
          k)
       \<subseteq> all_state_stack_str4 G k")
  apply(simp add: all_state_stack_str4_def all_state_stack_str3_def all_state_stack_str2_def)
  apply(rename_tac w n w' n')(*strict*)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__l3_approx_in_CFG: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> cons_l3 q1 A q2 \<in> F_SDPDA_TO_CFG_OPT__l3_approx_1 G k xb ((the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k}) (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp (F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb ((the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k})) k))
  \<Longrightarrow> xb \<in> F_SDPDA_TO_CFG_OPT__pushed_symbols G
  \<Longrightarrow> q2 \<in> epda_states G \<and> q1 \<in> epda_states G \<and> A \<in> epda_gamma G"
  apply(simp add: F_SDPDA_TO_CFG_OPT__l3_approx_1_def)
  apply(clarsimp)
  apply(rename_tac SE w n w' n')(*strict*)
  apply(thin_tac "cons_tuple2 None SE
       \<in> F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb ((the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k})")
  apply(thin_tac "
       cons_tuple2 SE (Some (cons_tuple3 q1 w n))
       \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
           (F_SDPDA_TO_CFG_OPT__step_closure__fp G
             (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb ((the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k}))
             k)")
  apply(thin_tac "w = [] \<or> [A] \<sqsubseteq> w")
  apply(subgoal_tac "X" for X)
   apply(rename_tac SE w n w' n')(*strict*)
   prefer 2
   apply(rule_tac E="(F_SDPDA_TO_CFG_OPT__step_closure__fp G
             (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb ((the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k}))
             k)" and G="G" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_preserves_all_state_stack_str4)
     apply(rename_tac SE w n w' n')(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac SE w n w' n')(*strict*)
    apply(force)
   apply(rename_tac SE w n w' n')(*strict*)
   apply(rule_tac B="all_state_stack_str3 G k" in subset_trans)
    apply(rename_tac SE w n w' n')(*strict*)
    prefer 2
    apply(simp add: all_state_stack_str4_def)
    apply(rename_tac w n w' n')(*strict*)
    apply(force)
   apply(rename_tac SE w n w' n')(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac SE w n w' n')(*strict*)
    prefer 2
    apply(rule_tac G="G" and k="k" and S="(F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb ((the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k}))" in F_SDPDA_TO_CFG_OPT__step_closure__fp_preserves_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST)
    prefer 2
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
   apply(rename_tac SE w n w' n')(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
   apply(rename_tac w n w' n')(*strict*)
   apply(rule conjI)
    apply(rename_tac w n w' n')(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(rename_tac w n w' n')(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l3_init_in_all_state_stack_str3_simp)
     apply(rename_tac w n w' n')(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac w n w' n')(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac w n w' n')(*strict*)
   apply(rule all_state_stack_str2_map_to_F_EPDA_AIA__codom)
   apply(subgoal_tac "X" for X)
    apply(rename_tac w n w' n')(*strict*)
    prefer 2
    apply(rule_tac G="G" and k="k" and E="{reach_k_initial G k}" in reach_k_preserves_reach_k_TERM_ARGS_TEST)
    apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(rename_tac w n w' n')(*strict*)
   apply(simp add: reach_k_TERM_ARGS_TEST_def reach_k_access_closure_TERM_ARGS_TEST_def)
   apply(rule_tac B="all_state_stack_str G k" in subset_trans)
    apply(rename_tac w n w' n')(*strict*)
    apply(force)
   apply(rename_tac w n w' n')(*strict*)
   apply (metis all_state_stack_str_in_all_state_stack_str2)
  apply(rename_tac SE w n w' n')(*strict*)
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
  apply(rename_tac w n w' n')(*strict*)
  apply(subgoal_tac "cons_tuple2 (Some (cons_tuple3 q1 w n)) (Some (cons_tuple3 q2 w' n')) \<in> all_state_stack_str4 G k")
   apply(rename_tac w n w' n')(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac w n w' n')(*strict*)
  apply(thin_tac "cons_tuple2 (Some (cons_tuple3 q1 w n)) (Some (cons_tuple3 q2 w' n'))
       \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
           (F_SDPDA_TO_CFG_OPT__step_closure__fp G
             (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb ((the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k}))
             k)")
  apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
        (F_SDPDA_TO_CFG_OPT__step_closure__fp G
          (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G xb ((the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k})) k)
       \<subseteq> all_state_stack_str4 G k")
  apply(simp add: all_state_stack_str4_def all_state_stack_str3_def all_state_stack_str2_def)
  apply(clarsimp)
  done

primrec reach_k_N :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 option DT_graph"
  where
    "reach_k_N G k E 0 = E"
  | "reach_k_N G k E (Suc n) = reach_k_N G k (reach_k_loop1 G k E) n"

lemma reach_k_Meta_Lift_prime: "
  reach_k_TERM_ARGS_TEST G k N
  \<Longrightarrow> (\<And>G k N. reach_k_TERM_ARGS_TEST G k (reach_k_loop1 G k N) \<Longrightarrow> reach_k_TERM_ARGS_TEST G k N \<Longrightarrow> reach_k_TRANSFER G k N \<Longrightarrow> P G k (reach_k_loop1 G k N) (reach_k G k N) \<Longrightarrow> P G k N (reach_k G k N) )
  \<Longrightarrow> (\<And>G k N. reach_k_loop1 G k N = N \<Longrightarrow> reach_k_TERM_ARGS_TEST G k N \<Longrightarrow> P G k N (reach_k G k N) )
  \<Longrightarrow> P G k N (reach_k G k N)"
  apply(subgoal_tac "(\<lambda>G k N. reach_k_TRANSFER G k N \<longrightarrow> (P G k N (reach_k G k N))) G k N")
   apply(erule impE)
    prefer 2
    apply(blast)
   apply(rule reach_k_TRANSFER_AT_START)
   apply(blast)
  apply(subgoal_tac "(\<lambda>(G,k,N). reach_k_TRANSFER G k N \<longrightarrow> (P G k N (reach_k G k N))) (G,k,N)")
   apply(blast)
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>(G,k,N). reach_k_TERM_ARGS_TEST G k N"
      and RECURSIVE_COND = "\<lambda>(G,k,N). reach_k_loop1 G k N\<noteq>N"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>(G,k,N). (G,k,reach_k_loop1 G k N)"
      and MEASURE = "\<lambda>(G,k,S). card (((all_state_stack_str G k))-S)"
      and TERM_FUN = "(\<lambda>(G,k,N). reach_k_TRANSFER G k N \<longrightarrow> (P G k N (reach_k G k N)))"
      and y = "(G,k,N)"
      in partial_termination_wf)
      apply(rule allI)
      apply(rename_tac x)(*strict*)
      apply(clarify)
      apply(rename_tac a aa b)(*strict*)
      apply(thin_tac "reach_k_TERM_ARGS_TEST G k N")
      apply(rename_tac G k N)
      apply(rename_tac G k N)(*strict*)
      apply(rule reach_k_loop1_preserves_reach_k_TERM_ARGS_TEST)
      apply(blast)
     apply(thin_tac "reach_k_TERM_ARGS_TEST G k N")
     apply(clarsimp)
     apply(rename_tac a aa b)(*strict*)
     apply(rename_tac G k N)
     apply(rename_tac G k N)(*strict*)
     apply(rule reach_k_termLem2)
      apply(rename_tac G k N)(*strict*)
      apply(simp add: reach_k_TERM_ARGS_TEST_def)
     apply(rename_tac G k N)(*strict*)
     apply(simp add: reach_k_TERM_ARGS_TEST_def)
    apply(simp add: reach_k_TERM_ARGS_TEST_def)
   prefer 2
   apply(clarsimp)
  apply(clarsimp)
  apply(rename_tac a aa b)(*strict*)
  apply(thin_tac "reach_k_TERM_ARGS_TEST G k N")
  apply(rename_tac G k N)
  apply(rename_tac G k N)(*strict*)
  apply(erule impE)
   apply(rename_tac G k N)(*strict*)
   apply(rule reach_k_loop1_TRANSFER_TRANSFERS_ALL)
     apply(rename_tac G k N)(*strict*)
     apply(blast)
    apply(rename_tac G k N)(*strict*)
    apply(blast)
   apply(rename_tac G k N)(*strict*)
   apply(blast)
  apply(rename_tac G k N)(*strict*)
  apply(subgoal_tac "P G k (reach_k_loop1 G k N) (reach_k G k N)")
   apply(rename_tac G k N)(*strict*)
   apply(thin_tac "P G k (reach_k_loop1 G k N) (reach_k G k (reach_k_loop1 G k N))")
   prefer 2
   apply(rule_tac
      t="reach_k G k N"
      and s="reach_k G k (reach_k_loop1 G k N)"
      in ssubst)
    apply(rename_tac G k N)(*strict*)
    apply(rule reach_k_reach_k_loop1_idemp2)
    apply(force)
   apply(rename_tac G k N)(*strict*)
   apply(force)
  apply(rename_tac G k N)(*strict*)
  apply(force)
  done

theorem reach_k_N_terminates: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> \<exists>n. reach_k_N G k E n = reach_k G k E"
  apply(rule reach_k_Meta_Lift_prime)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(thin_tac "reach_k_TERM_ARGS_TEST G k E")
   apply(rename_tac G k N)(*strict*)
   apply(clarsimp)
   apply(rename_tac G k N n)(*strict*)
   apply(rule_tac x="Suc n" in exI)
   apply(clarsimp)
  apply(rename_tac Ga ka N)(*strict*)
  apply(thin_tac "reach_k_TERM_ARGS_TEST G k E")
  apply(rename_tac G k N)(*strict*)
  apply(rule_tac x="0" in exI)
  apply(clarsimp)
  apply(rule_tac reach_k.pelims)
    apply(rename_tac G k N)(*strict*)
    apply(force)
   apply(rename_tac G k N)(*strict*)
   apply(rule reach_k_termination)
   apply(force)
  apply(rename_tac G k N Ga ka E)(*strict*)
  apply(force)
  done

primrec F_EPDA_AIA__fp_N :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 set
  \<Rightarrow> nat
  \<Rightarrow> ('state, 'stack list) DT_tuple2 set"
  where
    "F_EPDA_AIA__fp_N G k E 0 = E"
  | "F_EPDA_AIA__fp_N G k E (Suc n) = F_EPDA_AIA__fp_N G k (F_EPDA_AIA__fp_one G k E) n"

theorem F_EPDA_AIA__fp_N_terminates: "
  F_EPDA_AIA__fp_valid_input G k E
  \<Longrightarrow> \<exists>n. F_EPDA_AIA__fp_N G k E n = F_EPDA_AIA__fp G k E"
  apply(rule F_EPDA_AIA__fp_Meta_Lift_Without_Argument_With_Argument)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(thin_tac "F_EPDA_AIA__fp_valid_input G k E")
   apply(rename_tac G k N)(*strict*)
   apply(clarsimp)
   apply(rename_tac G k N n)(*strict*)
   apply(rule_tac x="Suc n" in exI)
   apply(clarsimp)
  apply(rename_tac Ga ka N)(*strict*)
  apply(thin_tac "F_EPDA_AIA__fp_valid_input G k E")
  apply(rename_tac G k N)(*strict*)
  apply(rule_tac x="0" in exI)
  apply(clarsimp)
  apply(rule_tac F_EPDA_AIA__fp.pelims)
    apply(rename_tac G k N)(*strict*)
    apply(force)
   apply(rename_tac G k N)(*strict*)
   apply(rule F_EPDA_AIA__fp_valid_input_implies_termination)
   apply(force)
  apply(rename_tac G k N Ga ka E)(*strict*)
  apply(force)
  done

lemma reach_k_N_pull_out: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_N G k (reach_k_loop1 G k E) n = reach_k_loop1 G k (reach_k_N G k E n)"
  apply(induct n arbitrary: E)
   apply(rename_tac E)(*strict*)
   apply(clarsimp)
  apply(rename_tac n E)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "reach_k_N G k (reach_k_loop1 G k E) n =
                reach_k_loop1 G k (reach_k_N G k E n)")
   apply(rename_tac n E)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac n E)(*strict*)
  apply(erule_tac x="reach_k_loop1 G k E" in meta_allE)
  apply(erule meta_impE)
   apply(rename_tac n E)(*strict*)
   apply (metis reach_k_loop1_preserves_reach_k_TERM_ARGS_TEST)
  apply(rename_tac n E)(*strict*)
  apply(force)
  done

theorem reach_k_N_coincides_with_F_EPDA_AIA__fp_N_ONE: "
  valid_epda G
  \<Longrightarrow> None \<notin> sel_tuple2_2 ` E2
  \<Longrightarrow> (the \<circ> sel_tuple2_2) ` E2 = E1
  \<Longrightarrow> (the \<circ> sel_tuple2_2) ` reach_k_N G k E2 (Suc 0) = F_EPDA_AIA__fp_N G k E1 (Suc 0)"
  apply(clarsimp)
  apply(simp add: F_EPDA_AIA__fp_one_def reach_k_loop1_def)
  apply(rule antisym)
   apply(clarsimp)
   apply(rename_tac xa)(*strict*)
   apply(erule disjE)
    apply(rename_tac xa)(*strict*)
    apply(force)
   apply(rename_tac xa)(*strict*)
   apply(clarsimp)
   apply(rename_tac c q1 s1 q2 w1 w2 x)(*strict*)
   apply(rule_tac x="q1" in exI)
   apply(rule_tac x="s1" in exI)
   apply(rule conjI)
    apply(rename_tac c q1 s1 q2 w1 w2 x)(*strict*)
    apply(force)
   apply(rename_tac c q1 s1 q2 w1 w2 x)(*strict*)
   apply(rule_tac x="x" in exI)
   apply(rule_tac x="w1" in exI)
   apply(rule_tac x="w2" in exI)
   apply(clarsimp)
  apply(clarsimp)
  apply(rule conjI)
   apply(force)
  apply(clarsimp)
  apply(rename_tac q1 s1 q2 xa xb w1 w2)(*strict*)
  apply(rule inMap)
  apply(rule_tac x="cons_tuple2 (Some(cons_tuple2 q1 s1)) (Some(cons_tuple2 q2 (take k w2 @ take (k - length w2) (drop (length w1) s1))))" in bexI)
   apply(rename_tac q1 s1 q2 xa xb w1 w2)(*strict*)
   apply(clarsimp)
  apply(rename_tac q1 s1 q2 xa xb w1 w2)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "False")
   apply(rename_tac q1 s1 q2 xa xb w1 w2)(*strict*)
   apply(force)
  apply(rename_tac q1 s1 q2 xa xb w1 w2)(*strict*)
  apply(case_tac xa)
  apply(rename_tac q1 s1 q2 xa xb w1 w2 x1 x2)(*strict*)
  apply(clarsimp)
  apply(rename_tac q1 s1 q2 xb w1 w2 x1 x2)(*strict*)
  apply(erule_tac x="x1" in allE)
  apply(case_tac x2)
   apply(rename_tac q1 s1 q2 xb w1 w2 x1 x2)(*strict*)
   prefer 2
   apply(rename_tac q1 s1 q2 xb w1 w2 x1 x2 a)(*strict*)
   apply(clarsimp)
   apply(rename_tac q1 s1 q2 xb w1 w2 x1)(*strict*)
   apply(erule_tac x="w1" in allE)
   apply(erule_tac x="w2" in allE)
   apply(clarsimp)
   apply(force)
  apply(rename_tac q1 s1 q2 xb w1 w2 x1 x2)(*strict*)
  apply(clarsimp)
  apply(rename_tac q1 s1 q2 xb w1 w2 x1)(*strict*)
  apply(force)
  done

lemma reach_k_N_no_None_in_second_part: "
  valid_epda G
  \<Longrightarrow> None \<notin> sel_tuple2_2 ` reach_k_N G k {reach_k_initial G k} n"
  apply(induct n)
   apply(clarsimp)
   apply(simp add: reach_k_initial_def)
  apply(rename_tac n)(*strict*)
  apply(simp (no_asm))
  apply(rule_tac t="reach_k_N G k (reach_k_loop1 G k {reach_k_initial G k}) n" in ssubst)
   apply(rename_tac n)(*strict*)
   apply(rule reach_k_N_pull_out)
   apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
   apply(force)
  apply(rename_tac n)(*strict*)
  apply(clarsimp)
  apply(rename_tac n x)(*strict*)
  apply(simp add: reach_k_loop1_def)
  apply(erule disjE)
   apply(rename_tac n x)(*strict*)
   apply(force)
  apply(rename_tac n x)(*strict*)
  apply(clarsimp)
  done

lemma F_EPDA_AIA__fp_N_pull_out: "
  F_EPDA_AIA__fp_valid_input G k E
  \<Longrightarrow> F_EPDA_AIA__fp_N G k (F_EPDA_AIA__fp_one G k E) n = F_EPDA_AIA__fp_one G k (F_EPDA_AIA__fp_N G k E n)"
  apply(induct n arbitrary: E)
   apply(rename_tac E)(*strict*)
   apply(clarsimp)
  apply(rename_tac n E)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "F_EPDA_AIA__fp_N G k (F_EPDA_AIA__fp_one G k E) n =
                F_EPDA_AIA__fp_one G k (F_EPDA_AIA__fp_N G k E n)")
   apply(rename_tac n E)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac n E)(*strict*)
  apply(erule_tac x="F_EPDA_AIA__fp_one G k E" in meta_allE)
  apply(erule meta_impE)
   apply(rename_tac n E)(*strict*)
   apply (metis F_EPDA_AIA__fp_one_preserves_F_EPDA_AIA__fp_valid_input)
  apply(rename_tac n E)(*strict*)
  apply(force)
  done

theorem reach_k_N_coincides_with_F_EPDA_AIA__fp_N: "
  valid_epda G
  \<Longrightarrow> (the \<circ> sel_tuple2_2) ` reach_k_N G k {reach_k_initial G k} n = F_EPDA_AIA__fp_N G k {F_EPDA_AIA__fp_start G k} n"
  apply(induct n)
   apply(clarsimp)
   apply(simp add: reach_k_initial_def F_EPDA_AIA__fp_start_def)
  apply(rename_tac n)(*strict*)
  apply(clarsimp)
  apply(rule_tac t="reach_k_N G k (reach_k_loop1 G k {reach_k_initial G k}) n" and s="reach_k_N G k (reach_k_N G k {reach_k_initial G k} n) (Suc 0)" in ssubst)
   apply(rename_tac n)(*strict*)
   apply(clarsimp)
   apply(rule reach_k_N_pull_out)
   apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
   apply(force)
  apply(rename_tac n)(*strict*)
  apply(rule_tac t="(the \<circ> sel_tuple2_2) `
         reach_k_N G k (reach_k_N G k {reach_k_initial G k} n) (Suc 0)" in ssubst)
   apply(rename_tac n)(*strict*)
   apply(rule reach_k_N_coincides_with_F_EPDA_AIA__fp_N_ONE)
     apply(rename_tac n)(*strict*)
     apply(force)
    apply(rename_tac n)(*strict*)
    apply(rule reach_k_N_no_None_in_second_part)
    apply(force)
   apply(rename_tac n)(*strict*)
   apply(force)
  apply(rename_tac n)(*strict*)
  apply(thin_tac "(the \<circ> sel_tuple2_2) ` reach_k_N G k {reach_k_initial G k} n =
         F_EPDA_AIA__fp_N G k {F_EPDA_AIA__fp_start G k} n")
  apply (metis F_EPDA_AIA__fp_N.simps(1) F_EPDA_AIA__fp_N.simps(2) F_EPDA_AIA__fp_N_pull_out F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
  done

lemma F_EPDA_AIA__fp_execution_beyond_termination: "
  F_EPDA_AIA__fp_valid_input G k E
  \<Longrightarrow> F_EPDA_AIA__fp G k E = F_EPDA_AIA__fp_one G k (F_EPDA_AIA__fp G k E)"
  apply(rule F_EPDA_AIA__fp_F_EPDA_AIA__fp_one_idempotent_outer)
  apply(force)
  done

lemma F_EPDA_AIA__fp_N_execution_beyond_termination_one: "
  F_EPDA_AIA__fp_valid_input G k E
  \<Longrightarrow> F_EPDA_AIA__fp_N G k E n = F_EPDA_AIA__fp G k E
  \<Longrightarrow> F_EPDA_AIA__fp_N G k E n = F_EPDA_AIA__fp_N G k E (Suc n)"
  apply(clarsimp)
  apply(rule_tac t="F_EPDA_AIA__fp_N G k (F_EPDA_AIA__fp_one G k E) n" and s="F_EPDA_AIA__fp_one G k (F_EPDA_AIA__fp_N G k E n)" in ssubst)
   prefer 2
   apply(rule_tac t="F_EPDA_AIA__fp_N G k E n" and s="F_EPDA_AIA__fp G k E" in ssubst)
    apply(force)
   apply(thin_tac "F_EPDA_AIA__fp_N G k E n = F_EPDA_AIA__fp G k E")
   apply(rule F_EPDA_AIA__fp_execution_beyond_termination)
   apply(force)
  apply(thin_tac "F_EPDA_AIA__fp_N G k E n = F_EPDA_AIA__fp G k E")
  apply(rule F_EPDA_AIA__fp_N_pull_out)
  apply(force)
  done

lemma F_EPDA_AIA__fp_N_execution_beyond_termination: "
  F_EPDA_AIA__fp_valid_input G k E
  \<Longrightarrow> F_EPDA_AIA__fp_N G k E n = F_EPDA_AIA__fp G k E
  \<Longrightarrow> F_EPDA_AIA__fp_N G k E n = F_EPDA_AIA__fp_N G k E (n + m)"
  apply(induct m)
   apply(clarsimp)
  apply(rename_tac m)(*strict*)
  apply (metis add_Suc add_Suc_shift F_EPDA_AIA__fp_N_execution_beyond_termination_one)
  done

lemma reach_k_execution_beyond_termination: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k G k E = reach_k_loop1 G k (reach_k G k E)"
  apply(rule_tac G="G" and k="k" and N="E" in reach_k_Meta_Lift)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply (metis reach_k_reach_k_loop1_idemp2)
  apply(rename_tac Ga ka N)(*strict*)
  apply (metis reach_k.psimps reach_k_termination)
  done

lemma reach_k_N_execution_beyond_termination_one: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_N G k E n = reach_k G k E
  \<Longrightarrow> reach_k_N G k E n = reach_k_N G k E (Suc n)"
  apply(clarsimp)
  apply(rule_tac t="reach_k_N G k (reach_k_loop1 G k E) n" and s="reach_k_loop1 G k (reach_k_N G k E n)" in ssubst)
   prefer 2
   apply(rule_tac t="reach_k_N G k E n" and s="reach_k G k E" in ssubst)
    apply(force)
   apply(thin_tac "reach_k_N G k E n = reach_k G k E")
   apply(rule reach_k_execution_beyond_termination)
   apply(force)
  apply(thin_tac "reach_k_N G k E n = reach_k G k E")
  apply(rule reach_k_N_pull_out)
  apply(force)
  done

lemma reach_k_N_execution_beyond_termination: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> reach_k_N G k E n = reach_k G k E
  \<Longrightarrow> reach_k_N G k E n = reach_k_N G k E (n + m)"
  apply(induct m)
   apply(clarsimp)
  apply(rename_tac m)(*strict*)
  apply (metis add_Suc add_Suc_shift reach_k_N_execution_beyond_termination_one)
  done

theorem reach_k_coincides_with_F_EPDA_AIA__fp: "
  valid_epda G
  \<Longrightarrow> (the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k} = F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac G="G" and k="k" and E="{reach_k_initial G k}" in reach_k_N_terminates)
   apply (metis reach_k_TERM_ARGS_TEST_with_reach_k_initial)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac G="G" and k="k" and E="{F_EPDA_AIA__fp_start G k}" in F_EPDA_AIA__fp_N_terminates)
   apply (metis F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
  apply(erule_tac exE)+
  apply(rename_tac n na)(*strict*)
  apply(case_tac "na\<le>n")
   apply(rename_tac n na)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac n na)(*strict*)
    prefer 2
    apply(rule_tac G="G" and k="k" and n="n" in reach_k_N_coincides_with_F_EPDA_AIA__fp_N)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(rule_tac t="reach_k G k {reach_k_initial G k}" and s="reach_k_N G k {reach_k_initial G k} n" in ssubst)
    apply(rename_tac n na)(*strict*)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(rule_tac t="F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}" and s="F_EPDA_AIA__fp_N G k {F_EPDA_AIA__fp_start G k} na" in ssubst)
    apply(rename_tac n na)(*strict*)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(rule_tac t="(the \<circ> sel_tuple2_2) ` reach_k_N G k {reach_k_initial G k} n" and s="F_EPDA_AIA__fp_N G k {F_EPDA_AIA__fp_start G k} n" in ssubst)
    apply(rename_tac n na)(*strict*)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(thin_tac "reach_k_N G k {reach_k_initial G k} n = reach_k G k {reach_k_initial G k}")
   apply(thin_tac "(the \<circ> sel_tuple2_2) ` reach_k_N G k {reach_k_initial G k} n =
       F_EPDA_AIA__fp_N G k {F_EPDA_AIA__fp_start G k} n")
   apply(subgoal_tac "\<exists>k. na+k=n")
    apply(rename_tac n na)(*strict*)
    prefer 2
    apply(rule_tac x="n-na" in exI)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(erule exE)
   apply(rename_tac n na ka)(*strict*)
   apply(rule sym)
   apply(rule_tac t="n" and s="na+ka" in ssubst)
    apply(rename_tac n na ka)(*strict*)
    apply(force)
   apply(rename_tac n na ka)(*strict*)
   apply(rule F_EPDA_AIA__fp_N_execution_beyond_termination)
    apply(rename_tac n na ka)(*strict*)
    apply (metis F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
   apply(rename_tac n na ka)(*strict*)
   apply(force)
  apply(rename_tac n na)(*strict*)
  apply(case_tac "n\<le>na")
   apply(rename_tac n na)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac n na)(*strict*)
    prefer 2
    apply(rule_tac G="G" and k="k" and n="na" in reach_k_N_coincides_with_F_EPDA_AIA__fp_N)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(rule_tac t="reach_k G k {reach_k_initial G k}" and s="reach_k_N G k {reach_k_initial G k} n" in ssubst)
    apply(rename_tac n na)(*strict*)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(rule_tac t="F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}" and s="F_EPDA_AIA__fp_N G k {F_EPDA_AIA__fp_start G k} na" in ssubst)
    apply(rename_tac n na)(*strict*)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(rule_tac t="F_EPDA_AIA__fp_N G k {F_EPDA_AIA__fp_start G k} na" and s="(the \<circ> sel_tuple2_2) ` reach_k_N G k {reach_k_initial G k} na" in ssubst)
    apply(rename_tac n na)(*strict*)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(thin_tac "F_EPDA_AIA__fp_N G k {F_EPDA_AIA__fp_start G k} na =
       F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}")
   apply(subgoal_tac "\<exists>k. n+k=na")
    apply(rename_tac n na)(*strict*)
    prefer 2
    apply(rule_tac x="na-n" in exI)
    apply(force)
   apply(rename_tac n na)(*strict*)
   apply(erule exE)
   apply(rename_tac n na ka)(*strict*)
   apply(rule_tac t="na" and s="n+ka" in ssubst)
    apply(rename_tac n na ka)(*strict*)
    apply(force)
   apply(rename_tac n na ka)(*strict*)
   apply(rule_tac f="%x. (the \<circ> sel_tuple2_2) ` x" in arg_cong)
   apply(rule reach_k_N_execution_beyond_termination)
    apply(rename_tac n na ka)(*strict*)
    apply (metis reach_k_TERM_ARGS_TEST_with_reach_k_initial)
   apply(rename_tac n na ka)(*strict*)
   apply(force)
  apply(rename_tac n na)(*strict*)
  apply(force)
  done

lemma finite_l3_dom: "
  valid_epda G
  \<Longrightarrow> finite (l3_dom G)"
  apply(simp add: l3_dom_def)
  apply(rule_tac t="{cons_l3 q A q' |q A q'. q \<in> epda_states G \<and> q' \<in> epda_states G \<and> A \<in> epda_gamma G}" and s="(%(q,A,q'). cons_l3 q A q')`(epda_states G \<times> epda_gamma G \<times> epda_states G)" in ssubst)
   apply(force)
  apply(rule finite_imageI)
  apply(simp add: valid_epda_def)
  done

theorem F_SDPDA_TO_CFG_OPT__is_cfg_sub_of_F_SDPDA_TO_CFG_STD: "
  valid_simple_dpda G
  \<Longrightarrow> k > 0
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT G k = Some Gopt
  \<Longrightarrow> cfg_sub Gopt (F_SDPDA_TO_CFG_STD G)"
  apply(simp add: F_SDPDA_TO_CFG_OPT_def F_SDPDA_TO_CFG_STD_def cfg_sub_def Let_def)
  apply(case_tac "cons_l2 (epda_initial G) (epda_box G)
        \<in> (case F_SDPDA_TO_CFG_OPT__nonterminals G k of cons_tuple2 S2 S3 \<Rightarrow> S2)")
   prefer 2
   apply(force)
  apply(clarsimp)
  apply(case_tac "F_SDPDA_TO_CFG_OPT__nonterminals G k")
  apply(rename_tac x1 x2)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT__nonterminals_def Let_def)
  apply(rename_tac S2 S3)
  apply(rename_tac S2 S3)(*strict*)
  apply(clarsimp)
  apply(rule context_conjI)
   apply(clarsimp)
   apply(rename_tac x)(*strict*)
   apply(case_tac x)
    apply(rename_tac x state stack)(*strict*)
    prefer 2
    apply(rename_tac x state1 stack state2)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_OPT__l2_approx_def F_SDPDA_TO_CFG_OPT__l2_approx_1_def)
    apply(clarsimp)
   apply(rename_tac x state stack)(*strict*)
   apply(clarsimp)
   apply(rename_tac state stack)(*strict*)
   apply(rename_tac q A)
   apply(rename_tac q A)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__l2_approx_in_CFG)
       apply(rename_tac q A)(*strict*)
       apply(force)
      apply(rename_tac q A)(*strict*)
      apply(force)
     apply(rename_tac q A)(*strict*)
     apply(force)
    apply(rename_tac q A)(*strict*)
    apply(force)
   apply(rename_tac q A)(*strict*)
   apply(rule_tac A="F_SDPDA_TO_CFG_OPT__l2_approx G k (F_EPDA_AIA G k)
               (\<lambda>x. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
                      (F_SDPDA_TO_CFG_OPT__step_closure__fp G
                        (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G x (F_EPDA_AIA G k)) k))" in set_mp)
    apply(rename_tac q A)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac q A)(*strict*)
   apply(simp add: F_EPDA_AIA_def)
  apply(rule context_conjI)
   apply(thin_tac "F_SDPDA_TO_CFG_OPT__l2_approx G k (F_EPDA_AIA G k)
     (\<lambda>x. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
            (F_SDPDA_TO_CFG_OPT__step_closure__fp G
              (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G x (F_EPDA_AIA G k)) k))
    \<subseteq> {cons_l2 q A |q A. q \<in> epda_states G \<and> A \<in> epda_gamma G} \<union>
       {cons_l3 q1 A q2 |q1 A q2.
        q1 \<in> epda_states G \<and> q2 \<in> epda_states G \<and> A \<in> epda_gamma G} ")
   apply(clarsimp)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__l3_approx_def)
   apply(clarsimp)
   apply(rename_tac x xb)(*strict*)
   apply(case_tac x)
    apply(rename_tac x xb state stack)(*strict*)
    apply(clarsimp)
    apply(rename_tac xb state stack)(*strict*)
    apply(rename_tac q s)
    apply(rename_tac xb q s)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_OPT__l3_approx_1_def)
   apply(rename_tac x xb state1 stack state2)(*strict*)
   apply(clarsimp)
   apply(rename_tac xb state1 stack state2)(*strict*)
   apply(rename_tac q1 A q2)
   apply(rename_tac xb q1 A q2)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac xb q1 A q2)(*strict*)
    prefer 2
    apply(rule F_SDPDA_TO_CFG_OPT__l3_approx_in_CFG)
       apply(rename_tac xb q1 A q2)(*strict*)
       apply(force)
      apply(rename_tac xb q1 A q2)(*strict*)
      apply(force)
     apply(rule_tac t="(the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k}" and s="F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}" in ssubst)
      apply(rule reach_k_coincides_with_F_EPDA_AIA__fp)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def F_EPDA_AIA_def)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def F_EPDA_AIA_def)
    apply(force)
   apply(force)
  apply(rule conjI)
   apply(rule_tac B="F_SDPDA_TO_CFG_STD__edges_l3 G" in subset_trans)
    prefer 2
    apply(force)
   apply(clarsimp)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l3_def F_SDPDA_TO_CFG_STD__edges_l3_def)
   apply(erule disjE)
    apply(rename_tac x)(*strict*)
    apply(rule disjI1)
    apply(clarsimp)
    apply(rename_tac x e)(*strict*)
    apply(rule_tac x="e" in bexI)
     apply(rename_tac x e)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac x e)(*strict*)
    apply(case_tac "edge_event e")
     apply(rename_tac x e)(*strict*)
     apply(clarsimp)
    apply(rename_tac x e a)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def F_SDPDA_TO_CFG_OPT__edges_l3_read_def)
    apply(clarsimp)
    apply(rename_tac e a qt)(*strict*)
    apply(force)
   apply(rename_tac x)(*strict*)
   apply(erule disjE)
    apply(rename_tac x)(*strict*)
    apply(rule disjI2)
    apply(rule disjI1)
    apply(clarsimp)
    apply(rename_tac x e)(*strict*)
    apply(rule_tac x="e" in bexI)
     apply(rename_tac x e)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac x e)(*strict*)
    apply(case_tac "edge_push e")
     apply(rename_tac x e)(*strict*)
     prefer 2
     apply(rename_tac x e a list)(*strict*)
     apply(clarsimp)
    apply(rename_tac x e)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_OPT__edges_l3_pop_def)
   apply(rename_tac x)(*strict*)
   apply(rule disjI2)
   apply(rule disjI2)
   apply(clarsimp)
   apply(rename_tac x e)(*strict*)
   apply(rule_tac x="e" in bexI)
    apply(rename_tac x e)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac x e)(*strict*)
   apply(case_tac "edge_push e")
    apply(rename_tac x e)(*strict*)
    apply(clarsimp)
   apply(rename_tac x e a list)(*strict*)
   apply(clarsimp)
   apply(case_tac "edge_event e")
    apply(rename_tac x e a list)(*strict*)
    prefer 2
    apply(rename_tac x e a list aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac x e a list)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_OPT__edges_l3_push_def)
   apply(clarsimp)
   apply(rename_tac e a list qs qt)(*strict*)
   apply(force)
  apply(rule_tac B="F_SDPDA_TO_CFG_STD__edges_l2 G" in subset_trans)
   prefer 2
   apply(force)
  apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_def F_SDPDA_TO_CFG_STD__edges_l2_def)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(rule disjI1)
   apply(clarsimp)
   apply(rename_tac x e)(*strict*)
   apply(rule_tac x="e" in bexI)
    apply(rename_tac x e)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac x e)(*strict*)
   apply(case_tac "edge_event e")
    apply(rename_tac x e)(*strict*)
    apply(clarsimp)
   apply(rename_tac x e a)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_OPT__edges_l2_read_def)
  apply(rename_tac x)(*strict*)
  apply(erule disjE)
   apply(rename_tac x)(*strict*)
   apply(rule disjI2)
   apply(rule disjI1)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_final_def F_SDPDA_TO_CFG_STD__edges_l2_final_def)
   apply(clarsimp)
   apply(rename_tac i A)(*strict*)
   apply(force)
  apply(rename_tac x)(*strict*)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(clarsimp)
  apply(rename_tac x e)(*strict*)
  apply(rule_tac x="e" in bexI)
   apply(rename_tac x e)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac x e)(*strict*)
  apply(case_tac "edge_push e")
   apply(rename_tac x e)(*strict*)
   apply(clarsimp)
  apply(rename_tac x e a list)(*strict*)
  apply(clarsimp)
  apply(case_tac "edge_event e")
   apply(rename_tac x e a list)(*strict*)
   prefer 2
   apply(rename_tac x e a list aa)(*strict*)
   apply(clarsimp)
  apply(rename_tac x e a list)(*strict*)
  apply(clarsimp)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def F_SDPDA_TO_CFG_OPT__edges_l2_push_def)
  apply(clarsimp)
  apply(force)
  done

theorem F_SDPDA_TO_CFG_OPT__makes_valid_cfg: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT G k = Some Gopt
  \<Longrightarrow> valid_cfg Gopt"
  apply(simp add: valid_cfg_def)
  apply(case_tac "F_SDPDA_TO_CFG_OPT__nonterminals G k ")
  apply(rename_tac x1 x2)(*strict*)
  apply(rename_tac S2 S3)
  apply(rename_tac S2 S3)(*strict*)
  apply(rule conjI)
   apply(rename_tac S2 S3)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT_def Let_def valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(erule if_option_simp_rev)
   apply(force)
  apply(rename_tac S2 S3)(*strict*)
  apply(rule conjI)
   apply(rename_tac S2 S3)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT_def Let_def F_SDPDA_TO_CFG_OPT__nonterminals_def)
   apply(erule if_option_simp_rev)
   apply(clarsimp)
   apply(rule conjI)
    apply(rule_tac B="l2_dom G" in finite_subset)
     apply(simp add: F_SDPDA_TO_CFG_OPT__l2_approx_def l2_dom_def)
     apply(clarsimp)
     apply(rename_tac x A Aa)(*strict*)
     apply(case_tac x)
      apply(rename_tac x A Aa state stack)(*strict*)
      prefer 2
      apply(rename_tac x A Aa state1 stack state2)(*strict*)
      apply(simp add: F_SDPDA_TO_CFG_OPT__l2_approx_1_def)
     apply(rename_tac x A Aa state stack)(*strict*)
     apply(clarsimp)
     apply(rename_tac A Aa state stack)(*strict*)
     apply(rule F_SDPDA_TO_CFG_OPT__l2_approx_in_CFG)
         apply(rename_tac A Aa state stack)(*strict*)
         apply(force)
        apply(rename_tac A Aa state stack)(*strict*)
        apply(force)
       apply(rename_tac A Aa state stack)(*strict*)
       apply(force)
      apply(rename_tac A Aa state stack)(*strict*)
      apply(force)
     apply(rename_tac A Aa state stack)(*strict*)
     apply(simp add: F_EPDA_AIA_def)
     apply(simp add: F_SDPDA_TO_CFG_OPT__l2_approx_def)
     apply(force)
    apply(rule finite_l2_dom)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(rule_tac B="l3_dom G" in finite_subset)
    apply(simp add: F_SDPDA_TO_CFG_OPT__l3_approx_def l3_dom_def)
    apply(clarsimp)
    apply(rename_tac x xa)(*strict*)
    apply(case_tac x)
     apply(rename_tac x xa state stack)(*strict*)
     apply(clarsimp)
     apply(rename_tac xa state stack)(*strict*)
     apply(simp add: F_SDPDA_TO_CFG_OPT__l3_approx_1_def)
    apply(rename_tac x xa state1 stack state2)(*strict*)
    apply(clarsimp)
    apply(rename_tac xa state1 stack state2)(*strict*)
    apply(subgoal_tac "X" for X)
     apply(rename_tac xa state1 stack state2)(*strict*)
     prefer 2
     apply(rule_tac G="G" and k="k" in F_SDPDA_TO_CFG_OPT__l3_approx_in_CFG)
        apply(rename_tac xa state1 stack state2)(*strict*)
        apply(force)
       apply(rename_tac xa state1 stack state2)(*strict*)
       apply(force)
      apply(rule_tac t="(the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k}" and s="F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}" in ssubst)
       apply(rule reach_k_coincides_with_F_EPDA_AIA__fp)
       apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
      apply(simp add: F_EPDA_AIA_def)
     apply(force)
    apply(force)
   apply(rule finite_l3_dom)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
  apply(rename_tac S2 S3)(*strict*)
  apply(rule conjI)
   apply(rename_tac S2 S3)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT_def)
   apply(erule if_option_simp_rev)
   apply(clarsimp)
  apply(rename_tac S2 S3)(*strict*)
  apply(rule conjI)
   apply(rename_tac S2 S3)(*strict*)
   apply(rule_tac B="(cfg_productions (F_SDPDA_TO_CFG_STD G))" in finite_subset)
    apply(rename_tac S2 S3)(*strict*)
    prefer 2
    apply(subgoal_tac "valid_cfg (F_SDPDA_TO_CFG_STD G)")
     apply(rename_tac S2 S3)(*strict*)
     prefer 2
     apply(rule F_SDPDA_TO_CFG_STD__makes_CFG)
     apply(force)
    apply(rename_tac S2 S3)(*strict*)
    apply(simp add: valid_cfg_def)
   apply(rename_tac S2 S3)(*strict*)
   apply(clarsimp)
   apply(rename_tac S2 S3 x)(*strict*)
   apply(subgoal_tac "cfg_sub (Gopt) (F_SDPDA_TO_CFG_STD G)")
    apply(rename_tac S2 S3 x)(*strict*)
    prefer 2
    apply(rule F_SDPDA_TO_CFG_OPT__is_cfg_sub_of_F_SDPDA_TO_CFG_STD)
      apply(rename_tac S2 S3 x)(*strict*)
      apply(force)
     apply(rename_tac S2 S3 x)(*strict*)
     apply(force)
    apply(rename_tac S2 S3 x)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 x)(*strict*)
   apply(simp add: cfg_sub_def F_SDPDA_TO_CFG_OPT_def F_SDPDA_TO_CFG_STD_def)
   apply(force)
  apply(rename_tac S2 S3)(*strict*)
  apply(clarsimp)
  apply(rename_tac S2 S3 e)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT_def F_SDPDA_TO_CFG_OPT__nonterminals_def Let_def)
  apply(erule if_option_simp_rev)
  apply(clarsimp)
  apply(rename_tac e)(*strict*)
  apply(erule disjE)
   apply(rename_tac e)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l3_def)
   apply(erule disjE)
    apply(rename_tac e)(*strict*)
    apply(clarsimp)
    apply(rename_tac e ea)(*strict*)
    apply(case_tac "edge_event ea")
     apply(rename_tac e ea)(*strict*)
     apply(clarsimp)
    apply(rename_tac e ea a)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l3_read_def)
    apply(clarsimp)
    apply(rename_tac ea a qt)(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
    apply(clarsimp)
    apply(erule_tac x="ea" in ballE)
     apply(rename_tac ea a qt)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac ea a qt)(*strict*)
    apply(simp add: valid_epda_step_label_def option_to_set_def)
   apply(rename_tac e)(*strict*)
   apply(erule disjE)
    apply(rename_tac e)(*strict*)
    apply(clarsimp)
    apply(rename_tac e ea)(*strict*)
    apply(case_tac "edge_push ea")
     apply(rename_tac e ea)(*strict*)
     prefer 2
     apply(rename_tac e ea a list)(*strict*)
     apply(clarsimp)
    apply(rename_tac e ea)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l3_pop_def)
   apply(rename_tac e)(*strict*)
   apply(clarsimp)
   apply(rename_tac e ea)(*strict*)
   apply(case_tac "edge_push ea")
    apply(rename_tac e ea)(*strict*)
    apply(clarsimp)
   apply(rename_tac e ea a list)(*strict*)
   apply(clarsimp)
   apply(case_tac "edge_event ea")
    apply(rename_tac e ea a list)(*strict*)
    prefer 2
    apply(rename_tac e ea a list aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac e ea a list)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l3_push_def)
   apply(clarsimp)
  apply(rename_tac e)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_def)
  apply(erule disjE)
   apply(rename_tac e)(*strict*)
   apply(clarsimp)
   apply(rename_tac e ea)(*strict*)
   apply(case_tac "edge_event ea")
    apply(rename_tac e ea)(*strict*)
    apply(clarsimp)
   apply(rename_tac e ea a)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_read_def)
   apply(clarsimp)
   apply(rename_tac ea a)(*strict*)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(clarsimp)
   apply(erule_tac x="ea" in ballE)
    apply(rename_tac ea a)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac ea a)(*strict*)
   apply(simp add: valid_epda_step_label_def option_to_set_def)
  apply(rename_tac e)(*strict*)
  apply(erule disjE)
   apply(rename_tac e)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_final_def)
   apply(clarsimp)
  apply(rename_tac e)(*strict*)
  apply(clarsimp)
  apply(rename_tac e ea)(*strict*)
  apply(case_tac "edge_push ea")
   apply(rename_tac e ea)(*strict*)
   apply(clarsimp)
  apply(rename_tac e ea a list)(*strict*)
  apply(clarsimp)
  apply(case_tac "edge_event ea")
   apply(rename_tac e ea a list)(*strict*)
   prefer 2
   apply(rename_tac e ea a list aa)(*strict*)
   apply(clarsimp)
  apply(rename_tac e ea a list)(*strict*)
  apply(clarsimp)
  apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_push_def)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__nonterminals_l2_in_S3: "
  F_SDPDA_TO_CFG_OPT__nonterminals G k = cons_tuple2 S2 S3
  \<Longrightarrow> cons_l2 q A \<in> S3
  \<Longrightarrow> Q"
  apply(simp add: F_SDPDA_TO_CFG_OPT__nonterminals_def Let_def F_SDPDA_TO_CFG_OPT__l3_approx_def F_SDPDA_TO_CFG_OPT__l3_approx_1_def)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__nonterminals_l3_in_S2: "
  F_SDPDA_TO_CFG_OPT__nonterminals G k = cons_tuple2 S2 S3
  \<Longrightarrow> cons_l3 q A q' \<in> S2
  \<Longrightarrow> Q"
  apply(simp add: F_SDPDA_TO_CFG_OPT__nonterminals_def Let_def)
  apply(clarsimp)
  apply(simp add: F_SDPDA_TO_CFG_OPT__l2_approx_def F_SDPDA_TO_CFG_OPT__l2_approx_1_def)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__cfg_sub_by_nonterminals: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT G k = Some Go
  \<Longrightarrow> valid_cfg Go
  \<Longrightarrow> valid_cfg (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfg_sub Go (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfg_productions Go = {p \<in> cfg_productions (F_SDPDA_TO_CFG_STD G) . prod_lhs p \<in> cfg_nonterminals Go \<and> setA (prod_rhs p) \<subseteq> cfg_nonterminals Go}"
  apply(rule antisym)
   apply(clarsimp)
   apply(rename_tac x)(*strict*)
   apply(simp add: cfg_sub_def)
   apply(rule context_conjI)
    apply(rename_tac x)(*strict*)
    apply(force)
   apply(rename_tac x)(*strict*)
   apply(simp add: valid_cfg_def)
  apply(clarsimp)
  apply(rename_tac x)(*strict*)
  apply(thin_tac "valid_cfg X" for X)
  apply(thin_tac "valid_cfg X" for X)
  apply(thin_tac "cfg_sub Y X" for X Y)
  apply(simp add: F_SDPDA_TO_CFG_STD_def F_SDPDA_TO_CFG_OPT_def Let_def)
  apply(case_tac "F_SDPDA_TO_CFG_OPT__nonterminals G k")
  apply(rename_tac x x1 x2)(*strict*)
  apply(clarsimp)
  apply(rename_tac S2 S3)
  apply(rename_tac x S2 S3)(*strict*)
  apply(case_tac x)
  apply(rename_tac x S2 S3 prod_lhsa prod_rhsa)(*strict*)
  apply(rename_tac A w)
  apply(rename_tac x S2 S3 A w)(*strict*)
  apply(clarsimp)
  apply(rename_tac S2 S3 A w)(*strict*)
  apply(case_tac A)
   apply(rename_tac S2 S3 A w state stack)(*strict*)
   apply(clarsimp)
   apply(rename_tac S2 S3 w state stack)(*strict*)
   apply(case_tac "cons_l2 state stack \<in> S3")
    apply(rename_tac S2 S3 w state stack)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_OPT__nonterminals_def Let_def F_SDPDA_TO_CFG_OPT__l3_approx_def F_SDPDA_TO_CFG_OPT__l3_approx_1_def)
    apply(force)
   apply(rename_tac S2 S3 w state stack)(*strict*)
   apply(erule if_option_simp_rev)
   apply(clarsimp)
   apply(erule disjE)
    apply(rename_tac S2 S3 w state stack)(*strict*)
    apply(thin_tac "\<lparr>prod_lhs = cons_l2 state stack, prod_rhs = w\<rparr> \<notin> F_SDPDA_TO_CFG_OPT__edges_l2 G S2 S3")
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_def F_SDPDA_TO_CFG_OPT__edges_l3_def)
    apply(erule disjE)
     apply(rename_tac S2 S3 w state stack)(*strict*)
     apply(rule disjI1)
     apply(clarsimp)
     apply(rename_tac S2 S3 w state stack e)(*strict*)
     apply(case_tac "edge_event e")
      apply(rename_tac S2 S3 w state stack e)(*strict*)
      apply(clarsimp)
     apply(rename_tac S2 S3 w state stack e a)(*strict*)
     apply(clarsimp)
     apply(rule_tac x="e" in bexI)
      apply(rename_tac S2 S3 w state stack e a)(*strict*)
      prefer 2
      apply(clarsimp)
     apply(rename_tac S2 S3 w state stack e a)(*strict*)
     apply(clarsimp)
     apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def)
    apply(rename_tac S2 S3 w state stack)(*strict*)
    apply(erule disjE)
     apply(rename_tac S2 S3 w state stack)(*strict*)
     apply(rule disjI2)
     apply(rule disjI1)
     apply(clarsimp)
     apply(rename_tac S2 S3 w state stack e)(*strict*)
     apply(case_tac "edge_push e")
      apply(rename_tac S2 S3 w state stack e)(*strict*)
      prefer 2
      apply(rename_tac S2 S3 w state stack e a list)(*strict*)
      apply(clarsimp)
     apply(rename_tac S2 S3 w state stack e)(*strict*)
     apply(clarsimp)
     apply(rule_tac x="e" in bexI)
      apply(rename_tac S2 S3 w state stack e)(*strict*)
      prefer 2
      apply(clarsimp)
     apply(rename_tac S2 S3 w state stack e)(*strict*)
     apply(clarsimp)
     apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def)
    apply(rename_tac S2 S3 w state stack)(*strict*)
    apply(rule disjI2)
    apply(rule disjI2)
    apply(clarsimp)
    apply(rename_tac S2 S3 w state stack e)(*strict*)
    apply(case_tac "edge_push e")
     apply(rename_tac S2 S3 w state stack e)(*strict*)
     apply(clarsimp)
    apply(rename_tac S2 S3 w state stack e a list)(*strict*)
    apply(clarsimp)
    apply(case_tac "edge_event e")
     apply(rename_tac S2 S3 w state stack e a list)(*strict*)
     prefer 2
     apply(rename_tac S2 S3 w state stack e a list aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac S2 S3 w state stack e a list)(*strict*)
    apply(clarsimp)
    apply(rule_tac x="e" in bexI)
     apply(rename_tac S2 S3 w state stack e a list)(*strict*)
     prefer 2
     apply(clarsimp)
    apply(rename_tac S2 S3 w state stack e a list)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def)
   apply(rename_tac S2 S3 w state stack)(*strict*)
   apply(subgoal_tac "\<lparr>prod_lhs = cons_l2 state stack, prod_rhs = w\<rparr> \<in> F_SDPDA_TO_CFG_OPT__edges_l2 G S2 S3")
    apply(rename_tac S2 S3 w state stack)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 w state stack)(*strict*)
   apply(thin_tac "\<lparr>prod_lhs = cons_l2 state stack, prod_rhs = w\<rparr> \<notin> F_SDPDA_TO_CFG_OPT__edges_l2 G S2 S3")
   apply(thin_tac "cons_l2 state stack \<notin> S3")
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_def F_SDPDA_TO_CFG_STD__edges_l2_def)
   apply(erule disjE)
    apply(rename_tac S2 S3 w state stack)(*strict*)
    apply(rule disjI1)
    apply(clarsimp)
    apply(rename_tac S2 S3 w state stack e)(*strict*)
    apply(case_tac "edge_event e")
     apply(rename_tac S2 S3 w state stack e)(*strict*)
     apply(clarsimp)
    apply(rename_tac S2 S3 w state stack e a)(*strict*)
    apply(clarsimp)
    apply(rule_tac x="e" in bexI)
     apply(rename_tac S2 S3 w state stack e a)(*strict*)
     prefer 2
     apply(clarsimp)
    apply(rename_tac S2 S3 w state stack e a)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_read_def)
    apply(clarsimp)
    apply(rename_tac S2 S3 e a)(*strict*)
    apply(rule  F_SDPDA_TO_CFG_OPT__nonterminals_l2_in_S3)
     apply(rename_tac S2 S3 e a)(*strict*)
     apply(force)
    apply(rename_tac S2 S3 e a)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 w state stack)(*strict*)
   apply(erule disjE)
    apply(rename_tac S2 S3 w state stack)(*strict*)
    apply(rule disjI2)
    apply(rule disjI1)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def F_SDPDA_TO_CFG_OPT__edges_l2_final_def)
   apply(rename_tac S2 S3 w state stack)(*strict*)
   apply(rule disjI2)
   apply(rule disjI2)
   apply(clarsimp)
   apply(rename_tac S2 S3 w state stack e)(*strict*)
   apply(case_tac "edge_push e")
    apply(rename_tac S2 S3 w state stack e)(*strict*)
    apply(clarsimp)
   apply(rename_tac S2 S3 w state stack e a list)(*strict*)
   apply(clarsimp)
   apply(case_tac "edge_event e")
    apply(rename_tac S2 S3 w state stack e a list)(*strict*)
    prefer 2
    apply(rename_tac S2 S3 w state stack e a list aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac S2 S3 w state stack e a list)(*strict*)
   apply(clarsimp)
   apply(rule_tac x="e" in bexI)
    apply(rename_tac S2 S3 w state stack e a list)(*strict*)
    prefer 2
    apply(clarsimp)
   apply(rename_tac S2 S3 w state stack e a list)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_push_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
   apply(clarsimp)
   apply(erule disjE)
    apply(rename_tac S2 S3 w state stack e a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac S2 S3 e a list)(*strict*)
    apply(rule  F_SDPDA_TO_CFG_OPT__nonterminals_l2_in_S3)
     apply(rename_tac S2 S3 e a list)(*strict*)
     apply(force)
    apply(rename_tac S2 S3 e a list)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 w state stack e a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac S2 S3 e a list qs)(*strict*)
   apply(erule disjE)
    apply(rename_tac S2 S3 e a list qs)(*strict*)
    apply(rule  F_SDPDA_TO_CFG_OPT__nonterminals_l3_in_S2)
     apply(rename_tac S2 S3 e a list qs)(*strict*)
     apply(force)
    apply(rename_tac S2 S3 e a list qs)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 e a list qs)(*strict*)
   apply(clarsimp)
   apply(rule  F_SDPDA_TO_CFG_OPT__nonterminals_l2_in_S3)
    apply(rename_tac S2 S3 e a list qs)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 e a list qs)(*strict*)
   apply(force)
  apply(rename_tac S2 S3 A w state1 stack state2)(*strict*)
  apply(clarsimp)
  apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
  apply(case_tac "cons_l3 state1 stack state2 \<in> S2")
   apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
   apply(rule  F_SDPDA_TO_CFG_OPT__nonterminals_l3_in_S2)
    apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
   apply(force)
  apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
  apply(erule if_option_simp_rev)
  apply(clarsimp)
  apply(thin_tac "cons_l3 state1 stack state2 \<notin> S2")
  apply(erule disjE)
   apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
   prefer 2
   apply(subgoal_tac "False")
    apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
   apply(thin_tac "\<lparr>prod_lhs = cons_l3 state1 stack state2, prod_rhs = w\<rparr>
       \<notin> F_SDPDA_TO_CFG_OPT__edges_l2 G S2 S3")
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_def)
   apply(erule disjE)
    apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
    apply(clarsimp)
    apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
    apply(case_tac "edge_event e")
     apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
     apply(clarsimp)
    apply(rename_tac S2 S3 w state1 stack state2 e a)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_read_def)
   apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
   apply(erule disjE)
    apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def F_SDPDA_TO_CFG_OPT__edges_l2_final_def)
   apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
   apply(clarsimp)
   apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
   apply(case_tac "edge_push e")
    apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
    apply(clarsimp)
   apply(rename_tac S2 S3 w state1 stack state2 e a list)(*strict*)
   apply(clarsimp)
   apply(case_tac "edge_event e")
    apply(rename_tac S2 S3 w state1 stack state2 e a list)(*strict*)
    prefer 2
    apply(rename_tac S2 S3 w state1 stack state2 e a list aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac S2 S3 w state1 stack state2 e a list)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l2_push_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
  apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
  apply(thin_tac "\<lparr>prod_lhs = cons_l3 state1 stack state2, prod_rhs = w\<rparr>
       \<notin> F_SDPDA_TO_CFG_OPT__edges_l2 G S2 S3")
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_def F_SDPDA_TO_CFG_OPT__edges_l3_def)
  apply(erule disjE)
   apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
   apply(rule disjI1)
   apply(clarsimp)
   apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
   apply(case_tac "edge_event e")
    apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
    apply(clarsimp)
   apply(rename_tac S2 S3 w state1 stack state2 e a)(*strict*)
   apply(clarsimp)
   apply(rule_tac x="e" in bexI)
    apply(rename_tac S2 S3 w state1 stack state2 e a)(*strict*)
    prefer 2
    apply(clarsimp)
   apply(rename_tac S2 S3 w state1 stack state2 e a)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l3_read_def F_SDPDA_TO_CFG_STD__edges_l3_read_def)
   apply(clarsimp)
   apply(rename_tac S2 S3 state2 e a)(*strict*)
   apply(rule  F_SDPDA_TO_CFG_OPT__nonterminals_l3_in_S2)
    apply(rename_tac S2 S3 state2 e a)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 state2 e a)(*strict*)
   apply(force)
  apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
  apply(erule disjE)
   apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
   apply(rule disjI2)
   apply(rule disjI1)
   apply(clarsimp)
   apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
   apply(case_tac "edge_push e")
    apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
    prefer 2
    apply(rename_tac S2 S3 w state1 stack state2 e a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
   apply(clarsimp)
   apply(rule_tac x="e" in bexI)
    apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
    prefer 2
    apply(clarsimp)
   apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def)
  apply(rename_tac S2 S3 w state1 stack state2)(*strict*)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(clarsimp)
  apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
  apply(case_tac "edge_push e")
   apply(rename_tac S2 S3 w state1 stack state2 e)(*strict*)
   apply(clarsimp)
  apply(rename_tac S2 S3 w state1 stack state2 e a list)(*strict*)
  apply(clarsimp)
  apply(case_tac "edge_event e")
   apply(rename_tac S2 S3 w state1 stack state2 e a list)(*strict*)
   prefer 2
   apply(rename_tac S2 S3 w state1 stack state2 e a list aa)(*strict*)
   apply(clarsimp)
  apply(rename_tac S2 S3 w state1 stack state2 e a list)(*strict*)
  apply(clarsimp)
  apply(rule_tac x="e" in bexI)
   apply(rename_tac S2 S3 w state1 stack state2 e a list)(*strict*)
   prefer 2
   apply(clarsimp)
  apply(rename_tac S2 S3 w state1 stack state2 e a list)(*strict*)
  apply(clarsimp)
  apply(simp add: F_SDPDA_TO_CFG_OPT__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_push_def)
  apply(clarsimp)
  apply(rename_tac S2 S3 state2 e a list qs)(*strict*)
  apply(erule disjE)
   apply(rename_tac S2 S3 state2 e a list qs)(*strict*)
   apply(rule  F_SDPDA_TO_CFG_OPT__nonterminals_l3_in_S2)
    apply(rename_tac S2 S3 state2 e a list qs)(*strict*)
    apply(force)
   apply(rename_tac S2 S3 state2 e a list qs)(*strict*)
   apply(force)
  apply(rename_tac S2 S3 state2 e a list qs)(*strict*)
  apply(clarsimp)
  apply(rule  F_SDPDA_TO_CFG_OPT__nonterminals_l3_in_S2)
   apply(rename_tac S2 S3 state2 e a list qs)(*strict*)
   apply(force)
  apply(rename_tac S2 S3 state2 e a list qs)(*strict*)
  apply(force)
  done

definition singleIsertionOfLM :: "
  ('a, 'b) cfg
  \<Rightarrow> bool"
  where
    "singleIsertionOfLM G \<equiv>
   (\<forall>p\<in> cfg_productions G. \<exists>b w v. prefix v [teB b]
  \<and> prod_rhs p = v @ liftA w )"

lemma singleIsertionOfLM_rechable_conf_form: "
  valid_cfg G
  \<Longrightarrow> cfgLM.derivation_initial G d
  \<Longrightarrow> singleIsertionOfLM G
  \<Longrightarrow> d n = Some (pair e \<lparr>cfg_conf = w\<rparr>)
  \<Longrightarrow> \<exists>w1 w2. w = w1 @ w2 \<and> setA w1 = {} \<and> setB w2 = {}"
  apply(induct n arbitrary: e w)
   apply(rename_tac e w)(*strict*)
   apply(simp add: cfgLM.derivation_initial_def cfg_initial_configurations_def)
   apply(clarsimp)
   apply(rule_tac
      x="[]"
      in exI)
   apply(clarsimp)
  apply(rename_tac n e w)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "\<exists>e1 e2 c1 c2. d n = Some (pair e1 c1) \<and> d (Suc n) = Some (pair (Some e2) c2) \<and> cfgLM_step_relation G c1 e2 c2")
   apply(rename_tac n e w)(*strict*)
   prefer 2
   apply(rule_tac
      m="Suc n"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac n e w)(*strict*)
     apply(rule cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac n e w)(*strict*)
    apply(force)
   apply(rename_tac n e w)(*strict*)
   apply(force)
  apply(rename_tac n e w)(*strict*)
  apply(clarsimp)
  apply(rename_tac n w e1 e2 c1)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac n e1 e2 c1 l r)(*strict*)
  apply(erule_tac
      x="e1"
      in meta_allE)
  apply(clarsimp)
  apply(case_tac c1)
  apply(rename_tac n e1 e2 c1 l r cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 l r)(*strict*)
  apply(erule_tac
      x="l @ teA (prod_lhs e2) # r"
      in meta_allE)
  apply(clarsimp)
  apply(rename_tac n e1 e2 l r w1 w2)(*strict*)
  apply(simp add: singleIsertionOfLM_def)
  apply(erule_tac
      x="e2"
      in ballE)
   apply(rename_tac n e1 e2 l r w1 w2)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac n e1 e2 l r w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 l r w1 w2 b w v)(*strict*)
  apply(case_tac e2)
  apply(rename_tac n e1 e2 l r w1 w2 b w v prod_lhsa prod_rhsa)(*strict*)
  apply(rename_tac B w)
  apply(rename_tac n e1 e2 l r w1 w2 b wa v B w)(*strict*)
  apply(rule_tac
      x="l@v"
      in exI)
  apply(rule_tac
      x="liftA wa@r"
      in exI)
  apply(clarsimp)
  apply(rename_tac n e1 l r w1 w2 b wa v B)(*strict*)
  apply(rule conjI)
   apply(rename_tac n e1 l r w1 w2 b wa v B)(*strict*)
   apply(simp add: setAConcat)
   apply(simp add: prefix_def)
   apply(clarsimp)
   apply(rename_tac n e1 l r w1 w2 b wa v B c)(*strict*)
   apply(case_tac v)
    apply(rename_tac n e1 l r w1 w2 b wa v B c)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 l r w1 w2 b wa v B c a list)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 l r w1 w2 b wa v B)(*strict*)
  apply(simp add: setBConcat)
  apply(rule conjI)
   apply(rename_tac n e1 l r w1 w2 b wa v B)(*strict*)
   apply (metis setB_liftA)
  apply(rename_tac n e1 l r w1 w2 b wa v B)(*strict*)
  apply(subgoal_tac "prefix l w1 \<or> prefix w1 l")
   apply(rename_tac n e1 l r w1 w2 b wa v B)(*strict*)
   prefer 2
   apply(rule mutual_prefix_prefix)
   apply(force)
  apply(rename_tac n e1 l r w1 w2 b wa v B)(*strict*)
  apply(erule disjE)
   apply(rename_tac n e1 l r w1 w2 b wa v B)(*strict*)
   apply(simp add: prefix_def)
   apply(clarsimp)
   apply(rename_tac n e1 l r w2 b wa v B c ca)(*strict*)
   apply(case_tac ca)
    apply(rename_tac n e1 l r w2 b wa v B c ca)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 l r w2 b wa v B c ca a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 l w2 b wa v B c list)(*strict*)
   apply(simp add: setBConcat)
   apply (metis all_not_in_conv elemInsetA)
  apply(rename_tac n e1 l r w1 w2 b wa v B)(*strict*)
  apply(simp add: prefix_def)
  apply(clarsimp)
  apply(rename_tac n e1 r w1 b wa v B c ca)(*strict*)
  apply(simp add: setBConcat)
  done

lemma LR1ProdFormSimp_implies_singleIsertionOfLM: "
  LR1ProdFormSimp G
  \<Longrightarrow> singleIsertionOfLM G"
  apply(simp add: LR1ProdFormSimp_def singleIsertionOfLM_def)
  apply(clarsimp)
  apply(rename_tac p)(*strict*)
  apply(erule_tac
      x="p"
      in ballE)
   apply(rename_tac p)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac p)(*strict*)
  apply(erule disjE)
   apply(rename_tac p)(*strict*)
   apply(clarsimp)
   apply(simp add: prefix_def)
   apply(rule_tac
      x="[]"
      in exI)
   apply(force)
  apply(rename_tac p)(*strict*)
  apply(clarsimp)
  apply(rename_tac p b A B)(*strict*)
  apply(erule disjE)
   apply(rename_tac p b A B)(*strict*)
   apply(clarsimp)
   apply(rename_tac b A B)(*strict*)
   apply(rule_tac
      x="b"
      in exI)
   apply(rule_tac
      x="[B]"
      in exI)
   apply(rule_tac
      x="[teB b]"
      in exI)
   apply(clarsimp)
   apply(simp add: prefix_def)
  apply(rename_tac p b A B)(*strict*)
  apply(erule disjE)
   apply(rename_tac p b A B)(*strict*)
   apply(clarsimp)
   apply(rename_tac A B)(*strict*)
   apply(rule_tac
      x="SOME b. True"
      in exI)
   apply(rule_tac
      x="[B]"
      in exI)
   apply(rule_tac
      x="[]"
      in exI)
   apply(clarsimp)
   apply(simp add: prefix_def)
  apply(rename_tac p b A B)(*strict*)
  apply(clarsimp)
  apply(rename_tac A B C)(*strict*)
  apply(rule_tac
      x="SOME b. True"
      in exI)
  apply(rule_tac
      x="[B,C]"
      in exI)
  apply(rule_tac
      x="[]"
      in exI)
  apply(clarsimp)
  apply(simp add: prefix_def)
  done

definition LR1ProdForm :: "
  (('q, 'b) DT_l2_l3_nonterminals, 'a) cfg
  \<Rightarrow> bool"
  where
    "LR1ProdForm G \<equiv>
   (\<forall>p\<in> cfg_productions G. \<exists>b q1 q2 q3 q4 A1 A2. prod_rhs p = [] \<or> (p = \<lparr>prod_lhs = cons_l2 q1 A1,
  prod_rhs = [teB b,
  teA (cons_l2 q2 A1)]\<rparr>) \<or> (p = \<lparr>prod_lhs = cons_l3 q1 A1 q2,
  prod_rhs = [teB b,
  teA (cons_l3 q3 A1 q2)]\<rparr>) \<or> (p = \<lparr>prod_lhs = cons_l2 q1 A1,
  prod_rhs = [teA (cons_l2 q2 A2)]\<rparr>) \<or> (p = \<lparr>prod_lhs = cons_l2 q1 A1,
  prod_rhs = [teA (cons_l3 q2 A2 q3),
  teA (cons_l2 q3 A1)]\<rparr>) \<or> (p = \<lparr>prod_lhs = cons_l3 q1 A1 q4,
  prod_rhs = [teA (cons_l3 q2 A2 q3),
  teA (cons_l3 q3 A1 q4)]\<rparr>) )"

lemma LR1ProdForm_implies_LR1ProdFormSimp: "
  LR1ProdForm G
  \<Longrightarrow> LR1ProdFormSimp G"
  apply(simp add: LR1ProdFormSimp_def LR1ProdForm_def)
  apply(clarsimp)
  apply(rename_tac p)(*strict*)
  apply(erule_tac
      x="p"
      in ballE)
   apply(rename_tac p)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac p)(*strict*)
  apply(clarsimp)
  done

lemma sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm: "
  cfg_sub G' (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> LR1ProdForm G'"
  apply(simp add: LR1ProdForm_def)
  apply(clarsimp)
  apply(rename_tac p)(*strict*)
  apply(simp add: cfg_sub_def)
  apply(clarsimp)
  apply(subgoal_tac "p \<in> cfg_productions (F_SDPDA_TO_CFG_STD G)")
   apply(rename_tac p)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac p)(*strict*)
  apply(thin_tac "cfg_events G' \<subseteq> cfg_events (F_SDPDA_TO_CFG_STD G)")
  apply(thin_tac "cfg_nonterminals G' \<subseteq> cfg_nonterminals (F_SDPDA_TO_CFG_STD G)")
  apply(thin_tac "cfg_initial G' = cfg_initial (F_SDPDA_TO_CFG_STD G)")
  apply(thin_tac "p \<in> cfg_productions G'")
  apply(simp add: F_SDPDA_TO_CFG_STD_def)
  apply(thin_tac "cfg_productions G' \<subseteq> F_SDPDA_TO_CFG_STD__edges_l3 G \<union> F_SDPDA_TO_CFG_STD__edges_l2 G")
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_def)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_def)
  apply(erule disjE)
   apply(rename_tac p)(*strict*)
   apply(clarsimp)
   apply(rename_tac p x)(*strict*)
   apply(case_tac "edge_event x")
    apply(rename_tac p x)(*strict*)
    apply(clarsimp)
   apply(rename_tac p x a)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def)
  apply(rename_tac p)(*strict*)
  apply(erule disjE)
   apply(rename_tac p)(*strict*)
   apply(clarsimp)
   apply(rename_tac p x)(*strict*)
   apply(case_tac "edge_push x")
    apply(rename_tac p x)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_read_def)
   apply(rename_tac p x a list)(*strict*)
   apply(clarsimp)
  apply(rename_tac p)(*strict*)
  apply(erule disjE)
   apply(rename_tac p)(*strict*)
   apply(clarsimp)
   apply(rename_tac p x)(*strict*)
   apply(case_tac "edge_push x")
    apply(rename_tac p x)(*strict*)
    apply(clarsimp)
   apply(rename_tac p x a list)(*strict*)
   apply(clarsimp)
   apply(case_tac "edge_event x")
    apply(rename_tac p x a list)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_read_def)
   apply(rename_tac p x a list aa)(*strict*)
   apply(clarsimp)
  apply(rename_tac p)(*strict*)
  apply(erule disjE)
   apply(rename_tac p)(*strict*)
   apply(clarsimp)
   apply(rename_tac p x)(*strict*)
   apply(case_tac "edge_event x")
    apply(rename_tac p x)(*strict*)
    apply(clarsimp)
   apply(rename_tac p x a)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_read_def)
  apply(rename_tac p)(*strict*)
  apply(erule disjE)
   apply(rename_tac p)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_read_def)
   apply(clarsimp)
  apply(rename_tac p)(*strict*)
  apply(clarsimp)
  apply(rename_tac p x)(*strict*)
  apply(case_tac "edge_push x")
   apply(rename_tac p x)(*strict*)
   apply(clarsimp)
  apply(rename_tac p x a list)(*strict*)
  apply(clarsimp)
  apply(case_tac "edge_event x")
   apply(rename_tac p x a list)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_read_def)
  apply(rename_tac p x a list aa)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_read_def)
  done

definition l3_l2_separation_ALT :: "
  ('state, 'stack) DT_l2_l3_nonterminals list
  \<Rightarrow> bool"
  where
    "l3_l2_separation_ALT w \<equiv>
  case w of
    [] \<Rightarrow> True
    | a # w' \<Rightarrow> (\<forall>A \<in> set (butlast w).
      (case A of
        cons_l2 q A \<Rightarrow> False
        | _ \<Rightarrow> True))
  \<and> (case last w of
      cons_l3 q A q' \<Rightarrow> False
      | _ \<Rightarrow> True)"

lemma cfgLM_reachable_conf_isl3_l2_separation_ALT_stack: "
  valid_simple_dpda G
  \<Longrightarrow> valid_cfg (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> G' = (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfgLM.derivation_initial G' d
  \<Longrightarrow> d n = Some (pair e c)
  \<Longrightarrow> cfg_conf c = liftB w1 @ liftA w2
  \<Longrightarrow> l3_l2_separation_ALT w2"
  apply(induct n arbitrary: e c w1 w2)
   apply(rename_tac e c w1 w2)(*strict*)
   apply(simp add: cfgLM.derivation_initial_def cfg_initial_configurations_def)
   apply(clarsimp)
   apply(rename_tac w1 w2)(*strict*)
   apply(case_tac w1)
    apply(rename_tac w1 w2)(*strict*)
    apply(clarsimp)
    apply(rename_tac w2)(*strict*)
    apply(case_tac w2)
     apply(rename_tac w2)(*strict*)
     apply(clarsimp)
    apply(rename_tac w2 a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac list)(*strict*)
    apply(case_tac list)
     apply(rename_tac list)(*strict*)
     apply(clarsimp)
     apply(simp add: l3_l2_separation_ALT_def)
     apply(simp add: cfg_sub_def F_SDPDA_TO_CFG_STD_def)
    apply(rename_tac list a lista)(*strict*)
    apply(clarsimp)
   apply(rename_tac w1 w2 a list)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e c w1 w2)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "\<exists>e1 e2 c1 c2. d n = Some (pair e1 c1) \<and> d (Suc n) = Some (pair (Some e2) c2) \<and> cfgLM_step_relation (F_SDPDA_TO_CFG_STD G) c1 e2 c2")
   apply(rename_tac n e c w1 w2)(*strict*)
   prefer 2
   apply(rule_tac
      m="Suc n"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac n e c w1 w2)(*strict*)
     apply(rule cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac n e c w1 w2)(*strict*)
    apply(force)
   apply(rename_tac n e c w1 w2)(*strict*)
   apply(force)
  apply(rename_tac n e c w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n c w1 w2 e1 e2 c1)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac n c w1 w2 e1 e2 c1 l r)(*strict*)
  apply(erule_tac
      x="e1"
      in meta_allE)
  apply(clarsimp)
  apply(erule_tac
      x="c1"
      in meta_allE)
  apply(clarsimp)
  apply(case_tac c1)
  apply(rename_tac n c w1 w2 e1 e2 c1 l r cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n c w1 w2 e1 e2 l r)(*strict*)
  apply(subgoal_tac "\<exists>l'. liftB l'=l")
   apply(rename_tac n c w1 w2 e1 e2 l r)(*strict*)
   prefer 2
   apply(rule_tac
      x="filterB l"
      in exI)
   apply (rule liftBDeConv2)
   apply(force)
  apply(rename_tac n c w1 w2 e1 e2 l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac n c w1 w2 e1 e2 r l')(*strict*)
  apply(erule_tac
      x="l'"
      in meta_allE)
  apply(case_tac c)
  apply(rename_tac n c w1 w2 e1 e2 r l' cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n w1 w2 e1 e2 r l')(*strict*)
  apply(subgoal_tac "\<exists>w1 w2. liftB l' @ teA (prod_lhs e2) # r=w1@w2 \<and> setA w1={} \<and> setB w2={}")
   apply(rename_tac n w1 w2 e1 e2 r l')(*strict*)
   prefer 2
   apply(rule_tac
      G="(F_SDPDA_TO_CFG_STD G)"
      in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac n w1 w2 e1 e2 r l')(*strict*)
      apply(force)
     apply(rename_tac n w1 w2 e1 e2 r l')(*strict*)
     apply(force)
    apply(rename_tac n w1 w2 e1 e2 r l')(*strict*)
    apply(rule_tac
      G="(F_SDPDA_TO_CFG_STD G)"
      in LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule_tac
      G="(F_SDPDA_TO_CFG_STD G)"
      in LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule_tac
      G="G"
      in sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(simp add: cfg_sub_def)
   apply(rename_tac n w1 w2 e1 e2 r l')(*strict*)
   apply(force)
  apply(rename_tac n w1 w2 e1 e2 r l')(*strict*)
  apply(clarsimp)
  apply(rename_tac n w1 w2 e1 e2 r l' w1a w2a)(*strict*)
  apply(case_tac w2a)
   apply(rename_tac n w1 w2 e1 e2 r l' w1a w2a)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 w2 e1 e2 r l')(*strict*)
   apply (metis elemInsetA emptyE)
  apply(rename_tac n w1 w2 e1 e2 r l' w1a w2a a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac n w1 w2 e1 e2 r l' w1a a list)(*strict*)
  apply(case_tac a)
   apply(rename_tac n w1 w2 e1 e2 r l' w1a a list aa)(*strict*)
   prefer 2
   apply(rename_tac n w1 w2 e1 e2 r l' w1a a list b)(*strict*)
   apply(clarsimp)
  apply(rename_tac n w1 w2 e1 e2 r l' w1a a list aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n w1 w2 e1 e2 r l' w1a list aa)(*strict*)
  apply(subgoal_tac "w1a=liftB l'")
   apply(rename_tac n w1 w2 e1 e2 r l' w1a list aa)(*strict*)
   prefer 2
   apply (metis setA_liftB append_Cons eq_Nil_appendI terminalHeadEquals1)
  apply(rename_tac n w1 w2 e1 e2 r l' w1a list aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n w1 w2 e1 e2 l' list)(*strict*)
  apply(case_tac w2)
   apply(rename_tac n w1 w2 e1 e2 l' list)(*strict*)
   apply(simp add: l3_l2_separation_ALT_def)
  apply(rename_tac n w1 w2 e1 e2 l' list a lista)(*strict*)
  apply(subgoal_tac "\<exists>w' x'. w2=w'@[x']")
   apply(rename_tac n w1 w2 e1 e2 l' list a lista)(*strict*)
   prefer 2
   apply(rule_tac
      n="length lista"
      in NonEmptyListHasTailElem)
   apply(force)
  apply(rename_tac n w1 w2 e1 e2 l' list a lista)(*strict*)
  apply(thin_tac "w2=a#lista")
  apply(clarsimp)
  apply(rename_tac n w1 e1 e2 l' list w' x')(*strict*)
  apply(subgoal_tac "\<exists>ww. liftA ww=list")
   apply(rename_tac n w1 e1 e2 l' list w' x')(*strict*)
   prefer 2
   apply(rule_tac
      x="filterA list"
      in exI)
   apply (metis setB_empty_then_liftA_vs_filterA)
  apply(rename_tac n w1 e1 e2 l' list w' x')(*strict*)
  apply(clarsimp)
  apply(rename_tac n w1 e1 e2 l' w' x' ww)(*strict*)
  apply(erule_tac
      x="(prod_lhs e2) # ww"
      in meta_allE)
  apply(clarsimp)
  apply(simp add: liftA_commutes_over_concat)
  apply(subgoal_tac "LR1ProdForm (F_SDPDA_TO_CFG_STD G)")
   apply(rename_tac n w1 e1 e2 l' w' x' ww)(*strict*)
   prefer 2
   apply(rule_tac
      G="G"
      in sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
   apply(simp add: cfg_sub_def)
  apply(rename_tac n w1 e1 e2 l' w' x' ww)(*strict*)
  apply(simp add: LR1ProdForm_def)
  apply(erule_tac
      x="e2"
      in ballE)
   apply(rename_tac n w1 e1 e2 l' w' x' ww)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac n w1 e1 e2 l' w' x' ww)(*strict*)
  apply(erule disjE)
   apply(rename_tac n w1 e1 e2 l' w' x' ww)(*strict*)
   apply(clarsimp)
   apply(simp add: l3_l2_separation_ALT_def)
   apply(clarsimp)
   apply(case_tac "w'")
    apply(rename_tac n w1 e1 e2 l' w' x' ww)(*strict*)
    apply(clarsimp)
    apply(rename_tac n w1 e1 e2 l' x' ww)(*strict*)
    apply(case_tac x')
     apply(rename_tac n w1 e1 e2 l' x' ww q b)(*strict*)
     apply(clarsimp)
    apply(rename_tac n w1 e1 e2 l' x' ww q1 b q2)(*strict*)
    apply(clarsimp)
    apply(rename_tac n w1 e1 e2 l' ww q1 b q2)(*strict*)
    apply(case_tac ww)
     apply(rename_tac n w1 e1 e2 l' ww q1 b q2)(*strict*)
     apply(clarsimp)
     apply(rename_tac n w1 e1 e2 l' q1 b q2)(*strict*)
     apply (metis setA_liftB elemInsetA emptyE)
    apply(rename_tac n w1 e1 e2 l' ww q1 b q2 a list)(*strict*)
    apply(subgoal_tac "\<exists>w' x'. ww=w'@[x']")
     apply(rename_tac n w1 e1 e2 l' ww q1 b q2 a list)(*strict*)
     prefer 2
     apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
     apply(force)
    apply(rename_tac n w1 e1 e2 l' ww q1 b q2 a list)(*strict*)
    apply(thin_tac "ww=a#list")
    apply(clarsimp)
    apply(rename_tac n w1 e1 e2 l' q1 b q2 w' x')(*strict*)
    apply(simp add: liftA_commutes_over_concat)
    apply(clarsimp)
   apply(rename_tac n w1 e1 e2 l' w' x' ww a list)(*strict*)
   apply(subgoal_tac "w1=l'")
    apply(rename_tac n w1 e1 e2 l' w' x' ww a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 e2 l' x' ww a list)(*strict*)
    apply(subgoal_tac "ww=a#list@[x']")
     apply(rename_tac n e1 e2 l' x' ww a list)(*strict*)
     prefer 2
     apply(rule liftA_inj)
     apply(simp add: liftA_commutes_over_concat)
     apply(rule sym)
     apply(force)
    apply(rename_tac n e1 e2 l' x' ww a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 e2 l' w' x' ww a list)(*strict*)
   apply (metis setA_liftB liftA_append_tail liftA_vs_filterA setB_liftA liftB_liftA_split liftB_inj append_injr)
  apply(rename_tac n w1 e1 e2 l' w' x' ww)(*strict*)
  apply(clarsimp)
  apply(rename_tac n w1 e1 e2 l' w' x' ww b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac n w1 e1 e2 l' w' x' ww b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1)(*strict*)
   apply(simp add: l3_l2_separation_ALT_def)
   apply(clarsimp)
   apply(subgoal_tac "(\<forall>A\<in> set (butlast (w' @ [x'])). case A of cons_l2 q A \<Rightarrow> False | cons_l3 q1 b q2 \<Rightarrow> True) \<and> (case last (w' @ [x']) of cons_l2 qa b \<Rightarrow> True | cons_l3 q A q' \<Rightarrow> False)")
    apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1)(*strict*)
    apply(case_tac "w'@[x']")
     apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1)(*strict*)
     apply(force)
    apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1 a list)(*strict*)
    apply(force)
   apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1)(*strict*)
   apply(case_tac ww)
    apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1)(*strict*)
    apply(clarsimp)
    apply(rename_tac n w1 e1 l' w' b q1 q2 A1 x)(*strict*)
    apply(case_tac w')
     apply(rename_tac n w1 e1 l' w' b q1 q2 A1 x)(*strict*)
     apply(clarsimp)
    apply(rename_tac n w1 e1 l' w' b q1 q2 A1 x a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n w1 e1 l' b q1 q2 A1 x a list)(*strict*)
    apply(subgoal_tac "list=[]")
     apply(rename_tac n w1 e1 l' b q1 q2 A1 x a list)(*strict*)
     apply(clarsimp)
    apply(rename_tac n w1 e1 l' b q1 q2 A1 x a list)(*strict*)
    apply (metis setA_liftB liftA.simps(2) liftB_commute_one_elem_app elemInsetA equals0D)
   apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1 a list)(*strict*)
   apply(subgoal_tac "\<exists>w' x'. ww=w'@[x']")
    apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1 a list)(*strict*)
    prefer 2
    apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
    apply(force)
   apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 A1 a list)(*strict*)
   apply(thin_tac "ww=a#list")
   apply(clarsimp)
  apply(rename_tac n w1 e1 e2 l' w' x' ww b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac n w1 e1 e2 l' w' x' ww b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 q3 A1)(*strict*)
   apply(simp add: l3_l2_separation_ALT_def)
   apply(subgoal_tac "(\<forall>A\<in> set (butlast (w' @ [x'])). case A of cons_l2 q A \<Rightarrow> False | cons_l3 q1 b q2 \<Rightarrow> True) \<and> (case last (w' @ [x']) of cons_l2 qa b \<Rightarrow> True | cons_l3 q A q' \<Rightarrow> False)")
    apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 q3 A1)(*strict*)
    apply(case_tac w')
     apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 q3 A1)(*strict*)
     apply(clarsimp)
    apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 q3 A1 a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 q3 A1)(*strict*)
   apply(clarsimp)
   apply(case_tac ww)
    apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 q3 A1)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 q3 A1 a list)(*strict*)
   apply(subgoal_tac "\<exists>w' x'. ww=w'@[x']")
    apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 q3 A1 a list)(*strict*)
    prefer 2
    apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
    apply(force)
   apply(rename_tac n w1 e1 l' w' x' ww b q1 q2 q3 A1 a list)(*strict*)
   apply(thin_tac "ww=a#list")
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' b q1 q2 q3 A1 w'a x'a)(*strict*)
   apply(simp add: liftA_commutes_over_concat)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' b q1 q2 q3 A1 w'a x'a x)(*strict*)
   apply(case_tac x)
    apply(rename_tac n w1 e1 l' w' b q1 q2 q3 A1 w'a x'a x q ba)(*strict*)
    prefer 2
    apply(rename_tac n w1 e1 l' w' b q1 q2 q3 A1 w'a x'a x q1a ba q2a)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' b q1 q2 q3 A1 w'a x'a x q ba)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' b q1 q2 q3 A1 w'a x'a q ba)(*strict*)
   apply(subgoal_tac "w1=l'@[b]")
    apply(rename_tac n w1 e1 l' w' b q1 q2 q3 A1 w'a x'a q ba)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 l' w' b q1 q2 q3 A1 w'a x'a q ba)(*strict*)
    apply(simp add: liftB_commutes_over_concat)
    apply(case_tac w')
     apply(rename_tac n e1 l' w' b q1 q2 q3 A1 w'a x'a q ba)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 l' w' b q1 q2 q3 A1 w'a x'a q ba a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 l' b q1 q2 q3 A1 w'a x'a q ba list)(*strict*)
    apply(subgoal_tac "list=w'a")
     apply(rename_tac n e1 l' b q1 q2 q3 A1 w'a x'a q ba list)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 l' b q1 q2 q3 A1 w'a x'a q ba)(*strict*)
     apply(force)
    apply(rename_tac n e1 l' b q1 q2 q3 A1 w'a x'a q ba list)(*strict*)
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac n w1 e1 l' w' b q1 q2 q3 A1 w'a x'a q ba)(*strict*)
   apply(rule liftB_inj)
   apply(case_tac w')
    apply(rename_tac n w1 e1 l' w' b q1 q2 q3 A1 w'a x'a q ba)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' b q1 q2 q3 A1 w'a x'a q ba a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' b q1 q2 q3 A1 w'a x'a q ba a list)(*strict*)
   apply(rule terminal_prefix_eq)
       apply(rename_tac n w1 e1 l' b q1 q2 q3 A1 w'a x'a q ba a list)(*strict*)
       apply (simp add: setA_liftB)
      apply(rename_tac n w1 e1 l' b q1 q2 q3 A1 w'a x'a q ba a list)(*strict*)
      apply (simp add: setA_liftB)
     apply(rename_tac n w1 e1 l' b q1 q2 q3 A1 w'a x'a q ba a list)(*strict*)
     prefer 3
     apply(simp add: liftB_commutes_over_concat)
    apply(rename_tac n w1 e1 l' b q1 q2 q3 A1 w'a x'a q ba a list)(*strict*)
    apply(force)
   apply(rename_tac n w1 e1 l' b q1 q2 q3 A1 w'a x'a q ba a list)(*strict*)
   apply(force)
  apply(rename_tac n w1 e1 e2 l' w' x' ww b q1 q2 q3 q4 A1)(*strict*)
  apply(clarsimp)
  apply(rename_tac n w1 e1 e2 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac n w1 e1 e2 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 A1 A2)(*strict*)
   apply(simp add: l3_l2_separation_ALT_def)
   apply(subgoal_tac "(\<forall>A\<in> set (butlast (w' @ [x'])). case A of cons_l2 q A \<Rightarrow> False | cons_l3 q1 b q2 \<Rightarrow> True) \<and> (case last (w' @ [x']) of cons_l2 qa b \<Rightarrow> True | cons_l3 q A q' \<Rightarrow> False)")
    apply(rename_tac n w1 e1 l' w' x' ww q1 q2 A1 A2)(*strict*)
    apply(case_tac w')
     apply(rename_tac n w1 e1 l' w' x' ww q1 q2 A1 A2)(*strict*)
     apply(clarsimp)
    apply(rename_tac n w1 e1 l' w' x' ww q1 q2 A1 A2 a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 A1 A2)(*strict*)
   apply(clarsimp)
   apply(case_tac ww)
    apply(rename_tac n w1 e1 l' w' x' ww q1 q2 A1 A2)(*strict*)
    apply(clarsimp)
    apply(rename_tac n w1 e1 l' w' q1 q2 A1 A2 x)(*strict*)
    apply(case_tac x)
     apply(rename_tac n w1 e1 l' w' q1 q2 A1 A2 x q b)(*strict*)
     apply(clarsimp)
     apply(rename_tac n w1 e1 l' w' q1 q2 A1 A2 q b)(*strict*)
     apply(case_tac w')
      apply(rename_tac n w1 e1 l' w' q1 q2 A1 A2 q b)(*strict*)
      apply(clarsimp)
     apply(rename_tac n w1 e1 l' w' q1 q2 A1 A2 q b a list)(*strict*)
     apply(clarsimp)
     apply(rename_tac n w1 e1 l' q1 q2 A1 A2 q b a list)(*strict*)
     apply (metis setA_liftB liftA.simps(2) elemInsetA equals0D)
    apply(rename_tac n w1 e1 l' w' q1 q2 A1 A2 x q1a b q2a)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 A1 A2 a list)(*strict*)
   apply(subgoal_tac "\<exists>w' x'. ww=w'@[x']")
    apply(rename_tac n w1 e1 l' w' x' ww q1 q2 A1 A2 a list)(*strict*)
    prefer 2
    apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
    apply(force)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 A1 A2 a list)(*strict*)
   apply(thin_tac "ww=a#list")
   apply(clarsimp)
  apply(rename_tac n w1 e1 e2 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac n w1 e1 e2 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 A1 A2)(*strict*)
   apply(simp add: l3_l2_separation_ALT_def)
   apply(subgoal_tac "(\<forall>A\<in> set (butlast (w' @ [x'])). case A of cons_l2 q A \<Rightarrow> False | cons_l3 q1 b q2 \<Rightarrow> True) \<and> (case last (w' @ [x']) of cons_l2 qa b \<Rightarrow> True | cons_l3 q A q' \<Rightarrow> False)")
    apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 A1 A2)(*strict*)
    apply(case_tac w')
     apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 A1 A2)(*strict*)
     apply(clarsimp)
    apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 A1 A2 a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 A1 A2)(*strict*)
   apply(clarsimp)
   apply(case_tac ww)
    apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 A1 A2)(*strict*)
    apply(clarsimp)
    apply(rename_tac n w1 e1 l' w' q1 q2 q3 A1 A2 x)(*strict*)
    apply(case_tac x)
     apply(rename_tac n w1 e1 l' w' q1 q2 q3 A1 A2 x q b)(*strict*)
     apply(clarsimp)
     apply(rename_tac n w1 e1 l' w' q1 q2 q3 A1 A2 q b)(*strict*)
     apply(case_tac w')
      apply(rename_tac n w1 e1 l' w' q1 q2 q3 A1 A2 q b)(*strict*)
      apply(clarsimp)
     apply(rename_tac n w1 e1 l' w' q1 q2 q3 A1 A2 q b a list)(*strict*)
     apply(clarsimp)
     apply(rename_tac n w1 e1 l' q1 q2 q3 A1 A2 q b a list)(*strict*)
     apply(case_tac list)
      apply(rename_tac n w1 e1 l' q1 q2 q3 A1 A2 q b a list)(*strict*)
      apply(clarsimp)
     apply(rename_tac n w1 e1 l' q1 q2 q3 A1 A2 q b a list aa lista)(*strict*)
     apply(subgoal_tac "\<exists>w' x'. list=w'@[x']")
      apply(rename_tac n w1 e1 l' q1 q2 q3 A1 A2 q b a list aa lista)(*strict*)
      prefer 2
      apply(rule_tac
      n="length lista"
      in NonEmptyListHasTailElem)
      apply(force)
     apply(rename_tac n w1 e1 l' q1 q2 q3 A1 A2 q b a list aa lista)(*strict*)
     apply(thin_tac "list=aa#lista")
     apply(clarsimp)
     apply(rename_tac n w1 e1 l' q1 q2 q3 A1 A2 q b a w' x')(*strict*)
     apply(simp add: liftA_commutes_over_concat)
     apply(clarsimp)
     apply(rename_tac n w1 e1 l' q1 q2 q3 A1 A2 q b a w')(*strict*)
     apply (metis setA_liftB liftA.simps(2) elemInsetA equals0D)
    apply(rename_tac n w1 e1 l' w' q1 q2 q3 A1 A2 x q1a b q2a)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 A1 A2 a list)(*strict*)
   apply(subgoal_tac "\<exists>w' x'. ww=w'@[x']")
    apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 A1 A2 a list)(*strict*)
    prefer 2
    apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
    apply(force)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 A1 A2 a list)(*strict*)
   apply(thin_tac "ww=a#list")
   apply(clarsimp)
  apply(rename_tac n w1 e1 e2 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
  apply(simp add: l3_l2_separation_ALT_def)
  apply(subgoal_tac "(\<forall>A\<in> set (butlast (w' @ [x'])). case A of cons_l2 q A \<Rightarrow> False | cons_l3 q1 b q2 \<Rightarrow> True) \<and> (case last (w' @ [x']) of cons_l2 qa b \<Rightarrow> True | cons_l3 q A q' \<Rightarrow> False)")
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
   apply(case_tac w')
    apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 q4 A1 A2 a list)(*strict*)
   apply(clarsimp)
  apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(case_tac ww)
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
  apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 q4 A1 A2 a list)(*strict*)
  apply(subgoal_tac "\<exists>w' x'. ww=w'@[x']")
   apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 q4 A1 A2 a list)(*strict*)
   prefer 2
   apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
   apply(force)
  apply(rename_tac n w1 e1 l' w' x' ww q1 q2 q3 q4 A1 A2 a list)(*strict*)
  apply(thin_tac "ww=a#list")
  apply(clarsimp)
  apply(rename_tac n w1 e1 l' w' x' q1 q2 q3 q4 A1 A2 w'a x'a)(*strict*)
  apply(simp add: liftA_commutes_over_concat)
  apply(clarsimp)
  apply(rename_tac n w1 e1 l' w' q1 q2 q3 q4 A1 A2 w'a x'a x)(*strict*)
  apply(case_tac x)
   apply(rename_tac n w1 e1 l' w' q1 q2 q3 q4 A1 A2 w'a x'a x q b)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' q1 q2 q3 q4 A1 A2 w'a x'a q b)(*strict*)
   apply(case_tac w')
    apply(rename_tac n w1 e1 l' w' q1 q2 q3 q4 A1 A2 w'a x'a q b)(*strict*)
    apply(clarsimp)
   apply(rename_tac n w1 e1 l' w' q1 q2 q3 q4 A1 A2 w'a x'a q b a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n w1 e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b a list)(*strict*)
   apply(subgoal_tac "w1=l'")
    apply(rename_tac n w1 e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b list)(*strict*)
    apply(case_tac list)
     apply(rename_tac n e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b list)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b list a lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b lista)(*strict*)
    apply(subgoal_tac "lista=w'a")
     apply(rename_tac n e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b lista)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b)(*strict*)
     apply(force)
    apply(rename_tac n e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b lista)(*strict*)
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac n w1 e1 l' q1 q2 q3 q4 A1 A2 w'a x'a q b a list)(*strict*)
   apply(rule_tac ?w1.0="w1" in leading_liftB_prefix_eq)
   apply(force)
  apply(rename_tac n w1 e1 l' w' q1 q2 q3 q4 A1 A2 w'a x'a x q1a b q2a)(*strict*)
  apply(clarsimp)
  done

lemma epdaH_all_stack_elements_pushed_or_box: "
  valid_simple_dpda G
  \<Longrightarrow> epdaH.derivation_initial G d
  \<Longrightarrow> d i = Some (pair e c)
  \<Longrightarrow> set (epdaH_conf_stack c) \<subseteq> F_SDPDA_TO_CFG_OPT__pushed_symbols G \<union> {epda_box G}"
  apply(induct i arbitrary: e c)
   apply(rename_tac e c)(*strict*)
   apply(clarsimp)
   apply(rename_tac e c x)(*strict*)
   apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def)
  apply(rename_tac i e c)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e c x)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac i e c x)(*strict*)
   prefer 2
   apply(rule_tac
      d="d" and
      n="i" and
      m="Suc i"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac i e c x)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac i e c x)(*strict*)
    apply(force)
   apply(rename_tac i e c x)(*strict*)
   apply(force)
  apply(rename_tac i e c x)(*strict*)
  apply(clarsimp)
  apply(rename_tac i c x e1 e2 c1)(*strict*)
  apply(simp add: epdaH_step_relation_def)
  apply(clarsimp)
  apply(rename_tac i c x e1 e2 c1 w)(*strict*)
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
  apply(clarsimp)
  apply(erule_tac x="e2" in ballE)
   apply(rename_tac i c x e1 e2 c1 w)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac i c x e1 e2 c1 w)(*strict*)
  apply(erule_tac x="e2" in ballE)
   apply(rename_tac i c x e1 e2 c1 w)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac i c x e1 e2 c1 w)(*strict*)
  apply(erule_tac x="e1" in meta_allE)
  apply(erule_tac x="c1" in meta_allE)
  apply(clarsimp)
  apply(case_tac e2)
  apply(rename_tac i c x e1 e2 c1 w edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac q r po pu q')
  apply(rename_tac i c x e1 e2 c1 w q r po pu q')(*strict*)
  apply(clarsimp)
  apply(rename_tac i c x e1 c1 w r po pu)(*strict*)
  apply(case_tac r)
   apply(rename_tac i c x e1 c1 w r po pu)(*strict*)
   apply(clarsimp)
   apply(rename_tac i c x e1 c1 w po pu)(*strict*)
   apply(case_tac po)
    apply(rename_tac i c x e1 c1 w po pu)(*strict*)
    apply(clarsimp)
   apply(rename_tac i c x e1 c1 w po pu a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac i c x e1 c1 w pu a)(*strict*)
   apply(case_tac pu)
    apply(rename_tac i c x e1 c1 w pu a)(*strict*)
    apply(clarsimp)
    apply(rename_tac i c x e1 c1 a)(*strict*)
    apply(force)
   apply(rename_tac i c x e1 c1 w pu a aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac i c x e1 c1 w a aa)(*strict*)
   apply(erule disjE)
    apply(rename_tac i c x e1 c1 w a aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac i c e1 c1 w a aa)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_OPT__pushed_symbols_def)
    apply(erule_tac x="a" in allE)
    apply(erule_tac x="\<lparr>edge_src = epdaH_conf_state c1, edge_event = None, edge_pop = [a],
          edge_push = [aa, a], edge_trg = epdaH_conf_state c\<rparr>" in allE)
    apply(clarsimp)
   apply(rename_tac i c x e1 c1 w a aa)(*strict*)
   apply(force)
  apply(rename_tac i c x e1 c1 w r po pu a)(*strict*)
  apply(clarsimp)
  apply(rename_tac i c x e1 c1 w pu a)(*strict*)
  apply(force)
  done

definition F_EPDA_AIA__fp_computed_stack_approximation2 :: "
  (('state, 'event, 'stack) epda_step_label, ('state, 'event, 'stack) epdaH_conf) derivation
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> nat"
  where
    "F_EPDA_AIA__fp_computed_stack_approximation2 d n i j k \<equiv>
  foldl (\<lambda>n e. min k (n - length (edge_pop e) + length (edge_push e))) n (map (\<lambda>i. the (get_label (d i))) (nat_seq (Suc i) j))"

definition F_EPDA_AIA__fp_computed_stack_approximation4 :: "
  (('state, 'event, 'stack) epda_step_label, ('state, 'event, 'stack) epdaH_conf) derivation
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> nat"
  where
    "F_EPDA_AIA__fp_computed_stack_approximation4 d i j k \<equiv>
  F_EPDA_AIA__fp_computed_stack_approximation2 d (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i (i + j) k"

definition F_EPDA_AIA__fp_computed_stack_approximation3 :: "
  (('state, 'event, 'stack) epda_step_label, ('state, 'event, 'stack) epdaH_conf) derivation
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> 'stack list
  \<Rightarrow> 'stack list"
  where
    "F_EPDA_AIA__fp_computed_stack_approximation3 d i j k w \<equiv>
  take (F_EPDA_AIA__fp_computed_stack_approximation4 d i j k) w"

definition F_EPDA_AIA__fp_computed_stack_approximationX :: "
  (('state, 'event, 'stack) epda_step_label, ('state, 'event, 'stack) epdaH_conf) derivation
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> nat option"
  where
    "F_EPDA_AIA__fp_computed_stack_approximationX d i j k \<equiv>
  foldl (%n (m,
  c,
  e) . case n of None
  \<Rightarrow> None
  | Some n
  \<Rightarrow> ( case edge_event e of Some a
  \<Rightarrow> Some n
  | None
  \<Rightarrow> (case edge_push e of []
  \<Rightarrow> Some (n - Suc 0)
  | _
  \<Rightarrow> if n = k
  then None
  else Some (Suc n)) )) (Some (Suc 0)) (map (%i. (F_EPDA_AIA__fp_computed_stack_approximation d (i - Suc 0) k,
  the (get_configuration (d (i - Suc 0))),
  the (get_label (d i)))) (nat_seq (Suc i) j))"

lemma finite_F_SDPDA_TO_CFG_OPT__step_closure__fp: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k S
  \<Longrightarrow> finite (F_SDPDA_TO_CFG_OPT__step_closure__fp G S k)"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_preserves_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST)
   apply(force)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
  apply(rule_tac B="all_state_stack_str3 G k" in finite_subset)
   apply(force)
  apply(rule finite_all_state_stack_str3)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
  done

lemma nat_seq_drop_last_simp2: "
  n \<le> Suc m
  \<Longrightarrow> nat_seq n (Suc m) = nat_seq n m @ [Suc m]"
  apply(case_tac "n\<le>m")
   apply(rule nat_seq_drop_last_simp)
   apply(force)
  apply(subgoal_tac "n=Suc m")
   prefer 2
   apply(force)
  apply(clarsimp)
  apply(simp add: nat_seqEmpty natUptTo_n_n)
  done

definition l3_derivation_MAX :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> (('state, 'event, 'stack) epda_step_label, ('state, 'event, 'stack) epdaH_conf) derivation
  \<Rightarrow> 'stack list
  \<Rightarrow> 'state
  \<Rightarrow> 'stack
  \<Rightarrow> 'state
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> bool"
  where
    "l3_derivation_MAX G d w q A q' i j \<equiv>
  \<exists>e1 c1 e2 c2. epdaH.derivation_initial G d
  \<and> d i = Some (pair e1 c1)
  \<and> epdaH_conf_state c1 = q
  \<and> d (i + Suc j) = Some (pair e2 c2)
  \<and> epdaH_conf_state c2 = q'
  \<and> epdaH_conf_stack c1 = A # w
  \<and> (case e1 of None
  \<Rightarrow> True
  | Some e1'
  \<Rightarrow> \<exists>X. edge_push e1' = [A,
  X])
  \<and> (\<forall>k \<le> j. \<forall>e c. d (i + k) = Some (pair e c) \<longrightarrow> suffix (epdaH_conf_stack c) (A # w))
  \<and> epdaH_conf_stack c2 = w"

lemma locale_help: "
  \<forall>i \<le> k. P1 i
  \<Longrightarrow> \<forall>i \<le> k. R1 i
  \<Longrightarrow> \<forall>i < k. Q1 i
  \<Longrightarrow> (\<forall>i \<le> k. P1 i \<longrightarrow> P2 i)
  \<Longrightarrow> (\<forall>i \<le> k. R1 i \<longrightarrow> R2 i)
  \<Longrightarrow> (\<forall>i < k. Q1 i \<longrightarrow> Q2 i)
  \<Longrightarrow> P2 (Suc k) \<and> R2 (Suc k) \<and> Q2 k
  \<Longrightarrow> (\<forall>i \<le> Suc k. P2 i) \<and> (\<forall>i \<le> Suc k. R2 i) \<and> (\<forall>i < Suc k. Q2 i)"
  apply(rule conjI)
   apply(clarsimp)
   apply(rename_tac i)(*strict*)
   apply(case_tac "i=Suc k")
    apply(rename_tac i)(*strict*)
    apply(clarsimp)
   apply(rename_tac i)(*strict*)
   apply(clarsimp)
  apply(clarsimp)
  apply(rule conjI)
   apply(clarsimp)
   apply(rename_tac i)(*strict*)
   apply(case_tac "i=Suc k")
    apply(rename_tac i)(*strict*)
    apply(clarsimp)
   apply(rename_tac i)(*strict*)
   apply(clarsimp)
  apply(clarsimp)
  apply(rename_tac i)(*strict*)
  apply(case_tac "i=k")
   apply(rename_tac i)(*strict*)
   apply(force)
  apply(rename_tac i)(*strict*)
  apply(force)
  done

lemma F_EPDA_AIA__fp_computed_stack_approximation2_unfold: "
  d (Suc (i + j)) = Some (pair (Some e) c)
  \<Longrightarrow> edge_pop e = po
  \<Longrightarrow> edge_push e = pu
  \<Longrightarrow> F_EPDA_AIA__fp_computed_stack_approximation2 d n i (Suc (i + j)) k = min k (F_EPDA_AIA__fp_computed_stack_approximation2 d n i (i + j) k - length po + length pu)"
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation2_def)
  apply(subgoal_tac "(nat_seq (Suc (i)) (Suc((i + j)))) = SSX" for SSX)
   prefer 2
   apply(rule nat_seq_drop_last_simp2)
   apply(force)
  apply(clarsimp)
  apply(simp add: get_label_def)
  done

lemma F_EPDA_AIA__fp_computed_stack_approximationX_unfold: "
  d (Suc (i + j)) = Some (pair (Some e) c)
  \<Longrightarrow> edge_pop e = po
  \<Longrightarrow> edge_push e = pu
  \<Longrightarrow> X = Suc (i + j)
  \<Longrightarrow> F_EPDA_AIA__fp_computed_stack_approximationX d i X k = (case (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + j) k) of None \<Rightarrow> None | Some n \<Rightarrow> case edge_event e of None \<Rightarrow> case edge_push e of [] \<Rightarrow> Some (n - Suc 0) | a # list \<Rightarrow> if n = k then None else Some (Suc n) | Some a \<Rightarrow> Some n)"
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def)
  apply(subgoal_tac "(nat_seq (Suc (i)) (Suc((i + j)))) = SSX" for SSX)
   prefer 2
   apply(rule nat_seq_drop_last_simp2)
   apply(force)
  apply(clarsimp)
  apply(simp add: get_label_def)
  apply(case_tac "foldl (\<lambda>n (m, c, e).
                    case n of None \<Rightarrow> None
                    | Some n \<Rightarrow>
                        case edge_event e of
                        None \<Rightarrow>
                          case edge_push e of [] \<Rightarrow> Some (n - Suc 0)
                          | a # list \<Rightarrow> if n = k then None else Some (Suc n)
                        | Some a \<Rightarrow> Some n)
           (Some (Suc 0))
           (map (\<lambda>i. (F_EPDA_AIA__fp_computed_stack_approximation d (i - Suc 0) k,
                       the (get_configuration (d (i - Suc 0))),
                       the (case d i of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> e)))
             (nat_seq (Suc i) (i + j)))")
   apply(clarsimp)
  apply(rename_tac a)(*strict*)
  apply(clarsimp)
  apply(simp add: get_label_def)
  apply(case_tac "edge_event e")
   apply(rename_tac a)(*strict*)
   apply(clarsimp)
   apply(simp add: get_label_def)
  apply(rename_tac a aa)(*strict*)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_one_mono2: "
  S1 \<subseteq> S2
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G S1 k \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G S2 k"
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule conjI)
   apply(force)
  apply(rule conjI)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__read__exists__greater_than_0 G S2" in subset_trans)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__read__exists__greater_than_0_def)
    apply(force)
   apply(clarsimp)
  apply(rule conjI)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__read__not_exists__none G S2" in subset_trans)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__read__not_exists__none_def)
    apply(force)
   apply(clarsimp)
  apply(rule conjI)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__greater_than_0 G S2" in subset_trans)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__greater_than_0_def)
    apply(force)
   apply(clarsimp)
  apply(rule conjI)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__none G S2" in subset_trans)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__none_def)
    apply(force)
   apply(clarsimp)
  apply(rule conjI)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__pop__not_exists__none G S2" in subset_trans)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__not_exists__none_def)
    apply(force)
   apply(clarsimp)
  apply(rule conjI)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__push__exists__none G k S2" in subset_trans)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__none_def)
    apply(force)
   apply(clarsimp)
  apply(rule conjI)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__push__not_exists__none G k S2" in subset_trans)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__not_exists__none_def)
    apply(force)
   apply(clarsimp)
  apply(rule conjI)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__push__exists__less_than_k G k S2" in subset_trans)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__less_than_k_def)
    apply(force)
   apply(clarsimp)
  apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__push__exists__k G k S2" in subset_trans)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__k_def)
   apply(force)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_intro1_hlp: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_one Ga Sa ka = Sa
  \<Longrightarrow> e \<in> Sa
  \<Longrightarrow> x \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one Ga {e} ka
  \<Longrightarrow> x \<in> Sa"
  apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_one Ga {e} ka \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp_one Ga Sa ka")
   apply(force)
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_one_mono2)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_intro1: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k S
  \<Longrightarrow> e \<in> S
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e} k \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G S k"
  apply(rule_tac P="e\<in> S" and Q="F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e} k \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G S k" in impE)
    prefer 2
    apply(force)
   prefer 2
   apply(force)
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_Meta_Lift_prime)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(clarsimp)
   apply(rename_tac Ga ka N x)(*strict*)
   apply(erule impE)
    apply(rename_tac Ga ka N x)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac Ga ka N x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rename_tac Ga ka N)(*strict*)
  apply(clarsimp)
  apply(rename_tac Ga ka N x)(*strict*)
  apply(rule_tac ?x.0="Ga" in F_SDPDA_TO_CFG_OPT__step_closure__fp.pelims)
    apply(rename_tac Ga ka N x)(*strict*)
    apply(force)
   apply(rename_tac Ga ka N x)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termination)
   apply(force)
  apply(rename_tac Ga ka N x Gaa Sa kaa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x Ga Sa ka)(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_intro1_hlp)
    apply(rename_tac x Ga Sa ka)(*strict*)
    apply(force)
   apply(rename_tac x Ga Sa ka)(*strict*)
   apply(force)
  apply(rename_tac x Ga Sa ka)(*strict*)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__l2_init_in_all_state_stack_str3: "
  F_EPDA_AIA__fp_valid_input G k S
  \<Longrightarrow> k > 0
  \<Longrightarrow> A \<in> epda_gamma G
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__l2_init G A S \<subseteq> all_state_stack_str3 G k"
  apply(simp add: F_EPDA_AIA__fp_valid_input_def F_SDPDA_TO_CFG_OPT__step_closure__l2_init_def all_state_stack_str3_def)
  apply(clarsimp)
  apply(rename_tac q w v)(*strict*)
  apply(simp add: all_state_stack_str2_def)
  apply(subgoal_tac "cons_tuple2 q w \<in> F_EPDA_AIA__codom G k")
   apply(rename_tac q w v)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac q w v)(*strict*)
  apply(thin_tac "S \<subseteq> X" for X)
  apply(thin_tac "X \<in> S" for X)
  apply(thin_tac "X \<in> S" for X)
  apply(simp add: F_EPDA_AIA__codom_def)
  apply(erule disjE)
   apply(rename_tac q w v)(*strict*)
   apply(erule disjE)
    apply(rename_tac q w v)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_start_def)
    apply(clarsimp)
    apply(simp add: valid_epda_def)
    apply(erule_tac x="[epda_box G]" in allE)
    apply(clarsimp)
   apply(rename_tac q w v)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_start_def)
   apply(clarsimp)
  apply(rename_tac q w v)(*strict*)
  apply(simp add: valid_epda_def)
  apply(erule disjE)
   apply(rename_tac q w v)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_start_def)
  apply(rename_tac q w v)(*strict*)
  apply(clarsimp)
  apply(rename_tac q s)(*strict*)
  apply(erule_tac x="[A]" in allE)
  apply(simp add: F_EPDA_AIA__fp_start_def)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__l2_init_satisfies_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST: "
  F_EPDA_AIA__fp_valid_input G k S
  \<Longrightarrow> k > 0
  \<Longrightarrow> A \<in> epda_gamma G
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G A S)"
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def F_EPDA_AIA__fp_valid_input_def)
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l2_init_in_all_state_stack_str3)
    apply(simp add: F_EPDA_AIA__fp_valid_input_def)
   apply(force)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_intro2: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k S
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e'} k \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G S k
  \<Longrightarrow> e \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e'} k
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e} k \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G S k"
  apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e'} k \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G S k
  \<longrightarrow> e \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e'} k
  \<longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e} k \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G S k")
   apply(force)
  apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e'} k \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G S k")
  apply(thin_tac "e \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {e'} k")
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_Meta_Lift_prime)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(clarsimp)
  apply(rename_tac Ga ka N)(*strict*)
  apply(clarsimp)
  apply(rename_tac Ga ka N x)(*strict*)
  apply(rule_tac ?x.0="Ga" in F_SDPDA_TO_CFG_OPT__step_closure__fp.pelims)
    apply(rename_tac Ga ka N x)(*strict*)
    apply(force)
   apply(rename_tac Ga ka N x)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termination)
   apply(force)
  apply(rename_tac Ga ka N x Gaa Sa kaa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x Ga Sa ka)(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_intro1_hlp)
    apply(rename_tac x Ga Sa ka)(*strict*)
    apply(force)
   apply(rename_tac x Ga Sa ka)(*strict*)
   apply(force)
  apply(rename_tac x Ga Sa ka)(*strict*)
  apply(force)
  done

lemma nth_with_last_and_map_and_Some: "
  (a # (map Some v) @ w) ! length v = last (a # map Some v)"
  apply(rule_tac xs="v" in rev_cases)
   apply(clarsimp)
  apply(rename_tac ys y)(*strict*)
  apply(clarsimp)
  apply (metis length_map_Some nth_append_length)
  done

lemma F_EPDA_AIA__fp_computed_stack_approximationX_smaller_equal_k: "
  F_EPDA_AIA__fp_computed_stack_approximationX d i j k = Some n
  \<Longrightarrow> k > 0
  \<Longrightarrow> n \<le> k"
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def)
  apply(induct j arbitrary: n)
   apply(rename_tac n)(*strict*)
   apply(simp add: nat_seqEmpty)
  apply(rename_tac j n)(*strict*)
  apply(clarsimp)
  apply(case_tac "j<i")
   apply(rename_tac j n)(*strict*)
   apply(simp add: nat_seqEmpty)
  apply(rename_tac j n)(*strict*)
  apply(case_tac "i=j")
   apply(rename_tac j n)(*strict*)
   apply(clarsimp)
   apply(rename_tac n)(*strict*)
   apply(simp add: nat_seqEmpty)
   apply(simp add: natUptTo_n_n)
   apply(case_tac "edge_event (the (get_label (d (Suc i))))")
    apply(rename_tac n)(*strict*)
    apply(clarsimp)
    apply(case_tac "edge_push (the (get_label (d (Suc i))))")
     apply(rename_tac n)(*strict*)
     apply(force)
    apply(rename_tac n a list)(*strict*)
    apply(clarsimp)
    apply(case_tac "Suc 0=k")
     apply(rename_tac n a list)(*strict*)
     apply(clarify)
     apply(force)
    apply(rename_tac n a list)(*strict*)
    apply(force)
   apply(rename_tac n a)(*strict*)
   apply(force)
  apply(rename_tac j n)(*strict*)
  apply(subgoal_tac "i<j")
   apply(rename_tac j n)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac j n)(*strict*)
  apply(subgoal_tac "\<exists>k. i+Suc k=j")
   apply(rename_tac j n)(*strict*)
   prefer 2
   apply(rule_tac x="j-i-Suc 0" in exI)
   apply(force)
  apply(rename_tac j n)(*strict*)
  apply(clarsimp)
  apply(rename_tac n ka)(*strict*)
  apply(subgoal_tac "nat_seq (Suc i) (Suc (Suc (i + ka))) = SSX" for SSX)
   apply(rename_tac n ka)(*strict*)
   prefer 2
   apply(rule nat_seq_drop_last_simp2)
   apply(force)
  apply(rename_tac n ka)(*strict*)
  apply(clarsimp)
  apply(case_tac "foldl
              (\<lambda>n (m, c, e).
                  case n of None \<Rightarrow> None
                  | Some n \<Rightarrow>
                      case edge_event e of
                      None \<Rightarrow>
                        case edge_push e of [] \<Rightarrow> Some (n - Suc 0)
                        | a # list \<Rightarrow> if n = k then None else Some (Suc n)
                      | Some a \<Rightarrow> Some n)
              (Some (Suc 0))
              (map (\<lambda>i. (F_EPDA_AIA__fp_computed_stack_approximation d (i - Suc 0) k,
                         the (get_configuration (d (i - Suc 0))),
                         the (get_label (d i))))
                (nat_seq (Suc i) (Suc (i + ka))))")
   apply(rename_tac n ka)(*strict*)
   apply(force)
  apply(rename_tac n ka a)(*strict*)
  apply(clarsimp)
  apply(erule_tac x="a" in meta_allE)
  apply(clarsimp)
  apply(case_tac "edge_event (the (get_label (d (Suc (Suc (i + ka))))))")
   apply(rename_tac n ka a)(*strict*)
   apply(clarsimp)
   apply(case_tac "edge_push (the (get_label (d (Suc (Suc (i + ka))))))")
    apply(rename_tac n ka a)(*strict*)
    apply(clarsimp)
    apply(rename_tac ka a)(*strict*)
    apply(case_tac a)
     apply(rename_tac ka a)(*strict*)
     apply(force)
    apply(rename_tac ka a nat)(*strict*)
    apply(force)
   apply(rename_tac n ka a aa list)(*strict*)
   apply(clarsimp)
   apply(case_tac "a=k")
    apply(rename_tac n ka a aa list)(*strict*)
    apply(force)
   apply(rename_tac n ka a aa list)(*strict*)
   apply(force)
  apply(rename_tac n ka a aa)(*strict*)
  apply(clarsimp)
  done

lemma L2Closure_strong_dependency: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> epdaH.derivation_initial G d
  \<Longrightarrow> d i = Some (pair e \<lparr>epdaH_conf_state = q, epdaH_conf_history = h, epdaH_conf_stack = s @ [epda_box G]\<rparr>)
  \<Longrightarrow> d (i + j) = Some (pair e' \<lparr>epdaH_conf_state = q', epdaH_conf_history = h', epdaH_conf_stack = s'\<rparr>)
  \<Longrightarrow> \<forall>k \<le> j. \<exists>c. epdaH_conf_stack (the (get_configuration (d (i + k)))) = c @ s @ [epda_box G]
  \<Longrightarrow> \<exists>\<xi>. length \<xi> = Suc j \<and> cons_tuple2 None (Some (\<xi> ! 0)) \<in> F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G])) (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}) \<and> (\<forall>ki \<le> j. (\<exists>q' w' n'. \<xi> ! ki = cons_tuple3 q' w' n' \<and> q' = epdaH_conf_state (the (get_configuration (d (i + ki)))) \<and> w' = F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k (epdaH_conf_stack (the (get_configuration (d (i + ki))))) \<and> n' = (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k) \<and> F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k \<le> k \<and> F_EPDA_AIA__fp_computed_stack_approximation d (i + ki) k \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k \<and> (case n' of None \<Rightarrow> True | Some y \<Rightarrow> y > 0 \<and> (F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k) \<ge> y))) \<and> (\<forall>ki \<le> j. case sel_tuple3_3 (\<xi> ! ki) of Some (Suc n) \<Rightarrow> \<exists>w. length w = n \<and> w @ epdaH_conf_stack (the (get_configuration (d (i)))) = epdaH_conf_stack (the (get_configuration (d (i + ki)))) | Some 0 \<Rightarrow> False | None \<Rightarrow> True) \<and> (\<forall>ki \<xi>'. \<xi>' = None # map Some \<xi> \<longrightarrow> Suc (Suc ki) < length \<xi>' \<longrightarrow> cons_tuple2 (\<xi>' ! Suc ki) (\<xi>' ! Suc (Suc ki)) \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {cons_tuple2 (\<xi>' ! ki) (\<xi>' ! Suc ki) } k \<and> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {cons_tuple2 (\<xi>' ! ki) (\<xi>' ! Suc ki) } k \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G])) (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k})) k)"
  apply(subgoal_tac "\<lparr>epdaH_conf_state = q, epdaH_conf_history = h,
                   epdaH_conf_stack = s @ [epda_box G]\<rparr> \<in> epdaH_configurations G")
   prefer 2
   apply(rule epdaH.belongs_configurations)
    apply(rule epdaH.derivation_initial_belongs)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(force)
   apply(force)
  apply(subgoal_tac "F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k} \<subseteq> F_EPDA_AIA__codom G k")
   prefer 2
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule_tac k="k" in F_EPDA_AIA__fp_preserves_F_EPDA_AIA__fp_valid_input)
    apply(rule F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(force)
   apply(simp add: F_EPDA_AIA__fp_valid_input_def)
  apply(subgoal_tac "finite
          (F_SDPDA_TO_CFG_OPT__step_closure__fp G
            (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G]))
              (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
            k)")
   prefer 2
   apply(rule finite_F_SDPDA_TO_CFG_OPT__step_closure__fp)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
   apply(rule conjI)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l2_init_in_all_state_stack_str3_simp)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
     apply(force)
    apply(force)
   apply(simp add: epdaH_configurations_def)
   apply(case_tac s)
    apply(force)
   apply(rename_tac a list)(*strict*)
   apply(force)
  apply(induct j arbitrary: e' q' h' s')
   apply(rename_tac e' q' h' s')(*strict*)
   apply(clarsimp)
   apply(rename_tac c)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac c)(*strict*)
    prefer 2
    apply(rule_tac M="G" and g="d" and n="0" in epdaH.pre_some_position_is_some_position)
      apply(rename_tac c)(*strict*)
      apply(simp add: epdaH.derivation_initial_def)
     apply(rename_tac c)(*strict*)
     apply(force)
    apply(rename_tac c)(*strict*)
    apply(force)
   apply(rename_tac c)(*strict*)
   apply(clarsimp)
   apply(rename_tac c ea ca)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac c ea ca)(*strict*)
    prefer 2
    apply(rule_tac i="0" and j="i" in F_EPDA_AIA__fp_strong_dependency)
        apply(rename_tac c ea ca)(*strict*)
        apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
        apply(force)
       apply(rename_tac c ea ca)(*strict*)
       apply(force)
      apply(rename_tac c ea ca)(*strict*)
      apply(force)
     apply(rename_tac c ea ca)(*strict*)
     apply(force)
    apply(rename_tac c ea ca)(*strict*)
    apply(force)
   apply(rename_tac c ea ca)(*strict*)
   apply(clarsimp)
   apply(rename_tac c ea ca w)(*strict*)
   apply(simp add: get_configuration_def)
   apply(erule_tac x="i" in allE)
   apply(clarsimp)
   apply(rename_tac ea ca w)(*strict*)
   apply(rule_tac x="[cons_tuple3 q
                  (take (F_EPDA_AIA__fp_computed_stack_approximation2 d
                          (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i i k)
                    s @
                   take (F_EPDA_AIA__fp_computed_stack_approximation2 d
                          (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i i k -
                         length s)
                    [epda_box G]) (Some(Suc 0))]" in exI)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac ea ca w)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__l2_init_def)
    apply(rule_tac x="(take (F_EPDA_AIA__fp_computed_stack_approximation d i k) s @
         take (F_EPDA_AIA__fp_computed_stack_approximation d i k - length s) [epda_box G])" in exI)
    apply(rule conjI)
     apply(rename_tac ea ca w)(*strict*)
     apply(rule_tac A="set w" in set_mp)
      apply(rename_tac ea ca w)(*strict*)
      apply(force)
     apply(rename_tac ea ca w)(*strict*)
     apply(rule_tac t="cons_tuple2 q
        (take (F_EPDA_AIA__fp_computed_stack_approximation d i k) s @
         take (F_EPDA_AIA__fp_computed_stack_approximation d i k - length s) [epda_box G])" and s="w!i" in ssubst)
      apply(rename_tac ea ca w)(*strict*)
      apply(force)
     apply(rename_tac ea ca w)(*strict*)
     apply(rule nth_mem)
     apply(force)
    apply(rename_tac ea ca w)(*strict*)
    apply(rule_tac t="F_EPDA_AIA__fp_computed_stack_approximation2 d
              (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i i k" and s="max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)" in ssubst)
     apply(rename_tac ea ca w)(*strict*)
     apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation2_def F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
    apply(rename_tac ea ca w)(*strict*)
    apply(case_tac s)
     apply(rename_tac ea ca w)(*strict*)
     apply(clarsimp)
     apply(simp add: prefix_def)
    apply(rename_tac ea ca w a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac a s)
    apply(rename_tac ea ca w a s)(*strict*)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d i k")
     apply(rename_tac ea ca w a s)(*strict*)
     apply(clarsimp)
    apply(rename_tac ea ca w a s nat)(*strict*)
    apply(clarsimp)
    apply(simp add: prefix_def)
   apply(rename_tac ea ca w)(*strict*)
   apply(rule conjI)
    apply(rename_tac ea ca w)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation2_def F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def F_EPDA_AIA__fp_computed_stack_approximation3_def F_EPDA_AIA__fp_computed_stack_approximation4_def)
   apply(rename_tac ea ca w)(*strict*)
   apply(rule conjI)
    apply(rename_tac ea ca w)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation2_def F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def F_EPDA_AIA__fp_computed_stack_approximation3_def F_EPDA_AIA__fp_computed_stack_approximation4_def)
   apply(rename_tac ea ca w)(*strict*)
   apply(rule_tac t="F_EPDA_AIA__fp_computed_stack_approximationX d i i k" and s="Some (Suc 0)" in ssubst)
    apply(rename_tac ea ca w)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation2_def F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
   apply(rename_tac ea ca w)(*strict*)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac ea ca w)(*strict*)
    prefer 2
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation2_def F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def F_EPDA_AIA__fp_computed_stack_approximation3_def F_EPDA_AIA__fp_computed_stack_approximation4_def)
   apply(rename_tac ea ca w)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def F_EPDA_AIA__fp_computed_stack_approximation2_def)
   apply(simp add: nat_seqEmpty)
   apply(case_tac i)
    apply(rename_tac ea ca w)(*strict*)
    apply(clarsimp)
   apply(rename_tac ea ca w nat)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    apply(rename_tac ea ca w nat)(*strict*)
    prefer 2
    apply(rule_tac
      n="nat"
      and m="Suc nat"
      in epdaH.step_detail_before_some_position)
      apply(rename_tac ea ca w nat)(*strict*)
      apply(rule epdaH.derivation_initial_is_derivation)
      apply(force)
     apply(rename_tac ea ca w nat)(*strict*)
     apply(force)
    apply(rename_tac ea ca w nat)(*strict*)
    apply(force)
   apply(rename_tac ea ca w nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac e ca w nat e1 e2 c1)(*strict*)
   apply(rule F_EPDA_AIA__fp_computed_stack_approximation_smaller_than_k)
     apply(rename_tac e ca w nat e1 e2 c1)(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
     apply(force)
    apply(rename_tac e ca w nat e1 e2 c1)(*strict*)
    apply(force)
   apply(rename_tac e ca w nat e1 e2 c1)(*strict*)
   apply(force)
  apply(rename_tac j e' q' h' s')(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   apply(rename_tac j e' q' h' s')(*strict*)
   prefer 2
   apply(rule_tac
      n="i+j"
      and m="Suc (i+j)"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac j e' q' h' s')(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac j e' q' h' s')(*strict*)
    apply(force)
   apply(rename_tac j e' q' h' s')(*strict*)
   apply(force)
  apply(rename_tac j e' q' h' s')(*strict*)
  apply(clarsimp)
  apply(rename_tac j q' h' s' e1 e2 c1)(*strict*)
  apply(simp add: epdaH_step_relation_def)
  apply(clarsimp)
  apply(rename_tac j e1 e2 c1 w)(*strict*)
  apply(erule_tac x="e1" in meta_allE)
  apply(case_tac c1)
  apply(rename_tac j e1 e2 c1 w epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac q1 h1 s1)
  apply(rename_tac j e1 e2 c1 w q1 h1 s1)(*strict*)
  apply(erule_tac x="q1" in meta_allE)
  apply(erule_tac x="h1" in meta_allE)
  apply(erule_tac x="s1" in meta_allE)
  apply(clarsimp)
  apply(rename_tac j e1 e2 w h1 \<xi>)(*strict*)
  apply(case_tac e2)
  apply(rename_tac j e1 e2 w h1 \<xi> edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac qs r po pu qt)
  apply(rename_tac j e1 e2 w h1 \<xi> qs r po pu qt)(*strict*)
  apply(clarsimp)
  apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
  apply(rule_tac x="\<xi>@[cons_tuple3 (epdaH_conf_state (the (get_configuration (d (i + (Suc j))))))
                (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc j) k
                  (epdaH_conf_stack (the (get_configuration (d (i + (Suc j)))))))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + (Suc j)) k)]" in exI)
  apply(clarsimp)
  apply(simp add: get_configuration_def)
  apply(rule_tac t="(\<xi> @ [cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc j) k (pu @ w))
                      (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + j)) k)]) !
               0"  and s="\<xi>!0" in ssubst)
   apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
   apply(rule nth_append_1)
   apply(force)
  apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
  apply(rule conjI)
   apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
   apply(force)
  apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
  apply(rule_tac ?P1.0="%ki. \<xi> ! ki =
               cons_tuple3
                (epdaH_conf_state
                  (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> Some c)))
                (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                  (epdaH_conf_stack
                    (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> Some c))))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k) \<and>
               F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k \<le> k \<and>
               F_EPDA_AIA__fp_computed_stack_approximation d (i + ki) k \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k \<and>
               (case F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k of None \<Rightarrow> True
                | Some y \<Rightarrow> 0 < y \<and> y \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k)"
      and ?R1.0="%ki. case F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k of None \<Rightarrow> True | Some 0 \<Rightarrow> False
               | Some (Suc n) \<Rightarrow>
                   \<exists>w. length w = n \<and>
                       w @ epdaH_conf_stack (the (get_configuration (d i))) =
                       epdaH_conf_stack (the (get_configuration (d (i + ki))))"
      and ?Q1.0="%ki. cons_tuple2
               (Some (cons_tuple3
                       (epdaH_conf_state
                         (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> Some c)))
                       (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                         (epdaH_conf_stack
                           (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> Some c))))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))
               (Some (cons_tuple3
                       (epdaH_conf_state
                         (the (case d (Suc (i + ki)) of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> Some c)))
                       (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc ki) k
                         (epdaH_conf_stack
                           (the (case d (Suc (i + ki)) of None \<Rightarrow> None
                                 | Some (pair e c) \<Rightarrow> Some c))))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + ki)) k)))
              \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
                  {cons_tuple2 ((None # map Some \<xi>) ! ki)
                    (Some (cons_tuple3
                            (epdaH_conf_state
                              (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> Some c)))
                            (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                              (epdaH_conf_stack
                                (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> Some c))))
                            (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))}
                  k \<and>
              F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
               {cons_tuple2 ((None # map Some \<xi>) ! ki)
                 (Some (cons_tuple3
                         (epdaH_conf_state
                           (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> Some c)))
                         (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                           (epdaH_conf_stack
                             (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> Some c))))
                         (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))}
               k
              \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G ((hd (s @ [epda_box G]))) (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k})) k" in locale_help)
        apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
        apply(force)
       apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
       apply(force)
      apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
      apply(force)
     apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
     apply(rule allI)
     apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
     apply(rule impI)
     apply(rule_tac t="(\<xi> @ [cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc j) k (pu @ w))
              (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + j)) k)]) !
       ia" and s="\<xi>!ia" in ssubst)
      apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
      apply(rule nth_append_1)
      apply(force)
     apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
     apply(force)
    apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
    apply(rule allI)
    apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
    apply(rule impI)
    apply(rule_tac t="(\<xi> @ [cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc j) k (pu @ w))
                           (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + j)) k)]) !
                    ia" and s="\<xi>!ia" in ssubst)
     apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
     apply(rule nth_append_1)
     apply(force)
    apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
    apply(force)
   apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
   apply(rule allI)
   apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
   apply(rule impI)
   apply(rule_tac t="(None #
            map Some \<xi> @
            [Some (cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc j) k (pu @ w))
                    (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + j)) k))]) !
           ia" and s="((None # map Some \<xi>) ! ia)" in ssubst)
    apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
    apply(rule append_nth_drop_tail)
    apply(force)
   apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
   apply(rule_tac t="(\<xi> @ [cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc j) k (pu @ w))
                        (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + j)) k)]) !
                 ia" and s="\<xi>!ia" in ssubst)
    apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
    apply(rule nth_append_1)
    apply(force)
   apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
   apply(rule_tac t="(\<xi> @ [cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc j) k (pu @ w))
                        (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + j)) k)]) !
                 Suc ia" and s="\<xi>!Suc ia" in ssubst)
    apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
    apply(rule nth_append_1)
    apply(force)
   apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ia)(*strict*)
   apply(force)
  apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
  apply(rule_tac t="(\<xi> @ [cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc j) k (pu @ w))
               (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + j)) k)]) !
        Suc j" and s="cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc j) k (pu @ w))
               (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + j)) k)" in ssubst)
   apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
   apply (metis (mono_tags, hide_lams) nth_append_length)
  apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
  apply(rule_tac xs="\<xi>" in rev_cases)
   apply(rename_tac j e1 w h1 \<xi> qs r po pu qt)(*strict*)
   apply(force)
  apply(rename_tac j e1 w h1 \<xi> qs r po pu qt ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs r po pu qt ys y)(*strict*)
  apply(case_tac y)
  apply(rename_tac e1 w h1 qs r po pu qt ys y x1 x2 x3)(*strict*)
  apply(rename_tac \<xi> y qX wX nX)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi> y qX wX nX)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi> qX wX nX)(*strict*)
  apply(rule_tac t="Suc (i + length \<xi>)" and s="i+ Suc (length \<xi>)" in ssubst)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi> qX wX nX)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi> qX wX nX)(*strict*)
  apply(erule_tac x="length \<xi>" and P="%ki. ki\<le>length \<xi> \<longrightarrow> ((\<xi> @ [cons_tuple3 qX wX nX]) ! ki =
          cons_tuple3
           (epdaH_conf_state (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
           (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
             (epdaH_conf_stack
               (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
           (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k) \<and>
          F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k \<le> k \<and>
          F_EPDA_AIA__fp_computed_stack_approximation d (i + ki) k \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k \<and>
          (case F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k of None \<Rightarrow> True
           | Some y \<Rightarrow> 0 < y \<and> y \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k))"  in allE')
  apply(erule_tac x="0" and P="%ki. ki\<le>length \<xi> \<longrightarrow> ((\<xi> @ [cons_tuple3 qX wX nX]) ! ki =
          cons_tuple3
           (epdaH_conf_state (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
           (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
             (epdaH_conf_stack
               (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
           (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k) \<and>
          F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k \<le> k \<and>
          F_EPDA_AIA__fp_computed_stack_approximation d (i + ki) k \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k \<and>
          (case F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k of None \<Rightarrow> True
           | Some y \<Rightarrow> 0 < y \<and> y \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i ki k))"  in allE')
  apply(simp add: get_configuration_def)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
  apply(rule_tac t="take SSn SSw @ (take (SSn - length SSw) SSv)" and s="take SSn (SSw@SSv)" for SSn SSw SSv in ssubst)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
  apply(rule_tac t="take SSn SSw @ (take (SSn - length SSw) SSv)" and s="take SSn (SSw@SSv)" for SSn SSw SSv in ssubst)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
  apply(rule_tac t="take SSn SSw @ (take (SSn - length SSw) SSv)" and s="take SSn (SSw@SSv)" for SSn SSw SSv in ssubst)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i i k = Some (Suc 0)")
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   prefer 2
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation2_def F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
  apply(clarsimp)
  apply(thin_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i i k = Some (Suc 0) ")
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k \<noteq> Some 0 ")
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   prefer 2
   apply(clarsimp)
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k = None")
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    apply(clarsimp)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation2_def F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   apply(thin_tac "\<forall>ki<length \<xi>.
          cons_tuple2
           (Some (cons_tuple3
                   (epdaH_conf_state
                     (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                   (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                     (epdaH_conf_stack
                       (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                   (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))
           (Some (cons_tuple3
                   (epdaH_conf_state
                     (the (case d (Suc (i + ki)) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                   (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc ki) k
                     (epdaH_conf_stack
                       (the (case d (Suc (i + ki)) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                   (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + ki)) k)))
          \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
              {cons_tuple2
                ((None #
                  map Some \<xi> @
                  [Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k (po @ w))
                          (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k))]) !
                 ki)
                (Some (cons_tuple3
                        (epdaH_conf_state
                          (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                        (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                          (epdaH_conf_stack
                            (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                        (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))}
              k \<and>
          F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
           {cons_tuple2
             ((None #
               map Some \<xi> @
               [Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k (po @ w))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k))]) !
              ki)
             (Some (cons_tuple3
                     (epdaH_conf_state
                       (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                     (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                       (epdaH_conf_stack
                         (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                     (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))}
           k
          \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G
              (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G])) (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
              k")
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k")
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i
        (Suc (i + length \<xi>)) k = X" for X)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
    prefer 2
    apply(rule F_EPDA_AIA__fp_computed_stack_approximation2_unfold)
      apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
      apply(force)
     apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
   apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k = SSX" for SSX)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
    prefer 2
    apply(rule F_EPDA_AIA__fp_computed_stack_approximationX_unfold)
       apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
       apply(force)
      apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
      apply(force)
     apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
   apply(clarsimp)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(clarsimp)
   apply(erule_tac x="\<lparr>edge_src = qs, edge_event = r, edge_pop = po, edge_push = pu, edge_trg = qt\<rparr>" in ballE)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
   apply(erule_tac x="\<lparr>edge_src = qs, edge_event = r, edge_pop = po, edge_push = pu, edge_trg = qt\<rparr>" in ballE)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
   apply(clarsimp)
   apply(case_tac po)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi> a aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs r pu qt \<xi> a aa)(*strict*)
   apply(case_tac r)
    apply(rename_tac e1 w h1 qs r pu qt \<xi> a aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs pu qt \<xi> a aa)(*strict*)
    apply(case_tac pu)
     apply(rename_tac e1 w h1 qs pu qt \<xi> a aa)(*strict*)
     prefer 2
     apply(rename_tac e1 w h1 qs pu qt \<xi> a aa ab list)(*strict*)
     apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> a aa ab)(*strict*)
     apply(case_tac "a=k")
      apply(rename_tac e1 w h1 qs qt \<xi> a aa ab)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> a aa ab)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs pu qt \<xi> a aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> a aa)(*strict*)
    apply(case_tac a)
     apply(rename_tac e1 w h1 qs qt \<xi> a aa)(*strict*)
     apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> aa)(*strict*)
     apply(erule_tac x="Suc(length \<xi>)" in allE')
     apply(erule_tac x="length \<xi>" in allE)+
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> a aa nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> aa)(*strict*)
    apply(erule_tac x="Suc(length \<xi>)" in allE')
    apply(erule_tac x="length \<xi>" in allE)+
    apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> aa c)(*strict*)
    apply(simp add: get_configuration_def)
   apply(rename_tac e1 w h1 qs r pu qt \<xi> a aa ab)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> aa ab)(*strict*)
   apply(erule_tac x="Suc(length \<xi>)" in allE')
   apply(erule_tac x="length \<xi>" in allE)+
   apply(clarsimp)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
  apply(subgoal_tac "\<exists>x. po=[x] \<and> ((pu=po \<and> r\<noteq>None) \<or> (r=None \<and> (pu=[] \<or> (\<exists>y. pu = [y,x]))))")
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   prefer 2
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(clarsimp)
   apply(erule_tac x="\<lparr>edge_src = qs, edge_event = r, edge_pop = po, edge_push = pu, edge_trg = qt\<rparr>" in ballE)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   apply(erule_tac x="\<lparr>edge_src = qs, edge_event = r, edge_pop = po, edge_push = pu, edge_trg = qt\<rparr>" in ballE)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   apply(clarsimp)
   apply(case_tac r)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs po pu qt \<xi>)(*strict*)
    apply(case_tac po)
     apply(rename_tac e1 w h1 qs po pu qt \<xi>)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs po pu qt \<xi> a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi> a)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs pu qt \<xi> a)(*strict*)
   apply(case_tac pu)
    apply(rename_tac e1 w h1 qs pu qt \<xi> a)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs pu qt \<xi> a aa list)(*strict*)
   apply(clarsimp)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (Suc (length \<xi>)) k \<le> k \<and>
       F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k
       \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i (Suc (length \<xi>)) k \<and>
       (case F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k of None \<Rightarrow> True
        | Some y \<Rightarrow> 0 < y \<and> y \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i (Suc (length \<xi>)) k) \<and>
       (case F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k of None \<Rightarrow> True
        | Some 0 \<Rightarrow> False
        | Some (Suc n) \<Rightarrow>
            \<exists>w. length w = n \<and>
                w @ epdaH_conf_stack (the (get_configuration (d i))) =
                epdaH_conf_stack (the (get_configuration (d (i + Suc (length \<xi>))))))")
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   prefer 2
   apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i
        (Suc (i + length \<xi>)) k = X" for X)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    prefer 2
    apply(rule F_EPDA_AIA__fp_computed_stack_approximation2_unfold)
      apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
      apply(force)
     apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k=SSX" for SSX)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    prefer 2
    apply(rule F_EPDA_AIA__fp_computed_stack_approximationX_unfold)
       apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
       apply(force)
      apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
      apply(force)
     apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k=SSX" for SSX)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    prefer 2
    apply(rule F_EPDA_AIA__fp_computed_stack_approximation_unfold)
      apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
      apply(force)
     apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
   apply(erule disjE)
    apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
    apply(erule_tac x="Suc(length \<xi>)" in allE)
    apply(erule_tac x="length \<xi>" in allE)   +
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
     apply(clarsimp)
     apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (i + length \<xi>) k")
      apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
      apply(clarsimp)
      apply(case_tac k)
       apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
       apply(clarsimp)
      apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
     apply(clarsimp)
     apply(rule_tac t="min k (Suc nat)" and s="Suc nat" in ssubst)
      apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
      apply(force)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
    apply(clarsimp)
    apply(case_tac a)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c wa)(*strict*)
    apply(simp add: get_configuration_def)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (i + length \<xi>) k")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
     apply(clarsimp)
     apply(case_tac k)
      apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
     apply(clarsimp)
     apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
     apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i (Suc nat))) i
           (i + length \<xi>) (Suc nat)")
      apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat nata)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
    apply(clarsimp)
    apply(rule_tac t="min k (Suc nat)" and s="Suc nat" in ssubst)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
    apply(clarsimp)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
   apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs pu qt \<xi> x)(*strict*)
   apply(erule disjE)
    apply(rename_tac e1 w h1 qs pu qt \<xi> x)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
    apply(erule_tac x="Suc(length \<xi>)" in allE)
    apply(erule_tac x="length \<xi>" in allE)+
    apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k")
     apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
     apply(clarsimp)
     apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (i + length \<xi>) k")
      apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
     apply(clarsimp)
     apply(rule_tac t="min k nat" and s="nat" in ssubst)
      apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
      apply(subgoal_tac "nat \<le> k")
       apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
       apply(arith)
      apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
      apply(force)
     apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
     apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i
               (i + length \<xi>) k")
      apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 h1 qs qt \<xi> x c nat nata)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> x c a)(*strict*)
    apply(clarsimp)
    apply(case_tac a)
     apply(rename_tac e1 h1 qs qt \<xi> x c a)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> x c a nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> x c w)(*strict*)
    apply(case_tac w)
     apply(rename_tac e1 h1 qs qt \<xi> x c w)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> x c w a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> x c a list)(*strict*)
    apply(simp add: get_configuration_def)
    apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
    apply(rule context_conjI)
     apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
     apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (i + length \<xi>) k")
      apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
     apply(clarsimp)
     apply(rule_tac t="min k nat" and s="nat" in ssubst)
      apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
      apply(subgoal_tac "nat \<le> k")
       apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
       apply(arith)
      apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
      apply(force)
     apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
     apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i
               (i + length \<xi>) k")
      apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 h1 qs qt \<xi> x c nat nata)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i
               (i + length \<xi>) k")
     apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs pu qt \<xi> x)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
   apply(erule_tac x="Suc(length \<xi>)" in allE)
   apply(erule_tac x="length \<xi>" in allE)   +
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k")
    apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
    apply(clarsimp)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (i + length \<xi>) k")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
     apply(clarsimp)
     apply(case_tac k)
      apply(rename_tac e1 w h1 qs qt \<xi> x y c)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
     apply(clarsimp)
     apply(rename_tac k)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c k)(*strict*)
     apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d
                (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i (Suc k))) i (i + length \<xi>) (Suc k)")
      apply(rename_tac e1 w h1 qs qt \<xi> x y c k)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
     apply(clarsimp)
     apply(case_tac "k\<le>Suc nat")
      apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
      apply(subgoal_tac "min k (Suc nat) =k")
       apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
       apply(clarsimp)
       apply(case_tac k)
        apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
        apply(clarsimp)
       apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat nata)(*strict*)
       apply(clarsimp)
      apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
      apply(force)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
     apply(clarsimp)
     apply(subgoal_tac "min k (Suc nat) =Suc nat")
      apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
     apply(clarsimp)
     apply(subgoal_tac "k> (Suc nat)")
      apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
     apply(clarsimp)
     apply(case_tac k)
      apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c k nat nata)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
    apply(clarsimp)
    apply(case_tac k)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c nat nata)(*strict*)
    apply(clarsimp)
    apply(rename_tac k)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k)(*strict*)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d
                (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i (Suc k))) i (i + length \<xi>) (Suc k)")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k nata)(*strict*)
    apply(clarsimp)
    apply(case_tac "k\<le>Suc nat")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k nata)(*strict*)
     apply(subgoal_tac "min k (Suc nat) =k")
      apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k nata)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k nata)(*strict*)
     apply(case_tac k)
      apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k nata)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k nata natb)(*strict*)
     apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat nata natb)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k nata)(*strict*)
    apply(subgoal_tac "min k (Suc nat) =Suc nat")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k nata)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c nat k nata)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
   apply(clarsimp)
   apply(simp add: get_configuration_def)
   apply(case_tac a)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c wa)(*strict*)
   apply(rename_tac a)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
   apply(simp add: get_configuration_def)
   apply(rule conjI)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
    apply(clarsimp)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (i + length \<xi>) (Suc (length a))")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
     apply(clarsimp)
     apply(case_tac a)
      apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a aa list)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
    apply(clarsimp)
    apply(case_tac "length a\<le>Suc nat")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
     apply(subgoal_tac "min (length a) (Suc nat) =(length a)")
      apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
     apply(case_tac a)
      apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat aa list)(*strict*)
     apply(clarsimp)
     apply(rename_tac e1 h1 qs qt \<xi> x y nat list)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
    apply(subgoal_tac "min (length a) (Suc nat) =Suc nat")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
   apply(clarsimp)
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (i + length \<xi>) k")
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
    apply(clarsimp)
    apply(case_tac k)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac k)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a k)(*strict*)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d
                (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i (Suc k))) i (i + length \<xi>) (Suc k)")
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a k)(*strict*)
     apply(clarsimp)
     apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a k nat)(*strict*)
    apply(clarsimp)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
    apply(case_tac k)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a k nat)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a k nat nata)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat nata)(*strict*)
    apply(case_tac c)
     apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat nata)(*strict*)
     apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y a nat nata)(*strict*)
     apply(case_tac a)
      apply(rename_tac e1 w h1 qs qt \<xi> x y a nat nata)(*strict*)
      apply(clarsimp)
     apply(rename_tac e1 w h1 qs qt \<xi> x y a nat nata aa list)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat nata aa list)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
   apply(clarsimp)
   apply(case_tac k)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat nata)(*strict*)
   apply(clarsimp)
   apply(rename_tac k)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat k)(*strict*)
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d
                (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i (Suc k))) i (i + length \<xi>) (Suc k)")
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat k)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat k nata)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
   apply(case_tac k)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat k nata)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat k nata natb)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat nata natb)(*strict*)
   apply(case_tac c)
    apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat nata natb)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y a nat nata natb)(*strict*)
    apply(case_tac a)
     apply(rename_tac e1 w h1 qs qt \<xi> x y a nat nata natb)(*strict*)
     apply(clarsimp)
    apply(rename_tac e1 w h1 qs qt \<xi> x y a nat nata natb aa list)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x y c a nat nata natb aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 w h1 qs qt \<xi> x nat nata natb aa list)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r po pu qt \<xi>)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
  apply(rule context_conjI)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
  prefer 2
  apply(subgoal_tac "X" for X)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
  prefer 2
  apply(rule_tac k="k" and i="i" and j="(Suc (length \<xi>))" in F_EPDA_AIA__fp_strong_dependency)
      apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
      apply(force)
     apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
  apply(rule_tac xs="\<xi>" in rev_cases)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
  apply(clarsimp del: subsetI)
  apply(rename_tac w r pu qt x wa)(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_intro1)
   apply(rename_tac w r pu qt x wa)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l2_init_satisfies_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST)
     apply(rename_tac w r pu qt x wa)(*strict*)
     apply(rule F_EPDA_AIA__fp_preserves_F_EPDA_AIA__fp_valid_input)
     apply(rule F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac w r pu qt x wa)(*strict*)
    apply(force)
   apply(rename_tac w r pu qt x wa)(*strict*)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(clarsimp)
   apply(erule_tac x="\<lparr>edge_src = q, edge_event = r, edge_pop = [x], edge_push = pu, edge_trg = qt\<rparr>" in ballE)
    apply(rename_tac w r pu qt x wa)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac w r pu qt x wa)(*strict*)
   apply(erule_tac x="\<lparr>edge_src = q, edge_event = r, edge_pop = [x], edge_push = pu, edge_trg = qt\<rparr>" in ballE)
    apply(rename_tac w r pu qt x wa)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac w r pu qt x wa)(*strict*)
   apply(clarsimp)
   apply(simp add: valid_epda_step_label_def)
   apply(simp add: may_terminated_by_def must_terminated_by_def append_language_def kleene_star_def)
   apply(clarsimp)
   apply(rename_tac w r pu qt x wa a aa)(*strict*)
   apply(case_tac s)
    apply(rename_tac w r pu qt x wa a aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac w r pu qt x wa a aa ab list)(*strict*)
   apply(clarsimp)
   apply(rename_tac r pu qt x wa a aa list)(*strict*)
   apply(simp add: epdaH_configurations_def)
  apply(rename_tac w r pu qt x wa)(*strict*)
  apply(rule_tac t="F_EPDA_AIA__fp_computed_stack_approximationX d i i k" and s="Some (Suc 0)" in ssubst)
   apply(rename_tac w r pu qt x wa)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation2_def F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
  apply(rename_tac w r pu qt x wa)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x ys y)(*strict*)
  apply(clarsimp del: subsetI)
  apply(rename_tac e1 w h1 qs r pu qt x ys y wa)(*strict*)
  apply(rename_tac  \<xi> \<xi>L wa)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
  apply(rule_tac t="(map Some \<xi> @
            [Some \<xi>L,
             Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (length \<xi>)) k (po @ w))
                    (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k)),
             Some (cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (Suc (length \<xi>))) k (pu @ w))
                    (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (Suc (i + length \<xi>))) k))]) !
           length \<xi>" and s="Some \<xi>L" in ssubst)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
  apply (metis (erased, hide_lams) length_map_Some nth_append_length)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
  apply(erule_tac x="length \<xi>" and P="%ki. ki<Suc (length \<xi>)\<longrightarrow>
          cons_tuple2
           (Some (cons_tuple3
                   (epdaH_conf_state
                     (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                   (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                     (epdaH_conf_stack
                       (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                   (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))
           (Some (cons_tuple3
                   (epdaH_conf_state
                     (the (case d (Suc (i + ki)) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                   (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc ki) k
                     (epdaH_conf_stack
                       (the (case d (Suc (i + ki)) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                   (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + ki)) k)))
          \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
              {cons_tuple2
                ((None #
                  map Some \<xi> @
                  [Some \<xi>L,
                   Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (length \<xi>)) k (x # w))
                          (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k))]) !
                 ki)
                (Some (cons_tuple3
                        (epdaH_conf_state
                          (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                        (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                          (epdaH_conf_stack
                            (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                        (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))}
              k \<and>
          F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
           {cons_tuple2
             ((None #
               map Some \<xi> @
               [Some \<xi>L,
                Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (length \<xi>)) k (x # w))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k))]) !
              ki)
             (Some (cons_tuple3
                     (epdaH_conf_state
                       (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                     (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                       (epdaH_conf_stack
                         (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                     (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))}
           k
          \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G
              (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G])) (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
              k" in allE)
  apply(erule impE)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
  apply(rule_tac e'="cons_tuple2
             ((None #
               map Some \<xi> @
               [Some \<xi>L,
                (Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (length \<xi>)) k (x # w))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k)))]) !
              length \<xi>)
             (Some (cons_tuple3
                     (epdaH_conf_state
                       (the (case d (i + length \<xi>) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                     (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k
                       (epdaH_conf_stack
                         (the (case d (i + length \<xi>) of None \<Rightarrow> None
                               | Some (pair e xa) \<Rightarrow> Some xa))))
                     (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k)))" in F_SDPDA_TO_CFG_OPT__step_closure__fp_intro2)
   apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l2_init_satisfies_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST)
     apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
     apply(rule F_EPDA_AIA__fp_preserves_F_EPDA_AIA__fp_valid_input)
     apply(rule F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
   apply(simp add: epdaH_configurations_def)
   apply(case_tac s)
    apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa a list)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> \<xi>L wa)(*strict*)
  apply(clarsimp)
  apply(erule_tac x="length \<xi>" in allE)+
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> wa c)(*strict*)
  apply(rule_tac t="((None #
               map Some \<xi> @
               [(Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (length \<xi>)) k (x # w))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k))),
                Some (cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (length \<xi>)) k (pu @ w))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k))]) !
              length \<xi>)" and s="Y" for Y in ssubst)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> wa c)(*strict*)
  apply(rule nth_with_last_and_map_and_Some)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> wa c)(*strict*)
  apply(rule_tac t="((map Some \<xi> @ [Some (cons_tuple3 (epdaH_conf_state (the (case d (i + length \<xi>) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))) (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k (c @ s @ [epda_box G])) (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k)), Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (length \<xi>)) k (x # w)) (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k)), Some (cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (Suc (length \<xi>))) k (pu @ w)) (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (Suc (i + length \<xi>))) k))]) ! length \<xi>) " and s="Some (cons_tuple3 (epdaH_conf_state (the (case d (i + length \<xi>) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))) (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k (c @ s @ [epda_box G])) (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k))" in ssubst)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> wa c)(*strict*)
  apply(rule nth_append_use_second)
   apply(rename_tac e1 w h1 qs r pu qt x \<xi> wa c)(*strict*)
   apply(clarsimp)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> wa c)(*strict*)
  apply(rule_tac t="length (map Some \<xi>)" and s="length \<xi>" in ssubst)
   apply(rename_tac e1 w h1 qs r pu qt x \<xi> wa c)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> wa c)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt x \<xi> wa c)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
  apply(thin_tac "\<forall>ki<length \<xi>.
          cons_tuple2
           (Some (cons_tuple3
                   (epdaH_conf_state
                     (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                   (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                     (epdaH_conf_stack
                       (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                   (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))
           (Some (cons_tuple3
                   (epdaH_conf_state
                     (the (case d (Suc (i + ki)) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                   (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc ki) k
                     (epdaH_conf_stack
                       (the (case d (Suc (i + ki)) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                   (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + ki)) k)))
          \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
              {cons_tuple2
                ((None #
                  map Some \<xi> @
                  [Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k (x # w))
                          (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k))]) !
                 ki)
                (Some (cons_tuple3
                        (epdaH_conf_state
                          (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                        (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                          (epdaH_conf_stack
                            (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                        (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))}
              k \<and>
          F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
           {cons_tuple2
             ((None #
               map Some \<xi> @
               [Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k (x # w))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k))]) !
              ki)
             (Some (cons_tuple3
                     (epdaH_conf_state
                       (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                     (F_EPDA_AIA__fp_computed_stack_approximation3 d i ki k
                       (epdaH_conf_stack
                         (the (case d (i + ki) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                     (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ki) k)))}
           k
          \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G
              (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G])) (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
              k")
  apply(subgoal_tac "\<forall>XX. cons_tuple2
        (Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k (x # w))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k)))
        (Some (cons_tuple3 qt (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc (length \<xi>)) k (pu @ w))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k)))
       \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
           {cons_tuple2 XX
             (Some (cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k (x # w))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k)))}
           k")
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x)(*strict*)
  apply(erule_tac x="length \<xi>" and P="%xa. xa\<le>length \<xi> \<longrightarrow> (\<xi> @ [cons_tuple3 qs (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length \<xi>) k (x # w))
                 (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k)]) !
          xa =
          cons_tuple3
           (epdaH_conf_state (the (case d (i + xa) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
           (F_EPDA_AIA__fp_computed_stack_approximation3 d i xa k
             (epdaH_conf_stack
               (the (case d (i + xa) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
           (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + xa) k) \<and>
          F_EPDA_AIA__fp_computed_stack_approximation4 d i xa k \<le> k \<and>
          F_EPDA_AIA__fp_computed_stack_approximation d (i + xa) k \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i xa k \<and>
          (case F_EPDA_AIA__fp_computed_stack_approximationX d i (i + xa) k of None \<Rightarrow> True
           | Some y \<Rightarrow> 0 < y \<and> y \<le> F_EPDA_AIA__fp_computed_stack_approximation4 d i xa k)" in allE')
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i
        (Suc (i + length \<xi>)) k = X" for X)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  prefer 2
  apply(rule F_EPDA_AIA__fp_computed_stack_approximation2_unfold)
   apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + length \<xi>)) k=SSX" for SSX)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  prefer 2
  apply(rule F_EPDA_AIA__fp_computed_stack_approximationX_unfold)
    apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k \<le> k")
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  prefer 2
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k")
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX a)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(unfold F_EPDA_AIA__fp_computed_stack_approximation3_def)
  apply(fold F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(clarsimp)
  apply(case_tac "r")
  (*read*)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  prefer 2
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX a)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k")
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX a)(*strict*)
  prefer 2
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX a nat)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__read__exists__greater_than_0_def)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x a nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x a nat)(*strict*)
  apply(rule conjI)
   apply(rename_tac e1 w h1 qs qt \<xi> x a nat)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x a nat)(*strict*)
  apply(rule conjI)
   apply(rename_tac e1 w h1 qs qt \<xi> x a nat)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x a nat)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (Suc (length \<xi>)) k")
   apply(rename_tac e1 w h1 qs qt \<xi> x a nat)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x a nat nata)(*strict*)
  apply(clarsimp)
  apply(rule conjI)
   apply(rename_tac e1 w h1 qs qt \<xi> x a nat nata)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
   apply(rule_tac k="k" in equal_take_1)
     apply(rename_tac e1 w h1 qs qt \<xi> x a nat nata)(*strict*)
     apply(force)
    apply(rename_tac e1 w h1 qs qt \<xi> x a nat nata)(*strict*)
    apply(force)
   apply(rename_tac e1 w h1 qs qt \<xi> x a nat nata)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x a nat nata)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k")
   apply(rename_tac e1 w h1 qs qt \<xi> x a nat nata)(*strict*)
   apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x a nat nata aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX a)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX a)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__read__not_exists__none_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x a)(*strict*)
  apply(rule_tac x="a" in exI)
  apply(rule_tac x="x" in exI)
  apply(clarsimp)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k ")
  apply(rename_tac e1 w h1 qs qt \<xi> x a)(*strict*)
  apply(clarsimp)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (Suc (length \<xi>)) k = Suc 0")
   apply(rename_tac e1 w h1 qs qt \<xi> x a)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x a)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x a aa)(*strict*)
  apply(clarsimp)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(case_tac aa)
  apply(rename_tac e1 w h1 qs qt \<xi> x a aa)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x a aa nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x a)(*strict*)
  apply(rename_tac aa)
  apply(rename_tac e1 w h1 qs qt \<xi> x aa)(*strict*)
  apply(simp add: get_configuration_def)
  apply(erule_tac x="Suc(length \<xi>)" in allE')
  apply(erule_tac x="length \<xi>" in allE)+
  apply(clarsimp)
  apply(simp add: get_configuration_def)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(rename_tac e1 w h1 qs r pu qt \<xi> x XX)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs pu qt \<xi> x XX)(*strict*)
  apply(erule disjE)
  apply(rename_tac e1 w h1 qs pu qt \<xi> x XX)(*strict*)
  apply(clarsimp)
  (*popping*)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i ((i + length \<xi>)) k = None \<and> F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k > 0")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__none_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
  apply(rule_tac x="x" in exI)
  apply(rule conjI)
   apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
  apply(clarsimp)
  apply(erule_tac x="Suc(length \<xi>)" in allE')
  apply(erule_tac x="length \<xi>" in allE)+
  apply(clarsimp)
  apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation2 d (max (Suc 0) (F_EPDA_AIA__fp_computed_stack_approximation d i k)) i
        (i + length \<xi>) k")
   apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
   apply(clarsimp)
  apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
  apply(clarsimp)
  apply(rule_tac t="min k nat" and s="nat" in ssubst)
   apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
   apply(force)
  apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i ((i + length \<xi>)) k = None \<and> F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k = 0")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__not_exists__none_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
  apply(rule conjI)
   apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
   apply(rule_tac x="x" in exI)
   apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
  apply(clarsimp)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(case_tac "\<exists>n. F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k = Some(Suc n) \<and> F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k > 0")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__greater_than_0_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
  apply(rule_tac x="qt" in exI)
  apply(rule_tac x="x" in exI)
  apply(rule conjI)
   apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x n)(*strict*)
  apply(erule_tac x="Suc(length \<xi>)" in allE')
  apply(erule_tac x="length \<xi>" in allE)+
  apply(clarsimp)
  apply(rename_tac e1 h1 qs qt \<xi> x c wa)(*strict*)
  apply(simp add: get_configuration_def)
  apply(clarsimp)
  apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k")
   apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
   apply(clarsimp)
  apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "min k nat=nat")
   apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac e1 h1 qs qt \<xi> x c nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 h1 qs qt \<xi> x c)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k = Some 0")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(erule_tac x="Suc(length \<xi>)" in allE')
  apply(erule_tac x="length \<xi>" in allE)+
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(case_tac "\<exists>n. F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k = Some(Suc n) \<and> F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k = 0")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(subgoal_tac "False")
   apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
   apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x n)(*strict*)
  apply(erule_tac x="Suc(length \<xi>)" in allE')
  apply(erule_tac x="length \<xi>" in allE)+
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i(i + length \<xi>) k ")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX a)(*strict*)
  apply(case_tac a)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX a)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX a nat)(*strict*)
  apply(force)
  (*push*)
  apply(rename_tac e1 w h1 qs pu qt \<xi> x XX)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length \<xi>) k = None \<and> F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k > 0")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__none_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x y)(*strict*)
  apply(rule_tac x="qt" in exI)
  apply(rule_tac x="y" in exI)
  apply(rule_tac x="x" in exI)
  apply(erule_tac x="Suc(length \<xi>)" in allE')
  apply(erule_tac x="length \<xi>" in allE)+
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k")
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(clarsimp)
  apply(rule_tac x="take (F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k - Suc 0)w" in exI)
  apply(rule_tac t="take (Suc nat) ca @
       take (Suc nat - length ca) s @ take (Suc nat - (length ca + length s)) [epda_box G]" and s="take (Suc nat) (ca@s@[epda_box G])" in ssubst)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(rule_tac t="x # take (F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k - Suc 0) w" and s="take (Suc (F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k - Suc 0)) (x#w)" in ssubst)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(simp (no_asm))
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(rule_tac t="take (F_EPDA_AIA__fp_computed_stack_approximation4 d i (Suc (length \<xi>)) k) [y, x] @
       take (F_EPDA_AIA__fp_computed_stack_approximation4 d i (Suc (length \<xi>)) k - Suc (Suc 0)) w" and s="take ((F_EPDA_AIA__fp_computed_stack_approximation4 d i (Suc (length \<xi>)) k)) ([y, x] @ w)" in ssubst)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(thin_tac "X" for X)
  apply(simp (no_asm))
  apply(rename_tac w \<xi> x y)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (Suc (length \<xi>)) k")
   apply(rename_tac w \<xi> x y)(*strict*)
   apply(force)
  apply(rename_tac w \<xi> x y nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac w \<xi> x nat)(*strict*)
  apply(case_tac nat)
   apply(rename_tac w \<xi> x nat)(*strict*)
   apply(force)
  apply(rename_tac w \<xi> x nat nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(rule_tac t="F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k" and s="Suc nat" in ssubst)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(rule_tac t="Suc nat - Suc 0" and s="nat" in ssubst)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(rule conjI)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(simp only: F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(rule_tac t="ca @ s @ [epda_box G]" and s="x#w" in ssubst)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(simp (no_asm))
  apply(case_tac "k \<le> (Suc (Suc nat))")
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply (metis take_Suc_Cons take_take)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply (metis take_Suc_Cons take_take)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i ((i + length \<xi>)) k = None \<and> F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k = 0")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__not_exists__none_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x y)(*strict*)
  apply(rule_tac x="y" in exI)
  apply(rule_tac x="x" in exI)
  apply(clarsimp)
  apply(case_tac k)
  apply(rename_tac e1 w h1 qs qt \<xi> x y)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y nat)(*strict*)
  apply(clarsimp)
  apply(case_tac nat)
  apply(rename_tac e1 w h1 qs qt \<xi> x y nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x y nat nata)(*strict*)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y nata)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(case_tac "\<exists>n. F_EPDA_AIA__fp_computed_stack_approximationX d i ( (i + length \<xi>)) k = Some (Suc n) \<and> F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k > 0 \<and> Suc (Suc n) \<le> k")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__less_than_k_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x y)(*strict*)
  apply(rule_tac x="qt" in exI)
  apply(rule_tac x="y" in exI)
  apply(rule_tac x="x" in exI)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k")
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k \<le> k")
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat)(*strict*)
  apply(rule_tac t="min k (Suc nat)" and s="Suc nat" in ssubst)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat)(*strict*)
  apply(clarsimp)
  apply(case_tac k)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat nata)(*strict*)
  apply(clarsimp)
  apply(case_tac "min nata (Suc nat)")
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat nata)(*strict*)
  apply(clarsimp)
  apply(case_tac nata)
   apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat nata)(*strict*)
   prefer 2
   apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat nata natb)(*strict*)
   apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat nata natb)(*strict*)
  apply(clarsimp)
  apply(case_tac nata)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat nata natb)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat nata natb natc)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n wa nat natc)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(case_tac "\<exists>n. F_EPDA_AIA__fp_computed_stack_approximationX d ( i) ( (i + length \<xi>)) k = Some (Suc n) \<and> F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k > 0 \<and> Suc n=k")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__k_def)
  apply(rename_tac e1 w h1 qs qt \<xi> x y)(*strict*)
  apply(rule_tac x="qt" in exI)
  apply(rule_tac x="y" in exI)
  apply(rule_tac x="x" in exI)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) (Suc n)")
  apply(rename_tac e1 w h1 qs qt \<xi> x y n)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) (Suc n) \<le> (Suc n)")
  apply(rename_tac e1 w h1 qs qt \<xi> x y n nat)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y n nat)(*strict*)
  apply(erule_tac x="Suc(length \<xi>)" in allE')
  apply(erule_tac x="length \<xi>" in allE)+
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y wa ca)(*strict*)
  apply(simp add: get_configuration_def)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation4_def)
  apply(case_tac "min (length ca) (Suc (length ca))")
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca)(*strict*)
  apply(clarsimp)
  apply(case_tac ca)
   apply(rename_tac e1 w h1 qs qt \<xi> x y ca)(*strict*)
   apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(clarsimp)
  apply(case_tac ca)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y ca nat a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "False")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d ( i) ( (i + length \<xi>)) k")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y a)(*strict*)
  apply(subgoal_tac "a \<le> k")
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y a)(*strict*)
  prefer 2
  apply(rule F_EPDA_AIA__fp_computed_stack_approximationX_smaller_equal_k)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y a)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y a)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x XX y a)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y a)(*strict*)
  apply(case_tac a)
  apply(rename_tac e1 w h1 qs qt \<xi> x y a)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y a nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 w h1 qs qt \<xi> x y nat)(*strict*)
  apply(rename_tac a)
  apply(rename_tac e1 w h1 qs qt \<xi> x y a)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation4 d i (length \<xi>) k")
  apply(rename_tac e1 w h1 qs qt \<xi> x y a)(*strict*)
  apply(force)
  apply(rename_tac e1 w h1 qs qt \<xi> x y a nat)(*strict*)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_mono: "
  finite E
  \<Longrightarrow> E \<subseteq> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp E"
  apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E")
   prefer 2
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
  apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_Meta_Lift_prime)
    apply(force)
   apply(rename_tac N)(*strict*)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N" in subset_trans)
    apply(rename_tac N)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac N)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def)
   apply(force)
  apply(rename_tac N)(*strict*)
  apply(rule_tac ?x.0="N" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp.pelims)
    apply(rename_tac N)(*strict*)
    apply(force)
   apply(rename_tac N)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termination)
   apply(force)
  apply(rename_tac N S)(*strict*)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro1: "
  finite S
  \<Longrightarrow> cons_tuple2 x y \<in> S
  \<Longrightarrow> cons_tuple2 x y \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S"
  apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST S")
   prefer 2
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
  apply(rule_tac A="S" in set_mp)
   apply (rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_mono)
   apply(force)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_Meta_Lift: "
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N
  \<Longrightarrow> (\<And>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N) \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<Longrightarrow> P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N)) \<Longrightarrow> P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N))
  \<Longrightarrow> (\<And>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one N = N \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<Longrightarrow> P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N))
  \<Longrightarrow> P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N)"
  apply(subgoal_tac "(\<lambda>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<longrightarrow> (P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N))) N")
   apply(erule impE)
    prefer 2
    apply(blast)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER_AT_START)
   apply(blast)
  apply(subgoal_tac "(\<lambda>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<longrightarrow> (P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N))) N")
   apply(blast)
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>E. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST E"
      and RECURSIVE_COND = "\<lambda>E. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one  E\<noteq>E"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>E. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one E"
      and MEASURE = "\<lambda>E. card (max_data E - E)"
      and TERM_FUN = "(\<lambda>N. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TRANSFER N \<longrightarrow> (P (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N)))"
      and y = "N"
      in partial_termination_wf)
      apply(rule allI)
      apply(rename_tac x)(*strict*)
      apply(clarify)
      apply(rename_tac b)(*strict*)
      apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N")
      apply(rename_tac N)
      apply(rename_tac N)(*strict*)
      apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_preserves_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST)
      apply(blast)
     apply(thin_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N")
     apply(clarsimp)
     apply(rename_tac b)(*strict*)
     apply(rename_tac N)
     apply(rename_tac N)(*strict*)
     apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termLem2)
      apply(rename_tac N)(*strict*)
      apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
     apply(rename_tac N)(*strict*)
     apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
    apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
   prefer 2
   apply(clarsimp)
  apply(clarsimp)
  apply(rename_tac b)(*strict*)
  apply(erule impE)
   apply(rename_tac b)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_TRANSFER_TRANSFERS_ALL)
     apply(rename_tac b)(*strict*)
     apply(blast)+
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_idemp3: "
  F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST N
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N = F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp N)"
  apply(rule_tac F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_Meta_Lift)
    apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def SpecOutput_reach_k_def reach_k_TRANSFER_def reach_k_EXTRA_01_def reach_k_EXTRA_02_def)
   apply(rename_tac Na)(*strict*)
   apply (metis F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_idemp2)
  apply(rename_tac Na)(*strict*)
  apply (metis F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp.psimps F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_termination)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro2: "
  finite S
  \<Longrightarrow> cons_tuple2 x y \<in> S
  \<Longrightarrow> cons_tuple2 y z \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S
  \<Longrightarrow> cons_tuple2 x z \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S"
  apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST S")
   prefer 2
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
  apply(rule_tac A="F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S)" in set_mp)
   apply (metis F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_idemp3 order_refl)
  apply(subgoal_tac "cons_tuple2 x y \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S")
   prefer 2
   apply(rule_tac A="S" in set_mp)
    apply (rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_mono)
    apply(force)
   apply(force)
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro_seq_TRANS: "
  finite S
  \<Longrightarrow> \<forall>i. Suc i < length w \<longrightarrow> cons_tuple2 (w ! i) (w ! Suc i) \<in> S
  \<Longrightarrow> length w > Suc 0
  \<Longrightarrow> cons_tuple2 (hd w) (last w) \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S"
  apply(induct w)
   apply(clarsimp)
  apply(rename_tac a w)(*strict*)
  apply(clarsimp)
  apply(erule meta_impE)
   apply(rename_tac a w)(*strict*)
   apply(clarsimp)
   apply(rename_tac a w i)(*strict*)
   apply(erule_tac x="Suc i" in allE)
   apply(force)
  apply(rename_tac a w)(*strict*)
  apply(case_tac w)
   apply(rename_tac a w)(*strict*)
   apply(clarsimp)
  apply(rename_tac a w aa list)(*strict*)
  apply(clarsimp)
  apply(rename_tac a aa list)(*strict*)
  apply(rule_tac xs="list" in rev_cases)
   apply(rename_tac a aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac a aa)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro1)
    apply(rename_tac a aa)(*strict*)
    apply(force)
   apply(rename_tac a aa)(*strict*)
   apply(force)
  apply(rename_tac a aa list ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac a aa ys y)(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro2)
    apply(rename_tac a aa ys y)(*strict*)
    apply(force)
   apply(rename_tac a aa ys y)(*strict*)
   apply(erule_tac x="0" in allE)
   apply(force)
  apply(rename_tac a aa ys y)(*strict*)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro3: "
  finite S
  \<Longrightarrow> cons_tuple2 x y \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S
  \<Longrightarrow> cons_tuple2 x x \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S"
  apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST S")
   prefer 2
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
  apply(rule_tac A="F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S)" in set_mp)
   apply (metis F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_idemp3 order_refl)
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro3b: "
  finite S
  \<Longrightarrow> cons_tuple2 y x \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S
  \<Longrightarrow> cons_tuple2 x x \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S"
  apply(subgoal_tac "F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST S")
   prefer 2
   apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_TERM_ARGS_TEST_def)
  apply(rule_tac A="F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S)" in set_mp)
   apply (metis F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_idemp3 order_refl)
  apply(simp add: F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_one_def)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_mono: "
  F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k S
  \<Longrightarrow> S \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G S k"
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_Meta_Lift_prime)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(rule_tac B="F_SDPDA_TO_CFG_OPT__step_closure__fp_one Ga N ka" in subset_trans)
    apply(rename_tac Ga ka N)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
   apply(force)
  apply(rename_tac Ga ka N)(*strict*)
  apply(rule_tac ?x.0="Ga" in F_SDPDA_TO_CFG_OPT__step_closure__fp.pelims)
    apply(rename_tac Ga ka N)(*strict*)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_termination)
   apply(force)
  apply(rename_tac Ga ka N Gaa Sa kaa)(*strict*)
  apply(clarsimp)
  done

theorem F_SDPDA_TO_CFG_OPT__contains_all_reachable_l2_nonterminals_BASIC: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> cons_l2 q A \<in> {cons_l2 q A | q A d i e c j e' c'. epdaH.derivation_initial G d \<and> d i = Some (pair e c) \<and> q = epdaH_conf_state c \<and> A = hd (epdaH_conf_stack c) \<and> d (i + j) = Some (pair e' c') \<and> epdaH_conf_state c' \<in> epda_marking G \<and> (\<forall>k. k \<le> j \<longrightarrow> suffix (epdaH_conf_stack (the (get_configuration (d (i + k))))) (epdaH_conf_stack c)) }
  \<Longrightarrow> cons_l2 q A \<in> (case F_SDPDA_TO_CFG_OPT__nonterminals G k of cons_tuple2 S2 S3 \<Rightarrow> S2)"
  apply(simp add: F_SDPDA_TO_CFG_OPT_def Let_def)
  apply(clarsimp)
  apply(rename_tac d i e c j e' c')(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac d i e c j e' c')(*strict*)
   prefer 2
   apply(rule epdaH_epda_box_stays_at_bottom)
     apply(rename_tac d i e c j e' c')(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
     apply(force)
    apply(rename_tac d i e c j e' c')(*strict*)
    apply(force)
   apply(rename_tac d i e c j e' c')(*strict*)
   apply(force)
  apply(rename_tac d i e c j e' c')(*strict*)
  apply(simp add: suffix_def)
  apply(clarsimp)
  apply(rename_tac d i e c j e' c' ca)(*strict*)
  apply(subgoal_tac "hd (epdaH_conf_stack c) \<in> F_SDPDA_TO_CFG_OPT__pushed_symbols G \<or> hd (epdaH_conf_stack c) = epda_box G")
   apply(rename_tac d i e c j e' c' ca)(*strict*)
   prefer 2
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    apply(rename_tac d i e c j e' c' ca)(*strict*)
    prefer 2
    apply(rule epdaH_all_stack_elements_pushed_or_box)
      apply(rename_tac d i e c j e' c' ca)(*strict*)
      apply(force)
     apply(rename_tac d i e c j e' c' ca)(*strict*)
     apply(force)
    apply(rename_tac d i e c j e' c' ca)(*strict*)
    apply(force)
   apply(rename_tac d i e c j e' c' ca)(*strict*)
   apply(case_tac ca)
    apply(rename_tac d i e c j e' c' ca)(*strict*)
    apply(force)
   apply(rename_tac d i e c j e' c' ca a list)(*strict*)
   apply(force)
  apply(rename_tac d i e c j e' c' ca)(*strict*)
  apply(clarsimp)
  apply(case_tac "F_SDPDA_TO_CFG_OPT__nonterminals G k")
  apply(rename_tac d i e c j e' c' ca x1 x2)(*strict*)
  apply(clarsimp)
  apply(rename_tac S2 S3)
  apply(rename_tac d i e c j e' c' ca S2 S3)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT__nonterminals_def Let_def)
  apply(clarsimp)
  apply(rename_tac d i e c j e' c' ca)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT__l2_approx_def)
  apply(rule_tac x="F_SDPDA_TO_CFG_OPT__l2_approx_1 G k (hd (ca @ [epda_box G])) (F_EPDA_AIA G k)
                     (F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
                       (F_SDPDA_TO_CFG_OPT__step_closure__fp G
                         (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (ca @ [epda_box G])) (F_EPDA_AIA G k)) k))" in exI)
  apply(rule conjI)
   apply(rename_tac d i e c j e' c' ca)(*strict*)
   apply(rule_tac x="(hd (ca @ [epda_box G]))" in exI)
   apply(rule conjI)
    apply(rename_tac d i e c j e' c' ca)(*strict*)
    apply(clarsimp)
   apply(rename_tac d i e c j e' c' ca)(*strict*)
   apply(force)
  apply(rename_tac d i e c j e' c' ca)(*strict*)
  apply(rule_tac t="(the \<circ> sel_tuple2_2) ` reach_k G k {reach_k_initial G k}" and s="F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}" in ssubst)
   apply(rename_tac d i e c j e' c' ca)(*strict*)
   apply(rule reach_k_coincides_with_F_EPDA_AIA__fp)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
  apply(rename_tac d i e c j e' c' ca)(*strict*)
  apply(case_tac c')
  apply(rename_tac d i e c j e' c' ca epdaH_conf_statea epdaH_conf_history epdaH_conf_stacka)(*strict*)
  apply(rename_tac q' h' s')
  apply(rename_tac d i e c j e' c' ca q' h' s')(*strict*)
  apply(case_tac c)
  apply(rename_tac d i e c j e' c' ca q' h' s' epdaH_conf_statea epdaH_conf_history epdaH_conf_stacka)(*strict*)
  apply(rename_tac q h s)
  apply(rename_tac d i e c j e' c' ca q' h' s' q h s)(*strict*)
  apply(clarsimp)
  apply(rename_tac d i e j e' ca q' h' s' q h)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT__l2_approx_1_def)
  apply(subgoal_tac "\<exists>w n w' n'.
          cons_tuple2 (Some (cons_tuple3 q w n)) (Some (cons_tuple3 q' w' n'))
          \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
              (F_SDPDA_TO_CFG_OPT__step_closure__fp G
                (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (ca @ [epda_box G])) (F_EPDA_AIA G k))
                k) \<and>
          cons_tuple2 None (Some (cons_tuple3 q w n))
          \<in> F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (ca @ [epda_box G])) (F_EPDA_AIA G k) \<and>
           n' \<noteq> Some 0")
   apply(rename_tac d i e j e' ca q' h' s' q h)(*strict*)
   apply(erule exE)+
   apply(rename_tac d i e j e' ca q' h' s' q h w n w' n')(*strict*)
   apply(rule_tac x="w" in exI)
   apply(rule_tac x="n" in exI)
   apply(rule_tac x="q'" in exI)
   apply(rule_tac x="w'" in exI)
   apply(rule_tac x="n'" in exI)
   apply(force)
  apply(rename_tac d i e j e' ca q' h' s' q h)(*strict*)
  apply(thin_tac "q' \<in> epda_marking G")
  apply(rename_tac s q' h' s' q h)
  apply(rename_tac d i e j e' s q' h' s' q h)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac d i e j e' s q' h' s' q h)(*strict*)
   prefer 2
   apply(rule L2Closure_strong_dependency)
        apply(rename_tac d i e j e' s q' h' s' q h)(*strict*)
        apply(force)
       apply(rename_tac d i e j e' s q' h' s' q h)(*strict*)
       apply(force)
      apply(rename_tac d i e j e' s q' h' s' q h)(*strict*)
      apply(force)
     apply(rename_tac d i e j e' s q' h' s' q h)(*strict*)
     apply(force)
    apply(rename_tac d i e j e' s q' h' s' q h)(*strict*)
    apply(force)
   apply(rename_tac d i e j e' s q' h' s' q h)(*strict*)
   apply(force)
  apply(rename_tac d i e j e' s q' h' s' q h)(*strict*)
  apply(clarsimp)
  apply(rename_tac d i e j e' s q' h' s' q h \<xi>)(*strict*)
  apply(rule_tac xs="\<xi>" in rev_cases)
   apply(rename_tac d i e j e' s q' h' s' q h \<xi>)(*strict*)
   apply(force)
  apply(rename_tac d i e j e' s q' h' s' q h \<xi> ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac d i e e' s q' h' s' q h ys y)(*strict*)
  apply(simp add: get_configuration_def)
  apply(erule_tac x="length ys" in allE')
  apply(erule_tac x="length ys" in allE')
  apply(erule_tac x="length ys" in allE')
  apply(clarsimp)
  apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
  apply(rule_tac x="(F_EPDA_AIA__fp_computed_stack_approximation3 d i 0 k (s @ [epda_box G]))" in exI)
  apply(rule_tac x="(F_EPDA_AIA__fp_computed_stack_approximationX d i i k)" in exI)
  apply(rule_tac x="
(F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k (c @ s @ [epda_box G]))" in exI)
  apply(rule_tac x="                          (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k)" in exI)
  apply(rule conjI)
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   prefer 2
   apply(erule_tac x="length ys" in allE)+
   apply(clarsimp)
   apply(simp add: F_EPDA_AIA_def)
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k")
    apply(force)
   apply(force)
  apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
  apply(subgoal_tac "\<lparr>epdaH_conf_state = q, epdaH_conf_history = h,
                   epdaH_conf_stack = s @ [epda_box G]\<rparr> \<in> epdaH_configurations G")
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   prefer 2
   apply(rule epdaH.belongs_configurations)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    apply(rule epdaH.derivation_initial_belongs)
     apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    apply(force)
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   apply(force)
  apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
  apply(subgoal_tac "F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k} \<subseteq> F_EPDA_AIA__codom G k")
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   prefer 2
   apply(subgoal_tac "X" for X)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    prefer 2
    apply(rule_tac k="k" in F_EPDA_AIA__fp_preserves_F_EPDA_AIA__fp_valid_input)
    apply(rule F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(force)
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_valid_input_def)
  apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
  apply(subgoal_tac "finite
          (F_SDPDA_TO_CFG_OPT__step_closure__fp G
            (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G]))
              (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
            k)")
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   prefer 2
   apply(rule finite_F_SDPDA_TO_CFG_OPT__step_closure__fp)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
   apply(rule conjI)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l2_init_in_all_state_stack_str3_simp)
      apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
     apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
     apply(force)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    apply(force)
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   apply(simp add: epdaH_configurations_def)
   apply(case_tac s)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    apply(force)
   apply(rename_tac d i e e' s q' h' q h ys c a list)(*strict*)
   apply(force)
  apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
  apply(case_tac "length ys>0")
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    prefer 2
    apply(rule_tac S="(F_SDPDA_TO_CFG_OPT__step_closure__fp G
              (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G])) (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))  k)" and w= "
               map Some ys @
               [Some (cons_tuple3 q'
                       (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k (c @ s @ [epda_box G]))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro_seq_TRANS)
      apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
      apply(force)
     apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
     apply(clarsimp)
     apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
     apply(erule_tac x="ia" in allE)
     apply(clarsimp)
     apply(rule_tac A="F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
           {cons_tuple2
             ((None #
               map Some ys @
               [Some (cons_tuple3 q'
                       (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k (c @ s @ [epda_box G]))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]) !
              ia)
             (Some (cons_tuple3
                     (epdaH_conf_state
                       (the (case d (i + ia) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                     (F_EPDA_AIA__fp_computed_stack_approximation3 d i ia k
                       (epdaH_conf_stack
                         (the (case d (i + ia) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                     (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ia) k)))}
           k
           " in set_mp)
      apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
      apply(force)
     apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
     apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
        {cons_tuple2
          ((None #
            map Some ys @
            [Some (cons_tuple3 q' (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k (c @ s @ [epda_box G]))
                    (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]) !
           ia)
          (Some (cons_tuple3
                  (epdaH_conf_state
                    (the (case d (i + ia) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                  (F_EPDA_AIA__fp_computed_stack_approximation3 d i ia k
                    (epdaH_conf_stack
                      (the (case d (i + ia) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                  (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ia) k)))}
        k
       \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G
           (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G])) (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k})) k")
     apply(rule_tac t="((map Some ys @
          [Some (cons_tuple3 q' (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k (c @ s @ [epda_box G]))
                  (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]) !
         ia)" and s="(Some (cons_tuple3
                (epdaH_conf_state
                  (the (case d (i + ia) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                (F_EPDA_AIA__fp_computed_stack_approximation3 d i ia k
                  (epdaH_conf_stack
                    (the (case d (i + ia) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + ia) k)))" in ssubst)
      apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
      apply(rule_tac t="((map Some ys @
          [Some (cons_tuple3 q' (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k (c @ s @ [epda_box G]))
                  (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]) !
         ia)" and s="map Some ys ! ia" in ssubst)
       apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
       apply(rule nth_append_1)
       apply(force)
      apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
      apply(clarsimp)
      apply(erule_tac x="ia" in allE)+
      apply(clarsimp)
      apply(rename_tac d i e e' s q' h' q h ys c ia ca)(*strict*)
      apply(rule_tac t="ys!ia" and s="(ys @
        [cons_tuple3 q'
          (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k (c @ s @ [epda_box G]))
          (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k)]) !
       ia" in subst)
       apply(rename_tac d i e e' s q' h' q h ys c ia ca)(*strict*)
       apply(rule nth_append_1)
       apply(force)
      apply(rename_tac d i e e' s q' h' q h ys c ia ca)(*strict*)
      apply(clarsimp)
     apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
     apply(rule_tac t="((map Some ys @
          [Some (cons_tuple3 q' (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k (c @ s @ [epda_box G]))
                  (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]) !
         Suc ia)" and s="(Some (cons_tuple3
                (epdaH_conf_state
                  (the (case d (Suc (i + ia)) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa)))
                (F_EPDA_AIA__fp_computed_stack_approximation3 d i (Suc ia) k
                  (epdaH_conf_stack
                    (the (case d (Suc (i + ia)) of None \<Rightarrow> None | Some (pair e xa) \<Rightarrow> Some xa))))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (Suc (i + ia)) k)))" in ssubst)
      apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
      apply(case_tac "Suc ia=length ys")
       apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
       apply(rule_tac t="(map Some ys @
        [Some (cons_tuple3 q'
                (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k
                  (c @ s @ [epda_box G]))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]) !
       Suc ia" and s="[Some (cons_tuple3 q'
                (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k
                  (c @ s @ [epda_box G]))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]!X" for X in ssubst)
        apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
        apply(rule nth_append_2)
        apply(force)
       apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
       apply(clarsimp)
       apply(erule_tac x="Suc ia" in allE)+
       apply(clarsimp)
       apply(case_tac ys)
        apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
        apply(clarsimp)
       apply(rename_tac d i e e' s q' h' q h ys c ia a list)(*strict*)
       apply(clarsimp)
      apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
      apply(rule_tac t="(map Some ys @
        [Some (cons_tuple3 q'
                (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k
                  (c @ s @ [epda_box G]))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]) !
       Suc ia" and s="map Some ys ! Suc ia" in ssubst)
       apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
       apply(rule nth_append_1)
       apply(force)
      apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
      apply(clarsimp)
      apply(erule_tac x="Suc ia" in allE)+
      apply(clarsimp)
      apply(rename_tac d i e e' s q' h' q h ys c ia ca)(*strict*)
      apply(rule_tac t="ys!Suc ia" and s="(ys @
        [cons_tuple3 q'
          (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k (c @ s @ [epda_box G]))
          (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k)]) !
       Suc ia " in subst)
       apply(rename_tac d i e e' s q' h' q h ys c ia ca)(*strict*)
       apply(rule nth_append_1)
       apply(force)
      apply(rename_tac d i e e' s q' h' q h ys c ia ca)(*strict*)
      apply(clarsimp)
     apply(rename_tac d i e e' s q' h' q h ys c ia)(*strict*)
     apply(force)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    apply(clarsimp)
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   apply(simp add: F_EPDA_AIA_def)
   apply(rule_tac t="cons_tuple2
        (Some (cons_tuple3 q (F_EPDA_AIA__fp_computed_stack_approximation3 d i 0 k (s @ [epda_box G]))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i i k)))
        (Some (cons_tuple3 q'
                (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k
                  (c @ s @ [epda_box G]))
                (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k)))" and s="cons_tuple2
        (hd (map Some ys @
             [Some (cons_tuple3 q'
                     (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k
                       (c @ s @ [epda_box G]))
                     (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]))
        (last (map Some ys @
               [Some (cons_tuple3 q'
                       (F_EPDA_AIA__fp_computed_stack_approximation3 d i (length ys) k
                         (c @ s @ [epda_box G]))
                       (F_EPDA_AIA__fp_computed_stack_approximationX d i (i + length ys) k))]))" in ssubst)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
   apply(simp (no_asm))
   apply(clarsimp)
   apply(case_tac ys)
    apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
    apply(force)
   apply(rename_tac d i e e' s q' h' q h ys c a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac d i e e' s q' h' q h c a list)(*strict*)
   apply(erule_tac x="0" in allE)+
   apply(clarsimp)
  apply(rename_tac d i e e' s q' h' q h ys c)(*strict*)
  apply(clarsimp)
  apply(simp add: F_EPDA_AIA_def)
  apply(rename_tac d i e' s q' h')(*strict*)
  apply(rule_tac y="None" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro3b)
   apply(rename_tac d i e' s q' h')(*strict*)
   apply(force)
  apply(rename_tac d i e' s q' h')(*strict*)
  apply(rule_tac A="(F_SDPDA_TO_CFG_OPT__step_closure__fp G
             (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G]))
               (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k})) k)" in set_mp)
   apply(rename_tac d i e' s q' h')(*strict*)
   apply(rule_tac F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_mono)
   apply(force)
  apply(rename_tac d i e' s q' h')(*strict*)
  apply(rule_tac A="(
             (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G (hd (s @ [epda_box G]))
               (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k})) )" in set_mp)
   apply(rename_tac d i e' s q' h')(*strict*)
   apply(rule_tac F_SDPDA_TO_CFG_OPT__step_closure__fp_mono)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def)
   apply(rule conjI)
    apply(rename_tac d i e' s q' h')(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(rename_tac d i e' s q' h')(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l2_init_in_all_state_stack_str3_simp)
      apply(rename_tac d i e' s q' h')(*strict*)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
     apply(rename_tac d i e' s q' h')(*strict*)
     apply(force)
    apply(rename_tac d i e' s q' h')(*strict*)
    apply(force)
   apply(rename_tac d i e' s q' h')(*strict*)
   apply(simp add: epdaH_configurations_def)
   apply(case_tac s)
    apply(rename_tac d i e' s q' h')(*strict*)
    apply(force)
   apply(rename_tac d i e' s q' h' a list)(*strict*)
   apply(force)
  apply(rename_tac d i e' s q' h')(*strict*)
  apply(force)
  done

theorem F_SDPDA_TO_CFG_OPT__contains_all_reachable_l2_nonterminals: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT G k = Some Go
  \<Longrightarrow> cons_l2 q A \<in> {cons_l2 q A | q A d i e c j e' c'. epdaH.derivation_initial G d \<and> d i = Some (pair e c) \<and> q = epdaH_conf_state c \<and> A = hd (epdaH_conf_stack c) \<and> d (i + j) = Some (pair e' c') \<and> epdaH_conf_state c' \<in> epda_marking G \<and> (\<forall>k. k \<le> j \<longrightarrow> suffix (epdaH_conf_stack (the (get_configuration (d (i + k))))) (epdaH_conf_stack c)) }
  \<Longrightarrow> cons_l2 q A \<in> cfg_nonterminals Go"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac G="G" and k="k" and q="q" and A="A" in F_SDPDA_TO_CFG_OPT__contains_all_reachable_l2_nonterminals_BASIC)
     apply(force)
    apply(force)
   apply(force)
  apply(simp add: F_SDPDA_TO_CFG_OPT_def Let_def)
  apply(erule if_option_simp_rev)
  apply(clarsimp)
  done

lemma tail_is_nonterminal_free: "
  liftB wa = liftB waa @ w
  \<Longrightarrow> setA w = {}"
  apply(induct w arbitrary: wa waa rule: rev_induct)
   apply(rename_tac wa waa)(*strict*)
   apply(clarsimp)
  apply(rename_tac x xs wa waa)(*strict*)
  apply(rule_tac xs="wa" in rev_cases)
   apply(rename_tac x xs wa waa)(*strict*)
   apply(clarsimp)
  apply(rename_tac x xs wa waa ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac x xs waa ys y)(*strict*)
  apply(simp add: liftB_commutes_over_concat liftA_commutes_over_concat setAConcat setA_liftB setB_liftA)
  apply(clarsimp)
  done

definition F_SDPDA_TO_CFG_STD__configuration_basic_RL :: "
  (('state, 'stack) DT_l2_l3_nonterminals, 'event) cfg_configuration
  \<Rightarrow> 'stack list
  \<Rightarrow> ('state, 'event, 'stack) epdaH_conf"
  where
    "F_SDPDA_TO_CFG_STD__configuration_basic_RL c X \<equiv>
  let
    h = THE w. \<exists>v. cfg_conf c = liftB w @ liftA v;
    ss = THE v. \<exists>w. cfg_conf c = liftB w @ liftA v;
    fs = \<lambda>x. case x of
        cons_l2 q A \<Rightarrow> A
        | cons_l3 q A q' \<Rightarrow> A;
    fq = \<lambda>x. case x of
        cons_l2 q A \<Rightarrow> q
        | cons_l3 q A q' \<Rightarrow> q;
    s = map fs ss
  in
    \<lparr>epdaH_conf_state = fq (hd ss),
    epdaH_conf_history = h,
    epdaH_conf_stack = s @ X\<rparr>"

lemma F_SDPDA_TO_CFG_STD__preserve_configuration: "
  valid_simple_dpda G1
  \<Longrightarrow> cR \<in> cfg_initial_configurations (F_SDPDA_TO_CFG_STD G1)
  \<Longrightarrow> F_SDPDA_TO_CFG_STD__configuration_basic_RL cR [] \<in> epdaH_configurations G1"
  apply(simp add: cfg_initial_configurations_def epdaH_configurations_def cfg_configurations_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(clarsimp)
  apply(rule_tac
      t="THE v. \<exists>w. [teA (cfg_initial (F_SDPDA_TO_CFG_STD G1))] = liftB w @ liftA v"
      and s="[cfg_initial (F_SDPDA_TO_CFG_STD G1)]"
      in ssubst)
   apply(rule THE_split1)
  apply(clarsimp)
  apply(rule_tac
      t="THE w. \<exists>v. [teA (cfg_initial (F_SDPDA_TO_CFG_STD G1))] = liftB w @ liftA v"
      and s="[]"
      in ssubst)
   apply(rule THE_split2)
  apply(clarsimp)
  apply(simp add: F_SDPDA_TO_CFG_STD_def)
  done

lemma F_SDPDA_TO_CFG_STD__preserve_initial_configuration: "
  valid_simple_dpda G1
  \<Longrightarrow> cR \<in> cfg_initial_configurations (F_SDPDA_TO_CFG_STD G1)
  \<Longrightarrow> F_SDPDA_TO_CFG_STD__configuration_basic_RL cR [] \<in> epdaH_initial_configurations G1"
  apply(simp add: epdaH_initial_configurations_def)
  apply(subgoal_tac "F_SDPDA_TO_CFG_STD__configuration_basic_RL cR [] \<in> epdaH_configurations G1")
   prefer 2
   apply(rule F_SDPDA_TO_CFG_STD__preserve_configuration)
    apply(force)
   apply(force)
  apply(clarsimp)
  apply(simp add: cfg_initial_configurations_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(clarsimp)
  apply(rule_tac
      t="THE v. \<exists>w. [teA (cfg_initial (F_SDPDA_TO_CFG_STD G1))] = liftB w @ liftA v"
      and s="[cfg_initial (F_SDPDA_TO_CFG_STD G1)]"
      in ssubst)
   apply(rule THE_split1)
  apply(clarsimp)
  apply(rule_tac
      t="THE w. \<exists>v. [teA (cfg_initial (F_SDPDA_TO_CFG_STD G1))] = liftB w @ liftA v"
      and s="[]"
      in ssubst)
   apply(rule THE_split2)
  apply(clarsimp)
  apply(simp add: F_SDPDA_TO_CFG_STD_def)
  done

definition event_stack_separation_and_proper_l3_l2_seq_ALT :: "
  (('state, 'stack) DT_l2_l3_nonterminals, 'event) cfg_configuration
  \<Rightarrow> bool"
  where
    "event_stack_separation_and_proper_l3_l2_seq_ALT c \<equiv>
  \<exists>w v.
    cfg_conf c = liftB w @ liftA v
    \<and> (case v of
        [] \<Rightarrow> True
        | a # y \<Rightarrow> (\<forall>w t.
            v = w @ [t]
            \<longrightarrow> (\<forall>x \<in> set w. case x of
                cons_l2 q y \<Rightarrow> False
                | _ \<Rightarrow> True)
                \<and> (case t of
                  cons_l2 q y \<Rightarrow> True
                  | _ \<Rightarrow> False)
                \<and> (\<forall>i.
                  Suc i < length v
                  \<longrightarrow> (case v ! i of cons_l3 q1 A q2 \<Rightarrow> q2)
                      = (case v ! (Suc i) of
                          cons_l3 q1 A q2 \<Rightarrow> q1
                          | cons_l2 q1 A \<Rightarrow> q1))))"

lemma nth_append_last: "
  length w = i
   \<Longrightarrow> (w @ [x]) ! i = x"
  apply(induct w)
   apply(clarsimp)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form: "
  valid_simple_dpda G
  \<Longrightarrow> cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G) d
  \<Longrightarrow> get_configuration (d n) = Some c
  \<Longrightarrow> event_stack_separation_and_proper_l3_l2_seq_ALT c"
  apply(induct n arbitrary: c)
   apply(rename_tac c)(*strict*)
   apply(case_tac "d 0")
    apply(rename_tac c)(*strict*)
    apply(clarsimp)
    apply(simp add: get_configuration_def)
   apply(rename_tac c a)(*strict*)
   apply(clarsimp)
   apply(simp add: get_configuration_def)
   apply(simp add: cfgLM.derivation_initial_def cfg_initial_configurations_def)
   apply(clarsimp)
   apply(case_tac a)
   apply(rename_tac c a option b)(*strict*)
   apply(clarsimp)
   apply(rename_tac c)(*strict*)
   apply(simp add: cfg_initial_configurations_def)
   apply(clarsimp)
   apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
   apply(rule_tac
      x="[]"
      in exI)
   apply(clarsimp)
   apply(rule_tac
      x="[cfg_initial (F_SDPDA_TO_CFG_STD G)]"
      in exI)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_STD_def)
  apply(rename_tac n c)(*strict*)
  apply(subgoal_tac "\<exists>e1 e2 c1 c2. d n = Some (pair e1 c1) \<and> d (Suc n) = Some (pair (Some e2) c2) \<and> cfgLM_step_relation (F_SDPDA_TO_CFG_STD G) c1 e2 c2")
   apply(rename_tac n c)(*strict*)
   prefer 2
   apply(rule_tac
      m="Suc n"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac n c)(*strict*)
     apply(simp add: cfgLM.derivation_initial_def)
    apply(rename_tac n c)(*strict*)
    apply(simp add: get_configuration_def)
    apply(case_tac "d (Suc n)")
     apply(rename_tac n c)(*strict*)
     apply(force)
    apply(rename_tac n c a)(*strict*)
    apply(force)
   apply(rename_tac n c)(*strict*)
   apply(force)
  apply(rename_tac n c)(*strict*)
  apply(clarsimp)
  apply(rename_tac n c e1 e2 c1 c2)(*strict*)
  apply(simp add: get_configuration_def)
  apply(erule_tac
      x="c1"
      in meta_allE)
  apply(clarsimp)
  apply(rename_tac n c e1 e2 c1)(*strict*)
  apply(simp add: cfgLM_step_relation_def event_stack_separation_and_proper_l3_l2_seq_ALT_def)
  apply(clarsimp)
  apply(rename_tac n c e1 e2 c1 w v l r)(*strict*)
  apply(case_tac v)
   apply(rename_tac n c e1 e2 c1 w v l r)(*strict*)
   apply(clarsimp)
   apply(rename_tac n c e1 e2 c1 w l r)(*strict*)
   apply(subgoal_tac "False")
    apply(rename_tac n c e1 e2 c1 w l r)(*strict*)
    apply(force)
   apply(rename_tac n c e1 e2 c1 w l r)(*strict*)
   apply (metis setA_liftB elemInsetA ex_in_conv)
  apply(rename_tac n c e1 e2 c1 w v l r a list)(*strict*)
  apply(subgoal_tac "\<exists>w' x'. v=w'@[x']")
   apply(rename_tac n c e1 e2 c1 w v l r a list)(*strict*)
   prefer 2
   apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
   apply(force)
  apply(rename_tac n c e1 e2 c1 w v l r a list)(*strict*)
  apply(thin_tac "v=a # list")
  apply(clarsimp)
  apply(rename_tac n c e1 e2 c1 w l r w' x')(*strict*)
  apply(case_tac "w'@[x']")
   apply(rename_tac n c e1 e2 c1 w l r w' x')(*strict*)
   apply(force)
  apply(rename_tac n c e1 e2 c1 w l r w' x' a list)(*strict*)
  apply(subgoal_tac "\<forall>w t. w' @ [x'] = w @ [t] \<longrightarrow> Ball (set w) (case_DT_l2_l3_nonterminals (\<lambda>q y. False) (\<lambda>q1 b q2. True)) \<and> (case t of cons_l2 q y \<Rightarrow> True | cons_l3 q1 b q2 \<Rightarrow> False) \<and> (\<forall>i. Suc i < length (w' @ [x']) \<longrightarrow> (case (w' @ [x']) ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case (w' @ [x']) ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
   apply(rename_tac n c e1 e2 c1 w l r w' x' a list)(*strict*)
   prefer 2
   apply(clarsimp)
  apply(rename_tac n c e1 e2 c1 w l r w' x' a list)(*strict*)
  apply(thin_tac "w'@[x']=a # list")
  apply(thin_tac "case w' @ [x'] of [] \<Rightarrow> True | a # y \<Rightarrow> \<forall>w t. w' @ [x'] = w @ [t] \<longrightarrow> Ball (set w) (case_DT_l2_l3_nonterminals (\<lambda>q y. False) (\<lambda>q1 b q2. True)) \<and> (case t of cons_l2 q y \<Rightarrow> True | cons_l3 q1 b q2 \<Rightarrow> False) \<and> (\<forall>i. Suc i < length (w' @ [x']) \<longrightarrow> (case (w' @ [x']) ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case (w' @ [x']) ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
  apply(rename_tac n c e1 e2 c1 w l r w' x' a list)(*strict*)
  apply(case_tac c)
  apply(rename_tac n c e1 e2 c1 w l r w' x' a list cfg_confa)(*strict*)
  apply(case_tac c1)
  apply(rename_tac n c e1 e2 c1 w l r w' x' a list cfg_confa cfg_confaa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 w l r w' x')(*strict*)
  apply(subgoal_tac "l=liftB w")
   apply(rename_tac n e1 e2 w l r w' x')(*strict*)
   prefer 2
   apply(subgoal_tac "prefix l (liftB w) \<or> prefix (liftB w) l")
    apply(rename_tac n e1 e2 w l r w' x')(*strict*)
    prefer 2
    apply(rule mutual_prefix_prefix)
    apply(force)
   apply(rename_tac n e1 e2 w l r w' x')(*strict*)
   apply(erule disjE)
    apply(rename_tac n e1 e2 w l r w' x')(*strict*)
    prefer 2
    apply(simp add: prefix_def)
    apply(clarsimp)
    apply(rename_tac n e1 e2 w r w' x' c)(*strict*)
    apply(case_tac c)
     apply(rename_tac n e1 e2 w r w' x' c)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 e2 w r w' x' c a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 e2 w r w' x' a list)(*strict*)
    apply(case_tac a)
     apply(rename_tac n e1 e2 w r w' x' a list aa)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 e2 w r w' x' list aa)(*strict*)
     apply (metis elemInsetA emptyE)
    apply(rename_tac n e1 e2 w r w' x' a list b)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 e2 w r w' x' list b)(*strict*)
    apply (metis setB_liftA setB_set_not ex_in_conv head_in_set rotate_simps)
   apply(rename_tac n e1 e2 w l r w' x')(*strict*)
   apply(simp add: prefix_def)
   apply(clarsimp)
   apply(rename_tac n e1 e2 w l r w' x' c)(*strict*)
   apply(case_tac c)
    apply(rename_tac n e1 e2 w l r w' x' c)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 e2 w l r w' x' c a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 e2 w l r w' x' a list)(*strict*)
   apply(subgoal_tac "False")
    apply(rename_tac n e1 e2 w l r w' x' a list)(*strict*)
    apply(force)
   apply(rename_tac n e1 e2 w l r w' x' a list)(*strict*)
   apply(case_tac a)
    apply(rename_tac n e1 e2 w l r w' x' a list aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 e2 w l r w' x' list aa)(*strict*)
    apply (metis liftBDeConv2 append_self_conv list.simps(2) maxTermPrefix_drop_tail maxTermPrefix_on_term_string_prime maxTermPrefix_term_string)
   apply(rename_tac n e1 e2 w l r w' x' a list b)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 e2 w l r w' x' list b)(*strict*)
   apply(subgoal_tac "l @ teA (prod_lhs e2) # r = (l @ teB b # list) @ liftA (w' @ [x'])")
    apply(rename_tac n e1 e2 w l r w' x' list b)(*strict*)
    apply(thin_tac "l @ teB b # list = liftB w")
    apply (metis append_Cons append_assoc DT_two_elements.distinct(1) nth_Cons_0 same_append_eq)
   apply(rename_tac n e1 e2 w l r w' x' list b)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 e2 w l r w' x')(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 w r w' x')(*strict*)
  apply(subgoal_tac "\<exists>w1 w2. liftB w1 @ w2 = prod_rhs e2 \<and> (case w2 of teB b # list \<Rightarrow> False | _ \<Rightarrow> True)")
   apply(rename_tac n e1 e2 w r w' x')(*strict*)
   prefer 2
   apply(rule maxSplit)
  apply(rename_tac n e1 e2 w r w' x')(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 w r w' x' w1 w2)(*strict*)
  apply(case_tac e2)
  apply(rename_tac n e1 e2 w r w' x' w1 w2 prod_lhsa prod_rhsa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' x' w1 w2 prod_lhs)(*strict*)
  apply(rename_tac A)
  apply(rename_tac n e1 w r w' x' w1 w2 A)(*strict*)
  apply(case_tac x')
   apply(rename_tac n e1 w r w' x' w1 w2 A q b)(*strict*)
   prefer 2
   apply(rename_tac n e1 w r w' x' w1 w2 A q1 b q2)(*strict*)
   apply(force)
  apply(rename_tac n e1 w r w' x' w1 w2 A q b)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
  apply(rule_tac
      x="w@w1"
      in exI)
  apply(simp add: liftB_commutes_over_concat)
  apply(subgoal_tac "\<lparr>prod_lhs = A, prod_rhs = liftB w1 @ w2\<rparr> \<in> F_SDPDA_TO_CFG_STD__edges_l3 G \<or> \<lparr>prod_lhs = A, prod_rhs = liftB w1 @ w2\<rparr> \<in> F_SDPDA_TO_CFG_STD__edges_l2 G")
   apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
   prefer 2
   apply(simp add: F_SDPDA_TO_CFG_STD_def)
  apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
  apply(subgoal_tac "setB r = {}")
   apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
   prefer 2
   apply(rule order_antisym)
    apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
   apply(rule_tac
      B="setB (liftA (w' @ [cons_l2 q b]))"
      in subset_trans)
    apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
    apply(rule_tac
      t="liftA (w' @ [cons_l2 q b])"
      and s="teA A # r"
      in ssubst)
     apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
     apply(force)
    apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
    apply(simp (no_asm))
   apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
   apply (metis setB_liftA equalityE)
  apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
  apply(erule disjE)
   apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_def)
   apply(erule disjE)
    apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
    apply(case_tac "edge_event x")
     apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' w1 w2 A q b x a)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' w1 w2 q b x a qt)(*strict*)
    apply(case_tac w1)
     apply(rename_tac n e1 w r w' w1 w2 q b x a qt)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' w1 w2 q b x a qt aa list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' w2 q b x a qt list)(*strict*)
    apply(case_tac list)
     apply(rename_tac n e1 w r w' w2 q b x a qt list)(*strict*)
     prefer 2
     apply(rename_tac n e1 w r w' w2 q b x a qt list aa lista)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' w2 q b x a qt list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a qt)(*strict*)
    apply(rule_tac
      x="[cons_l3 (edge_trg x) (edge_pop x ! 0) qt]@filterA r"
      in exI)
    apply(clarsimp)
    apply(rule conjI)
     apply(rename_tac n e1 w r w' q b x a qt)(*strict*)
     apply(rule setB_empty_then_liftA_vs_filterA)
     apply(force)
    apply(rename_tac n e1 w r w' q b x a qt)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a qt wa t)(*strict*)
    apply(rule conjI)
     apply(rename_tac n e1 w r w' q b x a qt wa t)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a qt wa t xa)(*strict*)
     apply(case_tac xa)
      apply(rename_tac n e1 w r w' q b x a qt wa t xa qa ba)(*strict*)
      prefer 2
      apply(rename_tac n e1 w r w' q b x a qt wa t xa q1 ba q2)(*strict*)
      apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a qt wa t xa qa ba)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a qt wa t qa ba)(*strict*)
     apply(case_tac wa)
      apply(rename_tac n e1 w r w' q b x a qt wa t qa ba)(*strict*)
      apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a qt wa t qa ba aa list)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a qt t qa ba list)(*strict*)
     apply(case_tac w')
      apply(rename_tac n e1 w r w' q b x a qt t qa ba list)(*strict*)
      apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a qt t qa ba list aa lista)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w q b x a qt t qa ba list lista)(*strict*)
     apply(subgoal_tac "filterA (liftA (lista @ [cons_l2 q b]))=lista @ [cons_l2 q b]")
      apply(rename_tac n e1 w q b x a qt t qa ba list lista)(*strict*)
      prefer 2
      apply(rule liftA_vs_filterA)
     apply(rename_tac n e1 w q b x a qt t qa ba list lista)(*strict*)
     apply(subgoal_tac "t=cons_l2 q b")
      apply(rename_tac n e1 w q b x a qt t qa ba list lista)(*strict*)
      prefer 2
      apply (simp add: liftA_vs_filterA append1_eq_conv)
     apply(rename_tac n e1 w q b x a qt t qa ba list lista)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w q b x a qt qa ba list lista)(*strict*)
     apply(subgoal_tac "list=lista")
      apply(rename_tac n e1 w q b x a qt qa ba list lista)(*strict*)
      prefer 2
      apply (simp add: liftA_vs_filterA append1_eq_conv)
     apply(rename_tac n e1 w q b x a qt qa ba list lista)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w q b x a qt qa ba lista)(*strict*)
     apply(erule_tac
      x="cons_l2 qa ba"
      in ballE)
      apply(rename_tac n e1 w q b x a qt qa ba lista)(*strict*)
      apply(force)
     apply(rename_tac n e1 w q b x a qt qa ba lista)(*strict*)
     apply(force)
    apply(rename_tac n e1 w r w' q b x a qt wa t)(*strict*)
    apply(rule conjI)
     apply(rename_tac n e1 w r w' q b x a qt wa t)(*strict*)
     apply(case_tac t)
      apply(rename_tac n e1 w r w' q b x a qt wa t qa ba)(*strict*)
      apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a qt wa t q1 ba q2)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a qt wa q1 ba q2)(*strict*)
     apply(case_tac w')
      apply(rename_tac n e1 w r w' q b x a qt wa q1 ba q2)(*strict*)
      apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a qt wa q1 ba q2 aa list)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w q b x a qt wa q1 ba q2 list)(*strict*)
     apply(subgoal_tac "filterA (liftA (list @ [cons_l2 q b]))=list @ [cons_l2 q b]")
      apply(rename_tac n e1 w q b x a qt wa q1 ba q2 list)(*strict*)
      prefer 2
      apply(rule liftA_vs_filterA)
     apply(rename_tac n e1 w q b x a qt wa q1 ba q2 list)(*strict*)
     apply(subgoal_tac "cons_l3 q1 ba q2=cons_l2 q b")
      apply(rename_tac n e1 w q b x a qt wa q1 ba q2 list)(*strict*)
      apply(force)
     apply(rename_tac n e1 w q b x a qt wa q1 ba q2 list)(*strict*)
     apply(simp add: liftA_vs_filterA)
    apply(rename_tac n e1 w r w' q b x a qt wa t)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
    apply(rule_tac
      t="(wa@[t])!i"
      and s="wa!i"
      in ssubst)
     apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
     apply (metis nth_append_1)
    apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
    apply(subgoal_tac "length r=length w'")
     apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
     apply(subgoal_tac "length r=length wa")
      apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
      apply(clarsimp)
      apply(erule_tac
      x="i"
      in allE)
      apply(clarsimp)
      apply(case_tac wa)
       apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
       apply(force)
      apply(rename_tac n e1 w r w' q b x a qt wa t i aa list)(*strict*)
      apply(case_tac w')
       apply(rename_tac n e1 w r w' q b x a qt wa t i aa list)(*strict*)
       apply(force)
      apply(rename_tac n e1 w r w' q b x a qt wa t i aa list ab lista)(*strict*)
      apply(clarsimp)
      apply(rename_tac n e1 w q b x a qt t i list lista)(*strict*)
      apply(case_tac i)
       apply(rename_tac n e1 w q b x a qt t i list lista)(*strict*)
       apply(clarsimp)
       apply(rename_tac n e1 w q b x a t list lista)(*strict*)
       apply(case_tac lista)
        apply(rename_tac n e1 w q b x a t list lista)(*strict*)
        apply(clarsimp)
       apply(rename_tac n e1 w q b x a t list lista aa listb)(*strict*)
       apply(clarsimp)
       apply(rename_tac n e1 w q b x a t list aa listb)(*strict*)
       apply(case_tac list)
        apply(rename_tac n e1 w q b x a t list aa listb)(*strict*)
        apply(clarsimp)
       apply(rename_tac n e1 w q b x a t list aa listb ab lista)(*strict*)
       apply(clarsimp)
      apply(rename_tac n e1 w q b x a qt t i list lista nat)(*strict*)
      apply(clarsimp)
      apply(rename_tac n e1 w q b x a qt t list lista nat)(*strict*)
      apply (metis liftA_vs_filterA nth_append_1)
     apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
     apply(rule_tac
      y="wa"
      in length_eq_prepend_append_singleton)
       apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
       apply(force)
      apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
      apply(rule filterA_preserves_length)
      apply(force)
     apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
     apply(force)
    apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
    apply(rule_tac
      x="r"
      and y="liftA w'"
      and B="teA (cons_l2   q b)"
      and A="teA (cons_l3   (edge_src x) (edge_pop x ! 0) qt)"
      in length_eq_prepend_append_singleton)
      apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
      apply(rule_tac
      t="liftA w' @ [teA (cons_l2   q b)]"
      and s="liftA (w' @ [cons_l2 q b])"
      in ssubst)
       apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
       apply (metis liftA_append_tail)
      apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
      apply(force)
     apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
     apply(force)
    apply(rename_tac n e1 w r w' q b x a qt wa t i)(*strict*)
    apply (metis liftA_vs_filterA filterA_preserves_length setB_liftA)
   apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
   apply(erule disjE)
    apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
    apply(case_tac "edge_push x")
     apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
     prefer 2
     apply(rename_tac n e1 w r w' w1 w2 A q b x a list)(*strict*)
     apply(force)
    apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' w1 q b x)(*strict*)
    apply(case_tac w1)
     apply(rename_tac n e1 w r w' w1 q b x)(*strict*)
     prefer 2
     apply(rename_tac n e1 w r w' w1 q b x a list)(*strict*)
     apply(force)
    apply(rename_tac n e1 w r w' w1 q b x)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x)(*strict*)
    apply(rule_tac
      x="filterA r"
      in exI)
    apply(rule conjI)
     apply(rename_tac n e1 w r w' q b x)(*strict*)
     apply(rule setB_empty_then_liftA_vs_filterA)
     apply(force)
    apply(rename_tac n e1 w r w' q b x)(*strict*)
    apply(case_tac "r")
     apply(rename_tac n e1 w r w' q b x)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a list)(*strict*)
    apply(subgoal_tac "\<exists>w' x'. r=w'@[x']")
     apply(rename_tac n e1 w r w' q b x a list)(*strict*)
     prefer 2
     apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
     apply(force)
    apply(rename_tac n e1 w r w' q b x a list)(*strict*)
    apply(thin_tac "r=a # list")
    apply(clarsimp)
    apply(rename_tac n e1 w w' q b x w'event x')(*strict*)
    apply(case_tac "filterA (w'event @ [x'])")
     apply(rename_tac n e1 w w' q b x w'event x')(*strict*)
     apply(force)
    apply(rename_tac n e1 w w' q b x w'event x' a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t)(*strict*)
    apply(rule conjI)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t xa)(*strict*)
     apply(case_tac xa)
      apply(rename_tac n e1 w w' q b x w'event x' a list wa t xa qa ba)(*strict*)
      apply(clarsimp)
      apply(rename_tac n e1 w w' q b x w'event x' a list wa t qa ba)(*strict*)
      prefer 2
      apply(rename_tac n e1 w w' q b x w'event x' a list wa t xa q1 ba q2)(*strict*)
      apply(clarsimp)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t qa ba)(*strict*)
     apply(case_tac w')
      apply(rename_tac n e1 w w' q b x w'event x' a list wa t qa ba)(*strict*)
      apply(clarsimp)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t qa ba aa lista)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w q b x w'event x' a list wa t qa ba lista)(*strict*)
     apply(subgoal_tac "lista=wa \<and> cons_l2 q b = t")
      apply(rename_tac n e1 w q b x w'event x' a list wa t qa ba lista)(*strict*)
      prefer 2
      apply(rule filterA_append_tail)
      apply(force)
     apply(rename_tac n e1 w q b x w'event x' a list wa t qa ba lista)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w q b x w'event x' a list wa qa ba)(*strict*)
     apply(erule_tac
      x="cons_l2 qa ba"
      in ballE)
      apply(rename_tac n e1 w q b x w'event x' a list wa qa ba)(*strict*)
      apply(force)
     apply(rename_tac n e1 w q b x w'event x' a list wa qa ba)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t)(*strict*)
    apply(rule conjI)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t)(*strict*)
     apply(case_tac t)
      apply(rename_tac n e1 w w' q b x w'event x' a list wa t qa ba)(*strict*)
      apply(clarsimp)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t q1 ba q2)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa q1 ba q2)(*strict*)
     apply(case_tac w')
      apply(rename_tac n e1 w w' q b x w'event x' a list wa q1 ba q2)(*strict*)
      apply(force)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa q1 ba q2 aa lista)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w q b x w'event x' a list wa q1 ba q2 lista)(*strict*)
     apply(subgoal_tac "lista=wa \<and> cons_l2 q b = cons_l3 q1 ba q2")
      apply(rename_tac n e1 w q b x w'event x' a list wa q1 ba q2 lista)(*strict*)
      prefer 2
      apply(rule filterA_append_tail)
      apply(force)
     apply(rename_tac n e1 w q b x w'event x' a list wa q1 ba q2 lista)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
    apply(rule_tac
      t="(wa@[t])!i"
      and s="wa!i"
      in ssubst)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
     apply (metis nth_append_1)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
    apply(subgoal_tac "filterA w'event=wa")
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
     prefer 2
     apply(rule filterA_append_tail_eq)
      apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
      apply(force)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
     apply(force)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
    apply(subgoal_tac "liftA (w' @ [cons_l2 q b]) = liftA w' @ [teA (cons_l2   q b)]")
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
     prefer 2
     apply (simp add: liftA_append_tail)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
    apply(subgoal_tac "liftA w' = teA (cons_l3   (edge_src x) (edge_pop x ! 0) (edge_trg x)) # w'event")
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
     prefer 2
     apply(rule hlp_lem)
      apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
      apply(force)
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
     apply(force)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
    apply(subgoal_tac "length w'=Suc(length w'event)")
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
     prefer 2
     apply(clarsimp)
     apply(rename_tac n e1 w w' q b x w'event x' a list t i)(*strict*)
     apply(rule_tac
      t="length w'"
      and s="length(liftA w')"
      in subst)
      apply(rename_tac n e1 w w' q b x w'event x' a list t i)(*strict*)
      apply (rule liftA_preserves_length)
     apply(rename_tac n e1 w w' q b x w'event x' a list t i)(*strict*)
     apply(rule_tac
      t="Suc (length w'event)"
      and s="length(teA (cons_l3   (edge_src x) (edge_pop x ! 0) (edge_trg x)) # w'event)"
      in ssubst)
      apply(rename_tac n e1 w w' q b x w'event x' a list t i)(*strict*)
      apply(force)
     apply(rename_tac n e1 w w' q b x w'event x' a list t i)(*strict*)
     apply(rule_tac
      f="length"
      in arg_cong)
     apply(force)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
    apply(subgoal_tac "length (filterA w'event) = length w'event")
     apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
     prefer 2
     apply(rule filterA_preserves_length)
     apply(rule_tac
      v="w'"
      and w="[teA (cons_l3   (edge_src x) (edge_pop x ! 0) (edge_trg x))]"
      and y="[]"
      in liftA_append_setB)
     apply(force)
    apply(rename_tac n e1 w w' q b x w'event x' a list wa t i)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w w' q b x w'event x' a list t i)(*strict*)
    apply(case_tac w')
     apply(rename_tac n e1 w w' q b x w'event x' a list t i)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w w' q b x w'event x' a list t i aa lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
    apply(erule_tac
      x="Suc i"
      in allE)
    apply(clarsimp)
    apply(subgoal_tac "(lista @ [cons_l2 q b]) ! i = lista!i")
     apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
     prefer 2
     apply (simp add: liftA_vs_filterA nth_append_1)
    apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
    apply(clarsimp)
    apply(rule_tac
      t="filterA (liftA lista)"
      and s="lista"
      in ssubst)
     apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
     apply (simp add: liftA_vs_filterA)
    apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
    apply(case_tac "Suc i=length (liftA lista)")
     apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
     apply(subgoal_tac "(lista @ [cons_l2 q b]) ! Suc i = cons_l2 q b")
      apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
      prefer 2
      apply(rule nth_append_last)
      apply(rule_tac t="length lista" and s="length (liftA lista)" in ssubst)
       apply(blast)
      apply(rule sym)
      apply(blast)
     apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
     apply(rule_tac
      t="(lista @ [t]) ! Suc i"
      and s="t"
      in ssubst)
      apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
      apply(rule nth_append_last)
      apply(rule_tac t="length lista" and s="length (liftA lista)" in ssubst)
       apply(blast)
      apply(rule sym)
      apply(blast)
     apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w b x x' a list t i lista)(*strict*)
     apply(erule_tac
      x="lista ! i"
      in ballE)
      apply(rename_tac n e1 w b x x' a list t i lista)(*strict*)
      prefer 2
      apply (simp add: nth_mem)
     apply(rename_tac n e1 w b x x' a list t i lista)(*strict*)
     apply(case_tac "lista !i")
      apply(rename_tac n e1 w b x x' a list t i lista q ba)(*strict*)
      apply(clarsimp)
     apply(rename_tac n e1 w b x x' a list t i lista q1 ba q2)(*strict*)
     apply(clarsimp)
     apply(case_tac t)
      apply(rename_tac n e1 w b x x' a list t i lista q1 ba q2 q bb)(*strict*)
      apply(clarsimp)
      apply(rename_tac n e1 w b x x' a list i lista q1 ba q2 q bb)(*strict*)
      apply (simp add: DT_l2_l3_nonterminals.simps(1) liftA_vs_filterA nth_append_length)
     apply(rename_tac n e1 w b x x' a list t i lista q1 ba q2 q1a bb q2a)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w b x x' a list i lista q1 ba q2 q1a bb q2a)(*strict*)
     apply (simp add: DT_l2_l3_nonterminals.simps(3) liftA_vs_filterA nth_append_length)
    apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
    apply(subgoal_tac "Suc i < length (liftA lista)")
     apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
     prefer 2
     apply(rule_tac t="length lista" and s="length (liftA lista)" in ssubst)
      apply(blast)
     apply(rule Suc_lessI)
      apply(blast)
     apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
     apply(subgoal_tac "(lista @ [cons_l2 q b]) ! (Suc i) = lista!(Suc i)")
      apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
      prefer 2
      apply(rule nth_append_1)
      apply(rule Suc_lessI)
       apply(rule_tac t="length lista" and s="length (liftA lista)" in ssubst)
        apply(blast)
       apply(blast)
      apply(rule_tac t="length lista" and s="length (liftA lista)" in ssubst)
       apply(blast)
      apply(blast)
     apply(blast)
    apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
    apply(clarsimp)
    apply(rule_tac
      t="(lista @ [t]) ! Suc i"
      and s=" lista ! Suc i"
      in ssubst)
     apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)
     apply (simp add: nth_shift2 liftA_vs_filterA)
     apply(rename_tac n e1 w q b x x' a list t i lista)(*strict*)

     apply(rule nth_append_1)
     apply(rule Suc_lessI)
      apply(rule_tac t="length lista" and s="length (liftA lista)" in ssubst)
       apply(blast)
      apply(force)
     apply(force)
    apply (simp add: nth_shift2 liftA_vs_filterA)
    apply(clarsimp)

    apply(subgoal_tac "(lista @ [cons_l2 q b]) ! (Suc i) = lista!(Suc i)")
     prefer 2
     apply(rule nth_append_1)
     apply(rule Suc_lessI)
      apply(rule_tac t="length lista" and s="length (liftA lista)" in ssubst)
       apply(blast)
      apply(force)
     apply(force)
    apply(force)
   apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
   apply(case_tac "edge_push x")
    apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
    apply(force)
   apply(rename_tac n e1 w r w' w1 w2 A q b x a list)(*strict*)
   apply(clarsimp)
   apply(case_tac "edge_event x")
    apply(rename_tac n e1 w r w' w1 w2 A q b x a list)(*strict*)
    prefer 2
    apply(rename_tac n e1 w r w' w1 w2 A q b x a list aa)(*strict*)
    apply(force)
   apply(rename_tac n e1 w r w' w1 w2 A q b x a list)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' w1 w2 q b x a list qs qt)(*strict*)
   apply(case_tac w1)
    apply(rename_tac n e1 w r w' w1 w2 q b x a list qs qt)(*strict*)
    prefer 2
    apply(rename_tac n e1 w r w' w1 w2 q b x a list qs qt aa lista)(*strict*)
    apply(force)
   apply(rename_tac n e1 w r w' w1 w2 q b x a list qs qt)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' q b x a list qs qt)(*strict*)
   apply(case_tac w')
    apply(rename_tac n e1 w r w' q b x a list qs qt)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w r w' q b x a list qs qt aa lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt lista)(*strict*)
   apply(rule_tac
      x="cons_l3 (edge_trg x) a qs # cons_l3 qs (edge_pop x ! 0) qt # lista @ [cons_l2 q b]"
      in exI)
   apply(rename_tac n e1 w q b x a list qs qt lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt lista i)(*strict*)
   apply(case_tac i)
    apply(rename_tac n e1 w q b x a list qs qt lista i)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt lista i nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt lista nat)(*strict*)
   apply(case_tac nat)
    apply(rename_tac n e1 w q b x a list qs qt lista nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w q b x a list qs qt lista)(*strict*)
    apply(erule_tac
      x="0"
      in allE)
    apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt lista nat nata)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt lista nata)(*strict*)
   apply(case_tac lista)
    apply(rename_tac n e1 w q b x a list qs qt lista nata)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt lista nata aa listb)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt nata aa listb)(*strict*)
   apply(case_tac listb)
    apply(rename_tac n e1 w q b x a list qs qt nata aa listb)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w q b x a list qs qt aa)(*strict*)
    apply(case_tac aa)
     apply(rename_tac n e1 w q b x a list qs qt aa qa ba)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w q b x a list qs qt aa q1 ba q2)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w q b x a list qs qt q1 ba q2)(*strict*)
    apply(erule_tac
      x="Suc 0"
      in allE)
    apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt nata aa listb ab lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w q b x a list qs qt nata aa ab lista)(*strict*)
   apply (metis not_less_eq nth_Cons_Suc)
  apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_def)
  apply(erule disjE)
   apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
   apply(case_tac "edge_event x")
    apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w r w' w1 w2 A q b x a)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' w1 w2 q b x a)(*strict*)
   apply(case_tac w1)
    apply(rename_tac n e1 w r w' w1 w2 q b x a)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w r w' w1 w2 q b x a aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' w2 q b x a list)(*strict*)
   apply(case_tac list)
    apply(rename_tac n e1 w r w' w2 q b x a list)(*strict*)
    prefer 2
    apply(rename_tac n e1 w r w' w2 q b x a list aa lista)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w r w' w2 q b x a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' q b x a)(*strict*)
   apply(rule_tac
      x="cons_l2 (edge_trg x) (edge_pop x ! 0) # filterA r"
      in exI)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac n e1 w r w' q b x a)(*strict*)
    apply(rule setB_empty_then_liftA_vs_filterA)
    apply(force)
   apply(rename_tac n e1 w r w' q b x a)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' q b x a wa t)(*strict*)
   apply(rule conjI)
    apply(rename_tac n e1 w r w' q b x a wa t)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a wa t xa)(*strict*)
    apply(case_tac wa)
     apply(rename_tac n e1 w r w' q b x a wa t xa)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a wa t xa aa list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a t xa list)(*strict*)
    apply(case_tac xa)
     apply(rename_tac n e1 w r w' q b x a t xa list qa ba)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w r w' q b x a t list qa ba)(*strict*)
     prefer 2
     apply(rename_tac n e1 w r w' q b x a t xa list q1 ba q2)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a t list qa ba)(*strict*)
    apply(case_tac w')
     apply(rename_tac n e1 w r w' q b x a t list qa ba)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a t list qa ba aa lista)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w r w' q b x a wa t)(*strict*)
   apply(rule conjI)
    apply(rename_tac n e1 w r w' q b x a wa t)(*strict*)
    apply(case_tac t)
     apply(rename_tac n e1 w r w' q b x a wa t qa ba)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a wa t q1 ba q2)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a wa q1 ba q2)(*strict*)
    apply(case_tac wa)
     apply(rename_tac n e1 w r w' q b x a wa q1 ba q2)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a wa q1 ba q2 aa list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a q1 ba q2 list)(*strict*)
    apply(case_tac w')
     apply(rename_tac n e1 w r w' q b x a q1 ba q2 list)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a q1 ba q2 list aa lista)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w r w' q b x a wa t)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' q b x a wa t i)(*strict*)
   apply(case_tac w')
    apply(rename_tac n e1 w r w' q b x a wa t i)(*strict*)
    apply(force)
   apply(rename_tac n e1 w r w' q b x a wa t i aa list)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
  apply(erule disjE)
   apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' w1 q b i Aa)(*strict*)
   apply(rule_tac
      x="filterA r"
      in exI)
   apply(rule conjI)
    apply(rename_tac n e1 w r w' w1 q b i Aa)(*strict*)
    apply(rule setB_empty_then_liftA_vs_filterA)
    apply(force)
   apply(rename_tac n e1 w r w' w1 q b i Aa)(*strict*)
   apply(case_tac "r")
    apply(rename_tac n e1 w r w' w1 q b i Aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w r w' w1 q b i Aa a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w w' w1 q b i Aa a list)(*strict*)
   apply(case_tac a)
    apply(rename_tac n e1 w w' w1 q b i Aa a list aa)(*strict*)
    prefer 2
    apply(rename_tac n e1 w w' w1 q b i Aa a list ba)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w w' w1 q b i Aa a list aa)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t)(*strict*)
   apply(rule conjI)
    apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t x)(*strict*)
    apply(case_tac wa)
     apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t x)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t x a lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w w' w1 q b i Aa list t x a lista)(*strict*)
    apply(case_tac x)
     apply(rename_tac n e1 w w' w1 q b i Aa list t x a lista qa ba)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1 w w' w1 q b i Aa list t a lista qa ba)(*strict*)
     prefer 2
     apply(rename_tac n e1 w w' w1 q b i Aa list t x a lista q1 ba q2)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w w' w1 q b i Aa list t a lista qa ba)(*strict*)
    apply(case_tac w')
     apply(rename_tac n e1 w w' w1 q b i Aa list t a lista qa ba)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w w' w1 q b i Aa list t a lista qa ba aa listb)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t)(*strict*)
   apply(rule conjI)
    apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t)(*strict*)
    apply(case_tac t)
     apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t qa ba)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t q1 ba q2)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w w' w1 q b i Aa list aa wa q1 ba q2)(*strict*)
    apply(case_tac w')
     apply(rename_tac n e1 w w' w1 q b i Aa list aa wa q1 ba q2)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w w' w1 q b i Aa list aa wa q1 ba q2 a lista)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t ia)(*strict*)
   apply(case_tac wa)
    apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t ia)(*strict*)
    apply(force)
   apply(rename_tac n e1 w w' w1 q b i Aa list aa wa t ia a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w w' w1 q b i Aa list t ia a lista)(*strict*)
   apply(case_tac w')
    apply(rename_tac n e1 w w' w1 q b i Aa list t ia a lista)(*strict*)
    apply(force)
   apply(rename_tac n e1 w w' w1 q b i Aa list t ia a lista aa listb)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 w r w' w1 w2 A q b)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
  apply(case_tac "edge_push x")
   apply(rename_tac n e1 w r w' w1 w2 A q b x)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 w r w' w1 w2 A q b x a list)(*strict*)
  apply(clarsimp)
  apply(case_tac "edge_event x")
   apply(rename_tac n e1 w r w' w1 w2 A q b x a list)(*strict*)
   prefer 2
   apply(rename_tac n e1 w r w' w1 w2 A q b x a list aa)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 w r w' w1 w2 A q b x a list)(*strict*)
  apply(clarsimp)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def)
  apply(erule disjE)
   apply(rename_tac n e1 w r w' w1 w2 A q b x a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' w1 w2 q b x a list)(*strict*)
   apply(case_tac w1)
    apply(rename_tac n e1 w r w' w1 w2 q b x a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a list)(*strict*)
    prefer 2
    apply(rename_tac n e1 w r w' w1 w2 q b x a list aa lista)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w r w' q b x a list)(*strict*)
   apply(rule_tac
      x="cons_l2 (edge_trg x) a # (filterA r)"
      in exI)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac n e1 w r w' q b x a list)(*strict*)
    apply(rule setB_empty_then_liftA_vs_filterA)
    apply(force)
   apply(rename_tac n e1 w r w' q b x a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w r w' q b x a list wa t)(*strict*)
   apply(rule conjI)
    apply(rename_tac n e1 w r w' q b x a list wa t)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a list wa t xa)(*strict*)
    apply(case_tac xa)
     apply(rename_tac n e1 w r w' q b x a list wa t xa qa ba)(*strict*)
     prefer 2
     apply(rename_tac n e1 w r w' q b x a list wa t xa q1 ba q2)(*strict*)
     apply(clarsimp)
    apply(rename_tac n e1 w r w' q b x a list wa t xa qa ba)(*strict*)
    apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list wa t qa ba)(*strict*)
  apply(case_tac wa)
   apply(rename_tac n e1 w r w' q b x a list wa t qa ba)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list wa t qa ba aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list t qa ba lista)(*strict*)
  apply(case_tac w')
   apply(rename_tac n e1 w r w' q b x a list t qa ba lista)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list t qa ba lista aa listb)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list wa t)(*strict*)
  apply(rule conjI)
  apply(rename_tac n e1 w r w' q b x a list wa t)(*strict*)
  apply(case_tac t)
   apply(rename_tac n e1 w r w' q b x a list wa t qa ba)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list wa t q1 ba q2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list wa q1 ba q2)(*strict*)
  apply(case_tac wa)
   apply(rename_tac n e1 w r w' q b x a list wa q1 ba q2)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list wa q1 ba q2 aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list q1 ba q2 lista)(*strict*)
  apply(case_tac w')
   apply(rename_tac n e1 w r w' q b x a list q1 ba q2 lista)(*strict*)
   apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list q1 ba q2 lista aa listb)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list wa t)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list wa t i)(*strict*)
  apply(case_tac wa)
  apply(rename_tac n e1 w r w' q b x a list wa t i)(*strict*)
  apply(force)
  apply(rename_tac n e1 w r w' q b x a list wa t i aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list t i lista)(*strict*)
  apply(case_tac w')
  apply(rename_tac n e1 w r w' q b x a list t i lista)(*strict*)
  apply(force)
  apply(rename_tac n e1 w r w' q b x a list t i lista aa listb)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' w1 w2 A q b x a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' w1 w2 q b x a list qs)(*strict*)
  apply(case_tac w1)
  apply(rename_tac n e1 w r w' w1 w2 q b x a list qs)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs)(*strict*)
  prefer 2
  apply(rename_tac n e1 w r w' w1 w2 q b x a list qs aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs)(*strict*)
  apply(rule_tac
    x="cons_l3 (edge_trg x) a qs # cons_l2 qs (edge_pop x ! 0) # (filterA r)"
    in exI)
  apply(clarsimp)
  apply(rule conjI)
  apply(rename_tac n e1 w r w' q b x a list qs)(*strict*)
  apply(rule setB_empty_then_liftA_vs_filterA)
  apply(force)
  apply(rename_tac n e1 w r w' q b x a list qs)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa t)(*strict*)
  apply(rule conjI)
  apply(rename_tac n e1 w r w' q b x a list qs wa t)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa t xa)(*strict*)
  apply(case_tac xa)
  apply(rename_tac n e1 w r w' q b x a list qs wa t xa qa ba)(*strict*)
  prefer 2
  apply(rename_tac n e1 w r w' q b x a list qs wa t xa q1 ba q2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa t xa qa ba)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa t qa ba)(*strict*)
  apply(case_tac wa)
  apply(rename_tac n e1 w r w' q b x a list qs wa t qa ba)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa t qa ba aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs t qa ba lista)(*strict*)
  apply(case_tac w')
  apply(rename_tac n e1 w r w' q b x a list qs t qa ba lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs t qa ba lista aa listb)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa t)(*strict*)
  apply(rule conjI)
  apply(rename_tac n e1 w r w' q b x a list qs wa t)(*strict*)
  apply(case_tac t)
  apply(rename_tac n e1 w r w' q b x a list qs wa t qa ba)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa t q1 ba q2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa q1 ba q2)(*strict*)
  apply(case_tac wa)
  apply(rename_tac n e1 w r w' q b x a list qs wa q1 ba q2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa q1 ba q2 aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs q1 ba q2 lista)(*strict*)
  apply(case_tac w')
  apply(rename_tac n e1 w r w' q b x a list qs q1 ba q2 lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs q1 ba q2 lista aa listb)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs wa t)(*strict*)
  apply(case_tac wa)
  apply(rename_tac n e1 w r w' q b x a list qs wa t)(*strict*)
  apply(force)
  apply(rename_tac n e1 w r w' q b x a list qs wa t aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w r w' q b x a list qs t lista i)(*strict*)
  apply(case_tac w')
  apply(rename_tac n e1 w r w' q b x a list qs t lista i)(*strict*)
  apply(force)
  apply(rename_tac n e1 w r w' q b x a list qs t lista i aa listb)(*strict*)
  apply(clarsimp)
  done

lemma LR1_cfgLM_derivations_reachable_conf_form: "
  valid_cfg G
  \<Longrightarrow> LR1ProdForm G
  \<Longrightarrow> cfg_initial G = cons_l2 q A
  \<Longrightarrow> cfgLM.derivation_initial G d
  \<Longrightarrow> d n = Some (pair e \<lparr>cfg_conf = w\<rparr>)
  \<Longrightarrow> setA w = {} \<or> (\<exists>w1 w2 B. w = (liftB w1) @ teA B # (liftA w2))"
  apply(induct n arbitrary: e w)
   apply(rename_tac e w)(*strict*)
   apply(clarsimp)
   apply(simp add: cfgLM.derivation_initial_def cfg_initial_configurations_def)
   apply(clarsimp)
   apply(erule_tac
      x="[]"
      in allE)
   apply(clarsimp)
   apply(erule_tac
      x="[]"
      in allE)
   apply(force)
  apply(rename_tac n e w)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "\<exists>e1 e2 c1 c2. d n = Some (pair e1 c1) \<and> d (Suc n) = Some (pair (Some e2) c2) \<and> cfgLM_step_relation G c1 e2 c2")
   apply(rename_tac n e w)(*strict*)
   prefer 2
   apply(rule_tac
      m="Suc n"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac n e w)(*strict*)
     apply(rule cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac n e w)(*strict*)
    apply(force)
   apply(rename_tac n e w)(*strict*)
   apply(force)
  apply(rename_tac n e w)(*strict*)
  apply(clarsimp)
  apply(rename_tac n w e1 e2 c1)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac n e1 e2 c1 l r)(*strict*)
  apply(case_tac c1)
  apply(rename_tac n e1 e2 c1 l r cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 l r)(*strict*)
  apply(erule_tac
      x="e1"
      in meta_allE)
  apply(clarsimp)
  apply(erule_tac
      x="l @ teA (prod_lhs e2) # r"
      in meta_allE)
  apply(clarsimp)
  apply(erule disjE)
   apply(rename_tac n e1 e2 l r)(*strict*)
   apply (metis elemInsetA ex_in_conv)
  apply(rename_tac n e1 e2 l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 l r w1 w2 B)(*strict*)
  apply(subgoal_tac "l=liftB w1")
   apply(rename_tac n e1 e2 l r w1 w2 B)(*strict*)
   prefer 2
   apply (metis liftA.simps(2) split_decide1)
  apply(rename_tac n e1 e2 l r w1 w2 B)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 w1 w2)(*strict*)
  apply(thin_tac "setA (liftB w1) = {}")
  apply(simp add: setAConcat)
  apply(rule conjI)
   apply(rename_tac n e1 e2 w1 w2)(*strict*)
   apply (metis setA_liftB)
  apply(rename_tac n e1 e2 w1 w2)(*strict*)
  apply(simp add: LR1ProdForm_def)
  apply(erule_tac
      x="e2"
      in ballE)
   apply(rename_tac n e1 e2 w1 w2)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac n e1 e2 w1 w2)(*strict*)
  apply(erule disjE)
   apply(rename_tac n e1 e2 w1 w2)(*strict*)
   apply(clarsimp)
   apply(case_tac e2)
   apply(rename_tac n e1 e2 w1 w2 prod_lhsa prod_rhsa)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w1 w2 prod_lhs)(*strict*)
   apply(rename_tac B)
   apply(rename_tac n e1 w1 w2 B)(*strict*)
   apply(erule_tac
      x="w1"
      in allE)
   apply(case_tac w2)
    apply(rename_tac n e1 w1 w2 B)(*strict*)
    apply(clarsimp)
   apply(rename_tac n e1 w1 w2 B a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w1 B a list)(*strict*)
   apply(force)
  apply(rename_tac n e1 e2 w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 w1 w2 b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac n e1 e2 w1 w2 b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w1 w2 b q1 q2 A1)(*strict*)
   apply(erule_tac
      x="w1@[b]"
      in allE)
   apply(simp add: liftB_commutes_over_concat)
   apply(force)
  apply(rename_tac n e1 e2 w1 w2 b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac n e1 e2 w1 w2 b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w1 w2 b q1 q2 q3 A1)(*strict*)
   apply(erule_tac
      x="w1@[b]"
      in allE)
   apply(simp add: liftB_commutes_over_concat)
   apply(force)
  apply(rename_tac n e1 e2 w1 w2 b q1 q2 q3 q4 A1)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 e2 w1 w2 q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac n e1 e2 w1 w2 q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w1 w2 q1 q2 A1 A2)(*strict*)
   apply(erule_tac
      x="w1"
      in allE)
   apply(force)
  apply(rename_tac n e1 e2 w1 w2 q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac n e1 e2 w1 w2 q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1 w1 w2 q1 q2 q3 A1 A2)(*strict*)
   apply(erule_tac
      x="w1"
      in allE)
   apply(clarsimp)
   apply(erule_tac
      x="(cons_l2 q3 A1 # w2)"
      in allE)
   apply(clarsimp)
  apply(rename_tac n e1 e2 w1 w2 q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 w1 w2 q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule_tac
      x="w1"
      in allE)
  apply(clarsimp)
  apply(erule_tac
      x="(cons_l3 q3 A1 q4 # w2)"
      in allE)
  apply(clarsimp)
  done

lemma F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD__SOUND_back_hlp_prime_prime: "
  valid_simple_dpda G1
  \<Longrightarrow> G2 = F_SDPDA_TO_CFG_STD G1
  \<Longrightarrow> cfgLM.derivation_initial G2 dR
  \<Longrightarrow> dR n = Some (pair eR cR)
  \<Longrightarrow> setA (cfg_conf cR) \<noteq> {}
  \<Longrightarrow> \<exists>dL. epdaH.derivation_initial G1 dL \<and> (\<forall>k \<le> n. \<exists>eL cL eR cR. (dL k = Some (pair eL cL) \<and> dR k = Some (pair eR cR)) \<and> ((case eR of Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR' | _ \<Rightarrow> False) | _ \<Rightarrow> True) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w))))"
  apply(induct n arbitrary: eR cR)
   apply(rename_tac eR cR)(*strict*)
   apply(clarsimp)
   apply(rule_tac
      x="der1 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR [])"
      in exI)
   apply(rule conjI)
    apply(rename_tac eR cR)(*strict*)
    apply(rule epdaH.derivation_initialI)
     apply(rename_tac eR cR)(*strict*)
     apply(rule epdaH.der1_is_derivation)
    apply(rename_tac eR cR)(*strict*)
    apply(simp add: get_configuration_def der1_def)
    apply(simp add: cfgLM.derivation_initial_def)
    apply(rule F_SDPDA_TO_CFG_STD__preserve_initial_configuration)
     apply(rename_tac eR cR)(*strict*)
     apply(force)
    apply(rename_tac eR cR)(*strict*)
    apply(force)
   apply(rename_tac eR cR)(*strict*)
   apply(simp add: der1_def)
   apply(rule conjI)
    apply(rename_tac eR cR)(*strict*)
    apply(case_tac eR)
     apply(rename_tac eR cR)(*strict*)
     apply(force)
    apply(rename_tac eR cR a)(*strict*)
    apply(clarsimp)
    apply(rename_tac cR a)(*strict*)
    apply (metis cfgLM.derivation_initial_is_derivation cfgLM.initialNotEdgeSome_prime)
   apply(rename_tac eR cR)(*strict*)
   apply(rule_tac
      x="[]"
      in exI)
   apply(force)
  apply(rename_tac n eR cR)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "\<exists>e1 e2 c1 c2. dR n = Some (pair e1 c1) \<and> dR (Suc n) = Some (pair (Some e2) c2) \<and> cfgLM_step_relation (F_SDPDA_TO_CFG_STD G1) c1 e2 c2")
   apply(rename_tac n eR cR)(*strict*)
   prefer 2
   apply(rule_tac
      m="Suc n"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac n eR cR)(*strict*)
     apply(rule cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac n eR cR)(*strict*)
    apply(force)
   apply(rename_tac n eR cR)(*strict*)
   apply(force)
  apply(rename_tac n eR cR)(*strict*)
  apply(clarsimp)
  apply(rename_tac n cR e1 e2 c1)(*strict*)
  apply(erule_tac
      x="e1"
      in meta_allE)
  apply(erule_tac
      x="c1"
      in meta_allE)
  apply(clarsimp)
  apply(erule meta_impE)
   apply(rename_tac n cR e1 e2 c1)(*strict*)
   apply(simp add: cfgLM_step_relation_def)
   apply(clarsimp)
   apply(rename_tac n cR e1 e2 c1 l r)(*strict*)
   apply (metis elemInsetA ex_in_conv)
  apply(rename_tac n cR e1 e2 c1)(*strict*)
  apply(clarsimp)
  apply(rename_tac n cR e1 e2 c1 dL)(*strict*)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
  apply(subgoal_tac "(eR2 \<in> F_SDPDA_TO_CFG_STD__edges_l3 G1 \<or> eR2 \<in> F_SDPDA_TO_CFG_STD__edges_l2 G1)")
   apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
   prefer 2
   apply(simp add: cfgLM_step_relation_def F_SDPDA_TO_CFG_STD_def)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
  apply(erule disjE)
   apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_def)
   apply(erule disjE)
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
    apply(case_tac "edge_event x")
     apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL x a qt)(*strict*)
    apply(subgoal_tac "\<exists>y. edge_pop x=[y]")
     apply(rename_tac nR cR2 eR1 cR1 dL x a qt)(*strict*)
     prefer 2
     apply(rule_tac
      G="G1"
      in valid_pda_edge_pop_single)
      apply(rename_tac nR cR2 eR1 cR1 dL x a qt)(*strict*)
      apply(simp add: valid_simple_dpda_def valid_dpda_def)
     apply(rename_tac nR cR2 eR1 cR1 dL x a qt)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL x a qt)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL x a qt y)(*strict*)
    apply(case_tac x)
    apply(rename_tac nR cR2 eR1 cR1 dL x a qt y edge_srca edge_eventa edge_popa edge_push edge_trga)(*strict*)
    apply(rename_tac qs re po pu qt)
    apply(rename_tac nR cR2 eR1 cR1 dL x a qta y qs re po pu qt)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt)(*strict*)
    apply(simp add: cfgLM_step_relation_def)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
    apply(rule_tac
      t="edge_src \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr>"
      and s="qs"
      in ssubst)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
    apply(rule_tac
      t="edge_pop \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr>"
      and s="[y]"
      in ssubst)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
    apply(rule_tac
      t="edge_trg \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr>"
      and s="qt"
      in ssubst)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
    apply(rule_tac
      t="[y] ! 0"
      and s="y"
      in ssubst)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
    apply(subgoal_tac "\<exists>eL cL. dL nR = Some (pair eL cL) \<and> (\<exists>eR cR. dR nR = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL cL)(*strict*)
    apply(erule impE)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL cL)(*strict*)
     apply (metis elemInsetA empty_iff)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL cL)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
    apply(subgoal_tac "epdaH_step_relation G1 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)")
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     prefer 2
     apply(simp add: epdaH_step_relation_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
     apply(rule_tac
      t="THE v. \<exists>w. l @ teA (cons_l3   qs y qta) # r = liftB w @ liftA v"
      and s="(cons_l3 qs y qta)#(filterA r)"
      in ssubst)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(rule THE_split3)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
       apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
        prefer 2
        apply(rule_tac
      n="nR"
      in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
          apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
          apply(force)
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
        apply(simp add: get_configuration_def)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
       apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
       apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
       apply(subgoal_tac "l=liftB wa")
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
        prefer 2
        apply(rule split_decide1)
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
       apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt r eL w wa v)(*strict*)
       apply(rule_tac
      v="v"
      and y="[]"
      and w="[teA (cons_l3   qs y qta)]"
      in liftA_append_setB)
       apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(rule_tac
      t="l @ teB a # teA (cons_l3   qt y qta) # r"
      and s="(l @ [teB a]) @ teA (cons_l3   qt y qta) # r"
      in ssubst)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(rule_tac
      t="THE v. \<exists>w. (l @ [teB a]) @ teA (cons_l3   qt y qta) # r = liftB w @ liftA v"
      and s="(cons_l3 qt y qta)#(filterA r)"
      in ssubst)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(rule THE_split3)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
       apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
        prefer 2
        apply(rule_tac
      n="nR"
      in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
          apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
          apply(force)
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
        apply(simp add: get_configuration_def)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
       apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
       apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
       apply(subgoal_tac "l=liftB wa")
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
        prefer 2
        apply(rule split_decide1)
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
       apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt r eL w wa v)(*strict*)
       apply(rule_tac
      v="v"
      and y="[]"
      and w="[teA (cons_l3   qs y qta)]"
      in liftA_append_setB)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(simp add: setAConcat)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(rule_tac
      t="THE w. \<exists>v. (l @ [teB a]) @ teA (cons_l3   qt y qta) # r = liftB w @ liftA v"
      and s="filterB l@[a]"
      in ssubst)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(rule THE_split4)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
        apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
         prefer 2
         apply(rule_tac
      n="nR"
      in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
           apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
           apply(force)
          apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
          apply(force)
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
         apply(simp add: get_configuration_def)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
        apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
        apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
        apply(subgoal_tac "l=liftB wa")
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
         prefer 2
         apply(rule split_decide1)
          apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
          apply(force)
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
        apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt r eL w wa v)(*strict*)
        apply(rule_tac
      v="v"
      and y="[]"
      and w="[teA (cons_l3   qs y qta)]"
      in liftA_append_setB)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
       apply(simp add: setAConcat)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(simp add: filterB_commutes_over_concat)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(rule_tac
      t="THE w. \<exists>v. l @ teA (cons_l3   qs y qta) # r = liftB w @ liftA v"
      and s="filterB l"
      in ssubst)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(rule THE_split4)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
        apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
         prefer 2
         apply(rule_tac
      n="nR"
      in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
           apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
           apply(force)
          apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
          apply(force)
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
         apply(simp add: get_configuration_def)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
        apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
        apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
        apply(subgoal_tac "l=liftB wa")
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
         prefer 2
         apply(rule split_decide1)
          apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
          apply(force)
         apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w wa v)(*strict*)
        apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt r eL w wa v)(*strict*)
        apply(rule_tac
      v="v"
      and y="[]"
      and w="[teA (cons_l3   qs y qta)]"
      in liftA_append_setB)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
       apply (metis)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply (metis liftBDeConv1 liftBDeConv2 liftB_commute_one_elem_app)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(clarsimp)
     apply(simp add: option_to_list_def)
     apply(simp add: valid_simple_dpda_def)
     apply(clarsimp)
     apply(erule_tac
      x="\<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr>"
      in ballE)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
    apply(rule_tac
      x="derivation_append dL (der2 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)) nR"
      in exI)
    apply(rule conjI)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(rule epdaH.derivation_append_preserves_derivation_initial)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
       apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(rule epdaH.derivation_append_preserves_derivation)
       apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
       apply(simp add: epdaH.derivation_initial_def)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(rule epdaH.der2_is_derivation)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(clarsimp)
     apply(simp add: der2_def)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
    apply(rule allI)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w k)(*strict*)
    apply(erule_tac
      x="k"
      in allE)
    apply(case_tac "k\<le>nR")
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w k)(*strict*)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w k eLa cL eR cR)(*strict*)
     apply(simp add: derivation_append_def der2_def)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w k)(*strict*)
    apply(clarsimp)
    apply(subgoal_tac "k=Suc nR")
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w k)(*strict*)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(simp add: derivation_append_def der2_def)
     apply(rule conjI)
      apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
      apply(clarsimp)
      apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def)
      apply(rule disjI1)
      apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def)
     apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w)(*strict*)
     apply(rule_tac
      x="w"
      in exI)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a qta y qs pu qt l r eL w k)(*strict*)
    apply(force)
   apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
   apply(erule disjE)
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
    apply(case_tac "edge_push x")
     apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
     prefer 2
     apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a list)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
    apply(clarsimp)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL x)(*strict*)
    apply(subgoal_tac "\<exists>y. edge_pop x=[y]")
     apply(rename_tac nR cR2 eR1 cR1 dL x)(*strict*)
     prefer 2
     apply(rule_tac
      G="G1"
      in valid_pda_edge_pop_single)
      apply(rename_tac nR cR2 eR1 cR1 dL x)(*strict*)
      apply(simp add: valid_simple_dpda_def valid_dpda_def)
     apply(rename_tac nR cR2 eR1 cR1 dL x)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL x)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL x y)(*strict*)
    apply(case_tac x)
    apply(rename_tac nR cR2 eR1 cR1 dL x y edge_srca edge_event edge_popa edge_pusha edge_trga)(*strict*)
    apply(rename_tac qs re po pu qt)
    apply(rename_tac nR cR2 eR1 cR1 dL x y qs re po pu qt)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
    apply(rule_tac
      t="edge_src \<lparr>edge_src = qs, edge_event = re, edge_pop = [y], edge_push = [], edge_trg = qt\<rparr>"
      and s="qs"
      in ssubst)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
    apply(rule_tac
      t="edge_pop \<lparr>edge_src = qs, edge_event = re, edge_pop = [y], edge_push = [], edge_trg = qt\<rparr>!0"
      and s="y"
      in ssubst)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
    apply(rule_tac
      t="edge_trg \<lparr>edge_src = qs, edge_event = re, edge_pop = [y], edge_push = [], edge_trg = qt\<rparr>"
      and s="qt"
      in ssubst)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
    apply(subgoal_tac "re=None")
     apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
     prefer 2
     apply(simp add: valid_simple_dpda_def)
     apply(clarsimp)
     apply(erule_tac
      x="\<lparr>edge_src = qs, edge_event = re, edge_pop = [y], edge_push = [], edge_trg = qt\<rparr>"
      in ballE)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
      apply(case_tac re)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
       apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt a)(*strict*)
      apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs re qt)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt)(*strict*)
    apply(subgoal_tac "\<exists>eL cL. dL nR = Some (pair eL cL) \<and> (\<exists>eR cR. dR nR = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL cL)(*strict*)
    apply(erule impE)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL cL)(*strict*)
     apply(clarsimp)
     apply(simp add: cfgLM_step_relation_def)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL cL l r)(*strict*)
     apply(case_tac cR1)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL cL l r cfg_confa)(*strict*)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 dL y qs qt eL cL l r)(*strict*)
     apply (metis elemInsetA empty_iff)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL cL)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
    apply(subgoal_tac "epdaH_step_relation G1 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [], edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)")
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
     prefer 2
     apply(thin_tac "\<forall>k\<le>nR. \<exists>eL cL. dL k = Some (pair eL cL) \<and> (\<exists>eR cR. dR k = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
     apply(thin_tac "case eR1 of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')")
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
     apply(simp add: epdaH_step_relation_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def cfgLM_step_relation_def)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
     apply(rule_tac
      t="THE v. \<exists>w. l @ teA (cons_l3   qs y qt) # r = liftB w @ liftA v"
      and s="(cons_l3 qs y qt)#(filterA r)"
      in ssubst)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(rule THE_split3)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
       apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
        prefer 2
        apply(rule_tac
      n="nR"
      in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
          apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
          apply(force)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
        apply(simp add: get_configuration_def)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
       apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
       apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
       apply(subgoal_tac "l=liftB wa")
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
        prefer 2
        apply(rule split_decide1)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
       apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w r wa v)(*strict*)
       apply(rule_tac
      v="v"
      and y="[]"
      and w="[teA (cons_l3   qs y qt)]"
      in liftA_append_setB)
       apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
     apply(subgoal_tac "setB r={} \<and> r\<noteq>[]")
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      prefer 2
      apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
       prefer 2
       apply(rule_tac
      n="nR"
      in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
       apply(simp add: get_configuration_def)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
      apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
      apply(subgoal_tac "l=liftB wa")
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
       prefer 2
       apply(rule split_decide1)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
      apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w r wa v)(*strict*)
      apply(rule context_conjI)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w r wa v)(*strict*)
       apply(rule_tac
      v="v"
      and y="[]"
      and w="[teA (cons_l3   qs y qt)]"
      in liftA_append_setB)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w r wa v)(*strict*)
      apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
     apply(rule_tac
      t="THE v. \<exists>w. l @ r = liftB w @ liftA v"
      and s="filterA r"
      in ssubst)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(rule THE_split5)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
     apply(rule_tac
      t="THE w. \<exists>v. l @ r = liftB w @ liftA v"
      and s="filterB l"
      in ssubst)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(rule THE_split6)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
     apply(rule_tac
      t="THE w. \<exists>v. l @ teA (cons_l3   qs y qt) # r = liftB w @ liftA v"
      and s="filterB l"
      in ssubst)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(rule THE_split6)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
     apply(clarsimp)
     apply(simp add: option_to_list_def)
     apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      prefer 2
      apply(rule_tac
      n="nR"
      in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
      apply(simp add: get_configuration_def)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r)(*strict*)
     apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
     apply(case_tac r)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l r wa v a list)(*strict*)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v a list)(*strict*)
     apply(case_tac a)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v a list aa)(*strict*)
      apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list aa)(*strict*)
      apply(case_tac aa)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list aa q b)(*strict*)
       apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
       apply(subgoal_tac "\<forall>w t. v = w @ [t] \<longrightarrow> Ball (set w) (case_DT_l2_l3_nonterminals (\<lambda>q y. False) (\<lambda>q1 b q2. True)) \<and> (case t of cons_l2 q y \<Rightarrow> True | cons_l3 q1 b q2 \<Rightarrow> False) \<and> (\<forall>i. Suc i < length v \<longrightarrow> (case v ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case v ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
        prefer 2
        apply(case_tac v)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b a lista)(*strict*)
        apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
       apply(thin_tac "case v of [] \<Rightarrow> True | a # y \<Rightarrow> \<forall>w t. v = w @ [t] \<longrightarrow> Ball (set w) (case_DT_l2_l3_nonterminals (\<lambda>q y. False) (\<lambda>q1 b q2. True)) \<and> (case t of cons_l2 q y \<Rightarrow> True | cons_l3 q1 b q2 \<Rightarrow> False) \<and> (\<forall>i. Suc i < length v \<longrightarrow> (case v ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case v ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
       apply(subgoal_tac "(\<forall>i. Suc i < length v \<longrightarrow> (case v ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case v ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
        prefer 2
        apply(case_tac v)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b a lista)(*strict*)
        apply(erule_tac
      x="butlast v"
      in allE)
        apply(erule_tac
      x="last v"
      in allE)
        apply(erule impE)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b a lista)(*strict*)
         apply (metis append_butlast_last_id list.simps(2))
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b a lista)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
       apply(thin_tac "\<forall>w t. v = w @ [t] \<longrightarrow> Ball (set w) (case_DT_l2_l3_nonterminals (\<lambda>q y. False) (\<lambda>q1 b q2. True)) \<and> (case t of cons_l2 q y \<Rightarrow> True | cons_l3 q1 b q2 \<Rightarrow> False) \<and> (\<forall>i. Suc i < length v \<longrightarrow> (case v ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case v ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
       apply(erule_tac
      x="0"
      in allE)
       apply(erule impE)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
        apply(case_tac v)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
         apply(clarsimp)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q b)(*strict*)
         apply (metis setA_liftB elemInsetA empty_iff)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b a lista)(*strict*)
        apply(case_tac lista)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b a lista)(*strict*)
         apply(clarsimp)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q b a)(*strict*)
         apply(case_tac list)
          apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q b a)(*strict*)
          apply(clarsimp)
          apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa q b)(*strict*)
          apply (metis setA_liftB elemInsetA empty_iff)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q b a aa lista)(*strict*)
         apply(subgoal_tac "\<exists>w' x'. list=w'@[x']")
          apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q b a aa lista)(*strict*)
          prefer 2
          apply(rule_tac
      n="length lista"
      in NonEmptyListHasTailElem)
          apply(force)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q b a aa lista)(*strict*)
         apply(thin_tac "list=aa#lista")
         apply(clarsimp)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa q b a w')(*strict*)
         apply (metis setA_liftB elemInsetA empty_iff)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b a lista aa listb)(*strict*)
        apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
       apply(subgoal_tac "l=liftB wa")
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
        apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w wa v list q b)(*strict*)
        apply(case_tac v)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w wa v list q b)(*strict*)
         apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w wa v list q b a lista)(*strict*)
        apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs eL w wa list q b lista)(*strict*)
        apply(case_tac lista)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs eL w wa list q b lista)(*strict*)
         apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs eL w wa list q b lista a listb)(*strict*)
        apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q b)(*strict*)
       apply (metis split_decide1)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list aa q1 b q2)(*strict*)
      apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
      apply(subgoal_tac "\<forall>w t. v = w @ [t] \<longrightarrow> Ball (set w) (case_DT_l2_l3_nonterminals (\<lambda>q y. False) (\<lambda>q1 b q2. True)) \<and> (case t of cons_l2 q y \<Rightarrow> True | cons_l3 q1 b q2 \<Rightarrow> False) \<and> (\<forall>i. Suc i < length v \<longrightarrow> (case v ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case v ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
       prefer 2
       apply(case_tac v)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2 a lista)(*strict*)
       apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
      apply(thin_tac "case v of [] \<Rightarrow> True | a # y \<Rightarrow> \<forall>w t. v = w @ [t] \<longrightarrow> Ball (set w) (case_DT_l2_l3_nonterminals (\<lambda>q y. False) (\<lambda>q1 b q2. True)) \<and> (case t of cons_l2 q y \<Rightarrow> True | cons_l3 q1 b q2 \<Rightarrow> False) \<and> (\<forall>i. Suc i < length v \<longrightarrow> (case v ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case v ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
      apply(subgoal_tac "(\<forall>i. Suc i < length v \<longrightarrow> (case v ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case v ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
       prefer 2
       apply(case_tac v)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2 a lista)(*strict*)
       apply(erule_tac
      x="butlast v"
      in allE)
       apply(erule_tac
      x="last v"
      in allE)
       apply(erule impE)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2 a lista)(*strict*)
        apply (metis append_butlast_last_id list.simps(2))
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2 a lista)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
      apply(thin_tac "\<forall>w t. v = w @ [t] \<longrightarrow> Ball (set w) (case_DT_l2_l3_nonterminals (\<lambda>q y. False) (\<lambda>q1 b q2. True)) \<and> (case t of cons_l2 q y \<Rightarrow> True | cons_l3 q1 b q2 \<Rightarrow> False) \<and> (\<forall>i. Suc i < length v \<longrightarrow> (case v ! i of cons_l3 q1 A q2 \<Rightarrow> q2) = (case v ! Suc i of cons_l2 q1 A \<Rightarrow> q1 | cons_l3 q1 A q2 \<Rightarrow> q1))")
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
      apply(erule_tac
      x="0"
      in allE)
      apply(erule impE)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
       apply(case_tac v)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
        apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q1 b q2)(*strict*)
        apply (metis setA_liftB elemInsetA empty_iff)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2 a lista)(*strict*)
       apply(case_tac lista)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2 a lista)(*strict*)
        apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q1 b q2 a)(*strict*)
        apply(case_tac list)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q1 b q2 a)(*strict*)
         apply(clarsimp)
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa q1 b q2)(*strict*)
         apply (metis setA_liftB elemInsetA empty_iff)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q1 b q2 a aa lista)(*strict*)
        apply(subgoal_tac "\<exists>w' x'. list=w'@[x']")
         apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q1 b q2 a aa lista)(*strict*)
         prefer 2
         apply(rule_tac
      n="length lista"
      in NonEmptyListHasTailElem)
         apply(force)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa list q1 b q2 a aa lista)(*strict*)
        apply(thin_tac "list=aa#lista")
        apply(clarsimp)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa q1 b q2 a w')(*strict*)
        apply (metis setA_liftB elemInsetA empty_iff)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2 a lista aa listb)(*strict*)
       apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
      apply(subgoal_tac "l=liftB wa")
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
       apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w wa v list q1 b q2)(*strict*)
       apply(case_tac v)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w wa v list q1 b q2)(*strict*)
        apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w wa v list q1 b q2 a lista)(*strict*)
       apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs eL w wa list q1 b q2 lista)(*strict*)
       apply(case_tac lista)
        apply(rename_tac nR cR2 eR1 cR1 dL y qs eL w wa list q1 b q2 lista)(*strict*)
        apply(clarsimp)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs eL w wa list q1 b q2 lista a listb)(*strict*)
       apply(clarsimp)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v list q1 b q2)(*strict*)
      apply (metis split_decide1)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w l wa v a list b)(*strict*)
     apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
    apply(rule_tac
      x="derivation_append dL (der2 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [], edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)) nR"
      in exI)
    apply(rule conjI)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
     apply(rule epdaH.derivation_append_preserves_derivation_initial)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
       apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
     apply(rule epdaH.derivation_append_preserves_derivation)
       apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
       apply(simp add: epdaH.derivation_initial_def)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
      apply(rule epdaH.der2_is_derivation)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
     apply(clarsimp)
     apply(simp add: der2_def)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
    apply(rule allI)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w k)(*strict*)
    apply(erule_tac
      x="k"
      in allE)
    apply(case_tac "k\<le>nR")
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w k)(*strict*)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w k eLa cL eR cR)(*strict*)
     apply(simp add: derivation_append_def der2_def)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w k)(*strict*)
    apply(clarsimp)
    apply(subgoal_tac "k=Suc nR")
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w k)(*strict*)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
     apply(simp add: derivation_append_def der2_def)
     apply(rule conjI)
      apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
      apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def)
      apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def)
     apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w)(*strict*)
     apply(rule_tac
      x="w"
      in exI)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL y qs qt eL w k)(*strict*)
    apply(force)
   apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
   apply(clarsimp)
   apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
   apply(case_tac "edge_push x")
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
    apply(clarsimp)
   apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a list)(*strict*)
   apply(clarsimp)
   apply(case_tac "edge_event x")
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a list)(*strict*)
    prefer 2
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a list aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a list)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "case edge_event x of None \<Rightarrow> edge_push x = [] \<or> (\<exists>y. edge_push x = y # edge_pop x) | Some a \<Rightarrow> edge_pop x = edge_push x")
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a list)(*strict*)
    prefer 2
    apply(simp add: valid_simple_dpda_def)
    apply(clarsimp)
    apply(erule_tac
      x="x"
      in ballE)
     apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a list)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a list)(*strict*)
    apply(force)
   apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def)
   apply(clarsimp)
   apply(rename_tac nR cR2 eR1 cR1 dL x a qs qt)(*strict*)
   apply(subgoal_tac "\<exists>y. edge_pop x=[y]")
    apply(rename_tac nR cR2 eR1 cR1 dL x a qs qt)(*strict*)
    prefer 2
    apply(rule_tac
      G="G1"
      in valid_pda_edge_pop_single)
     apply(rename_tac nR cR2 eR1 cR1 dL x a qs qt)(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def)
    apply(rename_tac nR cR2 eR1 cR1 dL x a qs qt)(*strict*)
    apply(force)
   apply(rename_tac nR cR2 eR1 cR1 dL x a qs qt)(*strict*)
   apply(clarsimp)
   apply(rename_tac nR cR2 eR1 cR1 dL x a qs qt y)(*strict*)
   apply(case_tac x)
   apply(rename_tac nR cR2 eR1 cR1 dL x a qs qt y edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
   apply(rename_tac qs re po pu qt)
   apply(rename_tac nR cR2 eR1 cR1 dL x a qsa qta y qs re po pu qt)(*strict*)
   apply(clarsimp)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt)(*strict*)
   apply(simp add: cfgLM_step_relation_def)
   apply(clarsimp)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r)(*strict*)
   apply(rule_tac
      t="edge_src \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>"
      and s="qs"
      in ssubst)
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r)(*strict*)
    apply(force)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r)(*strict*)
   apply(rule_tac
      t="edge_pop \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>!0"
      and s="y"
      in ssubst)
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r)(*strict*)
    apply(force)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r)(*strict*)
   apply(rule_tac
      t="edge_trg \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>"
      and s="qt"
      in ssubst)
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r)(*strict*)
    apply(force)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r)(*strict*)
   apply(subgoal_tac "\<exists>eL cL. dL nR = Some (pair eL cL) \<and> (\<exists>eR cR. dR nR = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r)(*strict*)
   apply(clarsimp)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL cL)(*strict*)
   apply(erule impE)
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL cL)(*strict*)
    apply (metis elemInsetA empty_iff)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL cL)(*strict*)
   apply(clarsimp)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
   apply(subgoal_tac "epdaH_step_relation G1 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a,y], edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)")
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
    prefer 2
    apply(thin_tac "\<forall>k\<le>nR. \<exists>eL cL. dL k = Some (pair eL cL) \<and> (\<exists>eR cR. dR k = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
    apply(thin_tac "case eR1 of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')")
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
    apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
     apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
     prefer 2
     apply(rule_tac
      n="nR"
      in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
       apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
     apply(simp add: get_configuration_def)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
  apply(thin_tac "cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G1) dR")
  apply(thin_tac "dR (Suc nR) = Some (pair (Some \<lparr>prod_lhs = cons_l3 qs y qta, prod_rhs = [teA (cons_l3   qt a qsa), teA (cons_l3   qsa y qta)]\<rparr>) cR2)")
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
  apply(thin_tac "dR nR = Some (pair eR1 cR1)")
  apply(thin_tac "epdaH.derivation_initial G1 dL")
  apply(thin_tac "dL nR = Some (pair eL (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w))")
  apply(simp add: epdaH_step_relation_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
  apply(subgoal_tac "setB r={} \<and> r\<noteq>[]")
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
   prefer 2
   apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
   apply(clarsimp)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w wa v)(*strict*)
   apply(subgoal_tac "l=liftB wa")
    apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w wa v)(*strict*)
    prefer 2
    apply(rule split_decide1)
     apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w wa v)(*strict*)
     apply(force)
    apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w wa v)(*strict*)
    apply(force)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w wa v)(*strict*)
   apply(clarsimp)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt r w wa v)(*strict*)
   apply(rule context_conjI)
    apply(rename_tac cR2 cR1 a qsa qta y qs qt r w wa v)(*strict*)
    apply(rule_tac
    v="v"
    and y="[]"
    and w="[teA (cons_l3   qs y qta)]"
    in liftA_append_setB)
    apply(force)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt r w wa v)(*strict*)
   apply(clarsimp)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt w wa v)(*strict*)
   apply(case_tac v)
    apply(rename_tac cR2 cR1 a qsa qta y qs qt w wa v)(*strict*)
    apply(force)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt w wa v aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt w wa list)(*strict*)
   apply(case_tac list)
    apply(rename_tac cR2 cR1 a qsa qta y qs qt w wa list)(*strict*)
    prefer 2
    apply(rename_tac cR2 cR1 a qsa qta y qs qt w wa list aa lista)(*strict*)
    apply(force)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt w wa list)(*strict*)
   apply(force)
  apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
  apply(clarsimp)
  apply(rule_tac
    t="THE v. \<exists>w. l @ teA (cons_l3   qs y qta) # r = liftB w @ liftA v"
    and s="(cons_l3 qs y qta)#(filterA r)"
    in ssubst)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
   apply(rule THE_split3)
    apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
    apply(force)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
   apply(force)
  apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
  apply(rule_tac
    t="THE v. \<exists>w. l @ teA (cons_l3   qt a qsa) # teA (cons_l3   qsa y qta) # r = liftB w @ liftA v"
    and s="(cons_l3 qt a qsa)#(cons_l3 qsa y qta)#(filterA r)"
    in ssubst)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
   apply(rule THE_split3_prime)
    apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
    apply(force)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
   apply(force)
  apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
  apply(clarsimp)
  apply(simp add: option_to_list_def)
  apply(rule_tac
    t="THE w. \<exists>v. l @ teA (cons_l3   qt a qsa) # teA (cons_l3   qsa y qta) # r = liftB w @ liftA v"
    and s="filterB l"
    in ssubst)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
   apply(rule THE_split6)
    apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
    apply(force)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
   apply(force)
  apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
  apply(rule_tac
    t="THE w. \<exists>v. l @ teA (cons_l3   qs y qta) # r = liftB w @ liftA v"
    and s="filterB l"
    in ssubst)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
   apply(rule THE_split6)
    apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
    apply(force)
   apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
   apply(force)
  apply(rename_tac cR2 cR1 a qsa qta y qs qt l r w)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
  apply(rule_tac
    x="derivation_append dL (der2 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a,y], edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)) nR"
    in exI)
  apply(rule conjI)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
  apply(rule epdaH.derivation_append_preserves_derivation_initial)
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
  apply(rule epdaH.derivation_append_preserves_derivation)
    apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
    apply(simp add: epdaH.derivation_initial_def)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
   apply(rule epdaH.der2_is_derivation)
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
  apply(clarsimp)
  apply(simp add: der2_def)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
  apply(rule allI)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w k)(*strict*)
  apply(erule_tac
    x="k"
    in allE)
  apply(case_tac "k\<le>nR")
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w k eLa cL eR cR)(*strict*)
  apply(simp add: derivation_append_def der2_def)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "k=Suc nR")
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
  apply(simp add: derivation_append_def der2_def)
  apply(rule conjI)
   apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
   apply(clarsimp)
   apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def)
   apply(rule disjI1)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w)(*strict*)
  apply(rule_tac
    x="w"
    in exI)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a qsa qta y qs qt l r eL w k)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_def)
  apply(erule disjE)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
  apply(case_tac "edge_event x")
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x a)(*strict*)
  apply(clarsimp)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL x a)(*strict*)
  apply(subgoal_tac "\<exists>y. edge_pop x=[y]")
  apply(rename_tac nR cR2 eR1 cR1 dL x a)(*strict*)
  prefer 2
  apply(rule_tac
    G="G1"
    in valid_pda_edge_pop_single)
   apply(rename_tac nR cR2 eR1 cR1 dL x a)(*strict*)
   apply(simp add: valid_simple_dpda_def valid_dpda_def)
  apply(rename_tac nR cR2 eR1 cR1 dL x a)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL x a)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL x a y)(*strict*)
  apply(case_tac x)
  apply(rename_tac nR cR2 eR1 cR1 dL x a y edge_srca edge_eventa edge_popa edge_push edge_trga)(*strict*)
  apply(rename_tac qs re po pu qt)
  apply(rename_tac nR cR2 eR1 cR1 dL x a y qs re po pu qt)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(rule_tac
    t="edge_src \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr>"
    and s="qs"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(rule_tac
    t="edge_pop \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr>"
    and s="[y]"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(rule_tac
    t="edge_trg \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr>"
    and s="qt"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(rule_tac
    t="[y] ! 0"
    and s="y"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(subgoal_tac "\<exists>eL cL. dL nR = Some (pair eL cL) \<and> (\<exists>eR cR. dR nR = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL cL)(*strict*)
  apply(erule impE)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL cL)(*strict*)
  apply (metis elemInsetA empty_iff)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL cL)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(subgoal_tac "epdaH_step_relation G1 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)")
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  prefer 2
  apply(thin_tac "\<forall>k\<le>nR. \<exists>eL cL. dL k = Some (pair eL cL) \<and> (\<exists>eR cR. dR k = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(thin_tac "case eR1 of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')")
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(simp add: epdaH_step_relation_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(rule_tac
    t="THE v. \<exists>w. l @ teA (cons_l2   qs y) # r = liftB w @ liftA v"
    and s="(cons_l2 qs y)#(filterA r)"
    in ssubst)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply(rule THE_split3)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
    apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
     prefer 2
     apply(rule_tac
    n="nR"
    in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
       apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
     apply(simp add: get_configuration_def)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
    apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
    apply(subgoal_tac "l=liftB wa")
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
     prefer 2
     apply(rule split_decide1)
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt r eL w wa v)(*strict*)
    apply(rule_tac
    v="v"
    and y="[]"
    and w="[teA (cons_l2   qs y)]"
    in liftA_append_setB)
    apply(clarsimp)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(rule_tac
    t="l @ teB a # teA (cons_l2   qt y) # r"
    and s="(l @ [teB a]) @ teA (cons_l2   qt y) # r"
    in ssubst)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(rule_tac
    t="THE v. \<exists>w. (l @ [teB a]) @ teA (cons_l2   qt y) # r = liftB w @ liftA v"
    and s="(cons_l2 qt y)#(filterA r)"
    in ssubst)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply(rule THE_split3)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
    apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
     prefer 2
     apply(rule_tac
    n="nR"
    in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
       apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
     apply(simp add: get_configuration_def)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
    apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
    apply(subgoal_tac "l=liftB wa")
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
     prefer 2
     apply(rule split_decide1)
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt r eL w wa v)(*strict*)
    apply(rule_tac
    v="v"
    and y="[]"
    and w="[teA (cons_l2   qs y)]"
    in liftA_append_setB)
    apply(force)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply (metis setA_liftB liftBDeConv2 liftB_commute_one_elem_app)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(rule_tac
    t="THE w. \<exists>v. (l @ [teB a]) @ teA (cons_l2   qt y) # r = liftB w @ liftA v"
    and s="filterB l@[a]"
    in ssubst)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply(rule THE_split4)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
     apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
      prefer 2
      apply(rule_tac
    n="nR"
    in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
        apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
      apply(simp add: get_configuration_def)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
     apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
     apply(subgoal_tac "l=liftB wa")
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
      prefer 2
      apply(rule split_decide1)
       apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt r eL w wa v)(*strict*)
     apply(rule_tac
    v="v"
    and y="[]"
    and w="[teA (cons_l2   qs y)]"
    in liftA_append_setB)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
    apply (metis setA_liftB liftBDeConv2 liftB_commute_one_elem_app)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply (metis liftBDeConv1 liftBDeConv2 liftB_commute_one_elem_app)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(rule_tac
    t="THE w. \<exists>v. l @ teA (cons_l2   qs y) # r = liftB w @ liftA v"
    and s="filterB l"
    in ssubst)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply(rule THE_split4)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
     apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
      prefer 2
      apply(rule_tac
    n="nR"
    in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
        apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
        apply(force)
       apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
      apply(simp add: get_configuration_def)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
     apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
     apply(subgoal_tac "l=liftB wa")
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
      prefer 2
      apply(rule split_decide1)
       apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
       apply(force)
      apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
      apply(force)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w wa v)(*strict*)
     apply(clarsimp)
     apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt r eL w wa v)(*strict*)
     apply(rule_tac
    v="v"
    and y="[]"
    and w="[teA (cons_l2   qs y)]"
    in liftA_append_setB)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
    apply (metis)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply (metis liftBDeConv1 liftBDeConv2 liftB_commute_one_elem_app)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(clarsimp)
  apply(simp add: option_to_list_def)
  apply(simp add: valid_simple_dpda_def)
  apply(clarsimp)
  apply(erule_tac
    x="\<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr>"
    in ballE)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(rule_tac
    x="derivation_append dL (der2 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = Some a, edge_pop = [y], edge_push = pu, edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)) nR"
    in exI)
  apply(rule conjI)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(rule epdaH.derivation_append_preserves_derivation_initial)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(rule epdaH.derivation_append_preserves_derivation)
    apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
    apply(simp add: epdaH.derivation_initial_def)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply(rule epdaH.der2_is_derivation)
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(clarsimp)
  apply(simp add: der2_def)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(rule allI)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w k)(*strict*)
  apply(erule_tac
    x="k"
    in allE)
  apply(case_tac "k\<le>nR")
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w k eLa cL eR cR)(*strict*)
  apply(simp add: derivation_append_def der2_def)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "k=Suc nR")
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(simp add: derivation_append_def der2_def)
  apply(rule conjI)
   apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
   apply(clarsimp)
   apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def)
   apply(rule disjI2)
   apply(rule disjI2)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w)(*strict*)
  apply(rule_tac
    x="w"
    in exI)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL a y qs pu qt l r eL w k)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
  apply(erule disjE)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL i A)(*strict*)
  apply(subgoal_tac "setA (cfg_conf cR2) = {}")
  apply(rename_tac nR cR2 eR1 cR1 dL i A)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL i A)(*strict*)
  apply(clarsimp)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL i A l r)(*strict*)
  apply(case_tac cR1)
  apply(rename_tac nR cR2 eR1 cR1 dL i A l r cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 dL i A l r)(*strict*)
  apply(case_tac cR2)
  apply(rename_tac nR cR2 eR1 dL i A l r cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR eR1 dL i A l r)(*strict*)
  apply(subgoal_tac "setA (l @ teA (cons_l2   i A) # r)={} \<or> (\<exists>w1 w2 B. (l @ teA (cons_l2   i A) # r)=(liftB w1)@teA B#(liftA w2))")
  apply(rename_tac nR eR1 dL i A l r)(*strict*)
  prefer 2
  apply(rule_tac
    G="F_SDPDA_TO_CFG_STD G1"
    in LR1_cfgLM_derivations_reachable_conf_form)
      apply(rename_tac nR eR1 dL i A l r)(*strict*)
      apply(rule F_SDPDA_TO_CFG_STD__makes_CFG)
      apply(force)
     apply(rename_tac nR eR1 dL i A l r)(*strict*)
     apply(rule_tac
    G="G1"
    in sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
     apply(simp add: cfg_sub_def)
    apply(rename_tac nR eR1 dL i A l r)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD_def)
   apply(rename_tac nR eR1 dL i A l r)(*strict*)
   apply(force)
  apply(rename_tac nR eR1 dL i A l r)(*strict*)
  apply(force)
  apply(rename_tac nR eR1 dL i A l r)(*strict*)
  apply(erule disjE)
  apply(rename_tac nR eR1 dL i A l r)(*strict*)
  apply (metis elemInsetA ex_in_conv)
  apply(rename_tac nR eR1 dL i A l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR eR1 dL i A l r w1 w2 B)(*strict*)
  apply(subgoal_tac "l=liftB w1")
  apply(rename_tac nR eR1 dL i A l r w1 w2 B)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
  apply(subgoal_tac "l3_l2_separation_ALT (cons_l2 i A # w2)")
   apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
   prefer 2
   apply(rule_tac
    n="nR"
    in cfgLM_reachable_conf_isl3_l2_separation_ALT_stack)
        apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
        apply(force)
       apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
       apply(rule F_SDPDA_TO_CFG_STD__makes_CFG)
       apply(force)
      apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
      apply(force)
     apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
     apply(force)
    apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
    apply(force)
   apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
   apply(force)
  apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
  apply(case_tac w2)
   apply(rename_tac nR eR1 dL i A w1 w2)(*strict*)
   apply(clarsimp)
  apply(rename_tac nR eR1 dL i A w1 w2 a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR eR1 dL i A w1 a list)(*strict*)
  apply(simp add: l3_l2_separation_ALT_def)
  apply(rename_tac nR eR1 dL i A l r w1 w2 B)(*strict*)
  apply(thin_tac "\<forall>k\<le>nR. \<exists>eL cL. dL k = Some (pair eL cL) \<and> (\<exists>eR cR. dR k = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
  apply(rename_tac nR eR1 dL i A l r w1 w2 B)(*strict*)
  apply (metis liftA.simps(2) split_decide1)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
  apply(subgoal_tac "\<exists>y. edge_pop x=[y]")
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
  prefer 2
  apply(rule_tac
    G="G1"
    in valid_pda_edge_pop_single)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
  apply(simp add: valid_simple_dpda_def valid_dpda_def)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y)(*strict*)
  apply(case_tac "edge_push x")
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a list)(*strict*)
  apply(clarsimp)
  apply(case_tac "edge_event x")
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a list)(*strict*)
  prefer 2
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a list aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a list)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "case edge_event x of None \<Rightarrow> edge_push x = [] \<or> (\<exists>y. edge_push x = y # edge_pop x) | Some a \<Rightarrow> edge_pop x = edge_push x")
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a list)(*strict*)
  prefer 2
  apply(simp add: valid_simple_dpda_def)
  apply(clarsimp)
  apply(erule_tac
    x="x"
    in ballE)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a list)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a list)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def)
  apply(erule disjE)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a)(*strict*)
  apply(subgoal_tac "\<exists>y. edge_pop x=[y]")
  apply(rename_tac nR cR2 eR1 cR1 dL x y a)(*strict*)
  prefer 2
  apply(rule_tac
    G="G1"
    in valid_pda_edge_pop_single)
   apply(rename_tac nR cR2 eR1 cR1 dL x y a)(*strict*)
   apply(simp add: valid_simple_dpda_def valid_dpda_def)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a)(*strict*)
  apply(clarsimp)
  apply(case_tac x)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac qs re po pu qt)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a qs re po pu qt)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r)(*strict*)
  apply(rule_tac
    t="edge_src \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>"
    and s="qs"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r)(*strict*)
  apply(rule_tac
    t="edge_pop \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>!0"
    and s="y"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r)(*strict*)
  apply(rule_tac
    t="edge_trg \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>"
    and s="qt"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r)(*strict*)
  apply(subgoal_tac "\<exists>eL cL. dL nR = Some (pair eL cL) \<and> (\<exists>eR cR. dR nR = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL cL)(*strict*)
  apply(erule impE)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL cL)(*strict*)
  apply (metis elemInsetA empty_iff)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL cL)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(subgoal_tac "epdaH_step_relation G1 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a,y], edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 (y#w))")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  prefer 2
  apply(thin_tac "\<forall>k\<le>nR. \<exists>eL cL. dL k = Some (pair eL cL) \<and> (\<exists>eR cR. dR k = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(thin_tac "case eR1 of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
   apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
   prefer 2
   apply(rule_tac
    n="nR"
    in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
     apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
     apply(force)
    apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
    apply(force)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
   apply(simp add: get_configuration_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(thin_tac "cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G1) dR")
  apply(thin_tac "dR (Suc nR) = Some (pair (Some \<lparr>prod_lhs = cons_l2 qs y, prod_rhs = [teA (cons_l2   qt a)]\<rparr>) cR2)")
  apply(thin_tac "dR nR = Some (pair eR1 cR1)")
  apply(thin_tac "epdaH.derivation_initial G1 dL")
  apply(thin_tac "dL nR = Some (pair eL (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w))")
  apply(simp add: epdaH_step_relation_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(rename_tac cR2 cR1 y a qs qt l r w)(*strict*)
  apply(subgoal_tac "r=[]")
   apply(rename_tac cR2 cR1 y a qs qt l r w)(*strict*)
   prefer 2
   apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
   apply(clarsimp)
   apply(rename_tac cR2 cR1 y a qs qt l r w wa v)(*strict*)
   apply(subgoal_tac "l=liftB wa")
    apply(rename_tac cR2 cR1 y a qs qt l r w wa v)(*strict*)
    prefer 2
    apply(rule split_decide1)
     apply(rename_tac cR2 cR1 y a qs qt l r w wa v)(*strict*)
     apply(force)
    apply(rename_tac cR2 cR1 y a qs qt l r w wa v)(*strict*)
    apply(force)
   apply(rename_tac cR2 cR1 y a qs qt l r w wa v)(*strict*)
   apply(clarsimp)
   apply(rename_tac cR2 cR1 y a qs qt r w wa v)(*strict*)
   apply(case_tac v)
    apply(rename_tac cR2 cR1 y a qs qt r w wa v)(*strict*)
    apply(clarsimp)
   apply(rename_tac cR2 cR1 y a qs qt r w wa v aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac cR2 cR1 y a qs qt w wa list)(*strict*)
   apply(case_tac list)
    apply(rename_tac cR2 cR1 y a qs qt w wa list)(*strict*)
    apply(clarsimp)
   apply(rename_tac cR2 cR1 y a qs qt w wa list aa lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac cR2 cR1 y a qs qt w wa aa lista)(*strict*)
   apply(erule_tac
    x="butlast(cons_l2 qs y # aa # lista)"
    in allE)
   apply(erule_tac
    x="last(cons_l2 qs y # aa # lista)"
    in allE)
   apply(erule impE)
    apply(rename_tac cR2 cR1 y a qs qt w wa aa lista)(*strict*)
    apply (metis append_butlast_last_id list.simps(2))
   apply(rename_tac cR2 cR1 y a qs qt w wa aa lista)(*strict*)
   apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qs qt l r w)(*strict*)
  apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qs qt l w)(*strict*)
  apply(case_tac cR1)
  apply(rename_tac cR2 cR1 y a qs qt l w cfg_confa)(*strict*)
  apply(case_tac cR2)
  apply(rename_tac cR2 cR1 y a qs qt l w cfg_confa cfg_confaa)(*strict*)
  apply(clarsimp)
  apply(rename_tac y a qs qt l w)(*strict*)
  apply(rule_tac
    t="THE v. \<exists>w. l @ [teA (cons_l2   qs y)] = liftB w @ liftA v"
    and s="[cons_l2 qs y]"
    in ssubst)
   apply(rename_tac y a qs qt l w)(*strict*)
   apply(rule THE_split3_X)
   apply(force)
  apply(rename_tac y a qs qt l w)(*strict*)
  apply(clarsimp)
  apply(rule_tac
    t="THE v. \<exists>w. l @ [teA (cons_l2   qt a)] = liftB w @ liftA v"
    and s="[cons_l2 qt a]"
    in ssubst)
   apply(rename_tac y a qs qt l w)(*strict*)
   apply(rule THE_split3_X)
   apply(force)
  apply(rename_tac y a qs qt l w)(*strict*)
  apply(clarsimp)
  apply(simp add: option_to_list_def)
  apply(subgoal_tac "\<exists>w'. liftB w'=l")
   apply(rename_tac y a qs qt l w)(*strict*)
   prefer 2
   apply(rule_tac
    x="filterB l"
    in exI)
   apply (rule liftBDeConv2)
   apply(force)
  apply(rename_tac y a qs qt l w)(*strict*)
  apply(clarsimp)
  apply(rename_tac y a qs qt w w')(*strict*)
  apply (metis split2)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(rule_tac
    x="derivation_append dL (der2 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a,y], edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 (y#w))) nR"
    in exI)
  apply(rule conjI)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(rule epdaH.derivation_append_preserves_derivation_initial)
    apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(rule epdaH.derivation_append_preserves_derivation)
    apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
    apply(simp add: epdaH.derivation_initial_def)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
   apply(rule epdaH.der2_is_derivation)
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(clarsimp)
  apply(simp add: der2_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(rule allI)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w k)(*strict*)
  apply(erule_tac
    x="k"
    in allE)
  apply(case_tac "k\<le>nR")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w k eLa cL eR cR)(*strict*)
  apply(simp add: derivation_append_def der2_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "k=Suc nR")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(simp add: derivation_append_def der2_def)
  apply(rule conjI)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
   apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def)
   apply(rule impI)
   apply(rule disjI2)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(rule_tac
    x="y#w"
    in exI)
  apply(rule conjI)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "valid_epda_step_label G1 \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>")
   apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
   apply(simp add: valid_epda_step_label_def)
   apply(clarsimp)
   apply(simp add: may_terminated_by_def append_language_def kleene_star_def)
   apply(clarsimp)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w aa ab)(*strict*)
   apply(erule_tac
    P="[] = aa \<and> y = epda_box G1"
    in disjE)
    apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w aa ab)(*strict*)
    apply(clarsimp)
    apply(rename_tac nR cR2 eR1 cR1 dL a qs qt l r eL w ab)(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w aa ab)(*strict*)
   apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w)(*strict*)
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qs qt l r eL w k)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 eR2 cR1 dL x y a)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a qs)(*strict*)
  apply(subgoal_tac "\<exists>y. edge_pop x=[y]")
  apply(rename_tac nR cR2 eR1 cR1 dL x y a qs)(*strict*)
  prefer 2
  apply(rule_tac
    G="G1"
    in valid_pda_edge_pop_single)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a qs)(*strict*)
  apply(simp add: valid_simple_dpda_def valid_dpda_def)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a qs)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a qs)(*strict*)
  apply(clarsimp)
  apply(case_tac x)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a qs edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac qs re po pu qt)
  apply(rename_tac nR cR2 eR1 cR1 dL x y a qsa qs re po pu qt)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r)(*strict*)
  apply(rule_tac
    t="edge_src \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>"
    and s="qs"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r)(*strict*)
  apply(rule_tac
    t="edge_pop \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>!0"
    and s="y"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r)(*strict*)
  apply(rule_tac
    t="edge_trg \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a, y], edge_trg = qt\<rparr>"
    and s="qt"
    in ssubst)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r)(*strict*)
  apply(subgoal_tac "\<exists>eL cL. dL nR = Some (pair eL cL) \<and> (\<exists>eR cR. dR nR = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL cL)(*strict*)
  apply(erule impE)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL cL)(*strict*)
  apply (metis elemInsetA empty_iff)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL cL)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(subgoal_tac "epdaH_step_relation G1 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a,y], edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  prefer 2
  apply(thin_tac "\<forall>k\<le>nR. \<exists>eL cL. dL k = Some (pair eL cL) \<and> (\<exists>eR cR. dR k = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')) \<and> (setA (cfg_conf cR) \<noteq> {} \<longrightarrow> (\<exists>w. set w \<subseteq> epda_gamma G1 \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(thin_tac "case eR1 of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G1) (epda_gamma G1) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G1 eR')")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(subgoal_tac "event_stack_separation_and_proper_l3_l2_seq_ALT cR1")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  prefer 2
  apply(rule_tac
    n="nR"
    in F_SDPDA_TO_CFG_STD__reachable_conf_of_certain_form)
    apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
    apply(force)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
   apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(simp add: get_configuration_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(thin_tac "cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G1) dR")
  apply(thin_tac "dR (Suc nR) = Some (pair (Some \<lparr>prod_lhs = cons_l2 qs y, prod_rhs = [teA (cons_l3   qt a qsa), teA (cons_l2   qsa y)]\<rparr>) cR2)")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(thin_tac "dR nR = Some (pair eR1 cR1)")
  apply(thin_tac "epdaH.derivation_initial G1 dL")
  apply(thin_tac "dL nR = Some (pair eL (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w))")
  apply(simp add: epdaH_step_relation_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(rename_tac cR2 cR1 y a qsa qs qt l r w)(*strict*)
  apply(subgoal_tac "r=[]")
  apply(rename_tac cR2 cR1 y a qsa qs qt l r w)(*strict*)
  prefer 2
  apply(simp add: event_stack_separation_and_proper_l3_l2_seq_ALT_def)
  apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qsa qs qt l r w wa v)(*strict*)
  apply(subgoal_tac "l=liftB wa")
   apply(rename_tac cR2 cR1 y a qsa qs qt l r w wa v)(*strict*)
   prefer 2
   apply(rule split_decide1)
    apply(rename_tac cR2 cR1 y a qsa qs qt l r w wa v)(*strict*)
    apply(force)
   apply(rename_tac cR2 cR1 y a qsa qs qt l r w wa v)(*strict*)
   apply(force)
  apply(rename_tac cR2 cR1 y a qsa qs qt l r w wa v)(*strict*)
  apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qsa qs qt r w wa v)(*strict*)
  apply(case_tac v)
   apply(rename_tac cR2 cR1 y a qsa qs qt r w wa v)(*strict*)
   apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qsa qs qt r w wa v aa list)(*strict*)
  apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qsa qs qt w wa list)(*strict*)
  apply(case_tac list)
   apply(rename_tac cR2 cR1 y a qsa qs qt w wa list)(*strict*)
   apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qsa qs qt w wa list aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qsa qs qt w wa aa lista)(*strict*)
  apply(erule_tac
    x="butlast(cons_l2 qs y # aa # lista)"
    in allE)
  apply(erule_tac
    x="last(cons_l2 qs y # aa # lista)"
    in allE)
  apply(erule impE)
   apply(rename_tac cR2 cR1 y a qsa qs qt w wa aa lista)(*strict*)
   apply (metis append_butlast_last_id list.simps(2))
  apply(rename_tac cR2 cR1 y a qsa qs qt w wa aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qsa qs qt l r w)(*strict*)
  apply(clarsimp)
  apply(rename_tac cR2 cR1 y a qsa qs qt l w)(*strict*)
  apply(case_tac cR1)
  apply(rename_tac cR2 cR1 y a qsa qs qt l w cfg_confa)(*strict*)
  apply(case_tac cR2)
  apply(rename_tac cR2 cR1 y a qsa qs qt l w cfg_confa cfg_confaa)(*strict*)
  apply(clarsimp)
  apply(rename_tac y a qsa qs qt l w)(*strict*)
  apply(rule_tac
    t="THE v. \<exists>w. l @ [teA (cons_l2   qs y)] = liftB w @ liftA v"
    and s="[cons_l2 qs y]"
    in ssubst)
  apply(rename_tac y a qsa qs qt l w)(*strict*)
  apply(rule THE_split3_X)
  apply(force)
  apply(rename_tac y a qsa qs qt l w)(*strict*)
  apply(clarsimp)
  apply(rule_tac
    t="THE v. \<exists>w. l @ [teA (cons_l3   qt a qsa), teA (cons_l2   qsa y)] = liftB w @ liftA v"
    and s="[cons_l3 qt a qsa,cons_l2 qsa y]"
    in ssubst)
  apply(rename_tac y a qsa qs qt l w)(*strict*)
  apply(rule THE_split3_XX)
  apply(force)
  apply(rename_tac y a qsa qs qt l w)(*strict*)
  apply(clarsimp)
  apply(simp add: option_to_list_def)
  apply(subgoal_tac "\<exists>w'. liftB w'=l")
  apply(rename_tac y a qsa qs qt l w)(*strict*)
  prefer 2
  apply(rule_tac
    x="filterB l"
    in exI)
  apply (rule liftBDeConv2)
  apply(force)
  apply(rename_tac y a qsa qs qt l w)(*strict*)
  apply(clarsimp)
  apply(rename_tac y a qsa qs qt w w')(*strict*)
  apply(rule_tac
    t="(THE w. \<exists>v. liftB w' @ [teA (cons_l3   qt a qsa), teA (cons_l2   qsa y)] = liftB w @ liftA v)"
    and s="w'"
    in ssubst)
  apply(rename_tac y a qsa qs qt w w')(*strict*)
  apply(rule SPLIT_4XX)
  apply(rename_tac y a qsa qs qt w w')(*strict*)
  apply(rule sym)
  apply (metis split2)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(rule_tac
    x="derivation_append dL (der2 (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR1 w) \<lparr>edge_src = qs, edge_event = None, edge_pop = [y], edge_push = [a,y], edge_trg = qt\<rparr> (F_SDPDA_TO_CFG_STD__configuration_basic_RL cR2 w)) nR"
    in exI)
  apply(rule conjI)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(rule epdaH.derivation_append_preserves_derivation_initial)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(rule epdaH.derivation_append_preserves_derivation)
   apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
   apply(simp add: epdaH.derivation_initial_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(rule epdaH.der2_is_derivation)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(clarsimp)
  apply(simp add: der2_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(rule allI)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w k)(*strict*)
  apply(erule_tac
    x="k"
    in allE)
  apply(case_tac "k\<le>nR")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w k eLa cL eR cR)(*strict*)
  apply(simp add: derivation_append_def der2_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "k=Suc nR")
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w k)(*strict*)
  apply(clarsimp)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(simp add: derivation_append_def der2_def)
  apply(rule conjI)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def)
  apply(rule impI)
  apply(rule disjI2)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w)(*strict*)
  apply(rule_tac
    x="w"
    in exI)
  apply(force)
  apply(rename_tac nR cR2 eR1 cR1 dL y a qsa qs qt l r eL w k)(*strict*)
  apply(force)
  done

lemma valid_simple_dpda_edge_pop_single: "
  valid_simple_dpda G
  \<Longrightarrow> e \<in> epda_delta G
  \<Longrightarrow> \<exists>x. edge_pop e = [x]"
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
  apply(clarsimp)
  apply(erule_tac x="e" in ballE)
   prefer 2
   apply(force)
  apply(erule_tac x="e" in ballE)
   prefer 2
   apply(force)
  apply(erule_tac x="e" in ballE)
   prefer 2
   apply(force)
  apply(case_tac "edge_pop e")
   apply(force)
  apply(rename_tac a list)(*strict*)
  apply(force)
  done

definition event_stack_separation :: "
  ('nonterminal, 'event) DT_two_elements list
  \<Rightarrow> 'nonterminal list"
  where
    "event_stack_separation w \<equiv>
  THE v. \<exists>x. w = liftB x @ liftA v"

lemma event_stack_separation_XX2: "
  wl = liftB w @ liftA v
  \<Longrightarrow> event_stack_separation wl = v"
  apply(simp add: event_stack_separation_def)
  apply(rule split_XX2)
  done

lemma F_SDPDA_TO_CFG_STD__configuration_basic_RL_transfer_with_dseq: "
  valid_simple_dpda G
  \<Longrightarrow> valid_cfg (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G) dR
  \<Longrightarrow> dR n = Some (pair en \<lparr>cfg_conf = wn\<rparr>)
  \<Longrightarrow> setA wn \<noteq> {}
  \<Longrightarrow> epdaH.derivation_initial G dL
  \<Longrightarrow> (\<forall>i \<le> n. \<exists>eL cL eR cR w. dL i = Some (pair eL cL) \<and> dR i = Some (pair eR cR) \<and> (\<forall>eR'. eR = Some eR' \<longrightarrow> (\<exists>eL'. eL = Some eL' \<and> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)
  \<Longrightarrow> k \<le> n
  \<Longrightarrow> \<exists>dseq. length dseq = k \<and> (\<forall>i < k. \<exists>eR' cR eL'. dR (Suc i) = Some (pair (Some eR') cR) \<and> ((dseq ! i = [] \<and> ((\<forall>q A. prod_lhs eR' \<noteq> cons_l2 q A) \<or> length (prod_rhs eR') \<noteq> Suc 0)) \<or> (\<exists>q A. dseq ! i = [A] \<and> prod_lhs eR' = cons_l2 q A \<and> length (prod_rhs eR') = Suc 0)) ) \<and> (\<forall>i \<le> k. \<exists>eL cL eR cR. dL i = Some (pair eL cL) \<and> dR i = Some (pair eR cR) \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR (foldl (@) [] (rev (take i dseq))))"
  apply(induct k)
   apply(simp add: epdaH.derivation_initial_def cfgLM.derivation_initial_def cfg_initial_configurations_def)
   apply(erule_tac x="0" in allE)
   apply(clarsimp)
   apply(rename_tac cR w)(*strict*)
   apply(simp add: epdaH.derivation_initial_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def epdaH_initial_configurations_def cfg_initial_configurations_def)
   apply(clarsimp)
   apply(rename_tac w)(*strict*)
   apply(rule_tac t="(THE v. \<exists>w. [teA (cfg_initial (F_SDPDA_TO_CFG_STD G))] =
                    liftB w @ liftA v)" and s="[ (cfg_initial (F_SDPDA_TO_CFG_STD G))]" in ssubst)
    apply(rename_tac w)(*strict*)
    apply (metis THE_split1)
   apply(rename_tac w)(*strict*)
   apply(simp add: cfg_initial_configurations_def F_SDPDA_TO_CFG_STD_def)
  apply(rename_tac k)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac dseq)(*strict*)
   prefer 2
   apply(rule_tac
      n="length dseq"
      and m="n"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac dseq)(*strict*)
     apply(rule cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac dseq)(*strict*)
    apply(force)
   apply(rename_tac dseq)(*strict*)
   apply(force)
  apply(rename_tac dseq)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 e2 c1 c2)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(case_tac c1)
  apply(rename_tac dseq e1 e2 c1 c2 cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 e2 c2 l r)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= l")
   apply(rename_tac dseq e1 e2 c2 l r)(*strict*)
   prefer 2
   apply(rule_tac x="filterB l" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac dseq e1 e2 c2 l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 e2 c2 r w)(*strict*)
  apply(thin_tac "setA (liftB w) = {}")
  apply(case_tac c2)
  apply(rename_tac dseq e1 e2 c2 r w cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 e2 r w)(*strict*)
  apply(case_tac e2)
  apply(rename_tac dseq e1 e2 r w prod_lhsa prod_rhsa)(*strict*)
  apply(rename_tac A w)
  apply(rename_tac dseq e1 e2 r wa A w)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 r wa A w)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac dseq e1 r wa A w)(*strict*)
   prefer 2
   apply(rule_tac n="length dseq" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac dseq e1 r wa A w)(*strict*)
      apply(force)
     apply(rename_tac dseq e1 r wa A w)(*strict*)
     apply(force)
    apply(rename_tac dseq e1 r wa A w)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac dseq e1 r wa A w)(*strict*)
   apply(force)
  apply(rename_tac dseq e1 r wa A w)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 r wa A w w1 w2)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= w1")
   apply(rename_tac dseq e1 r wa A w w1 w2)(*strict*)
   prefer 2
   apply(rule_tac x="filterB w1" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac dseq e1 r wa A w w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 r wa A w w2 wb)(*strict*)
  apply(thin_tac "setA (liftB wb) = {}")
  apply(subgoal_tac "\<exists>w. liftA w= w2")
   apply(rename_tac dseq e1 r wa A w w2 wb)(*strict*)
   prefer 2
   apply(rule_tac x="filterA w2" in exI)
   apply(rule sym)
   apply(rule setB_empty_then_liftA_vs_filterA)
   apply(force)
  apply(rename_tac dseq e1 r wa A w w2 wb)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 r wa A w wb wc)(*strict*)
  apply(thin_tac "setB (liftA wc) = {}")
  apply(subgoal_tac "wb=wa")
   apply(rename_tac dseq e1 r wa A w wb wc)(*strict*)
   prefer 2
   apply(rule_tac ?v1.0="wc" and A="A" and ?v2.0="r" in equal_left_liftB)
   apply(clarsimp)
  apply(rename_tac dseq e1 r wa A w wb wc)(*strict*)
  apply(simp add: liftB_commutes_over_concat)
  apply(clarsimp)
  apply(rename_tac dseq e1 r wa A w wc)(*strict*)
  apply(case_tac wc)
   apply(rename_tac dseq e1 r wa A w wc)(*strict*)
   apply(clarsimp)
  apply(rename_tac dseq e1 r wa A w wc a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 wa w a list)(*strict*)
  apply(rename_tac A w)
  apply(rename_tac dseq e1 wa wb A w)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac dseq e1 wa wb A w)(*strict*)
   prefer 2
   apply(rule_tac ?w2.0="A#w" and ?w1.0="wa" and n="length dseq" in cfgLM_reachable_conf_isl3_l2_separation_ALT_stack)
        apply(rename_tac dseq e1 wa wb A w)(*strict*)
        apply(force)
       apply(rename_tac dseq e1 wa wb A w)(*strict*)
       apply(force)
      apply(rename_tac dseq e1 wa wb A w)(*strict*)
      apply(force)
     apply(rename_tac dseq e1 wa wb A w)(*strict*)
     apply(force)
    apply(rename_tac dseq e1 wa wb A w)(*strict*)
    apply(force)
   apply(rename_tac dseq e1 wa wb A w)(*strict*)
   apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w)(*strict*)
  apply(case_tac "\<exists>qX AX . A = cons_l2 qX AX \<and> length wb = Suc 0")
   apply(rename_tac dseq e1 wa wb A w)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa wb w qX AX)(*strict*)
   apply(case_tac wb)
    apply(rename_tac dseq e1 wa wb w qX AX)(*strict*)
    apply(clarsimp)
   apply(rename_tac dseq e1 wa wb w qX AX a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa w qX AX a)(*strict*)
   apply(rename_tac B)
   apply(rename_tac dseq e1 wa w qX AX B)(*strict*)
   apply(rule_tac xs="w" in rev_cases)
    apply(rename_tac dseq e1 wa w qX AX B)(*strict*)
    prefer 2
    apply(rename_tac dseq e1 wa w qX AX B ys y)(*strict*)
    apply(clarsimp)
    apply(rename_tac dseq e1 wa qX AX B ys y)(*strict*)
    apply(simp add: l3_l2_separation_ALT_def)
   apply(rename_tac dseq e1 wa w qX AX B)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa qX AX B)(*strict*)
   apply(thin_tac "l3_l2_separation_ALT [cons_l2 qX AX]")
   apply(rule_tac x="dseq@[[AX]]" in exI)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac dseq e1 wa qX AX B)(*strict*)
    apply(clarsimp)
    apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
    apply(case_tac "i < (length dseq)")
     apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
     apply(erule_tac x="i" in allE)
     apply(clarsimp)
     apply(rename_tac dseq e1 wa qX AX B i eL eR cR w)(*strict*)
     apply(subgoal_tac "(dseq @ [[AX]]) ! i = dseq!i")
      apply(rename_tac dseq e1 wa qX AX B i eL eR cR w)(*strict*)
      prefer 2
      apply(rule nth_append_1)
      apply(force)
     apply(rename_tac dseq e1 wa qX AX B i eL eR cR w)(*strict*)
     apply(clarsimp)
    apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
    apply(subgoal_tac "i=length dseq")
     apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
    apply(clarify)
    apply(rule_tac x="\<lparr>prod_lhs = cons_l2 qX AX, prod_rhs = [B]\<rparr>" in exI)
    apply(rule conjI)
     apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
     apply(force)
    apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
    apply(rule disjI2)
    apply(clarsimp)
   apply(rename_tac dseq e1 wa qX AX B)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
   apply(case_tac "i \<le>(length dseq)")
    apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
    apply(erule_tac x="i" in allE)+
    apply(clarsimp)
   apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
   apply(subgoal_tac "i=Suc(length dseq)")
    apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa qX AX B i)(*strict*)
   apply(clarify)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa qX AX B)(*strict*)
   apply(erule_tac x="Suc(length dseq)" and P="%i. i\<le>n \<longrightarrow> (\<exists>eL cL.
                 dL i = Some (pair eL cL) \<and>
                 (\<exists>eR cR.
                     dR i = Some (pair eR cR) \<and>
                     (\<forall>eR'. eR = Some eR' \<longrightarrow>
                            (\<exists>eL'. eL = Some eL' \<and> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                     (\<exists>w. cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))"  in allE')
   apply(erule_tac x="(length dseq)" and P="%i. i\<le>n \<longrightarrow> (\<exists>eL cL.
                 dL i = Some (pair eL cL) \<and>
                 (\<exists>eR cR.
                     dR i = Some (pair eR cR) \<and>
                     (\<forall>eR'. eR = Some eR' \<longrightarrow>
                            (\<exists>eL'. eL = Some eL' \<and> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                     (\<exists>w. cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))"  in allE)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb)(*strict*)
    prefer 2
    apply(rule_tac
      n="length dseq"
      and m="Suc(length dseq)"
      in epdaH.step_detail_before_some_position)
      apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb)(*strict*)
      apply(rule epdaH.derivation_initial_is_derivation)
      apply(force)
     apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb)(*strict*)
     apply(force)
    apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb)(*strict*)
    apply(force)
   apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb)(*strict*)
   apply(clarsimp)
   apply(simp add: epdaH_step_relation_def)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
   apply(subgoal_tac "w =
        (foldl (@) [AX] (rev dseq))")
    apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
    apply(force)
   apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
   apply(thin_tac "\<forall>eR'. e1 = Some eR' \<longrightarrow> (\<exists>eL'. eLa = Some eL' \<and> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')")
   apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def)
   apply(erule disjE)
    apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def)
   apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
   apply(erule disjE)
    apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def)
   apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
   apply(erule disjE)
    apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def)
   apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
   apply(erule disjE)
    apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
   apply(rename_tac dseq e1 wa qX AX B eLa eL' w wb wc)(*strict*)
   apply(clarsimp)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa eLa eL' w wb wc)(*strict*)
   apply(case_tac eL')
   apply(rename_tac dseq e1 wa eLa eL' w wb wc edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
   apply(rename_tac qs r po pu qt)
   apply(rename_tac dseq e1 wa eLa eL' w wb wc qs r po pu qt)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa eLa w wb wc qs po pu qt)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac dseq e1 wa eLa w wb wc qs po pu qt)(*strict*)
    prefer 2
    apply(rule valid_simple_dpda_edge_pop_single)
     apply(rename_tac dseq e1 wa eLa w wb wc qs po pu qt)(*strict*)
     apply(force)
    apply(rename_tac dseq e1 wa eLa w wb wc qs po pu qt)(*strict*)
    apply(force)
   apply(rename_tac dseq e1 wa eLa w wb wc qs po pu qt)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa eLa w wb wc qs pu qt x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
   apply(subgoal_tac "(THE w. \<exists>v. liftB wa @ [teA (cons_l2   qt (pu ! 0))] = liftB w @ liftA v) = wa")
    apply(rename_tac dseq e1 wa eLa w wb wc qs pu qt x)(*strict*)
    prefer 2
    apply (metis split2)
   apply(rename_tac dseq e1 wa eLa w wb wc qs pu qt x)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "(THE v. \<exists>w. liftB wa @ [teA (cons_l2   qt (pu ! 0))] = liftB w @ liftA v) = [cons_l2 qt (pu ! 0)]")
    apply(rename_tac dseq e1 wa eLa w wb wc qs pu qt x)(*strict*)
    prefer 2
    apply (metis split1)
   apply(rename_tac dseq e1 wa eLa w wb wc qs pu qt x)(*strict*)
   apply(clarsimp)
   apply(case_tac pu)
    apply(rename_tac dseq e1 wa eLa w wb wc qs pu qt x)(*strict*)
    apply(clarsimp)
   apply(rename_tac dseq e1 wa eLa w wb wc qs pu qt x a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa eLa wb wc qs qt x a list)(*strict*)
   apply(subgoal_tac "list=[x]")
    apply(rename_tac dseq e1 wa eLa wb wc qs qt x a list)(*strict*)
    prefer 2
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
    apply(clarsimp)
    apply(erule_tac x="\<lparr>edge_src = qs, edge_event = None, edge_pop = [x], edge_push = a # list,
          edge_trg = qt\<rparr>" in ballE)
     apply(rename_tac dseq e1 wa eLa wb wc qs qt x a list)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac dseq e1 wa eLa wb wc qs qt x a list)(*strict*)
    apply(erule_tac x="\<lparr>edge_src = qs, edge_event = None, edge_pop = [x], edge_push = a # list,
          edge_trg = qt\<rparr>" in ballE)
     apply(rename_tac dseq e1 wa eLa wb wc qs qt x a list)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac dseq e1 wa eLa wb wc qs qt x a list)(*strict*)
    apply(erule_tac x="\<lparr>edge_src = qs, edge_event = None, edge_pop = [x], edge_push = a # list,
          edge_trg = qt\<rparr>" in ballE)
     apply(rename_tac dseq e1 wa eLa wb wc qs qt x a list)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac dseq e1 wa eLa wb wc qs qt x a list)(*strict*)
    apply(force)
   apply(rename_tac dseq e1 wa eLa wb wc qs qt x a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa eLa wb wc qs qt x a)(*strict*)
   apply(subgoal_tac "(THE v. \<exists>w. liftB wa @ [teA (cons_l2   qs x)] = liftB w @ liftA v) = [cons_l2 qs x]")
    apply(rename_tac dseq e1 wa eLa wb wc qs qt x a)(*strict*)
    prefer 2
    apply (metis split1)
   apply(rename_tac dseq e1 wa eLa wb wc qs qt x a)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa eLa wc qs qt x a)(*strict*)
   apply(erule_tac x="length dseq" in allE)+
   apply(clarsimp)
   apply(rename_tac dseq e1 wa eLa qs qt x a)(*strict*)
   apply (metis append_Cons append_Nil foldl_append_initial_pullout)
  apply(rename_tac dseq e1 wa wb A w)(*strict*)
  apply(rule_tac x="dseq@[[]]" in exI)
  apply(clarsimp)
  apply(rule conjI)
   apply(rename_tac dseq e1 wa wb A w)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa wb A w i)(*strict*)
   apply(case_tac "i < (length dseq)")
    apply(rename_tac dseq e1 wa wb A w i)(*strict*)
    apply(erule_tac x="i" in allE)
    apply(clarsimp)
    apply(rename_tac dseq e1 wa wb A w i eL eR cR wc)(*strict*)
    apply(subgoal_tac "(dseq @ [[]]) ! i = dseq!i")
     apply(rename_tac dseq e1 wa wb A w i eL eR cR wc)(*strict*)
     prefer 2
     apply(rule nth_append_1)
     apply(force)
    apply(rename_tac dseq e1 wa wb A w i eL eR cR wc)(*strict*)
    apply(clarsimp)
   apply(rename_tac dseq e1 wa wb A w i)(*strict*)
   apply(subgoal_tac "i=length dseq")
    apply(rename_tac dseq e1 wa wb A w i)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa wb A w i)(*strict*)
   apply(clarify)
   apply(rule_tac x="\<lparr>prod_lhs = A, prod_rhs = wb\<rparr>" in exI)
   apply(rule conjI)
    apply(rename_tac dseq e1 wa wb A w i)(*strict*)
    apply(force)
   apply(rename_tac dseq e1 wa wb A w i)(*strict*)
   apply(rule disjI1)
   apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w i)(*strict*)
  apply(case_tac "i \<le>(length dseq)")
   apply(rename_tac dseq e1 wa wb A w i)(*strict*)
   apply(erule_tac x="i" in allE)+
   apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w i)(*strict*)
  apply(subgoal_tac "i=Suc(length dseq)")
   apply(rename_tac dseq e1 wa wb A w i)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac dseq e1 wa wb A w i)(*strict*)
  apply(clarify)
  apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w)(*strict*)
  apply(erule_tac x="Suc(length dseq)" and P="%i. i\<le>n \<longrightarrow> (\<exists>eL cL.
                 dL i = Some (pair eL cL) \<and>
                 (\<exists>eR cR.
                     dR i = Some (pair eR cR) \<and>
                     (\<forall>eR'. eR = Some eR' \<longrightarrow>
                            (\<exists>eL'. eL = Some eL' \<and> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                     (\<exists>w. cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))"  in allE')
  apply(erule_tac x="(length dseq)" and P="%i. i\<le>n \<longrightarrow> (\<exists>eL cL.
                 dL i = Some (pair eL cL) \<and>
                 (\<exists>eR cR.
                     dR i = Some (pair eR cR) \<and>
                     (\<forall>eR'. eR = Some eR' \<longrightarrow>
                            (\<exists>eL'. eL = Some eL' \<and> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                     (\<exists>w. cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))"  in allE)
  apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd)(*strict*)
   prefer 2
   apply(rule_tac
      n="length dseq"
      and m="Suc(length dseq)"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd)(*strict*)
    apply(force)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd)(*strict*)
   apply(force)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd)(*strict*)
  apply(clarsimp)
  apply(simp add: epdaH_step_relation_def)
  apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we)(*strict*)
  apply(subgoal_tac "wc =
        (foldl (@) [] (rev dseq))")
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we)(*strict*)
   apply(force)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we)(*strict*)
  apply(thin_tac "\<forall>eR'. e1 = Some eR' \<longrightarrow> (\<exists>eL'. eLa = Some eL' \<and> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')")
  apply(subgoal_tac "X" for X)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we)(*strict*)
   prefer 2
   apply(rule valid_simple_dpda_edge_pop_single)
    apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we)(*strict*)
    apply(force)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we)(*strict*)
   apply(force)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we x)(*strict*)
  apply(erule_tac x="length dseq" in allE)+
  apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def)
  apply(erule_tac P="\<lparr>prod_lhs = A, prod_rhs = wb\<rparr> \<in> F_SDPDA_TO_CFG_STD__edges_l3_read eL' (epda_states G) \<and>
       (\<exists>y. edge_event eL' = Some y)" in disjE)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa w eLa eL' wc wd we x qt y)(*strict*)
   apply(fold event_stack_separation_def)
   apply(subgoal_tac "(event_stack_separation (liftB wa @ teA (cons_l3   (edge_src eL') x qt) # liftA w)) = cons_l3 (edge_src eL') x qt#w")
    apply(rename_tac dseq e1 wa w eLa eL' wc wd we x qt y)(*strict*)
    prefer 2
    apply(rule_tac w="wa" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac dseq e1 wa w eLa eL' wc wd we x qt y)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qt y)(*strict*)
   apply(subgoal_tac "event_stack_separation (liftB wa @ teB y # teA (cons_l3   (edge_trg eL') x qt) # liftA w) = cons_l3 (edge_trg eL') x qt # w")
    apply(rename_tac dseq e1 wa w eLa eL' wc x qt y)(*strict*)
    prefer 2
    apply(rule_tac w="wa@[y]" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qt y)(*strict*)
   apply(clarsimp)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(clarsimp)
   apply(erule_tac x="eL'" in ballE)
    apply(rename_tac dseq e1 wa w eLa eL' wc x qt y)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qt y)(*strict*)
   apply(erule_tac x="eL'" in ballE)
    apply(rename_tac dseq e1 wa w eLa eL' wc x qt y)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qt y)(*strict*)
   apply(erule_tac x="eL'" in ballE)
    apply(rename_tac dseq e1 wa w eLa eL' wc x qt y)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qt y)(*strict*)
   apply(clarsimp)
   apply(case_tac eL')
   apply(rename_tac dseq e1 wa w eLa eL' wc x qt y edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
   apply(rename_tac qs r po pu qt)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qta y qs r po pu qt)(*strict*)
   apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we x)(*strict*)
  apply(subgoal_tac "wd=(foldl (@) [] (rev dseq))")
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we x)(*strict*)
   prefer 2
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
   apply(fold event_stack_separation_def)
   apply(subgoal_tac "event_stack_separation (liftB wa @ teA A # liftA w) = A#w")
    apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we x)(*strict*)
    prefer 2
    apply(rule_tac w="wa" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we x)(*strict*)
   apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc wd we x)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
  apply(erule_tac P="\<lparr>prod_lhs = A, prod_rhs = wb\<rparr> \<in> F_SDPDA_TO_CFG_STD__edges_l3_pop eL' \<and>
       edge_push eL' = []" in disjE)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa w eLa eL' wc x)(*strict*)
   apply(fold event_stack_separation_def)
   apply(subgoal_tac "event_stack_separation (liftB wa @ liftA w) = w")
    apply(rename_tac dseq e1 wa w eLa eL' wc x)(*strict*)
    prefer 2
    apply(rule_tac w="wa" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac dseq e1 wa w eLa eL' wc x)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "event_stack_separation
          (liftB wa @ teA (cons_l3   (edge_src eL') x (edge_trg eL')) # liftA w) = cons_l3 (edge_src eL') x (edge_trg eL') #w ")
    apply(rename_tac dseq e1 wa w eLa eL' wc x)(*strict*)
    prefer 2
    apply(rule_tac w="wa" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac dseq e1 wa w eLa eL' wc x)(*strict*)
   apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
  apply(erule_tac P="\<lparr>prod_lhs = A, prod_rhs = wb\<rparr> \<in> F_SDPDA_TO_CFG_STD__edges_l3_push eL' (epda_states G) \<and>
       edge_push eL' \<noteq> [] \<and> edge_event eL' = None" in disjE)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa w eLa eL' wc we x qs qt)(*strict*)
   apply(fold event_stack_separation_def)
   apply(subgoal_tac "event_stack_separation
          (liftB wa @
           teA (cons_l3   (edge_trg eL') (edge_push eL' ! 0) qs) #
           teA (cons_l3   qs x qt) # liftA w) =  (cons_l3   (edge_trg eL') (edge_push eL' ! 0) qs) #
            (cons_l3 qs x qt) #  w")
    apply(rename_tac dseq e1 wa w eLa eL' wc we x qs qt)(*strict*)
    prefer 2
    apply(rule_tac w="wa" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac dseq e1 wa w eLa eL' wc we x qs qt)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "event_stack_separation (liftB wa @ teA (cons_l3   (edge_src eL') x qt) # liftA w) = cons_l3 (edge_src eL') x qt#w ")
    apply(rename_tac dseq e1 wa w eLa eL' wc we x qs qt)(*strict*)
    prefer 2
    apply(rule_tac w="wa" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac dseq e1 wa w eLa eL' wc we x qs qt)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qs qt)(*strict*)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(clarsimp)
   apply(erule_tac x="eL'" in ballE)
    apply(rename_tac dseq e1 wa w eLa eL' wc x qs qt)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qs qt)(*strict*)
   apply(erule_tac x="eL'" in ballE)
    apply(rename_tac dseq e1 wa w eLa eL' wc x qs qt)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qs qt)(*strict*)
   apply(erule_tac x="eL'" in ballE)
    apply(rename_tac dseq e1 wa w eLa eL' wc x qs qt)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qs qt)(*strict*)
   apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
  apply(erule_tac P="\<lparr>prod_lhs = A, prod_rhs = wb\<rparr> \<in> F_SDPDA_TO_CFG_STD__edges_l2_read eL' \<and>
       (\<exists>y. edge_event eL' = Some y)" in disjE)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa w eLa eL' wc we x y)(*strict*)
   apply(fold event_stack_separation_def)
   apply(subgoal_tac "event_stack_separation (liftB wa @ teA (cons_l2   (edge_src eL') x) # liftA w) =  cons_l2 (edge_src eL') x#w")
    apply(rename_tac dseq e1 wa w eLa eL' wc we x y)(*strict*)
    prefer 2
    apply(rule_tac w="wa" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac dseq e1 wa w eLa eL' wc we x y)(*strict*)
   apply(clarsimp)
   apply(rename_tac dseq e1 wa w eLa eL' wc x y)(*strict*)
   apply(subgoal_tac "event_stack_separation (liftB wa @ teB y # teA (cons_l2   (edge_trg eL') x) # liftA w) =  cons_l2 (edge_trg eL') x#w")
    apply(rename_tac dseq e1 wa w eLa eL' wc x y)(*strict*)
    prefer 2
    apply(rule_tac w="wa@[y]" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac dseq e1 wa w eLa eL' wc x y)(*strict*)
   apply(clarsimp)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
   apply(clarsimp)
   apply(erule_tac x="eL'" in ballE)
    apply(rename_tac dseq e1 wa w eLa eL' wc x y)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa w eLa eL' wc x y)(*strict*)
   apply(erule_tac x="eL'" in ballE)
    apply(rename_tac dseq e1 wa w eLa eL' wc x y)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa w eLa eL' wc x y)(*strict*)
   apply(erule_tac x="eL'" in ballE)
    apply(rename_tac dseq e1 wa w eLa eL' wc x y)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac dseq e1 wa w eLa eL' wc x y)(*strict*)
   apply(clarsimp)
   apply(case_tac eL')
   apply(rename_tac dseq e1 wa w eLa eL' wc x y edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
   apply(rename_tac qs r po pu qt)
   apply(rename_tac dseq e1 wa w eLa eL' wc x y qs r po pu qt)(*strict*)
   apply(clarsimp)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(clarsimp)
  apply(fold event_stack_separation_def)
  apply(erule disjE)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
   apply(force)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
  apply(erule disjE)
   apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
   apply(force)
  apply(rename_tac dseq e1 wa wb A w eLa eL' wc we x)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 wa w eLa eL' wc we x qs)(*strict*)
  apply(subgoal_tac "event_stack_separation (liftB wa @
           teA (cons_l3   (edge_trg eL') (edge_push eL' ! 0) qs) #
           teA (cons_l2   qs x) # liftA w) =   (cons_l3   (edge_trg eL') (edge_push eL' ! 0) qs) #
            (cons_l2 qs x) #  w")
   apply(rename_tac dseq e1 wa w eLa eL' wc we x qs)(*strict*)
   prefer 2
   apply(rule_tac w="wa" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac dseq e1 wa w eLa eL' wc we x qs)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "event_stack_separation (liftB wa @ teA (cons_l2   (edge_src eL') x) # liftA w) =   (cons_l2   (edge_src eL') x) # w")
   apply(rename_tac dseq e1 wa w eLa eL' wc we x qs)(*strict*)
   prefer 2
   apply(rule_tac w="wa" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac dseq e1 wa w eLa eL' wc we x qs)(*strict*)
  apply(clarsimp)
  apply(rename_tac dseq e1 wa w eLa eL' wc x qs)(*strict*)
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
  apply(clarsimp)
  apply(erule_tac x="eL'" in ballE)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qs)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac dseq e1 wa w eLa eL' wc x qs)(*strict*)
  apply(erule_tac x="eL'" in ballE)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qs)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac dseq e1 wa w eLa eL' wc x qs)(*strict*)
  apply(erule_tac x="eL'" in ballE)
   apply(rename_tac dseq e1 wa w eLa eL' wc x qs)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac dseq e1 wa w eLa eL' wc x qs)(*strict*)
  apply(clarsimp)
  done

lemma take_unfold: "
  length w \<ge> Suc n
  \<Longrightarrow> take (Suc n) w = take n w @ [w ! n]"
  apply (metis Suc_leD nat_less_le not_less_eq_eq take_Suc_conv_app_nth)
  done

lemma foldl_take_suffix: "
  Suc (n + k) \<le> length w
  \<Longrightarrow> foldl (@) [] (rev (take (n + k) w)) \<sqsupseteq> foldl (@) [] (rev (take n w))"
  apply(induct k)
   apply(clarsimp)
   apply(simp add: suffix_def)
  apply(rename_tac k)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "foldl (@) [] (rev (take (Suc (n + k)) w))
=
(w!(n+k)) @
foldl (@) [] (rev (take ((n + k)) w))")
   apply(rename_tac k)(*strict*)
   prefer 2
   apply(rule_tac t="take (Suc (n + k)) w" in ssubst)
    apply(rename_tac k)(*strict*)
    apply(rule take_unfold)
    apply(force)
   apply(rename_tac k)(*strict*)
   apply(clarsimp)
   apply (metis append_Nil foldl_Cons foldl_Nil parser_inst_AX_join_scheduler_fragments_foldl_split)
  apply(rename_tac k)(*strict*)
  apply(clarsimp)
  apply(simp add: suffix_def)
  apply(force)
  done

definition stack :: "
  ('a, 'b) DT_l2_l3_nonterminals list
  \<Rightarrow> 'b list"
  where
    "stack w \<equiv>
  map (%x. case x of cons_l2 q A \<Rightarrow> A | cons_l3 q A q' \<Rightarrow> A) w"

lemma F_SDPDA_TO_CFG_OPT__has_same_reachable_nonterminals_hlp2: "
  valid_simple_dpda G
  \<Longrightarrow> valid_cfg (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G) d
  \<Longrightarrow> d (n) = Some (pair e0 \<lparr>cfg_conf = liftB w1 @ liftA v1 @ [teA (cons_l2 q0 A0)]\<rparr>)
  \<Longrightarrow> d (n + m) = Some (pair e1 \<lparr>cfg_conf = liftB w2 @ [teA (cons_l2 q1 A1)]\<rparr>)
  \<Longrightarrow> epdaH.derivation_initial G dL
  \<Longrightarrow> length dseq = i + n + m
  \<Longrightarrow> \<forall>ia < n + m. \<exists>eR'. (\<exists>cR. d (Suc ia) = Some (pair (Some eR') cR)) \<and> (dseq ! ia = [] \<and> ((\<forall>q A. prod_lhs eR' \<noteq> cons_l2 q A) \<or> length (prod_rhs eR') \<noteq> Suc 0) \<or> (\<exists>q A. dseq ! ia = [A] \<and> prod_lhs eR' = cons_l2 q A \<and> length (prod_rhs eR') = Suc 0))
  \<Longrightarrow> \<forall>x \<le> n + m. \<exists>eL cL. dL x = Some (pair eL cL) \<and> (\<exists>eR cR. d x = Some (pair eR cR) \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR (foldl (@) [] (rev (take x dseq))))
  \<Longrightarrow> k \<le> m
  \<Longrightarrow> epdaH_conf_stack (the (get_configuration (dL ( n + k)))) \<sqsupseteq> epdaH_conf_stack (F_SDPDA_TO_CFG_STD__configuration_basic_RL \<lparr>cfg_conf = liftB w1 @ [teA (cons_l2 q0 A0)]\<rparr> (foldl (@) [] (rev (take n dseq))))"
  apply(induct k)
   apply(clarsimp)
   apply(erule_tac x="n" in allE)+
   apply(clarsimp)
   apply(rename_tac eL)(*strict*)
   apply(simp add: get_configuration_def suffix_def)
   apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
   apply(fold event_stack_separation_def)
   apply(subgoal_tac "event_stack_separation (liftB w1 @ [teA (cons_l2   q0 A0)]) = [cons_l2 q0 A0]")
    apply(rename_tac eL)(*strict*)
    prefer 2
    apply(rule_tac w="w1" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac eL)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "event_stack_separation (liftB w1 @ liftA v1 @ [teA (cons_l2   q0 A0)]) = v1@[cons_l2 q0 A0]")
    apply(rename_tac eL)(*strict*)
    prefer 2
    apply(rule_tac w="w1" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac eL)(*strict*)
   apply(clarsimp)
  apply(rename_tac k)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   apply(rename_tac k)(*strict*)
   prefer 2
   apply(rule_tac
      n="n+k"
      and m="n+m"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac k)(*strict*)
     apply(rule cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac k)(*strict*)
    apply(force)
   apply(rename_tac k)(*strict*)
   apply(force)
  apply(rename_tac k)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a e2 c1 c2)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(case_tac c1)
  apply(rename_tac k e1a e2 c1 c2 cfg_confa)(*strict*)
  apply(case_tac c2)
  apply(rename_tac k e1a e2 c1 c2 cfg_confa cfg_confaa)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a e2 l r)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= l")
   apply(rename_tac k e1a e2 l r)(*strict*)
   prefer 2
   apply(rule_tac x="filterB l" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac k e1a e2 l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a e2 r w)(*strict*)
  apply(thin_tac "setA (liftB w) = {}")
  apply(case_tac e2)
  apply(rename_tac k e1a e2 r w prod_lhsa prod_rhsa)(*strict*)
  apply(rename_tac A w)
  apply(rename_tac k e1a e2 r wa A w)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a r wa A w)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac k e1a r wa A w)(*strict*)
   prefer 2
   apply(rule_tac n="n+k" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac k e1a r wa A w)(*strict*)
      apply(force)
     apply(rename_tac k e1a r wa A w)(*strict*)
     apply(force)
    apply(rename_tac k e1a r wa A w)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac k e1a r wa A w)(*strict*)
   apply(force)
  apply(rename_tac k e1a r wa A w)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a r wa A w w1a w2a)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= w1a")
   apply(rename_tac k e1a r wa A w w1a w2a)(*strict*)
   prefer 2
   apply(rule_tac x="filterB w1a" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac k e1a r wa A w w1a w2a)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a r wa A w w2a wb)(*strict*)
  apply(thin_tac "setA (liftB wb) = {}")
  apply(subgoal_tac "\<exists>w. liftA w= w2a")
   apply(rename_tac k e1a r wa A w w2a wb)(*strict*)
   prefer 2
   apply(rule_tac x="filterA w2a" in exI)
   apply(rule sym)
   apply(rule setB_empty_then_liftA_vs_filterA)
   apply(force)
  apply(rename_tac k e1a r wa A w w2a wb)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a r wa A w wb wc)(*strict*)
  apply(thin_tac "setB (liftA wc) = {}")
  apply(subgoal_tac "wb=wa")
   apply(rename_tac k e1a r wa A w wb wc)(*strict*)
   prefer 2
   apply(rule_tac ?v1.0="wc" and A="A" and ?v2.0="r" in equal_left_liftB)
   apply(clarsimp)
  apply(rename_tac k e1a r wa A w wb wc)(*strict*)
  apply(simp add: liftB_commutes_over_concat)
  apply(clarsimp)
  apply(rename_tac k e1a r wa A w wc)(*strict*)
  apply(case_tac wc)
   apply(rename_tac k e1a r wa A w wc)(*strict*)
   apply(clarsimp)
  apply(rename_tac k e1a r wa A w wc a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a wa w a list)(*strict*)
  apply(rename_tac A w)
  apply(rename_tac k e1a wa wb A w)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac k e1a wa wb A w)(*strict*)
   prefer 2
   apply(rule_tac ?w2.0="A#w" and ?w1.0="wa" and n="n+k" in cfgLM_reachable_conf_isl3_l2_separation_ALT_stack)
        apply(rename_tac k e1a wa wb A w)(*strict*)
        apply(force)
       apply(rename_tac k e1a wa wb A w)(*strict*)
       apply(force)
      apply(rename_tac k e1a wa wb A w)(*strict*)
      apply(force)
     apply(rename_tac k e1a wa wb A w)(*strict*)
     apply(force)
    apply(rename_tac k e1a wa wb A w)(*strict*)
    apply(force)
   apply(rename_tac k e1a wa wb A w)(*strict*)
   apply(clarsimp)
  apply(rename_tac k e1a wa wb A w)(*strict*)
  apply(subgoal_tac "suffix ((foldl (@) [] (rev (take (n+k) dseq)))) ((foldl (@) [] (rev (take n dseq))))")
   apply(rename_tac k e1a wa wb A w)(*strict*)
   prefer 2
   apply(rule foldl_take_suffix)
   apply(force)
  apply(rename_tac k e1a wa wb A w)(*strict*)
  apply(erule_tac x="n+k" in allE)
  apply(erule_tac x="n+k" in allE')
  apply(erule_tac x="n+Suc k" in allE)
  apply(clarsimp)
  apply(rename_tac k e1a wa wb A w eL eLa)(*strict*)
  apply(simp add: get_configuration_def)
  apply(subgoal_tac "foldl (@) [] (rev (take (Suc (n + k)) dseq))
=
(dseq!(n+k)) @
foldl (@) [] (rev (take ((n + k)) dseq))")
   apply(rename_tac k e1a wa wb A w eL eLa)(*strict*)
   prefer 2
   apply(rule_tac t="take (Suc (n + k)) dseq" in ssubst)
    apply(rename_tac k e1a wa wb A w eL eLa)(*strict*)
    apply(rule take_unfold)
    apply(force)
   apply(rename_tac k e1a wa wb A w eL eLa)(*strict*)
   apply(clarsimp)
   apply (metis append_Nil foldl_append_initial_pullout)
  apply(rename_tac k e1a wa wb A w eL eLa)(*strict*)
  apply(clarsimp)
  apply(thin_tac "foldl (@) [] (rev (take (Suc (n + k)) dseq)) =
       dseq ! (n + k) @ foldl (@) [] (rev (take (n + k) dseq))")
  apply(simp add: suffix_def)
  apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(fold event_stack_separation_def)
  apply(subgoal_tac "event_stack_separation (liftB wa @ teA A # liftA w) = A#w")
   apply(rename_tac k e1a wa wb A w eL eLa)(*strict*)
   prefer 2
   apply(rule_tac w="wa" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac k e1a wa wb A w eL eLa)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a wa wb A w eL eLa c ca)(*strict*)
  apply(subgoal_tac "\<exists>w1 w2. wb=liftB w1@liftA w2")
   apply(rename_tac k e1a wa wb A w eL eLa c ca)(*strict*)
   prefer 2
   apply(subgoal_tac "X" for X)
    apply(rename_tac k e1a wa wb A w eL eLa c ca)(*strict*)
    prefer 2
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule_tac G="G" in sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(simp add: cfg_sub_def)
    apply(force)
   apply(rename_tac k e1a wa wb A w eL eLa c ca)(*strict*)
   apply(simp add: singleIsertionOfLM_def)
   apply(erule_tac x="\<lparr>prod_lhs = A, prod_rhs = wb\<rparr>" in ballE)
    apply(rename_tac k e1a wa wb A w eL eLa c ca)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac k e1a wa wb A w eL eLa c ca)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa A w eL eLa c ca b wc v)(*strict*)
   apply(case_tac v)
    apply(rename_tac k e1a wa A w eL eLa c ca b wc v)(*strict*)
    apply(rule_tac x="[]" in exI)
    apply(clarsimp)
    apply(rename_tac k e1a wa A w eL eLa c ca b wc)(*strict*)
    apply(force)
   apply(rename_tac k e1a wa A w eL eLa c ca b wc v a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa A w eL eLa c ca b wc a list)(*strict*)
   apply(simp add: prefix_def)
   apply(clarsimp)
   apply(rename_tac k e1a wa A w eL eLa c ca b wc)(*strict*)
   apply(rule_tac x="[b]" in exI)
   apply(clarsimp)
   apply(force)
  apply(rename_tac k e1a wa wb A w eL eLa c ca)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
  apply(subgoal_tac "event_stack_separation (liftB wa @ liftB w1a @ liftA w2a @ liftA w) = w2a@w")
   apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
   prefer 2
   apply(rule_tac w="wa@w1a" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
  apply(clarsimp)
  apply(fold stack_def)
  apply(thin_tac "event_stack_separation (liftB wa @ teA A # liftA w) = A # w")
  apply(thin_tac "event_stack_separation (liftB wa @ liftB w1a @ liftA w2a @ liftA w) = w2a @ w")
  apply(erule disjE)
   apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
   prefer 2
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca w1a w2a q Aa)(*strict*)
   apply(rule_tac xs="w" in rev_cases)
    apply(rename_tac k e1a wa w eL eLa c ca w1a w2a q Aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac k e1a wa eL eLa c ca w1a w2a q Aa)(*strict*)
    apply(simp add: l3_l2_separation_ALT_def)
    apply(simp add: stack_def)
   apply(rename_tac k e1a wa w eL eLa c ca w1a w2a q Aa ys y)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa eL eLa c ca w1a w2a q Aa ys y)(*strict*)
   apply(simp add: l3_l2_separation_ALT_def)
  apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "LR1ProdForm (F_SDPDA_TO_CFG_STD G)")
   apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
   prefer 2
   apply(rule_tac G="G" in sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
   apply(simp add: cfg_sub_def)
  apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
  apply(simp add: LR1ProdForm_def)
  apply(erule_tac x="\<lparr>prod_lhs = A, prod_rhs = liftB w1a @ liftA w2a\<rparr>" in ballE)
   apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "event_stack_separation (liftB w1 @ [teA (cons_l2   q0 A0)]) = [cons_l2 q0 A0]")
   apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
   prefer 2
   apply(rule_tac w="w1" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
  apply(clarsimp)
  apply(case_tac w1a)
   apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa A w eL eLa c ca w2a)(*strict*)
   apply(case_tac w2a)
    apply(rename_tac k e1a wa A w eL eLa c ca w2a)(*strict*)
    apply(clarsimp)
    apply(rename_tac k e1a wa A w eL eLa c ca)(*strict*)
    apply(simp add: stack_def)
    apply(fold stack_def)
    apply(rule_tac xs="ca" in rev_cases)
     apply(rename_tac k e1a wa A w eL eLa c ca)(*strict*)
     apply(clarsimp)
     apply(rename_tac k e1a wa A w eL eLa c)(*strict*)
     apply(rule_tac xs="w" in rev_cases)
      apply(rename_tac k e1a wa A w eL eLa c)(*strict*)
      apply(clarsimp)
      apply(rename_tac k e1a wa A eL eLa c)(*strict*)
      apply(simp add: stack_def)
      apply(clarsimp)
      apply(rename_tac k e1a wa A eL eLa)(*strict*)
      apply(case_tac "m=Suc k")
       apply(rename_tac k e1a wa A eL eLa)(*strict*)
       apply(clarsimp)
       apply(rename_tac k e1 wa A eL eLa)(*strict*)
       apply(rule_tac xs="wa" in rev_cases)
        apply(rename_tac k e1 wa A eL eLa)(*strict*)
        apply(clarsimp)
       apply(rename_tac k e1 wa A eL eLa ys y)(*strict*)
       apply(clarsimp)
       apply(rename_tac k e1 A eL eLa ys y)(*strict*)
       apply(simp add: liftB_commutes_over_concat liftA_commutes_over_concat setAConcat setA_liftB setB_liftA)
      apply(rename_tac k e1a wa A eL eLa)(*strict*)
      apply(subgoal_tac "X" for X)
       apply(rename_tac k e1a wa A eL eLa)(*strict*)
       prefer 2
       apply(rule_tac
      n="n+Suc k"
      and m="n+m"
      in cfgLM.step_detail_before_some_position)
         apply(rename_tac k e1a wa A eL eLa)(*strict*)
         apply(rule cfgLM.derivation_initial_is_derivation)
         apply(force)
        apply(rename_tac k e1a wa A eL eLa)(*strict*)
        apply(force)
       apply(rename_tac k e1a wa A eL eLa)(*strict*)
       apply(force)
      apply(rename_tac k e1a wa A eL eLa)(*strict*)
      apply(clarsimp)
      apply(rename_tac k e1a wa A eL eLa e2 c2)(*strict*)
      apply(simp add: cfgLM_step_relation_def)
      apply(clarsimp)
      apply(rename_tac k e1a wa A eL eLa e2 c2 l r)(*strict*)
      apply (metis setA_liftB_empty elemInsetA empty_iff)
     apply(rename_tac k e1a wa A w eL eLa c ys y)(*strict*)
     apply(clarsimp)
     apply(rename_tac k e1a wa A eL eLa c ys y)(*strict*)
     apply(simp add: stack_def)
    apply(rename_tac k e1a wa A w eL eLa c ca ys y)(*strict*)
    apply(clarsimp)
   apply(rename_tac k e1a wa A w eL eLa c ca w2a a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa A w eL eLa c ca a list q1a q2 q3 q4 A1a A2)(*strict*)
   apply(erule_tac P="A = cons_l2 q1a A1a \<and> a = cons_l2 q2 A2 \<and> liftA list = []" in disjE)
    apply(rename_tac k e1a wa A w eL eLa c ca a list q1a q2 q3 q4 A1a A2)(*strict*)
    apply(force)
   apply(rename_tac k e1a wa A w eL eLa c ca a list q1a q2 q3 q4 A1a A2)(*strict*)
   apply(erule_tac P="A = cons_l2 q1a A1a \<and> a = cons_l3 q2 A2 q3 \<and> liftA list = [teA (cons_l2   q3 A1a)]" in disjE)
    apply(rename_tac k e1a wa A w eL eLa c ca a list q1a q2 q3 q4 A1a A2)(*strict*)
    apply(clarsimp)
    apply(rename_tac k e1a wa w eL eLa c ca list q1a q2 q3 A1a A2)(*strict*)
    apply(case_tac list)
     apply(rename_tac k e1a wa w eL eLa c ca list q1a q2 q3 A1a A2)(*strict*)
     apply(clarsimp)
    apply(rename_tac k e1a wa w eL eLa c ca list q1a q2 q3 A1a A2 a lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 A1a A2 lista)(*strict*)
    apply(case_tac lista)
     apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 A1a A2 lista)(*strict*)
     prefer 2
     apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 A1a A2 lista a list)(*strict*)
     apply(clarsimp)
    apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 A1a A2 lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 A1a A2)(*strict*)
    apply(rule_tac xs="ca" in rev_cases)
     apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 A1a A2)(*strict*)
     apply(clarsimp)
     apply(rename_tac k e1a wa w eL eLa c q1a q2 q3 A1a A2)(*strict*)
     apply(rule_tac xs="w" in rev_cases)
      apply(rename_tac k e1a wa w eL eLa c q1a q2 q3 A1a A2)(*strict*)
      apply(clarsimp)
      apply(rename_tac k e1a wa eL eLa c q1a q2 q3 A1a A2)(*strict*)
      apply(simp add: stack_def)
     apply(rename_tac k e1a wa w eL eLa c q1a q2 q3 A1a A2 ys y)(*strict*)
     apply(simp add: stack_def)
    apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 A1a A2 ys y)(*strict*)
    apply(clarsimp)
    apply(rename_tac k e1a wa w eL eLa c q1a q2 q3 A1a A2 ys y)(*strict*)
    apply(simp add: stack_def)
   apply(rename_tac k e1a wa A w eL eLa c ca a list q1a q2 q3 q4 A1a A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca list q1a q2 q3 q4 A1a A2)(*strict*)
   apply(case_tac list)
    apply(rename_tac k e1a wa w eL eLa c ca list q1a q2 q3 q4 A1a A2)(*strict*)
    apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca list q1a q2 q3 q4 A1a A2 a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 q4 A1a A2 lista)(*strict*)
   apply(case_tac lista)
    apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 q4 A1a A2 lista)(*strict*)
    prefer 2
    apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 q4 A1a A2 lista a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 q4 A1a A2 lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 q4 A1a A2)(*strict*)
   apply(rule_tac xs="ca" in rev_cases)
    apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 q4 A1a A2)(*strict*)
    apply(clarsimp)
    apply(rename_tac k e1a wa w eL eLa c q1a q2 q3 q4 A1a A2)(*strict*)
    apply(rule_tac xs="w" in rev_cases)
     apply(rename_tac k e1a wa w eL eLa c q1a q2 q3 q4 A1a A2)(*strict*)
     apply(clarsimp)
     apply(rename_tac k e1a wa eL eLa c q1a q2 q3 q4 A1a A2)(*strict*)
     apply(simp add: stack_def)
    apply(rename_tac k e1a wa w eL eLa c q1a q2 q3 q4 A1a A2 ys y)(*strict*)
    apply(simp add: stack_def)
   apply(rename_tac k e1a wa w eL eLa c ca q1a q2 q3 q4 A1a A2 ys y)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c q1a q2 q3 q4 A1a A2 ys y)(*strict*)
   apply(simp add: stack_def)
  apply(rename_tac k e1a wa A w eL eLa c ca w1a w2a a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a wa A w eL eLa c ca w2a a list b q1a q2 q3 A1a)(*strict*)
  apply(erule_tac P="A = cons_l2 q1a A1a \<and> a = b \<and> liftB list @ liftA w2a = [teA (cons_l2   q2 A1a)]" in disjE)
   apply(rename_tac k e1a wa A w eL eLa c ca w2a a list b q1a q2 q3 A1a)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca w2a list b q1a q2 A1a)(*strict*)
   apply(case_tac list)
    apply(rename_tac k e1a wa w eL eLa c ca w2a list b q1a q2 A1a)(*strict*)
    prefer 2
    apply(rename_tac k e1a wa w eL eLa c ca w2a list b q1a q2 A1a a lista)(*strict*)
    apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca w2a list b q1a q2 A1a)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca w2a b q1a q2 A1a)(*strict*)
   apply(case_tac w2a)
    apply(rename_tac k e1a wa w eL eLa c ca w2a b q1a q2 A1a)(*strict*)
    apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca w2a b q1a q2 A1a a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 A1a list)(*strict*)
   apply(case_tac list)
    apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 A1a list)(*strict*)
    prefer 2
    apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 A1a list a lista)(*strict*)
    apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 A1a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 A1a)(*strict*)
   apply(rule_tac xs="ca" in rev_cases)
    apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 A1a)(*strict*)
    apply(clarsimp)
    apply(rename_tac k e1a wa w eL eLa c b q1a q2 A1a)(*strict*)
    apply(rule_tac xs="w" in rev_cases)
     apply(rename_tac k e1a wa w eL eLa c b q1a q2 A1a)(*strict*)
     apply(clarsimp)
     apply(rename_tac k e1a wa eL eLa c b q1a q2 A1a)(*strict*)
     apply(simp add: stack_def)
    apply(rename_tac k e1a wa w eL eLa c b q1a q2 A1a ys y)(*strict*)
    apply(simp add: stack_def)
   apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 A1a ys y)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c b q1a q2 A1a ys y)(*strict*)
   apply(simp add: stack_def)
  apply(rename_tac k e1a wa A w eL eLa c ca w2a a list b q1a q2 q3 A1a)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a wa w eL eLa c ca w2a list b q1a q2 q3 A1a)(*strict*)
  apply(case_tac list)
   apply(rename_tac k e1a wa w eL eLa c ca w2a list b q1a q2 q3 A1a)(*strict*)
   prefer 2
   apply(rename_tac k e1a wa w eL eLa c ca w2a list b q1a q2 q3 A1a a lista)(*strict*)
   apply(clarsimp)
  apply(rename_tac k e1a wa w eL eLa c ca w2a list b q1a q2 q3 A1a)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a wa w eL eLa c ca w2a b q1a q2 q3 A1a)(*strict*)
  apply(case_tac w2a)
   apply(rename_tac k e1a wa w eL eLa c ca w2a b q1a q2 q3 A1a)(*strict*)
   apply(clarsimp)
  apply(rename_tac k e1a wa w eL eLa c ca w2a b q1a q2 q3 A1a a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 q3 A1a list)(*strict*)
  apply(case_tac list)
   apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 q3 A1a list)(*strict*)
   prefer 2
   apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 q3 A1a list a lista)(*strict*)
   apply(clarsimp)
  apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 q3 A1a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 q3 A1a)(*strict*)
  apply(rule_tac xs="ca" in rev_cases)
   apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 q3 A1a)(*strict*)
   apply(clarsimp)
   apply(rename_tac k e1a wa w eL eLa c b q1a q2 q3 A1a)(*strict*)
   apply(rule_tac xs="w" in rev_cases)
    apply(rename_tac k e1a wa w eL eLa c b q1a q2 q3 A1a)(*strict*)
    apply(clarsimp)
    apply(rename_tac k e1a wa eL eLa c b q1a q2 q3 A1a)(*strict*)
    apply(simp add: stack_def)
   apply(rename_tac k e1a wa w eL eLa c b q1a q2 q3 A1a ys y)(*strict*)
   apply(simp add: stack_def)
  apply(rename_tac k e1a wa w eL eLa c ca b q1a q2 q3 A1a ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac k e1a wa w eL eLa c b q1a q2 q3 A1a ys y)(*strict*)
  apply(simp add: stack_def)
  done

definition discard_font_state :: "
  ('state, 'stack) DT_l2_l3_nonterminals list
  \<Rightarrow> ('stack \<times> 'state option) list"
  where
    "discard_font_state w \<equiv>
  map (\<lambda>x.
      case x of
        cons_l2 q A \<Rightarrow> (A, None)
        | cons_l3 q1 A q2 \<Rightarrow> (A, Some q2)) w"

lemma discard_font_state_append: "
  discard_font_state (v' @ v) = discard_font_state v' @ discard_font_state v"
  apply(simp add: discard_font_state_def)
  done

lemma discard_font_state_length: "
  length (discard_font_state v) = length v"
  apply(simp add: discard_font_state_def)
  done

lemma discard_font_state_suffix_stays: "
  length v \<ge> length w
  \<Longrightarrow> discard_font_state (v' @ v) \<sqsupseteq> discard_font_state w
  \<Longrightarrow> discard_font_state v \<sqsupseteq> discard_font_state w"
  apply(simp add: suffix_def discard_font_state_append)
  apply(clarsimp)
  apply(rename_tac c)(*strict*)
  apply(subgoal_tac "prefix (discard_font_state v') c \<or> SSX" for SSX)
   apply(rename_tac c)(*strict*)
   prefer 2
   apply(rule mutual_prefix_prefix)
   apply(force)
  apply(rename_tac c)(*strict*)
  apply(erule disjE)
   apply(rename_tac c)(*strict*)
   apply(simp add: prefix_def)
   apply(clarsimp)
  apply(rename_tac c)(*strict*)
  apply(simp add: prefix_def)
  apply(clarsimp)
  apply(rename_tac c ca)(*strict*)
  apply(case_tac ca)
   apply(rename_tac c ca)(*strict*)
   apply(force)
  apply(rename_tac c ca a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac c a b list)(*strict*)
  apply(subgoal_tac "False")
   apply(rename_tac c a b list)(*strict*)
   apply(force)
  apply(rename_tac c a b list)(*strict*)
  apply (metis append_assoc discard_font_state_length length_shorter_append2 list.distinct(1) same_append_eq)
  done

lemma F_SDPDA_TO_CFG_OPT__has_same_reachable_nonterminals_hlp: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT G k = Some Gopt
  \<Longrightarrow> valid_cfg (Gopt)
  \<Longrightarrow> valid_cfg (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfg_sub (Gopt) (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G) d
  \<Longrightarrow> d (Suc (k1 + (k2 + k3))) = Some (pair e4 \<lparr>cfg_conf = liftB wa\<rparr>)
  \<Longrightarrow> d k1 = Some (pair e1 \<lparr>cfg_conf = liftB v1 @ teA (cons_l3 qA A qA') # liftA s1\<rparr>)
  \<Longrightarrow> l3_l2_separation_ALT (cons_l3 qA A qA' # s1)
  \<Longrightarrow> d (Suc (k1 + k2)) = Some (pair (Some \<lparr>prod_lhs = cons_l3 qB B qB', prod_rhs = []\<rparr>) \<lparr>cfg_conf = liftB v2 @ teA C # liftA s2\<rparr>)
  \<Longrightarrow> d (k1 + k2) = Some (pair e2 \<lparr>cfg_conf = liftB v2 @ teA (cons_l3 qB B qB') # teA C # liftA s2\<rparr>)
  \<Longrightarrow> \<lparr>prod_lhs = cons_l3 qB B qB', prod_rhs = []\<rparr> \<in> cfg_productions (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> \<forall>x < Suc k2. \<forall>e c. d (k1 + x) = Some (pair e c) \<longrightarrow> (\<forall>w1 w2. cfg_conf c = liftB w1 @ liftA w2 \<longrightarrow> \<not> length w2 < Suc (length s1))
  \<Longrightarrow> Suc (length s2) = length s1
  \<Longrightarrow> l3_l2_separation_ALT (cons_l3 qB B qB' # C # s2)
  \<Longrightarrow> x < Suc k2 \<longrightarrow> (\<forall>e c. d (k1 + x) = Some (pair e c) \<longrightarrow> (\<forall>w1 w2. cfg_conf c = liftB w1 @ liftA w2 \<longrightarrow> discard_font_state (event_stack_separation (cfg_conf c)) \<sqsupseteq> discard_font_state (event_stack_separation (teA (cons_l3 qA A qA') # liftA s1))))"
  apply(induct x)
   apply(clarsimp)
   apply(rename_tac w1 w2)(*strict*)
   apply(subgoal_tac "w1=v1")
    apply(rename_tac w1 w2)(*strict*)
    prefer 2
    apply(rule_tac ?v1.0="w2" and A="cons_l3 qA A qA'" and ?v2.0="liftA s1" in equal_left_liftB)
    apply(clarsimp)
   apply(rename_tac w1 w2)(*strict*)
   apply(clarsimp)
   apply(rename_tac w2)(*strict*)
   apply(case_tac w2)
    apply(rename_tac w2)(*strict*)
    apply(clarsimp)
   apply(rename_tac w2 a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac list)(*strict*)
   apply(subgoal_tac "list=s1")
    apply(rename_tac list)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(rule sym)
    apply(force)
   apply(rename_tac list)(*strict*)
   apply(clarify)
   apply(clarsimp)
   apply(simp add: event_stack_separation_def)
   apply(subgoal_tac "(THE v. \<exists>x. liftB v1 @ teA (cons_l3   qA A qA') # liftA s1 =
                 liftB x @ liftA v) = cons_l3 qA A qA'#s1")
    prefer 2
    apply (metis SPLIT_2_0)
   apply(clarsimp)
   apply(subgoal_tac "(THE v. \<exists>x. liftB [] @ teA (cons_l3   qA A qA') # liftA s1 = liftB x @ liftA v) = cons_l3 qA A qA'#s1")
    prefer 2
    apply (rule SPLIT_2_0)
   apply(clarsimp)
   apply(simp add: suffix_def)
   apply(rule_tac x="[]" in exI)
   apply(clarsimp)
   apply(rule_tac f="discard_font_state" in arg_cong)
   apply(rule sym)
   apply(force)
  apply(rename_tac x)(*strict*)
  apply(clarsimp)
  apply(rename_tac x e c w1 w2)(*strict*)
  apply(case_tac c)
  apply(rename_tac x e c w1 w2 cfg_confa)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac x e c w1 w2 cfg_confa)(*strict*)
   prefer 2
   apply(rule_tac
      n="(k1 + x)"
      and m="Suc (k1 + x)"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac x e c w1 w2 cfg_confa)(*strict*)
     apply(rule cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac x e c w1 w2 cfg_confa)(*strict*)
    apply(force)
   apply(rename_tac x e c w1 w2 cfg_confa)(*strict*)
   apply(force)
  apply(rename_tac x e c w1 w2 cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a e2a c1)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac x w1 w2 e1a e2a c1)(*strict*)
   prefer 2
   apply(rule_tac G="G" in sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
   apply(rule cfg_sub_reflexive)
  apply(rename_tac x w1 w2 e1a e2a c1)(*strict*)
  apply(simp add: LR1ProdForm_def)
  apply(simp add: cfgLM_step_relation_def)
  apply(case_tac c1)
  apply(rename_tac x w1 w2 e1a e2a c1 cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a e2a l r)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= l")
   apply(rename_tac x w1 w2 e1a e2a l r)(*strict*)
   prefer 2
   apply(rule_tac x="filterB l" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac x w1 w2 e1a e2a l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a e2a r w)(*strict*)
  apply(thin_tac "setA (liftB w) = {}")
  apply(subgoal_tac "X" for X)
   apply(rename_tac x w1 w2 e1a e2a r w)(*strict*)
   prefer 2
   apply(rule_tac n="k1 + x" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac x w1 w2 e1a e2a r w)(*strict*)
      apply(force)
     apply(rename_tac x w1 w2 e1a e2a r w)(*strict*)
     apply(force)
    apply(rename_tac x w1 w2 e1a e2a r w)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac x w1 w2 e1a e2a r w)(*strict*)
   apply(force)
  apply(rename_tac x w1 w2 e1a e2a r w)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a e2a r w w1a w2a)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= w1a")
   apply(rename_tac x w1 w2 e1a e2a r w w1a w2a)(*strict*)
   prefer 2
   apply(rule_tac x="filterB w1a" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac x w1 w2 e1a e2a r w w1a w2a)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a e2a r w w2a waa)(*strict*)
  apply(thin_tac "setA (liftB waa) = {}")
  apply(subgoal_tac "\<exists>w. liftA w= w2a")
   apply(rename_tac x w1 w2 e1a e2a r w w2a waa)(*strict*)
   prefer 2
   apply(rule_tac x="filterA w2a" in exI)
   apply(rule sym)
   apply(rule setB_empty_then_liftA_vs_filterA)
   apply(force)
  apply(rename_tac x w1 w2 e1a e2a r w w2a waa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a e2a r w waa wb)(*strict*)
  apply(thin_tac "setB (liftA wb) = {} ")
  apply(subgoal_tac "w=waa")
   apply(rename_tac x w1 w2 e1a e2a r w waa wb)(*strict*)
   prefer 2
   apply (metis equal_left_liftB)
  apply(rename_tac x w1 w2 e1a e2a r w waa wb)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a e2a r waa wb)(*strict*)
  apply(case_tac wb)
   apply(rename_tac x w1 w2 e1a e2a r waa wb)(*strict*)
   apply(force)
  apply(rename_tac x w1 w2 e1a e2a r waa wb a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a e2a waa list)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac x w1 w2 e1a e2a waa list)(*strict*)
   prefer 2
   apply(rule_tac ?w2.0="prod_lhs e2a#list" and ?w1.0="waa" and n="k1+x" in cfgLM_reachable_conf_isl3_l2_separation_ALT_stack)
        apply(rename_tac x w1 w2 e1a e2a waa list)(*strict*)
        apply(force)
       apply(rename_tac x w1 w2 e1a e2a waa list)(*strict*)
       apply(force)
      apply(rename_tac x w1 w2 e1a e2a waa list)(*strict*)
      apply(force)
     apply(rename_tac x w1 w2 e1a e2a waa list)(*strict*)
     apply(force)
    apply(rename_tac x w1 w2 e1a e2a waa list)(*strict*)
    apply(force)
   apply(rename_tac x w1 w2 e1a e2a waa list)(*strict*)
   apply(clarsimp)
  apply(rename_tac x w1 w2 e1a e2a waa list)(*strict*)
  apply(erule_tac x="waa" in allE)
  apply(erule_tac x="prod_lhs e2a#list" in allE)
  apply(clarsimp)
  apply(case_tac e2a)
  apply(rename_tac x w1 w2 e1a e2a waa list prod_lhsa prod_rhsa)(*strict*)
  apply(rename_tac X w)
  apply(rename_tac x w1 w2 e1a e2a waa list X w)(*strict*)
  apply(erule_tac x="e2a" in ballE)
   apply(rename_tac x w1 w2 e1a e2a waa list X w)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac x w1 w2 e1a e2a waa list X w)(*strict*)
  apply(erule disjE)
   apply(rename_tac x w1 w2 e1a e2a waa list X w)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 w2 e1a waa list X)(*strict*)
   apply(subgoal_tac "w1=waa")
    apply(rename_tac x w1 w2 e1a waa list X)(*strict*)
    prefer 2
    apply(rule  liftB_liftA_eq_liftB_liftA)
    apply(force)
   apply(rename_tac x w1 w2 e1a waa list X)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w2 e1a waa list X)(*strict*)
   apply(subgoal_tac "w2=list")
    apply(rename_tac x w2 e1a waa list X)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac x w2 e1a waa list X)(*strict*)
   apply(clarsimp)
   apply(rename_tac x e1a waa list X)(*strict*)
   apply(erule_tac x="Suc x" in allE')
   apply(clarsimp)
   apply(erule_tac x="waa" in allE)
   apply(erule_tac x="list" in allE)
   apply(clarsimp)
   apply(erule_tac x="x" in allE)
   apply(clarsimp)
   apply(erule_tac x="waa" in allE)
   apply(erule_tac x="X#list" in allE)
   apply(clarsimp)
   apply(subgoal_tac "event_stack_separation (liftB waa @ teA X # liftA list) = X#list")
    apply(rename_tac x e1a waa list X)(*strict*)
    prefer 2
    apply(simp add: event_stack_separation_def)
    apply (metis SPLIT_2_0)
   apply(rename_tac x e1a waa list X)(*strict*)
   apply(subgoal_tac "event_stack_separation (liftB waa @ liftA list) = list")
    apply(rename_tac x e1a waa list X)(*strict*)
    prefer 2
    apply(simp add: event_stack_separation_def)
    apply(rule split_XX2)
   apply(rename_tac x e1a waa list X)(*strict*)
   apply(subgoal_tac "event_stack_separation (teA (cons_l3   qA A qA') # liftA s1) = cons_l3 qA A qA'#s1")
    apply(rename_tac x e1a waa list X)(*strict*)
    prefer 2
    apply(simp add: event_stack_separation_def)
    apply(rule_tac t="teA (cons_l3   qA A qA') # liftA s1" and s="liftB [] @ teA (cons_l3   qA A qA') # liftA s1" in ssubst)
     apply(rename_tac x e1a waa list X)(*strict*)
     apply(force)
    apply(rename_tac x e1a waa list X)(*strict*)
    apply (rule SPLIT_2_0)
   apply(rename_tac x e1a waa list X)(*strict*)
   apply(subgoal_tac "event_stack_separation (liftB waa @ teA X # liftA list) = X#list")
    apply(rename_tac x e1a waa list X)(*strict*)
    prefer 2
    apply(simp add: event_stack_separation_def)
   apply(rename_tac x e1a waa list X)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "discard_font_state (X # list) \<sqsupseteq>
       discard_font_state (cons_l3 qA A qA' # s1)")
    apply(rename_tac x e1a waa list X)(*strict*)
    apply(thin_tac "discard_font_state (X # list) \<sqsupseteq>
       discard_font_state (event_stack_separation (teA (cons_l3   qA A qA') # liftA s1))")
    apply(subgoal_tac "discard_font_state list \<sqsupseteq> discard_font_state (cons_l3 qA A qA' # s1)")
     apply(rename_tac x e1a waa list X)(*strict*)
     apply(rule_tac t="event_stack_separation (teA (cons_l3   qA A qA') # liftA s1)" and s="cons_l3 qA A qA' # s1" in ssubst)
      apply(rename_tac x e1a waa list X)(*strict*)
      apply(force)
     apply(rename_tac x e1a waa list X)(*strict*)
     apply(force)
    apply(rename_tac x e1a waa list X)(*strict*)
    apply(rule_tac v'="[X]" in discard_font_state_suffix_stays)
     apply(rename_tac x e1a waa list X)(*strict*)
     apply(force)
    apply(rename_tac x e1a waa list X)(*strict*)
    apply(force)
   apply(rename_tac x e1a waa list X)(*strict*)
   apply(force)
  apply(rename_tac x w1 w2 e1a e2a waa list X w)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a waa list X w b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac x w1 w2 e1a waa list X w b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 w2 e1a waa list b q1 q2 A1)(*strict*)
   apply(case_tac list)
    apply(rename_tac x w1 w2 e1a waa list b q1 q2 A1)(*strict*)
    prefer 2
    apply(rename_tac x w1 w2 e1a waa list b q1 q2 A1 a lista)(*strict*)
    apply(simp add: l3_l2_separation_ALT_def)
   apply(rename_tac x w1 w2 e1a waa list b q1 q2 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 w2 e1a waa b q1 q2 A1)(*strict*)
   apply(rule_tac xs="w2" in rev_cases)
    apply(rename_tac x w1 w2 e1a waa b q1 q2 A1)(*strict*)
    apply(clarsimp)
    apply(rename_tac x w1 e1a waa b q1 q2 A1)(*strict*)
    apply(rule_tac xs="w1" in rev_cases)
     apply(rename_tac x w1 e1a waa b q1 q2 A1)(*strict*)
     apply(clarsimp)
    apply(rename_tac x w1 e1a waa b q1 q2 A1 ys y)(*strict*)
    apply(clarsimp)
    apply(rename_tac x e1a waa b q1 q2 A1 ys y)(*strict*)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac x w1 w2 e1a waa b q1 q2 A1 ys y)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 e1a waa b q1 q2 A1 ys y)(*strict*)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(clarsimp)
   apply(rename_tac x w1 e1a waa b q1 q2 A1 ys)(*strict*)
   apply(erule_tac x="Suc x" in allE')
   apply(clarsimp)
   apply(erule_tac x="waa@[b]" in allE)
   apply(erule_tac x="[cons_l2 q2 A1]" in allE)
   apply(clarsimp)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac x w1 w2 e1a waa list X w b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac x w1 w2 e1a waa list X w b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 w2 e1a waa list b q1 q2 q3 A1)(*strict*)
   apply(subgoal_tac "w1=waa@[b]")
    apply(rename_tac x w1 w2 e1a waa list b q1 q2 q3 A1)(*strict*)
    prefer 2
    apply(rule_tac ?w4.0="cons_l3 q3 A1 q2#list" in liftB_liftA_eq_liftB_liftA)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac x w1 w2 e1a waa list b q1 q2 q3 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w2 e1a waa list b q1 q2 q3 A1)(*strict*)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(case_tac w2)
    apply(rename_tac x w2 e1a waa list b q1 q2 q3 A1)(*strict*)
    apply(clarsimp)
   apply(rename_tac x w2 e1a waa list b q1 q2 q3 A1 a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac x e1a waa list b q1 q2 q3 A1 lista)(*strict*)
   apply(subgoal_tac "lista=list")
    apply(rename_tac x e1a waa list b q1 q2 q3 A1 lista)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac x e1a waa list b q1 q2 q3 A1 lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac x e1a waa list b q1 q2 q3 A1)(*strict*)
   apply(erule_tac x="x" in allE)
   apply(clarsimp)
   apply(erule_tac x="waa" in allE)
   apply(erule_tac x="cons_l3 q1 A1 q2#list" in allE)
   apply(clarsimp)
   apply(subgoal_tac "event_stack_separation (liftB waa @ teA (cons_l3   q1 A1 q2) # liftA list) = cons_l3 q1 A1 q2#list")
    apply(rename_tac x e1a waa list b q1 q2 q3 A1)(*strict*)
    prefer 2
    apply(rule_tac w="waa" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac x e1a waa list b q1 q2 q3 A1)(*strict*)
   apply(subgoal_tac "event_stack_separation (teA (cons_l3   qA A qA') # liftA s1) = cons_l3 qA A qA'#s1")
    apply(rename_tac x e1a waa list b q1 q2 q3 A1)(*strict*)
    prefer 2
    apply(rule_tac w="[]" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac x e1a waa list b q1 q2 q3 A1)(*strict*)
   apply(subgoal_tac "event_stack_separation (liftB waa @ teB b # teA (cons_l3   q3 A1 q2) # liftA list) = cons_l3 q3 A1 q2#list")
    apply(rename_tac x e1a waa list b q1 q2 q3 A1)(*strict*)
    prefer 2
    apply(rule_tac w="waa@[b]" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac x e1a waa list b q1 q2 q3 A1)(*strict*)
   apply(clarsimp)
   apply(simp add: discard_font_state_def)
  apply(rename_tac x w1 w2 e1a waa list X w b q1 q2 q3 q4 A1)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a waa list X w q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac x w1 w2 e1a waa list X w q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 w2 e1a waa list q1 q2 A1 A2)(*strict*)
   apply(case_tac list)
    apply(rename_tac x w1 w2 e1a waa list q1 q2 A1 A2)(*strict*)
    prefer 2
    apply(rename_tac x w1 w2 e1a waa list q1 q2 A1 A2 a lista)(*strict*)
    apply(simp add: l3_l2_separation_ALT_def)
   apply(rename_tac x w1 w2 e1a waa list q1 q2 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 w2 e1a waa q1 q2 A1 A2)(*strict*)
   apply(rule_tac xs="w2" in rev_cases)
    apply(rename_tac x w1 w2 e1a waa q1 q2 A1 A2)(*strict*)
    apply(clarsimp)
    apply(rename_tac x w1 e1a waa q1 q2 A1 A2)(*strict*)
    apply(rule_tac xs="w1" in rev_cases)
     apply(rename_tac x w1 e1a waa q1 q2 A1 A2)(*strict*)
     apply(clarsimp)
    apply(rename_tac x w1 e1a waa q1 q2 A1 A2 ys y)(*strict*)
    apply(clarsimp)
    apply(rename_tac x e1a waa q1 q2 A1 A2 ys y)(*strict*)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac x w1 w2 e1a waa q1 q2 A1 A2 ys y)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 e1a waa q1 q2 A1 A2 ys y)(*strict*)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(clarsimp)
   apply(rename_tac x w1 e1a waa q1 q2 A1 A2 ys)(*strict*)
   apply(erule_tac x="Suc x" in allE')
   apply(clarsimp)
   apply(erule_tac x="waa" in allE)
   apply(erule_tac x="[cons_l2 q2 A2]" in allE)
   apply(clarsimp)
  apply(rename_tac x w1 w2 e1a waa list X w q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac x w1 w2 e1a waa list X w q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 w2 e1a waa list q1 q2 q3 A1 A2)(*strict*)
   apply(case_tac list)
    apply(rename_tac x w1 w2 e1a waa list q1 q2 q3 A1 A2)(*strict*)
    prefer 2
    apply(rename_tac x w1 w2 e1a waa list q1 q2 q3 A1 A2 a lista)(*strict*)
    apply(simp add: l3_l2_separation_ALT_def)
   apply(rename_tac x w1 w2 e1a waa list q1 q2 q3 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac x w1 w2 e1a waa q1 q2 q3 A1 A2)(*strict*)
   apply(erule_tac x="x" in allE)
   apply(clarsimp)
   apply(erule_tac x="waa" in allE)
   apply(erule_tac x="[cons_l2 q1 A1]" in allE)
   apply(clarsimp)
  apply(rename_tac x w1 w2 e1a waa list X w q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w1 w2 e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(subgoal_tac "w1=waa")
   apply(rename_tac x w1 w2 e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
   prefer 2
   apply(rule_tac ?w4.0=" (cons_l3 q2 A2 q3) #  (cons_l3 q3 A1 q4) # list" in liftB_liftA_eq_liftB_liftA)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac x w1 w2 e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(rename_tac x w2 e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(case_tac w2)
   apply(rename_tac x w2 e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
  apply(rename_tac x w2 e1a waa list q1 q2 q3 q4 A1 A2 a lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2 lista)(*strict*)
  apply(case_tac lista)
   apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2 lista)(*strict*)
   apply(clarsimp)
  apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2 lista a listb)(*strict*)
  apply(clarsimp)
  apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2 listb)(*strict*)
  apply(subgoal_tac "listb=list")
   apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2 listb)(*strict*)
   prefer 2
   apply(rule liftA_inj)
   apply(force)
  apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2 listb)(*strict*)
  apply(clarsimp)
  apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule_tac x="x" in allE)
  apply(clarsimp)
  apply(erule_tac x="waa" in allE)
  apply(erule_tac x=" (cons_l3 q1 A1 q4) #  list" in allE)
  apply(clarsimp)
  apply(subgoal_tac "event_stack_separation (liftB waa @ teA (cons_l3   q1 A1 q4) # liftA list) = cons_l3 q1 A1 q4#list")
   apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
   prefer 2
   apply(rule_tac w="waa" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(subgoal_tac "event_stack_separation (teA (cons_l3   qA A qA') # liftA s1) = cons_l3 qA A qA'#s1")
   apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
   prefer 2
   apply(rule_tac w="[]" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(subgoal_tac "event_stack_separation
          (liftB waa @ teA (cons_l3   q2 A2 q3) # teA (cons_l3   q3 A1 q4) # liftA list) =  (cons_l3 q2 A2 q3) #  (cons_l3 q3 A1 q4) #  list")
   apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
   prefer 2
   apply(rule_tac w="waa" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac x e1a waa list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(simp add: discard_font_state_def suffix_def)
  apply(force)
  done

definition l3_derivation :: "
  ('state, 'event, 'stack) epda
  \<Rightarrow> (('state, 'event, 'stack) epda_step_label, ('state, 'event, 'stack) epdaH_conf) derivation
  \<Rightarrow> 'stack list
  \<Rightarrow> 'state
  \<Rightarrow> 'stack
  \<Rightarrow> 'state
  \<Rightarrow> nat
  \<Rightarrow> nat
  \<Rightarrow> bool"
  where
    "l3_derivation G d w q A q' i j \<equiv>
  \<exists>e1 c1 e2 c2.
  epdaH.derivation_initial G d
  \<and> d i = Some (pair e1 c1)
  \<and> epdaH_conf_state c1 = q
  \<and> d (i+Suc j) = Some (pair e2 c2)
  \<and> epdaH_conf_state c2 = q'
  \<and> epdaH_conf_stack c1 = A # w
  \<and> (\<forall>k\<le>j. \<forall>e c. d (i+k) = Some (pair e c) \<longrightarrow> suffix (epdaH_conf_stack c) (A # w))
  \<and> epdaH_conf_stack c2 = w"

lemma l3_derivation_to_l3_derivationMAX: "
  valid_simple_dpda G
  \<Longrightarrow> l3_derivation G d w q A q' i j
  \<Longrightarrow> \<exists>qI k e c. k \<le> i \<and> l3_derivation_MAX G d w qI A q' (i - k) (j + k) \<and> d i = Some (pair e c) \<and> epdaH_conf_state c = q \<and> epdaH_conf_stack c = A # w"
  apply(simp only: l3_derivation_def)
  apply(erule exE)+
  apply(rename_tac e1 c1 e2 c2)(*strict*)
  apply(erule conjE)+
  apply(subgoal_tac "X" for X)
   apply(rename_tac e1 c1 e2 c2)(*strict*)
   prefer 2
   apply(rule_tac ?n="i" and P="%n.
   (\<forall>k. n+k\<le>i \<longrightarrow>
           (\<forall>e c. d (n+k) = Some (pair e c) \<longrightarrow>
                 epdaH_conf_stack c \<sqsupseteq> (A # w)))" in ex_least_nat_le_prime)
   apply(clarsimp)
   apply(simp add: suffix_def)
  apply(rename_tac e1 c1 e2 c2)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 k)(*strict*)
  apply(erule_tac x="0" and P="%ka.
  k + ka \<le> i
    \<longrightarrow> (\<forall>e c. d (k + ka) = Some (pair e c)
    \<longrightarrow> epdaH_conf_stack c \<sqsupseteq> (A # epdaH_conf_stack c2))" in allE')
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   apply(rename_tac e1 c1 e2 c2 k)(*strict*)
   prefer 2
   apply(rule_tac M="G" and g="d" and n="k" in epdaH.pre_some_position_is_some_position)
     apply(rename_tac e1 c1 e2 c2 k)(*strict*)
     apply(simp add: epdaH.derivation_initial_def)
    apply(rename_tac e1 c1 e2 c2 k)(*strict*)
    apply(force)
   apply(rename_tac e1 c1 e2 c2 k)(*strict*)
   apply(force)
  apply(rename_tac e1 c1 e2 c2 k)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 k e c)(*strict*)
  apply(rule_tac x="epdaH_conf_state c" in exI)
  apply(rule_tac x="i-k" in exI)
  apply(simp only: l3_derivation_MAX_def)
  apply(rule_tac t="(i - (i - k) + Suc XX)" and s="(Suc (i + j))" for XX in ssubst)
   apply(rename_tac e1 c1 e2 c2 k e c)(*strict*)
   apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 k e c)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "epdaH_conf_stack c = A # epdaH_conf_stack c2 \<and>
       (case e of None \<Rightarrow> True
        | Some e1' \<Rightarrow> \<exists>X. edge_push e1' = [A, X])")
   apply(rename_tac e1 c1 e2 c2 k e c)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 k e c ka ea ca)(*strict*)
   apply(subgoal_tac "\<exists>kX. k+kX=i")
    apply(rename_tac e1 c1 e2 c2 k e c ka ea ca)(*strict*)
    prefer 2
    apply(rule_tac x="i-k" in exI)
    apply(force)
   apply(rename_tac e1 c1 e2 c2 k e c ka ea ca)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX)(*strict*)
   apply(subgoal_tac "\<exists>kY. ka+kY=kX + j")
    apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX)(*strict*)
    prefer 2
    apply(rule_tac x="(kX + j)-ka" in exI)
    apply(force)
   apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX kY)(*strict*)
   apply(case_tac "ka\<le>kX")
    apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX kY)(*strict*)
    apply(subgoal_tac "\<exists>kZ. ka+kZ=kX")
     apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX kY)(*strict*)
     prefer 2
     apply(rule_tac x="kX-ka" in exI)
     apply(force)
    apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX kY)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX kY)(*strict*)
   apply(subgoal_tac "kX<ka")
    apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX kY)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX kY)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "\<exists>x. kX+Suc x=ka")
    apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX kY)(*strict*)
    prefer 2
    apply(rule_tac x="ka-Suc kX" in exI)
    apply(force)
   apply(rename_tac e1 c1 e2 c2 k e c ka ea ca kX kY)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 k e c ea ca kX kY x)(*strict*)
   apply(erule_tac x="Suc x" in allE)
   apply(clarsimp)
   apply(erule_tac x="ea" in allE)
   apply(erule_tac x="ca" in allE)
   apply(clarsimp)
   apply(subgoal_tac "(Suc (k + kX + x)) = (Suc (k + (kX + x)))")
    apply(rename_tac e1 c1 e2 c2 k e c ea ca kX kY x)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac e1 c1 e2 c2 k e c ea ca kX kY x)(*strict*)
   apply(force)
  apply(rename_tac e1 c1 e2 c2 k e c)(*strict*)
  apply(case_tac k)
   apply(rename_tac e1 c1 e2 c2 k e c)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 e c)(*strict*)
   apply(erule_tac x="0" in allE)+
   apply(clarsimp)
   apply(simp add: suffix_def)
   apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 c ca)(*strict*)
   apply(case_tac ca)
    apply(rename_tac e1 c1 e2 c2 c ca)(*strict*)
    prefer 2
    apply(rename_tac e1 c1 e2 c2 c ca a list)(*strict*)
    apply(force)
   apply(rename_tac e1 c1 e2 c2 c ca)(*strict*)
   apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 k e c nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 e c nat)(*strict*)
  apply(rename_tac n)
  apply(rename_tac e1 c1 e2 c2 e c n)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac e1 c1 e2 c2 e c n)(*strict*)
   prefer 2
   apply(rule_tac
      d="d" and
      n="n" and
      m="Suc n"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac e1 c1 e2 c2 e c n)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac e1 c1 e2 c2 e c n)(*strict*)
    apply(force)
   apply(rename_tac e1 c1 e2 c2 e c n)(*strict*)
   apply(force)
  apply(rename_tac e1 c1 e2 c2 e c n)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 c n e1a e2a c1a)(*strict*)
  apply(simp add: epdaH_step_relation_def)
  apply(case_tac e2a)
  apply(rename_tac e1 c1 e2 c2 c n e1a e2a c1a edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac qs r po pu qt)
  apply(rename_tac e1 c1 e2 c2 c n e1a e2a c1a qs r po pu qt)(*strict*)
  apply(case_tac c1a)
  apply(rename_tac e1 c1 e2 c2 c n e1a e2a c1a qs r po pu qt epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac q1 h1 s1)
  apply(rename_tac e1 c1 e2 c2 c n e1a e2a c1a qs r po pu qt q1 h1 s1)(*strict*)
  apply(case_tac c)
  apply(rename_tac e1 c1 e2 c2 c n e1a e2a c1a qs r po pu qt q1 h1 s1 epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac q2 h2 s2)
  apply(rename_tac e1 c1 e2 c2 c n e1a e2a c1a qs r po pu qt q1 h1 s1 q2 h2 s2)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 n e1a qs r po pu qt h1 w)(*strict*)
  apply(simp add: suffix_def)
  apply(simp add: valid_simple_dpda_def)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 n e1a qs r po pu qt h1 w c)(*strict*)
  apply(erule_tac x="\<lparr>edge_src = qs, edge_event = r, edge_pop = po, edge_push = pu,
          edge_trg = qt\<rparr>" in ballE)
   apply(rename_tac e1 c1 e2 c2 n e1a qs r po pu qt h1 w c)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac e1 c1 e2 c2 n e1a qs r po pu qt h1 w c)(*strict*)
  apply(clarsimp)
  apply(case_tac r)
   apply(rename_tac e1 c1 e2 c2 n e1a qs r po pu qt h1 w c)(*strict*)
   prefer 2
   apply(rename_tac e1 c1 e2 c2 n e1a qs r po pu qt h1 w c a)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs pu qt h1 w c a)(*strict*)
   apply(simp add: valid_dpda_def valid_pda_def)
   apply(clarsimp)
   apply(erule_tac x="\<lparr>edge_src = qs, edge_event = Some a, edge_pop = pu, edge_push = pu,
          edge_trg = qt\<rparr>" in ballE)
    apply(rename_tac e1 c1 e2 c2 n e1a qs pu qt h1 w c a)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac e1 c1 e2 c2 n e1a qs pu qt h1 w c a)(*strict*)
   apply(clarsimp)
   apply(case_tac pu)
    apply(rename_tac e1 c1 e2 c2 n e1a qs pu qt h1 w c a)(*strict*)
    apply(force)
   apply(rename_tac e1 c1 e2 c2 n e1a qs pu qt h1 w c a aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c a aa)(*strict*)
   apply(subgoal_tac "\<exists>k. n + k \<le> i \<and>
              (\<exists>e c. d (n + k) = Some (pair e c) \<and>
                     (\<forall>ca. epdaH_conf_stack c \<noteq>
                           ca @ A # epdaH_conf_stack c2))")
    apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c a aa)(*strict*)
    prefer 2
    apply(erule_tac x="n" in allE)+
    apply(force)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c a aa)(*strict*)
   apply(thin_tac "\<forall>ia<Suc n.
          \<exists>k. ia + k \<le> i \<and>
              (\<exists>e c. d (ia + k) = Some (pair e c) \<and>
                     (\<forall>ca. epdaH_conf_stack c \<noteq>
                           ca @ A # epdaH_conf_stack c2))")
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c a aa k e ca)(*strict*)
   apply(case_tac k)
    apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c a aa k e ca)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n qs qt h1 w c a aa e)(*strict*)
   apply(force)
  apply(rename_tac e1 c1 e2 c2 n e1a qs r po pu qt h1 w c)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 n e1a qs po pu qt h1 w c)(*strict*)
  apply(erule disjE)
   apply(rename_tac e1 c1 e2 c2 n e1a qs po pu qt h1 w c)(*strict*)
   prefer 2
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 w c wa)(*strict*)
   apply(simp add: valid_dpda_def valid_pda_def)
   apply(clarsimp)
   apply(erule_tac x="\<lparr>edge_src = qs, edge_event = None, edge_pop = po,
          edge_push = wa # po, edge_trg = qt\<rparr>" in ballE)
    apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 w c wa)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 w c wa)(*strict*)
   apply(clarsimp)
   apply(case_tac po)
    apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 w c wa)(*strict*)
    apply(force)
   apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 w c wa a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c wa a)(*strict*)
   apply(subgoal_tac "\<exists>k. n + k \<le> i \<and>
              (\<exists>e c. d (n + k) = Some (pair e c) \<and>
                     (\<forall>ca. epdaH_conf_stack c \<noteq>
                           ca @ A # epdaH_conf_stack c2))")
    apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c wa a)(*strict*)
    prefer 2
    apply(erule_tac x="n" in allE)+
    apply(force)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c wa a)(*strict*)
   apply(thin_tac "\<forall>ia<Suc n.
          \<exists>k. ia + k \<le> i \<and>
              (\<exists>e c. d (ia + k) = Some (pair e c) \<and>
                     (\<forall>ca. epdaH_conf_stack c \<noteq>
                           ca @ A # epdaH_conf_stack c2))")
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c wa a k e ca)(*strict*)
   apply(case_tac c)
    apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c wa a k e ca)(*strict*)
    apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w c wa a k e ca aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w a k e ca aa list)(*strict*)
   apply(case_tac list)
    apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w a k e ca aa list)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 k e ca aa)(*strict*)
    apply(case_tac k)
     apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 k e ca aa)(*strict*)
     apply(force)
    apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 k e ca aa nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 e ca aa nat)(*strict*)
    apply(erule_tac x="nat" in allE)+
    apply(force)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 w a k e ca aa list ab lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 k e ca aa ab lista)(*strict*)
   apply(case_tac k)
    apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 k e ca aa ab lista)(*strict*)
    apply(force)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 k e ca aa ab lista nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 e ca aa ab lista nat)(*strict*)
   apply(erule_tac x="nat" in allE)+
   apply(force)
  apply(rename_tac e1 c1 e2 c2 n e1a qs po pu qt h1 w c)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 c)(*strict*)
  apply(simp add: valid_dpda_def valid_pda_def)
  apply(clarsimp)
  apply(erule_tac x="\<lparr>edge_src = qs, edge_event = None, edge_pop = po, edge_push = [],
          edge_trg = qt\<rparr>" in ballE)
   apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 c)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 c)(*strict*)
  apply(clarsimp)
  apply(case_tac po)
   apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 c)(*strict*)
   apply(force)
  apply(rename_tac e1 c1 e2 c2 n e1a qs po qt h1 c a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a)(*strict*)
  apply(subgoal_tac "\<exists>x. Suc n+x=i")
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a)(*strict*)
   prefer 2
   apply(rule_tac x="i-Suc n" in exI)
   apply(force)
  apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a x)(*strict*)
  apply(subgoal_tac "\<exists>k. n + k \<le> Suc (n + x) \<and>
              (\<exists>e c. d (n + k) = Some (pair e c) \<and>
                     (\<forall>ca. epdaH_conf_stack c \<noteq>
                           ca @ A # epdaH_conf_stack c2))")
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a x)(*strict*)
   prefer 2
   apply(erule_tac x="n" in allE)+
   apply(force)
  apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a x)(*strict*)
  apply(thin_tac "\<forall>i<Suc n.
          \<exists>k. i + k \<le> Suc (n + x) \<and>
              (\<exists>e c. d (i + k) = Some (pair e c) \<and>
                     (\<forall>ca. epdaH_conf_stack c \<noteq>
                           ca @ A # epdaH_conf_stack c2))")
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a x k e ca)(*strict*)
  apply(case_tac k)
   apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a x k e ca)(*strict*)
   apply(force)
  apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a x k e ca nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 e2 c2 n e1a qs qt h1 c a x e ca nat)(*strict*)
  apply(erule_tac x="nat" in allE)+
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__pushed_symbols_from_F_SDPDA_TO_CFG_OPT__push_target_state: "
  qI \<in> F_SDPDA_TO_CFG_OPT__push_target_state G A
  \<Longrightarrow> A \<in> F_SDPDA_TO_CFG_OPT__pushed_symbols G"
  apply(simp add: F_SDPDA_TO_CFG_OPT__pushed_symbols_def F_SDPDA_TO_CFG_OPT__push_target_state_def)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__l3_approx_intro: "
  cons_l3 q A q' \<in> F_SDPDA_TO_CFG_OPT__l3_approx_1 G k A ReachS (CL A)
  \<Longrightarrow> A \<in> F_SDPDA_TO_CFG_OPT__pushed_symbols G
  \<Longrightarrow> cons_l3 q A q' \<in> F_SDPDA_TO_CFG_OPT__l3_approx G k ReachS CL"
  apply(simp add: F_SDPDA_TO_CFG_OPT__l3_approx_def)
  apply(rule_tac x="F_SDPDA_TO_CFG_OPT__l3_approx_1 G k A ReachS (CL A)" in exI)
  apply(rule conjI)
   apply(rule_tac x="A" in exI)
   apply(clarsimp)
  apply(force)
  done

lemma extract_ex_conj: "
  \<exists>a. P \<and> Q a
  \<Longrightarrow> P \<and> (\<exists>a. Q a)"
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__l3_init_in_all_state_stack_str3: "
  F_EPDA_AIA__fp_valid_input G k S
  \<Longrightarrow> k > 0
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__l3_init G A S \<subseteq> all_state_stack_str3 G k"
  apply(simp add: F_EPDA_AIA__fp_valid_input_def F_SDPDA_TO_CFG_OPT__step_closure__l3_init_def all_state_stack_str3_def)
  apply(clarsimp)
  apply(rename_tac q w)(*strict*)
  apply(simp add: all_state_stack_str2_def)
  apply(subgoal_tac "cons_tuple2 q (A # w) \<in> F_EPDA_AIA__codom G k")
   apply(rename_tac q w)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac q w)(*strict*)
  apply(thin_tac "S \<subseteq> X" for X)
  apply(thin_tac "X \<in> S" for X)
  apply(thin_tac "X \<in> S" for X)
  apply(simp add: F_EPDA_AIA__codom_def)
  apply(erule disjE)
   apply(rename_tac q w)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_start_def)
   apply(clarsimp)
   apply(simp add: valid_epda_def)
   apply(erule_tac x="[epda_box G]" in allE)
   apply(clarsimp)
  apply(rename_tac q w)(*strict*)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__l3_init_satisfies_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST: "
  F_EPDA_AIA__fp_valid_input G k S
  \<Longrightarrow> k > 0
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST G k (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G A S)"
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST_def F_EPDA_AIA__fp_valid_input_def)
  apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l3_init_in_all_state_stack_str3)
   apply(simp add: F_EPDA_AIA__fp_valid_input_def)
  apply(force)
  done

lemma nth_of_append_Cons_Cons: "
  (w @ [a, b]) ! Suc (length w) = b"
  apply (metis append_Cons append_Nil append_assoc length_Suc nth_append_length)
  done

lemma F_EPDA_AIA__fp_computed_stack_approximation_less_eq_than_k: "
  F_EPDA_AIA__fp_computed_stack_approximation d i k \<le> k"
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation_def)
  apply(induct i)
   apply(simp add: nat_seqEmpty)
  apply(rename_tac i)(*strict*)
  apply(simp add: nat_seq_drop_last_prime)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_strong_dependency_hlp: "
  valid_simple_dpda G
  \<Longrightarrow> epdaH.derivation_initial G d
  \<Longrightarrow> k>0
  \<Longrightarrow> d i = Some (pair ei ci)
  \<Longrightarrow> d (i+j+Suc 0) = Some (pair ej cj)
  \<Longrightarrow> l3_derivation_MAX G d w qi A qj i j
  \<Longrightarrow> IV \<le> Suc 0 + (Suc(i+j)) - i
  \<Longrightarrow> \<exists>\<xi>. length \<xi> = IV \<and>
           (\<forall>ik<length \<xi>.
               \<forall>e c. d (i + ik) = Some (pair e c) \<longrightarrow>
                     \<xi> ! ik =
                     cons_tuple3 (epdaH_conf_state c)
                      (take (F_EPDA_AIA__fp_computed_stack_approximation d (i + ik) k)
                        (epdaH_conf_stack c))
                      (F_EPDA_AIA__fp_computed_stack_approximationX d i (i+ik) k)
                      \<and>
                      (case F_EPDA_AIA__fp_computed_stack_approximationX d i (i+ik) k of None \<Rightarrow> True | Some n \<Rightarrow> n \<le> F_EPDA_AIA__fp_computed_stack_approximation d (i+ik) k)
                      \<and>
                      (F_EPDA_AIA__fp_computed_stack_approximation d (i+ik) k = 0 \<longrightarrow> (F_EPDA_AIA__fp_computed_stack_approximationX d i (i+ik) k = None \<or> F_EPDA_AIA__fp_computed_stack_approximationX d i (i+ik) k = Some 0))) \<and>
           (\<forall>ik<length \<xi>.
               case sel_tuple3_3 (\<xi> ! ik) of
               Some (Suc n) \<Rightarrow> \<exists>w.
                                length w=n
                                \<and> w @ epdaH_conf_stack (the (get_configuration (d (i))))
                                  =epdaH_conf_stack (the (get_configuration (d (i + ik))))
              | Some 0 \<Rightarrow> epdaH_conf_stack (the (get_configuration (d (i))))
                          =A # epdaH_conf_stack (the (get_configuration (d (i + ik))))
              | None \<Rightarrow> True) \<and>
           (\<forall>ik \<xi>'.
               \<xi>' = None # map Some \<xi> \<longrightarrow>
               Suc (Suc ik) < length \<xi>' \<longrightarrow>
               cons_tuple2 (\<xi>' ! Suc ik) (\<xi>' ! Suc (Suc ik))
               \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {cons_tuple2 (\<xi>' ! ik) (\<xi>' ! Suc ik)} k \<and>
               F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {cons_tuple2 (\<xi>' ! ik) (\<xi>' ! Suc ik)} k
               \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G
                   (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G A
                     (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
                   k)"
  apply(induct IV)
   apply(clarsimp)
  apply(rename_tac IV)(*strict*)
  apply(clarsimp)
  apply(rename_tac \<xi>)(*strict*)
  apply(case_tac i)
   apply(rename_tac \<xi>)(*strict*)
   apply(clarsimp)
   apply(simp add: l3_derivation_MAX_def)
   apply(clarsimp)
   apply(subgoal_tac "ci \<in> epdaH_initial_configurations G")
    apply(rename_tac \<xi>)(*strict*)
    prefer 2
    apply(simp add: epdaH.derivation_initial_def)
   apply(rename_tac \<xi>)(*strict*)
   apply(simp add: epdaH_initial_configurations_def)
   apply(clarsimp)
   apply(case_tac ci)
   apply(rename_tac \<xi> epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
   apply(clarsimp)
   apply(rename_tac \<xi>)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac \<xi>)(*strict*)
    prefer 2
    apply(rule_tac i="Suc j" in epda_box_stays_at_bottom_epdaH)
      apply(rename_tac \<xi>)(*strict*)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
      apply(force)
     apply(rename_tac \<xi>)(*strict*)
     apply(force)
    apply(rename_tac \<xi>)(*strict*)
    apply(force)
   apply(rename_tac \<xi>)(*strict*)
   apply(clarsimp)
  apply(rename_tac \<xi> nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i)
  apply(rename_tac \<xi> i)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac \<xi> i)(*strict*)
   prefer 2
   apply(rule_tac
      d="d" and
      n="((i) + (length \<xi>))" and
      m="Suc (Suc i+j)"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac \<xi> i)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac \<xi> i)(*strict*)
    apply(force)
   apply(rename_tac \<xi> i)(*strict*)
   apply(force)
  apply(rename_tac \<xi> i)(*strict*)
  apply(clarsimp)
  apply(rename_tac \<xi> i e1 e2 c1 c2)(*strict*)
  apply(rule_tac x="\<xi>@[cons_tuple3 (epdaH_conf_state c2)
                   (take (F_EPDA_AIA__fp_computed_stack_approximation d ((Suc i) + (length \<xi>)) k)
                     (epdaH_conf_stack c2))
                   (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) ((Suc i) + ((length \<xi>))) k)]" in exI)
  apply(rule conjI)
   apply(rename_tac \<xi> i e1 e2 c1 c2)(*strict*)
   apply(clarsimp)
  apply(rename_tac \<xi> i e1 e2 c1 c2)(*strict*)
  apply(rule conjI)
   apply(rename_tac \<xi> i e1 e2 c1 c2)(*strict*)
   apply(clarsimp)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik e c)(*strict*)
   apply(thin_tac "\<forall>ik. Suc ik < length \<xi> \<longrightarrow>
            cons_tuple2 (Some (\<xi> ! ik)) (Some (\<xi> ! Suc ik))
            \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
                {cons_tuple2 ((None # map Some \<xi>) ! ik) (Some (\<xi> ! ik))}
                k \<and>
            F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
             {cons_tuple2 ((None # map Some \<xi>) ! ik) (Some (\<xi> ! ik))} k
            \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G
                (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G A
                  (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
                k")
   apply(case_tac "ik<length \<xi>")
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik e c)(*strict*)
    apply(clarsimp)
    apply(rule_tac t="(SSw@[SSa])!SSn" and s="SSw!SSn" for SSw SSa SSn in ssubst)
     apply(rename_tac \<xi> i e1 e2 c1 c2 ik e c)(*strict*)
     apply(rule nth_append_1)
     apply(force)
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik e c)(*strict*)
    apply(clarsimp)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik e c)(*strict*)
   apply(subgoal_tac "ik=length \<xi>")
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik e c)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik e c)(*strict*)
   apply(clarsimp)
   apply(rename_tac \<xi> i e1 e2 c1 c)(*strict*)
   apply(rule_tac xs="\<xi>" in rev_cases)
    apply(rename_tac \<xi> i e1 e2 c1 c)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
    apply(force)
   apply(rename_tac \<xi> i e1 e2 c1 c ys y)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c ys y)(*strict*)
   apply(erule_tac x="length ys" in allE)+
   apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c ys)(*strict*)
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (Suc (i + length ys))) k")
    apply(rename_tac i e1 e2 c1 c ys)(*strict*)
    apply(force)
   apply(rename_tac i e1 e2 c1 c ys a)(*strict*)
   apply(clarsimp)
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length ys)) k")
    apply(rename_tac i e1 e2 c1 c ys a)(*strict*)
    apply(clarsimp)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
   apply(rename_tac i e1 e2 c1 c ys a aa)(*strict*)
   apply(clarsimp)
   apply(case_tac aa)
    apply(rename_tac i e1 e2 c1 c ys a aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c ys a)(*strict*)
    apply(simp add: l3_derivation_MAX_def)
    apply(clarsimp)
    apply(simp add: get_configuration_def)
    apply(erule_tac x="length ys" in allE)+
    apply(clarsimp)
    apply(simp add: suffix_def)
   apply(rename_tac i e1 e2 c1 c ys a aa nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c ys a wa)(*strict*)
   apply(simp add: get_configuration_def)
   apply(subgoal_tac "\<forall>e\<in> epda_delta G. length (edge_pop e) = Suc 0")
    apply(rename_tac i e1 e2 c1 c ys a wa)(*strict*)
    prefer 2
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
   apply(rename_tac i e1 e2 c1 c ys a wa)(*strict*)
   apply(subgoal_tac "(\<forall>e\<in> epda_delta G.
            case edge_event e of
            None \<Rightarrow> edge_push e = [] \<or> (\<exists>w. edge_push e = w # edge_pop e)
            | Some a \<Rightarrow> edge_pop e = edge_push e)")
    apply(rename_tac i e1 e2 c1 c ys a wa)(*strict*)
    prefer 2
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
   apply(rename_tac i e1 e2 c1 c ys a wa)(*strict*)
   apply(simp add: epdaH_step_relation_def)
   apply(erule_tac x="e2" in ballE)
    apply(rename_tac i e1 e2 c1 c ys a wa)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac i e1 e2 c1 c ys a wa)(*strict*)
   apply(erule_tac x="e2" in ballE)
    apply(rename_tac i e1 e2 c1 c ys a wa)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac i e1 e2 c1 c ys a wa)(*strict*)
   apply(case_tac e2)
   apply(rename_tac i e1 e2 c1 c ys a wa edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
   apply(rename_tac q1 r po pu q2)
   apply(rename_tac i e1 e2 c1 c ys a wa q1 r po pu q2)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c ys a wa r po pu waa)(*strict*)
   apply(case_tac po)
    apply(rename_tac i e1 c1 c ys a wa r po pu waa)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c ys a wa r po pu waa aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c ys a wa r pu waa aa)(*strict*)
   apply(case_tac r)
    apply(rename_tac i e1 c1 c ys a wa r pu waa aa)(*strict*)
    prefer 2
    apply(rename_tac i e1 c1 c ys a wa r pu waa aa ab)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c ys a wa waa aa ab)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def)
    apply(case_tac a)
     apply(rename_tac i e1 c1 c ys a wa waa aa ab)(*strict*)
     apply(force)
    apply(rename_tac i e1 c1 c ys a wa waa aa ab nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c ys wa waa aa ab)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def)
    apply(case_tac "min k
           (foldl (\<lambda>n e. min k (n - length (edge_pop e) + length (edge_push e)))
             (min k (Suc 0))
             (map (\<lambda>i. the (case d i of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> e))
               (nat_seq (Suc 0) (i + length ys))) -
            length (edge_pop (the e1)) +
            length (edge_push (the e1)))")
     apply(rename_tac i e1 c1 c ys wa waa aa ab)(*strict*)
     apply(force)
    apply(rename_tac i e1 c1 c ys wa waa aa ab nat)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c ys a wa r pu waa aa)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c ys a wa pu waa aa)(*strict*)
   apply(simp add: l3_derivation_MAX_def)
   apply(case_tac "length ys=j")
    apply(rename_tac i e1 c1 c ys a wa pu waa aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 ys a w pu wa aa)(*strict*)
    apply(erule_tac x="length ys" in allE)
    apply(clarsimp)
    apply(simp add: suffix_def)
    apply(clarsimp)
    apply(rename_tac i e1 c1 ys a pu wa aa c)(*strict*)
    apply(case_tac c)
     apply(rename_tac i e1 c1 ys a pu wa aa c)(*strict*)
     apply(clarsimp)
     apply(rename_tac i e1 c1 ys a)(*strict*)
     apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation_def)
     apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def l3_derivation_MAX_def)
    apply(rename_tac i e1 c1 ys a pu wa aa c ab list)(*strict*)
    apply(clarsimp)
   apply(rename_tac i e1 c1 c ys a wa pu waa aa)(*strict*)
   apply(erule disjE)
    apply(rename_tac i e1 c1 c ys a wa pu waa aa)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c ys a w aa)(*strict*)
    apply(case_tac a)
     apply(rename_tac i e1 c1 c ys a w aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac i e1 c1 c ys a w aa nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c ys w aa nat)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def)
    apply(case_tac "min k
           (foldl (\<lambda>n e. min k (n - length (edge_pop e) + length (edge_push e)))
             (min k (Suc 0))
             (map (\<lambda>i. the (case d i of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> e))
               (nat_seq (Suc 0) (i + length ys))) -
            length (edge_pop (the e1)) +
            length (edge_push (the e1)))")
     apply(rename_tac i e1 c1 c ys w aa nat)(*strict*)
     apply(force)
    apply(rename_tac i e1 c1 c ys w aa nat nata)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c ys a wa pu waa aa)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c ys a w wa aa wb)(*strict*)
   apply(case_tac a)
    apply(rename_tac i e1 c1 c ys a w wa aa wb)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c ys a w wa aa wb nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c ys w wa aa wb nat)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximation_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def)
   apply(case_tac "min k
           (foldl (\<lambda>n e. min k (n - length (edge_pop e) + length (edge_push e)))
             (min k (Suc 0))
             (map (\<lambda>i. the (case d i of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> e))
               (nat_seq (Suc 0) (i + length ys))) -
            length (edge_pop (the e1)) +
            length (edge_push (the e1)))")
    apply(rename_tac i e1 c1 c ys w wa aa wb nat)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c ys w wa aa wb nat nata)(*strict*)
   apply(clarsimp)
   apply(case_tac "Suc (length w) = k")
    apply(rename_tac i e1 c1 c ys w wa aa wb nat nata)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c ys w wa aa wb nat nata)(*strict*)
   apply(force)
  apply(rename_tac \<xi> i e1 e2 c1 c2)(*strict*)
  apply(rule conjI)
   apply(rename_tac \<xi> i e1 e2 c1 c2)(*strict*)
   apply(clarsimp)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   apply(case_tac "ik < (length \<xi>)")
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
    apply(erule_tac x="ik" in allE)+
    apply(rule_tac t="(SSw@[SSa])!SSn" and s="SSw!SSn" for SSw SSa SSn in ssubst)
     apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
     apply(rule nth_append_1)
     apply(force)
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
    apply(clarsimp)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   apply(subgoal_tac "ik=length \<xi>")
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   apply(clarsimp)
   apply(rename_tac \<xi> i e1 e2 c1 c2)(*strict*)
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k")
    apply(rename_tac \<xi> i e1 e2 c1 c2)(*strict*)
    apply(force)
   apply(rename_tac \<xi> i e1 e2 c1 c2 a)(*strict*)
   apply(clarsimp)
   apply(rule_tac xs="\<xi>" in rev_cases)
    apply(rename_tac \<xi> i e1 e2 c1 c2 a)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 a)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def)
    apply(simp add: nat_seqEmpty)
    apply(clarsimp)
   apply(rename_tac \<xi> i e1 e2 c1 c2 a ys y)(*strict*)
   apply(rename_tac \<xi> \<xi>L)
   apply(rename_tac \<xi>' i e1 e2 c1 c2 a \<xi> \<xi>L)(*strict*)
   apply(case_tac a)
    apply(rename_tac \<xi>' i e1 e2 c1 c2 a \<xi> \<xi>L)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
    apply(simp add: get_configuration_def)
    apply(simp add: l3_derivation_MAX_def)
    apply(clarsimp)
    apply(erule_tac x="length \<xi>" in allE)+
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 \<xi>)(*strict*)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k")
     apply(rename_tac i e1 e2 c1 c2 \<xi>)(*strict*)
     apply(clarsimp)
     apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2)
    apply(rename_tac i e1 e2 c1 c2 \<xi> a)(*strict*)
    apply(clarsimp)
    apply(case_tac a)
     apply(rename_tac i e1 e2 c1 c2 \<xi> a)(*strict*)
     apply(clarsimp)
     apply(rename_tac i e1 e2 c1 c2 \<xi>)(*strict*)
     apply(simp add: get_configuration_def)
     apply(simp add: suffix_def)
    apply(rename_tac i e1 e2 c1 c2 \<xi> a nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 \<xi> w)(*strict*)
    apply(simp add: get_configuration_def)
    apply(simp add: suffix_def)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 \<xi> c)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n nat_seq_drop_last_simp2 get_label_def)
    apply(simp add: epdaH_step_relation_def)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 \<xi> c w)(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(clarsimp)
    apply(erule_tac x="e2" in ballE)
     apply(rename_tac i e1 e2 c1 c2 \<xi> c w)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac i e1 e2 c1 c2 \<xi> c w)(*strict*)
    apply(erule_tac x="e2" in ballE)
     apply(rename_tac i e1 e2 c1 c2 \<xi> c w)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac i e1 e2 c1 c2 \<xi> c w)(*strict*)
    apply(case_tac e2)
    apply(rename_tac i e1 e2 c1 c2 \<xi> c w edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
    apply(rename_tac q1 r po pu q2)
    apply(rename_tac i e1 e2 c1 c2 \<xi> c w q1 r po pu q2)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> c w r po pu)(*strict*)
    apply(case_tac po)
     apply(rename_tac i e1 c1 c2 \<xi> c w r po pu)(*strict*)
     apply(force)
    apply(rename_tac i e1 c1 c2 \<xi> c w r po pu a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> c w r pu a)(*strict*)
    apply(case_tac r)
     apply(rename_tac i e1 c1 c2 \<xi> c w r pu a)(*strict*)
     prefer 2
     apply(rename_tac i e1 c1 c2 \<xi> c w r pu a aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> c w r pu a)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> c w pu a)(*strict*)
    apply(case_tac pu)
     apply(rename_tac i e1 c1 c2 \<xi> c w pu a)(*strict*)
     apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> c w pu a aa list)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> c w a aa)(*strict*)
    apply(case_tac k)
     apply(rename_tac i e1 c1 c2 \<xi> c w a aa)(*strict*)
     apply(force)
    apply(rename_tac i e1 c1 c2 \<xi> c w a aa nat)(*strict*)
    apply(clarsimp)
    apply(case_tac "length c = nat")
     apply(rename_tac i e1 c1 c2 \<xi> c w a aa nat)(*strict*)
     apply(force)
    apply(rename_tac i e1 c1 c2 \<xi> c w a aa nat)(*strict*)
    apply(force)
   apply(rename_tac \<xi>' i e1 e2 c1 c2 a \<xi> \<xi>L nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L nat)(*strict*)
   apply(rename_tac n)
   apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L n)(*strict*)
   apply(rule_tac xs="\<xi>" in rev_cases)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L n)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e2 c2 n)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def get_configuration_def nat_seqEmpty natUptTo_n_n get_label_def)
    apply(case_tac "edge_event e2")
     apply(rename_tac i e2 c2 n)(*strict*)
     apply(clarsimp)
     apply(case_tac "edge_push e2")
      apply(rename_tac i e2 c2 n)(*strict*)
      apply(clarsimp)
     apply(rename_tac i e2 c2 n a list)(*strict*)
     apply(simp add: l3_derivation_MAX_def)
     apply(clarsimp)
     apply(case_tac "Suc 0 = k")
      apply(rename_tac i e2 c2 n a list)(*strict*)
      apply(force)
     apply(rename_tac i e2 c2 n a list)(*strict*)
     apply(clarsimp)
     apply(rename_tac i e2 c2 a list)(*strict*)
     apply(case_tac k)
      apply(rename_tac i e2 c2 a list)(*strict*)
      apply(force)
     apply(rename_tac i e2 c2 a list nat)(*strict*)
     apply(clarsimp)
     apply(rename_tac k)
     apply(rename_tac i e2 c2 a list k)(*strict*)
     apply(case_tac k)
      apply(rename_tac i e2 c2 a list k)(*strict*)
      apply(force)
     apply(rename_tac i e2 c2 a list k nat)(*strict*)
     apply(clarsimp)
     apply(rename_tac i e2 c2 a list nat)(*strict*)
     apply(rename_tac k)
     apply(rename_tac i e2 c2 a list k)(*strict*)
     apply(erule_tac x="Suc 0" in allE)
     apply(clarsimp)
     apply(simp add: epdaH_step_relation_def)
     apply(clarsimp)
     apply(rename_tac i e2 c2 a list k w)(*strict*)
     apply(subgoal_tac "\<forall>e\<in> epda_delta G. length (edge_pop e) = Suc 0")
      apply(rename_tac i e2 c2 a list k w)(*strict*)
      prefer 2
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
     apply(rename_tac i e2 c2 a list k w)(*strict*)
     apply(subgoal_tac "(\<forall>e\<in> epda_delta G.
          case edge_event e of
          None \<Rightarrow> edge_push e = [] \<or> (\<exists>w. edge_push e = w # edge_pop e)
          | Some a \<Rightarrow> edge_pop e = edge_push e)")
      apply(rename_tac i e2 c2 a list k w)(*strict*)
      prefer 2
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
     apply(rename_tac i e2 c2 a list k w)(*strict*)
     apply(erule_tac x="e2" in ballE)
      apply(rename_tac i e2 c2 a list k w)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac i e2 c2 a list k w)(*strict*)
     apply(erule_tac x="e2" in ballE)
      apply(rename_tac i e2 c2 a list k w)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac i e2 c2 a list k w)(*strict*)
     apply(clarsimp)
    apply(rename_tac i e2 c2 n a)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e2 c2 a)(*strict*)
    apply(simp add: epdaH_step_relation_def)
    apply(clarsimp)
    apply(rename_tac i e2 c2 a wa)(*strict*)
    apply(subgoal_tac "\<forall>e\<in> epda_delta G. length (edge_pop e) = Suc 0")
     apply(rename_tac i e2 c2 a wa)(*strict*)
     prefer 2
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
    apply(rename_tac i e2 c2 a wa)(*strict*)
    apply(subgoal_tac "(\<forall>e\<in> epda_delta G.
         case edge_event e of
         None \<Rightarrow> edge_push e = [] \<or> (\<exists>w. edge_push e = w # edge_pop e)
         | Some a \<Rightarrow> edge_pop e = edge_push e)")
     apply(rename_tac i e2 c2 a wa)(*strict*)
     prefer 2
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
    apply(rename_tac i e2 c2 a wa)(*strict*)
    apply(erule_tac x="e2" in ballE)
     apply(rename_tac i e2 c2 a wa)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac i e2 c2 a wa)(*strict*)
    apply(erule_tac x="e2" in ballE)
     apply(rename_tac i e2 c2 a wa)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac i e2 c2 a wa)(*strict*)
    apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L n ys y)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c2 \<xi>L n ys y)(*strict*)
   apply(rename_tac \<xi>LL n \<xi> \<xi>L)
   apply(rename_tac i e1 e2 c1 c2 \<xi>LL n \<xi> \<xi>L)(*strict*)
   apply(erule_tac x="Suc(length \<xi>)" in allE)
   apply(erule_tac x="Suc(length \<xi>)" in allE)
   apply(erule_tac x="length \<xi>" in allE)
   apply(clarsimp)
   apply(subgoal_tac "(\<xi> @ [\<xi>L, \<xi>LL]) ! Suc (length \<xi>) = \<xi>LL")
    apply(rename_tac i e1 e2 c1 c2 \<xi>LL n \<xi> \<xi>L)(*strict*)
    prefer 2
    apply (metis (erased, hide_lams) add_diff_cancel_left' length_Suc length_append list.size(3) minus_nat.diff_0 nth_Cons_0 nth_Cons_Suc nth_append_length_plus)
   apply(rename_tac i e1 e2 c1 c2 \<xi>LL n \<xi> \<xi>L)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
   apply(thin_tac "(\<xi> @
        [\<xi>L,
         cons_tuple3 (epdaH_conf_state c1)
          (take (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (Suc (i + length \<xi>))) k)
            (epdaH_conf_stack c1))
          (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (Suc (i + length \<xi>)))
            k)]) !
       Suc (length \<xi>) =
       cons_tuple3 (epdaH_conf_state c1)
        (take (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (Suc (i + length \<xi>))) k)
          (epdaH_conf_stack c1))
        (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (Suc (i + length \<xi>))) k)")
   apply(subgoal_tac "((None #
               map Some \<xi> @
               [Some \<xi>L,
                Some
                 (cons_tuple3 (epdaH_conf_state c1)
                   (take
                     (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (Suc (i + length \<xi>))) k)
                     (epdaH_conf_stack c1))
                   (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i)
                     (Suc (Suc (i + length \<xi>))) k))]) !
              length \<xi>) = last(None#map Some \<xi>)")
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
    prefer 2
    apply(rule nth_with_last_and_map_and_Some)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
   apply(clarsimp)
   apply(thin_tac "(None #
        map Some \<xi> @
        [Some \<xi>L,
         Some
          (cons_tuple3 (epdaH_conf_state c1)
            (take (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (Suc (i + length \<xi>))) k)
              (epdaH_conf_stack c1))
            (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (Suc (i + length \<xi>)))
              k))]) !
       length \<xi> =
       (if \<xi> = [] then None else last (map Some \<xi>))")
   apply(thin_tac "F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
        {cons_tuple2 (if \<xi> = [] then None else last (map Some \<xi>))
          (Some \<xi>L)}
        k
       \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G
           (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G A
             (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
           k")
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (Suc (i + length \<xi>))) k")
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
    apply(clarsimp)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def)
    apply(subgoal_tac "nat_seq (Suc (Suc i)) (Suc (Suc (Suc (i + length \<xi>)))) = nat_seq (Suc (Suc i)) ((Suc (Suc (i + length \<xi>)))) @[Suc (Suc (Suc (i + length \<xi>)))]")
     apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
     prefer 2
     apply(rule nat_seq_drop_last_simp)
     apply(force)
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
    apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L a)(*strict*)
   apply(clarsimp)
   apply(simp add: get_configuration_def)
   apply(case_tac a)
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L a)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def)
    apply(subgoal_tac "nat_seq (Suc (Suc i)) (Suc (Suc (Suc (i + length \<xi>)))) = nat_seq (Suc (Suc i)) ((Suc (Suc (i + length \<xi>)))) @[Suc (Suc (Suc (i + length \<xi>)))]")
     apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
     prefer 2
     apply(rule nat_seq_drop_last_simp)
     apply(force)
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
    apply(clarsimp)
    apply(simp add: get_label_def)
    apply(case_tac "edge_event e2")
     apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
     prefer 2
     apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L a)(*strict*)
     apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
    apply(clarsimp)
    apply(simp add: get_label_def)
    apply(case_tac "edge_push e2")
     apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L)(*strict*)
     apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L a list)(*strict*)
    apply(simp add: get_configuration_def epdaH_step_relation_def)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L a list wa)(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(clarsimp)
    apply(erule_tac x="e2" in ballE)
     apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L a list wa)(*strict*)
     prefer 2
     apply(simp add: epdaH_step_relation_def)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L a list wa)(*strict*)
    apply(erule_tac x="e2" in ballE)
     apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L a list wa)(*strict*)
     prefer 2
     apply(simp add: epdaH_step_relation_def)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L a list wa)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L a wa)(*strict*)
    apply(case_tac e2)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L a wa edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
    apply(rename_tac q1 r po pu q2)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L a wa q1 r po pu q2)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L a wa po)(*strict*)
    apply(case_tac po)
     apply(rename_tac i e1 c1 c2 \<xi> \<xi>L a wa po)(*strict*)
     apply(force)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L a wa po aa list)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L a wa aa)(*strict*)
    apply(simp add: l3_derivation_MAX_def)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L a w aa)(*strict*)
    apply(erule_tac x="Suc((length \<xi>))" in allE)
    apply(clarsimp)
    apply(simp add: suffix_def)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L a nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa)(*strict*)
   apply(simp add: get_configuration_def)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def)
   apply(subgoal_tac "nat_seq (Suc (Suc i)) (Suc (Suc (Suc (i + length \<xi>)))) = nat_seq (Suc (Suc i)) ((Suc (Suc (i + length \<xi>)))) @[Suc (Suc (Suc (i + length \<xi>)))]")
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa)(*strict*)
    prefer 2
    apply(rule nat_seq_drop_last_simp)
    apply(force)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa)(*strict*)
   apply(clarsimp)
   apply(simp add: get_label_def)
   apply(case_tac "edge_event e2")
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa)(*strict*)
    prefer 2
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa a)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L wa a)(*strict*)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(clarsimp)
    apply(erule_tac x="e2" in ballE)
     apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L wa a)(*strict*)
     prefer 2
     apply(simp add: epdaH_step_relation_def)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L wa a)(*strict*)
    apply(erule_tac x="e2" in ballE)
     apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L wa a)(*strict*)
     prefer 2
     apply(simp add: epdaH_step_relation_def)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L wa a)(*strict*)
    apply(clarsimp)
    apply(case_tac e2)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L wa a edge_src edge_eventa edge_popa edge_pusha edge_trg)(*strict*)
    apply(rename_tac q1 r po pu q2)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L wa a q1 r po pu q2)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L wa a q1 pu q2)(*strict*)
    apply(case_tac pu)
     apply(rename_tac i e1 c1 c2 \<xi> \<xi>L wa a q1 pu q2)(*strict*)
     apply(force)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L wa a q1 pu q2 aa list)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L wa a q1 q2 aa)(*strict*)
    apply(simp add: l3_derivation_MAX_def)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L w a q1 q2 aa)(*strict*)
    apply(erule_tac x="Suc((length \<xi>))" in allE)
    apply(clarsimp)
    apply(simp add: suffix_def)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L a q1 q2 aa c)(*strict*)
    apply(simp add: epdaH_step_relation_def)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 \<xi> \<xi>L a aa c w)(*strict*)
    apply(rule_tac x="c" in exI)
    apply(clarsimp)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa)(*strict*)
   apply(clarsimp)
   apply(simp add: get_label_def)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(clarsimp)
   apply(erule_tac x="e2" in ballE)
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa)(*strict*)
    prefer 2
    apply(simp add: epdaH_step_relation_def)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa)(*strict*)
   apply(erule_tac x="e2" in ballE)
    apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa)(*strict*)
    prefer 2
    apply(simp add: epdaH_step_relation_def)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa)(*strict*)
   apply(clarsimp)
   apply(case_tac e2)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa edge_src edge_eventa edge_popa edge_pusha edge_trg)(*strict*)
   apply(rename_tac q1 r po pu q2)
   apply(rename_tac i e1 e2 c1 c2 n \<xi> \<xi>L wa q1 r po pu q2)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L wa q1 po pu q2)(*strict*)
   apply(case_tac po)
    apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L wa q1 po pu q2)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L wa q1 po pu q2 a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L wa q1 pu q2 a)(*strict*)
   apply(simp add: l3_derivation_MAX_def)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L w q1 pu q2 a)(*strict*)
   apply(erule_tac x="Suc((length \<xi>))" in allE)
   apply(clarsimp)
   apply(simp add: suffix_def)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L q1 pu q2 a c)(*strict*)
   apply(simp add: epdaH_step_relation_def)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L pu a c w)(*strict*)
   apply(erule disjE)
    apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L pu a c w)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L a c)(*strict*)
    apply(case_tac c)
     apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L a c)(*strict*)
     apply(force)
    apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L a c aa list)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L pu a c w)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L a c w wa)(*strict*)
   apply(case_tac "Suc (length c) = k ")
    apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L a c w wa)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L a c w wa)(*strict*)
   apply(case_tac c)
    apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L a c w wa)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c2 n \<xi> \<xi>L a c w wa aa list)(*strict*)
   apply(force)
  apply(rename_tac \<xi> i e1 e2 c1 c2)(*strict*)
  apply(clarsimp)
  apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
  apply(case_tac "Suc ik < length \<xi>")
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   apply(erule_tac x="ik" in allE)+
   apply(clarsimp)
   apply(rule_tac t="(XI @ [X]) ! ik" and s="XI!ik" for XI X in ssubst)
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
    apply(rule nth_append_1)
    apply(force)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   apply(rule_tac t="(XI @ [X]) ! Suc ik" and s="XI!Suc ik" for XI X in ssubst)
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
    apply(rule nth_append_1)
    apply(force)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   apply(rule_tac t="(None # map Some \<xi> @ [X]) ! (Suc ik)" and s="Some (\<xi>! ik)" for X in ssubst)
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
    apply(clarsimp)
    apply(simp add: nth_append_1)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   apply(rule_tac t="(None # map Some \<xi> @ [X]) ! (ik)" and s="(None # map Some \<xi> )! ik" for X in ssubst)
    apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
    apply (metis (no_types, hide_lams) Suc_less_eq add_Suc_right append_Cons length_map less_Suc_eq list.size(4) monoid_add_class.add.right_neutral nth_append)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   apply(clarsimp)
  apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
  apply(subgoal_tac "Suc ik = length \<xi>")
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
  apply(rule_tac xs="\<xi>" in rev_cases)
   apply(rename_tac \<xi> i e1 e2 c1 c2 ik)(*strict*)
   apply(force)
  apply(rename_tac \<xi> i e1 e2 c1 c2 ik ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 e2 c1 c2 ys y)(*strict*)
  apply(rename_tac \<xi> \<xi>L)
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  apply(rule context_conjI)
   apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
   prefer 2
   apply(subgoal_tac "X" for X)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
    prefer 2
    apply(rule_tac k="k" and i="Suc i" and j="(Suc (j))" in F_EPDA_AIA__fp_strong_dependency)
        apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
        apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
        apply(force)
       apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
       apply(force)
      apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
      apply(force)
     apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
     apply(force)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
    apply(force)
   apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
   apply(rule_tac xs="\<xi>" in rev_cases)
    apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
    apply(clarsimp del: subsetI)
    apply(rename_tac i e2 c2 wa)(*strict*)
    apply(rule F_SDPDA_TO_CFG_OPT__step_closure__fp_intro1)
     apply(rename_tac i e2 c2 wa)(*strict*)
     apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l3_init_satisfies_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST)
      apply(rename_tac i e2 c2 wa)(*strict*)
      apply(rule F_EPDA_AIA__fp_preserves_F_EPDA_AIA__fp_valid_input)
      apply(rule F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
     apply(rename_tac i e2 c2 wa)(*strict*)
     apply(force)
    apply(rename_tac i e2 c2 wa)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__l3_init_def F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seqEmpty l3_derivation_MAX_def)
    apply(clarsimp)
    apply(rename_tac i e2 c2 w)(*strict*)
    apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc i) k")
     apply(rename_tac i e2 c2 w)(*strict*)
     apply(clarsimp)
    apply(rename_tac i e2 c2 w nat)(*strict*)
    apply(clarsimp)
    apply(rule conjI)
     apply(rename_tac i e2 c2 w nat)(*strict*)
     apply(rule_tac A="set w" in set_mp)
      apply(rename_tac i e2 c2 w nat)(*strict*)
      apply(force)
     apply(rename_tac i e2 c2 w nat)(*strict*)
     apply(rule_tac t="cons_tuple2 (epdaH_conf_state ci)
        (A # take nat (epdaH_conf_stack cj))" and s="w ! (0)" in ssubst)
      apply(rename_tac i e2 c2 w nat)(*strict*)
      apply(erule_tac x="0" in allE)
      apply(clarsimp)
     apply(rename_tac i e2 c2 w nat)(*strict*)
     apply(rule nth_mem)
     apply(force)
    apply(rename_tac i e2 c2 w nat)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_OPT__push_target_state_def)
    apply(subgoal_tac "X" for X)
     apply(rename_tac i e2 c2 w nat)(*strict*)
     prefer 2
     apply(rule_tac
      d="d" and
      n="i" and
      m="Suc i"
      in epdaH.step_detail_before_some_position)
       apply(rename_tac i e2 c2 w nat)(*strict*)
       apply(rule epdaH.derivation_initial_is_derivation)
       apply(force)
      apply(rename_tac i e2 c2 w nat)(*strict*)
      apply(force)
     apply(rename_tac i e2 c2 w nat)(*strict*)
     apply(force)
    apply(rename_tac i e2 c2 w nat)(*strict*)
    apply(clarsimp)
    apply(rename_tac i e2 c2 w nat e1 e2a c1 X)(*strict*)
    apply(simp add: epdaH_step_relation_def)
    apply(clarsimp)
    apply(rename_tac i e2 c2 w nat e1 e2a c1 X wa wb)(*strict*)
    apply(rule_tac x="X" in exI)
    apply(rule_tac x="e2a" in exI)
    apply(clarsimp)
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(clarsimp)
    apply(erule_tac x="e2a" in ballE)
     apply(rename_tac i e2 c2 w nat e1 e2a c1 X wa wb)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac i e2 c2 w nat e1 e2a c1 X wa wb)(*strict*)
    apply(erule_tac x="e2a" in ballE)
     apply(rename_tac i e2 c2 w nat e1 e2a c1 X wa wb)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac i e2 c2 w nat e1 e2a c1 X wa wb)(*strict*)
    apply(case_tac "edge_event e2a")
     apply(rename_tac i e2 c2 w nat e1 e2a c1 X wa wb)(*strict*)
     apply(force)
    apply(rename_tac i e2 c2 w nat e1 e2a c1 X wa wb a)(*strict*)
    apply(force)
   apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L ys y)(*strict*)
   apply(clarsimp del: subsetI)
   apply(rename_tac i e1 e2 c1 c2 \<xi>L ys y wa)(*strict*)
   apply(rename_tac \<xi>LL \<xi> \<xi>L wa)
   apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
   apply(rule_tac t="((map Some \<xi> @
            [Some \<xi>L, Some \<xi>LL,
             Some
              (cons_tuple3 (epdaH_conf_state c2)
                (take
                  (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (Suc (Suc (i + length \<xi>))))
                    k)
                  (epdaH_conf_stack c2))
                (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i)
                  (Suc (Suc (Suc (i + length \<xi>)))) k))]) !
           length \<xi>)" and s="Some \<xi>L" in ssubst)
    apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
    apply (metis (erased, hide_lams) length_map_Some nth_append_length)
   apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
   apply(subgoal_tac "cons_tuple2 (Some ((\<xi> @ [\<xi>L, \<xi>LL]) ! length \<xi>)) (Some ((\<xi> @ [\<xi>L, \<xi>LL]) ! Suc (length \<xi>)))
          \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
              {cons_tuple2 ((None # map Some \<xi> @ [Some \<xi>L, Some \<xi>LL]) ! length \<xi>)
                (Some ((\<xi> @ [\<xi>L, \<xi>LL]) ! length \<xi>))}
              k \<and>
          F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
           {cons_tuple2 ((None # map Some \<xi> @ [Some \<xi>L, Some \<xi>LL]) ! length \<xi>)
             (Some ((\<xi> @ [\<xi>L, \<xi>LL]) ! length \<xi>))}
           k
          \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G A (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
              k")
    apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
    prefer 2
    apply(erule_tac x="length \<xi>" in allE)+
    apply(force)
   apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
   apply(rule_tac e'="cons_tuple2 ((None # map Some \<xi> @ [Some \<xi>L, Some \<xi>LL]) ! length \<xi>)
          (Some ((\<xi> @ [\<xi>L, \<xi>LL]) ! length \<xi>))" in F_SDPDA_TO_CFG_OPT__step_closure__fp_intro2)
     apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
     apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l3_init_satisfies_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST)
      apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
      apply(rule F_EPDA_AIA__fp_preserves_F_EPDA_AIA__fp_valid_input)
      apply(rule F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
     apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
     apply(force)
    apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
    apply(force)
   apply(rename_tac i e1 e2 c1 c2 \<xi>LL \<xi> \<xi>L wa)(*strict*)
   apply (metis nth_append_length nth_of_append_Cons_Cons)
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  apply(rule_tac t="((None #
               map Some \<xi> @
               [Some \<xi>L,
                Some
                 (cons_tuple3 (epdaH_conf_state c2)
                   (take
                     (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (Suc (i + length \<xi>))) k)
                     (epdaH_conf_stack c2))
                   (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i)
                     (Suc (Suc (i + length \<xi>))) k))]) !
              length \<xi>)" and s="Y" for Y in ssubst)
   apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
   apply(rule nth_with_last_and_map_and_Some)
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  apply(rule_tac t="((\<xi> @
            [\<xi>L,
             cons_tuple3 (epdaH_conf_state c2)
              (take (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (Suc (i + length \<xi>))) k)
                (epdaH_conf_stack c2))
              (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (Suc (i + length \<xi>)))
                k)]) !
           Suc (length \<xi>))" and s="cons_tuple3 (epdaH_conf_state c2)
              (take (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (Suc (i + length \<xi>))) k)
                (epdaH_conf_stack c2))
              (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (Suc (i + length \<xi>)))
                k)" in ssubst)
   apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
   apply (rule nth_of_append_Cons_Cons)
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  apply(thin_tac "\<forall>ik<length \<xi>.
          cons_tuple2 (Some ((\<xi> @ [\<xi>L]) ! ik))
           (Some ((\<xi> @ [\<xi>L]) ! Suc ik))
          \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
              {cons_tuple2 ((None # map Some \<xi> @ [Some \<xi>L]) ! ik)
                (Some ((\<xi> @ [\<xi>L]) ! ik))}
              k \<and>
          F_SDPDA_TO_CFG_OPT__step_closure__fp_one G
           {cons_tuple2 ((None # map Some \<xi> @ [Some \<xi>L]) ! ik)
             (Some ((\<xi> @ [\<xi>L]) ! ik))}
           k
          \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G
              (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G A
                (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
              k")
  apply(subgoal_tac "\<forall>x. cons_tuple2 (Some \<xi>L)
        (Some
          (cons_tuple3 (epdaH_conf_state c2)
            (take (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (Suc (i + length \<xi>))) k)
              (epdaH_conf_stack c2))
            (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (Suc (i + length \<xi>)))
              k)))
       \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {cons_tuple2 x (Some \<xi>L)}
           k")
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  apply(force)
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  apply(subgoal_tac "\<forall>e c. d (Suc (i + length \<xi>)) = Some (pair e c) \<longrightarrow>
                (\<xi> @ [\<xi>L]) ! length \<xi> =
                cons_tuple3 (epdaH_conf_state c)
                 (take (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k) (epdaH_conf_stack c))
                 (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k) \<and>
                (case F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k of None \<Rightarrow> True
                 | Some n \<Rightarrow> n \<le> F_EPDA_AIA__fp_computed_stack_approximation d (Suc i + length \<xi>) k)")
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  apply(subgoal_tac "case sel_tuple3_3 ((\<xi> @ [\<xi>L]) ! length \<xi>) of None \<Rightarrow> True
          | Some 0 \<Rightarrow>
              epdaH_conf_stack (the (get_configuration (d (Suc i)))) =
              A # epdaH_conf_stack (the (get_configuration (d (Suc i + length \<xi>))))
          | Some (Suc n) \<Rightarrow>
              \<exists>w. length w = n \<and>
                  w @ epdaH_conf_stack (the (get_configuration (d (Suc i)))) =
                  epdaH_conf_stack (the (get_configuration (d (Suc i + length \<xi>))))")
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac i e1 e2 c1 c2 \<xi> \<xi>L)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc(Suc (i + length \<xi>))) k =
  min k (F_EPDA_AIA__fp_computed_stack_approximation d (Suc(i + length \<xi>)) k - length (edge_pop e2) + length (edge_push e2))")
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  prefer 2
  apply(rule F_EPDA_AIA__fp_computed_stack_approximation_unfold)
   apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
   apply(force)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "\<forall>e\<in> epda_delta G. length (edge_pop e) = Suc 0")
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  prefer 2
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  apply(subgoal_tac "(\<forall>e\<in> epda_delta G.
           case edge_event e of
           None \<Rightarrow> edge_push e = [] \<or> (\<exists>w. edge_push e = w # edge_pop e)
           | Some a \<Rightarrow> edge_pop e = edge_push e)")
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  prefer 2
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  apply(simp add: epdaH_step_relation_def)
  apply(erule_tac x="e2" in ballE)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  apply(erule_tac x="e2" in ballE)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x)(*strict*)
  apply(case_tac e2)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac q1 r po pu q2)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x q1 r po pu q2)(*strict*)
  apply(case_tac po)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x q1 r po pu q2)(*strict*)
  apply(force)
  apply(rename_tac i e1 e2 c1 c2 \<xi> x q1 r po pu q2 a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa)(*strict*)
  apply(subgoal_tac "X" for X)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa)(*strict*)
  prefer 2
  apply(rule_tac
    d="d" and
    n="i" and
    m="Suc i"
    in epdaH.step_detail_before_some_position)
   apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa)(*strict*)
   apply(rule epdaH.derivation_initial_is_derivation)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a)(*strict*)
  apply(simp add: epdaH_step_relation_def)
  apply(subgoal_tac "\<forall>e\<in> epda_delta G. length (edge_pop e) = Suc 0")
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a)(*strict*)
  prefer 2
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a)(*strict*)
  apply(subgoal_tac "(\<forall>e\<in> epda_delta G.
           case edge_event e of
           None \<Rightarrow> edge_push e = [] \<or> (\<exists>w. edge_push e = w # edge_pop e)
           | Some a \<Rightarrow> edge_pop e = edge_push e)")
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a)(*strict*)
  prefer 2
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def epdaH_step_relation_def)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a)(*strict*)
  apply(erule_tac x="e2" in ballE)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a)(*strict*)
  apply(erule_tac x="e2" in ballE)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a)(*strict*)
  apply(case_tac e2)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac q1i ri poi pui q2i)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a e2 c1a q1i ri poi pui q2i)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a wa e1a c1a ri poi pui waa)(*strict*)
  apply(simp add: l3_derivation_MAX_def)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a ri poi wa X)(*strict*)
  apply(case_tac poi)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a ri poi wa X)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a ri poi wa X aa list)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a ri wa X aa)(*strict*)
  apply(case_tac ri)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a ri wa X aa)(*strict*)
  prefer 2
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a ri wa X aa ab)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a ri wa X aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa)(*strict*)
  apply(case_tac "r")
  (*read*)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa)(*strict*)
  prefer 2
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa ab)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k")
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa ab)(*strict*)
  prefer 2
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa ab nat)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__read__exists__greater_than_0_def)
  apply(rename_tac i e1 c1 c2 \<xi> r pu a w e1a c1a wa aa ab nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
  apply(rule conjI)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
  apply(rule conjI)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
   apply(clarsimp)
   apply(erule_tac x="length \<xi>" in allE)+
   apply(clarsimp)
   apply(simp add: get_configuration_def)
   apply(simp add: suffix_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
  apply(rule conjI)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
   prefer 2
   apply(rule_tac xs="\<xi>" in rev_cases)
    apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
    apply(thin_tac "\<forall>ik<Suc (length \<xi>).
          \<forall>e c. d (Suc (i + ik)) = Some (pair e c) \<longrightarrow>
                (\<xi> @ [cons_tuple3 (epdaH_conf_state c1) (a # take nat w)
                       (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k)]) !
                ik =
                cons_tuple3 (epdaH_conf_state c)
                 (take (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + ik)) k) (epdaH_conf_stack c))
                 (F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + ik)) k) \<and>
                (case F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + ik)) k of None \<Rightarrow> True
                 | Some n \<Rightarrow> n \<le> F_EPDA_AIA__fp_computed_stack_approximation d (Suc i + ik) k) \<and>
                (F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + ik)) k = 0 \<longrightarrow>
                 F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + ik)) k = None \<or>
                 F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + ik)) k = Some 0)")
    apply(clarify)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n)
    apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa ab nat)(*strict*)
    apply(simp add: get_label_def)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat ys y)(*strict*)
   apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def)
   apply(subgoal_tac "(nat_seq (Suc (Suc i)) (Suc (Suc (i + length \<xi>)))) = SSX" for SSX)
    apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat ys y)(*strict*)
    prefer 2
    apply(rule nat_seq_drop_last_simp)
    apply(force)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat ys y)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa ab nat ys y)(*strict*)
   apply(simp add: get_label_def)
   apply(case_tac "foldl
             (\<lambda>n (m, c, e).
                 case n of None \<Rightarrow> None
                 | Some n \<Rightarrow>
                     case edge_event e of
                     None \<Rightarrow>
                       case edge_push e of [] \<Rightarrow> Some (n - Suc 0)
                       | a # list \<Rightarrow> if n = k then None else Some (Suc n)
                     | Some a \<Rightarrow> Some n)
             (Some (Suc 0))
             (map (\<lambda>i. (F_EPDA_AIA__fp_computed_stack_approximation d (i - Suc 0) k,
                         the (get_configuration (d (i - Suc 0))),
                         the (case d i of None \<Rightarrow> None | Some (pair e c) \<Rightarrow> e)))
               (nat_seq (Suc (Suc i)) (Suc (Suc (i + length ys)))))")
    apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa ab nat ys y)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa ab nat ys y ac)(*strict*)
   apply(clarsimp)
   apply(simp add: get_label_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k \<le> k")
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
   prefer 2
   apply(rule F_EPDA_AIA__fp_computed_stack_approximation_less_eq_than_k)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k")
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
   prefer 2
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat nata)(*strict*)
   apply(clarsimp)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
   apply(case_tac k)
    apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
    apply(force)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat nata)(*strict*)
   apply(clarsimp)
   apply (metis min_absorb2)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa ab)(*strict*)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = None")
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa ab)(*strict*)
  prefer 2
  apply(case_tac "i + length \<xi>")
   apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa ab)(*strict*)
   apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa ab nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
  apply(case_tac "length \<xi>")
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat)(*strict*)
   apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nat nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nata)(*strict*)
  apply(rule_tac xs="\<xi>" in rev_cases)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nata)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab nata ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa ab ys y)(*strict*)
  apply(erule_tac x="(Suc ( ( length ys)))" in allE)+
  apply(clarsimp)
  apply(simp add: suffix_def)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa ab ys y c)(*strict*)
  apply(simp add: get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa ab)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa ab)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__read__not_exists__none_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab)(*strict*)
  apply(rule conjI)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa ab)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x r pu a w e1a c1a wa aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x pu a w e1a c1a wa aa)(*strict*)
  apply(erule disjE)
  apply(rename_tac i e1 c1 c2 \<xi> x pu a w e1a c1a wa aa)(*strict*)
  apply(clarsimp)
  (*popping*)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = None \<and> F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k > 0")
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__none_def)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
  apply(rule_tac x="a" in exI)
  apply(rule conjI)
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
  apply(clarsimp)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k")
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k \<le> k")
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat)(*strict*)
   prefer 2
   apply(rule F_EPDA_AIA__fp_computed_stack_approximation_less_eq_than_k)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat)(*strict*)
  apply(rule_tac t="min k nat" and s="nat" in ssubst)
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat)(*strict*)
  apply(rule conjI)
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = None \<and> F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k = 0")
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__not_exists__none_def)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
  apply(rule conjI)
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
   apply(rule_tac x="a" in exI)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
  apply(clarsimp)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(case_tac "\<exists>n. F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = Some(Suc n) \<and> F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k > 0")
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__pop__exists__greater_than_0_def)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
  apply(rule_tac x="epdaH_conf_state c2" in exI)
  apply(rule_tac x="a" in exI)
  apply(rule conjI)
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k")
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k \<le> k")
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat)(*strict*)
   prefer 2
   apply(rule F_EPDA_AIA__fp_computed_stack_approximation_less_eq_than_k)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat)(*strict*)
  apply(rule_tac t="min k nat" and s="nat" in ssubst)
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat)(*strict*)
  apply(rule conjI)
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = Some 0")
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(subgoal_tac "False")
   apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
  apply(case_tac "i + length \<xi>")
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa)(*strict*)
   apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat)(*strict*)
  apply(clarsimp)
  apply(case_tac "length \<xi>")
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat)(*strict*)
   apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nat nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nata)(*strict*)
  apply(rule_tac xs="\<xi>" in rev_cases)
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nata)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa nata ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 a e1a c1a wa aa ys y)(*strict*)
  apply(erule_tac x="(Suc ( ( length ys)))" in allE)+
  apply(clarsimp)
  apply(simp add: suffix_def)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 a e1a c1a wa aa ys y c)(*strict*)
  apply(simp add: get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(case_tac "\<exists>n. F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = Some(Suc n) \<and> F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k = 0")
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(subgoal_tac "False")
   apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w)(*strict*)
  apply(simp add: get_configuration_def)
  apply(case_tac "i + length \<xi>")
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w)(*strict*)
   apply(clarsimp)
   apply(rename_tac c2 e1a c1a wa aa)(*strict*)
   apply(erule disjE)
    apply(rename_tac c2 e1a c1a wa aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac c2 e1a c1a wa aa)(*strict*)
   apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat)(*strict*)
  apply(clarsimp)
  apply(rule_tac xs="\<xi>" in rev_cases)
   apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac c2 e1a c1a wa aa nat)(*strict*)
   apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a e1a c1a wa aa w nat ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 a e1a c1a wa aa w ys y)(*strict*)
  apply(erule_tac x="(Suc ( ( length ys)))" in allE)+
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k ")
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa ab)(*strict*)
  apply(case_tac ab)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa ab)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x a e1a c1a wa aa ab nat)(*strict*)
  apply(force)
  (*push*)
  apply(rename_tac i e1 c1 c2 \<xi> x pu a w e1a c1a wa aa)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = None \<and> F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k > 0")
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__none_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(rule_tac x="epdaH_conf_state c2" in exI)
  apply(rule_tac x="wb" in exI)
  apply(rule_tac x="a" in exI)
  apply(clarsimp)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k \<le> k")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  prefer 2
  apply(rule F_EPDA_AIA__fp_computed_stack_approximation_less_eq_than_k)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  apply(rule_tac t="min k (Suc nat)" and s="Suc nat" in ssubst)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  apply(clarsimp)
  apply(case_tac k)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata)(*strict*)
  apply(clarsimp)
  apply(case_tac "min nata (Suc nat)")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata)(*strict*)
  apply(clarsimp)
  apply(case_tac nata)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata)(*strict*)
   prefer 2
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata natb)(*strict*)
   apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata natb)(*strict*)
  apply(clarsimp)
  apply(case_tac nata)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata natb)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata natb natc)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat natc)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = None \<and> F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k = 0")
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__not_exists__none_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(rule_tac x="wb" in exI)
  apply(rule_tac x="a" in exI)
  apply(clarsimp)
  apply(case_tac k)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  apply(clarsimp)
  apply(case_tac nat)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nata)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(case_tac "\<exists>n. F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = Some (Suc n) \<and> F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k > 0 \<and> Suc (Suc n) \<le> k")
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI1)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__less_than_k_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(rule_tac x="epdaH_conf_state c2" in exI)
  apply(rule_tac x="wb" in exI)
  apply(rule_tac x="a" in exI)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k \<le> k")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  prefer 2
  apply(rule F_EPDA_AIA__fp_computed_stack_approximation_less_eq_than_k)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(rule_tac t="min k (Suc nat)" and s="Suc nat" in ssubst)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(clarsimp)
  apply(case_tac k)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata)(*strict*)
  apply(clarsimp)
  apply(case_tac "min nata (Suc nat)")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata)(*strict*)
  apply(clarsimp)
  apply(case_tac nata)
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata)(*strict*)
   prefer 2
   apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata natb)(*strict*)
   apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata natb)(*strict*)
  apply(clarsimp)
  apply(case_tac nata)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata natb)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata natb natc)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat natc)(*strict*)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty  natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(case_tac "\<exists>n. F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k = Some (Suc n) \<and> F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k > 0 \<and> Suc n=k")
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_OPT__step_closure__fp_one_def)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(rule disjI2)
  apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__push__exists__k_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(rule_tac x="epdaH_conf_state c2" in exI)
  apply(rule_tac x="wb" in exI)
  apply(rule_tac x="a" in exI)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) (Suc (length wc))")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) (Suc (length wc)) \<le> (Suc (length wc))")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  prefer 2
  apply(rule F_EPDA_AIA__fp_computed_stack_approximation_less_eq_than_k)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(rule_tac t="min ((Suc (length wc))) (Suc nat)" and s="Suc nat" in ssubst)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(clarsimp)
  apply(case_tac "((Suc (length wc)))")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(case_tac "length wc")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(simp add: get_configuration_def)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty   natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb wc nat nata)(*strict*)
  apply(clarsimp)
  apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def F_EPDA_AIA__fp_computed_stack_approximation_def nat_seq_drop_last_simp nat_seqEmpty   natUptTo_n_n)
  apply(simp add: nat_seq_drop_last_simp2 get_label_def get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(subgoal_tac "False")
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximationX d (Suc i) (Suc (i + length \<xi>)) k")
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab)(*strict*)
  apply(subgoal_tac "ab \<le> k")
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab)(*strict*)
  prefer 2
  apply(rule F_EPDA_AIA__fp_computed_stack_approximationX_smaller_equal_k)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (i + length \<xi>)) k > 0")
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab)(*strict*)
  apply(case_tac ab)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab)(*strict*)
  prefer 2
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(case_tac "i + length \<xi>")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  apply(clarsimp)
  apply(case_tac "length \<xi>")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nat nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nata)(*strict*)
  apply(rule_tac xs="\<xi>" in rev_cases)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nata)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb nata ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa wb ys y)(*strict*)
  apply(erule_tac x="(Suc ( ( length ys)))" in allE)+
  apply(clarsimp)
  apply(simp add: suffix_def)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa wb ys y c)(*strict*)
  apply(simp add: get_configuration_def)
  apply(rename_tac i e1 c1 c2 \<xi> x a w e1a c1a wa aa wb ab)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb ab)(*strict*)
  apply(case_tac "i + length \<xi>")
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb ab)(*strict*)
  apply(clarsimp)
  apply(rename_tac c2 e1a c1a wa aa wb ab)(*strict*)
  apply(erule disjE)
  apply(rename_tac c2 e1a c1a wa aa wb ab)(*strict*)
  apply(clarsimp)
  apply(rename_tac c2 e1a c1a wa aa wb ab)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb ab nat)(*strict*)
  apply(clarsimp)
  apply(rule_tac xs="\<xi>" in rev_cases)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb ab nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac c2 e1a c1a wa aa wb ab nat)(*strict*)
  apply(force)
  apply(rename_tac i e1 c1 c2 \<xi> a w e1a c1a wa aa wb ab nat ys y)(*strict*)
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa wb ab ys y)(*strict*)
  apply(erule_tac x="(Suc ( ( length ys)))" in allE)+
  apply(clarsimp)
  apply(rename_tac i e1 c1 c2 a w e1a c1a wa aa wb ys y)(*strict*)
  apply(simp add: get_configuration_def suffix_def)
  done

lemma F_SDPDA_TO_CFG_OPT__step_closure__fp_strong_dependency: "
  valid_simple_dpda G
  \<Longrightarrow> epdaH.derivation_initial G d
  \<Longrightarrow> k>0
  \<Longrightarrow> d i = Some (pair ei ci)
  \<Longrightarrow> d (i+j+Suc 0) = Some (pair ej cj)
  \<Longrightarrow> l3_derivation_MAX G d w qi A qj i j
  \<Longrightarrow> \<exists>\<xi>. length \<xi> = Suc 0 + (Suc(i+j)) - i \<and>
           (\<forall>ik<length \<xi>.
               \<forall>e c. d (i + ik) = Some (pair e c) \<longrightarrow>
                     \<xi> ! ik =
                     cons_tuple3 (epdaH_conf_state c)
                      (take (F_EPDA_AIA__fp_computed_stack_approximation d (i + ik) k)
                        (epdaH_conf_stack c))
                      (F_EPDA_AIA__fp_computed_stack_approximationX d i (i+ik) k)
                      \<and>
                      (case F_EPDA_AIA__fp_computed_stack_approximationX d i (i+ik) k of None \<Rightarrow> True | Some n \<Rightarrow> n \<le> F_EPDA_AIA__fp_computed_stack_approximation d (i+ik) k)
                      \<and>
                      (F_EPDA_AIA__fp_computed_stack_approximation d (i+ik) k = 0 \<longrightarrow> (F_EPDA_AIA__fp_computed_stack_approximationX d i (i+ik) k = None \<or> F_EPDA_AIA__fp_computed_stack_approximationX d i (i+ik) k = Some 0))) \<and>
           (\<forall>ik<length \<xi>.
               case sel_tuple3_3 (\<xi> ! ik) of
               Some (Suc n) \<Rightarrow> \<exists>w.
                                length w=n
                                \<and> w @ epdaH_conf_stack (the (get_configuration (d (i))))
                                  =epdaH_conf_stack (the (get_configuration (d (i + ik))))
              | Some 0 \<Rightarrow> epdaH_conf_stack (the (get_configuration (d (i))))
                          =A # epdaH_conf_stack (the (get_configuration (d (i + ik))))
              | None \<Rightarrow> True) \<and>
           (\<forall>ik \<xi>'.
               \<xi>' = None # map Some \<xi> \<longrightarrow>
               Suc (Suc ik) < length \<xi>' \<longrightarrow>
               cons_tuple2 (\<xi>' ! Suc ik) (\<xi>' ! Suc (Suc ik))
               \<in> F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {cons_tuple2 (\<xi>' ! ik) (\<xi>' ! Suc ik)} k \<and>
               F_SDPDA_TO_CFG_OPT__step_closure__fp_one G {cons_tuple2 (\<xi>' ! ik) (\<xi>' ! Suc ik)} k
               \<subseteq> F_SDPDA_TO_CFG_OPT__step_closure__fp G
                   (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G A
                     (F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}))
                   k)"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac IV="Suc 0 + (Suc(i+j)) - i" in F_SDPDA_TO_CFG_OPT__step_closure__fp_strong_dependency_hlp)
         apply(force)
        apply(force)
       apply(force)
      apply(force)
     apply(force)
    apply(force)
   apply(force)
  apply(force)
  done

lemma third_conjI: "
  R
  \<Longrightarrow> P \<and> Q
  \<Longrightarrow> P \<and> Q \<and> R"
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro_seq_REFL: "
  finite S
  \<Longrightarrow> cons_tuple2 a b \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S
  \<Longrightarrow> cons_tuple2 a a \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S"
  apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro3)
   apply(force)
  apply(force)
  done

lemma nth_to_take_last: "
  n < length w
  \<Longrightarrow> w ! n = last (take (Suc n) w)"
  apply (metis last_snoc lessI nth_take take_Suc_conv_app_nth)
  done

lemma nth_to_drop_hd: "
  n < length w
  \<Longrightarrow> w ! n = hd (drop n w)"
  apply (metis hd_drop_conv_nth)
  done

lemma F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro_seq2: "
  finite S
  \<Longrightarrow> \<forall>i. Suc i < length w \<longrightarrow> cons_tuple2 (w ! i) (w ! Suc i) \<in> S
  \<Longrightarrow> k < length w
  \<Longrightarrow> Suc k < length w
  \<Longrightarrow> length w > Suc 0
  \<Longrightarrow> hd w = x
  \<Longrightarrow> w ! k = y
  \<Longrightarrow> last w = z
  \<Longrightarrow> cons_tuple2 x y \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S \<and> cons_tuple2 y z \<in> F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp S"
  apply(rule conjI)
   apply(case_tac k)
    apply(clarsimp)
    apply(case_tac w)
     apply(clarsimp)
    apply(rename_tac a list)(*strict*)
    apply(clarsimp)
    apply(case_tac list)
     apply(rename_tac a list)(*strict*)
     apply(force)
    apply(rename_tac a list aa lista)(*strict*)
    apply(erule_tac x="0" in allE)
    apply(clarsimp)
    apply(rename_tac a aa)(*strict*)
    apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro_seq_REFL)
     apply(rename_tac a aa)(*strict*)
     apply(force)
    apply(rename_tac a aa)(*strict*)
    apply(rule_tac A="S" in set_mp)
     apply(rename_tac a aa)(*strict*)
     apply(rule F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_mono)
     apply(force)
    apply(rename_tac a aa)(*strict*)
    apply(force)
   apply(rename_tac nat)(*strict*)
   apply(clarsimp)
   apply(rule_tac t="w!Suc nat" and s="last(take (Suc (Suc nat)) w)" in ssubst)
    apply(rename_tac nat)(*strict*)
    apply(rule nth_to_take_last)
    apply(force)
   apply(rename_tac nat)(*strict*)
   apply(rule_tac t="hd w" and s="hd(take (Suc (Suc nat)) w)" in ssubst)
    apply(rename_tac nat)(*strict*)
    apply(case_tac w)
     apply(rename_tac nat)(*strict*)
     apply(force)
    apply(rename_tac nat a list)(*strict*)
    apply(force)
   apply(rename_tac nat)(*strict*)
   apply(rule_tac w="take (Suc (Suc nat)) w" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro_seq_TRANS)
     apply(rename_tac nat)(*strict*)
     apply(force)
    apply(rename_tac nat)(*strict*)
    apply(clarsimp)
   apply(rename_tac nat)(*strict*)
   apply(clarsimp)
  apply(clarsimp)
  apply(rule_tac t="w!k" and s="hd(drop k w)" in ssubst)
   apply(rule nth_to_drop_hd)
   apply(force)
  apply(rule_tac t="last w" and s="last(drop k w)" in ssubst)
   apply(rule_tac xs="w" in rev_cases)
    apply(force)
   apply(rename_tac ys y)(*strict*)
   apply(force)
  apply(rule_tac w="drop k w" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro_seq_TRANS)
    apply(force)
   apply(clarsimp)
  apply(clarsimp)
  apply(force)
  done

theorem F_SDPDA_TO_CFG_OPT__l3_approx_contains_all_relevant_nonterminals: "
  valid_simple_dpda G
  \<Longrightarrow> ReachS = F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}
  \<Longrightarrow> CL = (%x. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp (F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G x ReachS) k))
  \<Longrightarrow> l3_derivation G d w q A q' i j
  \<Longrightarrow> k > 0
  \<Longrightarrow> cons_l3 q A q' \<in> F_SDPDA_TO_CFG_OPT__l3_approx G k ReachS CL"
  apply(subgoal_tac "\<exists>qI k e c. k\<le> i \<and> l3_derivation_MAX G d w qI A q' (i-k) (j+k) \<and> d i = Some (pair e c) \<and> epdaH_conf_state c = q \<and> epdaH_conf_stack c = A # w")
   apply(thin_tac "l3_derivation G d w q A q' i j")
   prefer 2
   apply(thin_tac "ReachS = F_EPDA_AIA__fp G k {F_EPDA_AIA__fp_start G k}")
   apply(thin_tac "CL =
    (\<lambda>x. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
          (F_SDPDA_TO_CFG_OPT__step_closure__fp G (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G x ReachS) k))")
   apply(rule l3_derivation_to_l3_derivationMAX)
    apply(force)
   apply(force)
  apply(erule exE)+
  apply(rename_tac qI ka e c)(*strict*)
  apply(erule conjE)+
  apply(subgoal_tac "qI \<in> F_SDPDA_TO_CFG_OPT__push_target_state G A")
   apply(rename_tac qI ka e c)(*strict*)
   prefer 2
   apply(simp add: l3_derivation_MAX_def)
   apply(clarsimp)
   apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
   apply(case_tac e1)
    apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
    apply(clarsimp)
    apply(rename_tac ka e c c1 e2 c2)(*strict*)
    apply(case_tac "i-ka=0")
     apply(rename_tac ka e c c1 e2 c2)(*strict*)
     prefer 2
     apply(subgoal_tac "X" for X)
      apply(rename_tac ka e c c1 e2 c2)(*strict*)
      prefer 2
      apply(rule_tac n="i-ka" and m="i - ka" in epdaH.pre_some_position_is_some_position_prime)
         apply(rename_tac ka e c c1 e2 c2)(*strict*)
         apply(simp add: epdaH.derivation_initial_def)
         apply(force)
        apply(rename_tac ka e c c1 e2 c2)(*strict*)
        apply(force)
       apply(rename_tac ka e c c1 e2 c2)(*strict*)
       apply(force)
      apply(rename_tac ka e c c1 e2 c2)(*strict*)
      apply(force)
     apply(rename_tac ka e c c1 e2 c2)(*strict*)
     apply(clarsimp)
    apply(rename_tac ka e c c1 e2 c2)(*strict*)
    apply(clarsimp)
    apply(rename_tac e c c1 e2 c2)(*strict*)
    apply(subgoal_tac "c1 \<in> epdaH_initial_configurations G")
     apply(rename_tac e c c1 e2 c2)(*strict*)
     prefer 2
     apply(simp add: epdaH.derivation_initial_def)
    apply(rename_tac e c c1 e2 c2)(*strict*)
    apply(simp add: epdaH_initial_configurations_def)
    apply(clarsimp)
    apply(case_tac c1)
    apply(rename_tac e c c1 e2 c2 epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
    apply(clarsimp)
    apply(rename_tac e c e2 c2)(*strict*)
    apply(case_tac c2)
    apply(rename_tac e c e2 c2 epdaH_conf_state epdaH_conf_history epdaH_conf_stacka)(*strict*)
    apply(clarsimp)
    apply(rename_tac e c e2 epdaH_conf_state epdaH_conf_history)(*strict*)
    apply(subgoal_tac "X" for X)
     apply(rename_tac e c e2 epdaH_conf_state epdaH_conf_history)(*strict*)
     prefer 2
     apply(rule_tac i="(Suc (i+j))" in epda_box_stays_at_bottom_epdaH)
       apply(rename_tac e c e2 epdaH_conf_state epdaH_conf_history)(*strict*)
       apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
       apply(force)
      apply(rename_tac e c e2 epdaH_conf_state epdaH_conf_history)(*strict*)
      apply(force)
     apply(rename_tac e c e2 epdaH_conf_state epdaH_conf_history)(*strict*)
     apply(force)
    apply(rename_tac e c e2 epdaH_conf_state epdaH_conf_history)(*strict*)
    apply(clarsimp)
   apply(rename_tac ka e c e1 c1 e2 c2 a)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 a X)(*strict*)
   apply(case_tac "i-ka")
    apply(rename_tac ka e c c1 e2 c2 a X)(*strict*)
    apply(clarsimp)
    apply(rename_tac e c c1 e2 c2 a X)(*strict*)
    apply(subgoal_tac "X" for X)
     apply(rename_tac e c c1 e2 c2 a X)(*strict*)
     prefer 2
     apply(rule epdaH.some_position_has_details_at_0)
     apply(simp add: epdaH.derivation_initial_def)
    apply(rename_tac e c c1 e2 c2 a X)(*strict*)
    apply(force)
   apply(rename_tac ka e c c1 e2 c2 a X nat)(*strict*)
   apply(clarsimp)
   apply(case_tac i)
    apply(rename_tac ka e c c1 e2 c2 a X nat)(*strict*)
    apply(force)
   apply(rename_tac ka e c c1 e2 c2 a X nat nata)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "nata=nat+ka")
    apply(rename_tac ka e c c1 e2 c2 a X nat nata)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac ka e c c1 e2 c2 a X nat nata)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 a X nat)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__pushed_symbols_def F_SDPDA_TO_CFG_OPT__push_target_state_def)
   apply(rule_tac x="X" in exI)
   apply(rule_tac x="a" in exI)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    apply(rename_tac ka e c c1 e2 c2 a X nat)(*strict*)
    prefer 2
    apply(rule_tac
      d="d" and
      n="nat" and
      m="Suc nat"
      in epdaH.step_detail_before_some_position)
      apply(rename_tac ka e c c1 e2 c2 a X nat)(*strict*)
      apply(rule epdaH.derivation_initial_is_derivation)
      apply(force)
     apply(rename_tac ka e c c1 e2 c2 a X nat)(*strict*)
     apply(force)
    apply(rename_tac ka e c c1 e2 c2 a X nat)(*strict*)
    apply(force)
   apply(rename_tac ka e c c1 e2 c2 a X nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 a X nat e1 c1a)(*strict*)
   apply(simp add: epdaH_step_relation_def valid_simple_dpda_def)
   apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 a X nat e1 c1a w)(*strict*)
   apply(erule_tac x="a" in ballE)
    apply(rename_tac ka e c c1 e2 c2 a X nat e1 c1a w)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac ka e c c1 e2 c2 a X nat e1 c1a w)(*strict*)
   apply(case_tac "edge_event a")
    apply(rename_tac ka e c c1 e2 c2 a X nat e1 c1a w)(*strict*)
    apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 a X nat e1 c1a w aa)(*strict*)
   apply(clarsimp)
   apply(simp add: valid_dpda_def valid_pda_def)
   apply(clarsimp)
   apply(erule_tac x="a" in ballE)
    apply(rename_tac ka e c c1 e2 c2 a X nat e1 c1a w aa)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac ka e c c1 e2 c2 a X nat e1 c1a w aa)(*strict*)
   apply(force)
  apply(rename_tac qI ka e c)(*strict*)
  apply(subgoal_tac "A \<in> F_SDPDA_TO_CFG_OPT__pushed_symbols G")
   apply(rename_tac qI ka e c)(*strict*)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__pushed_symbols_from_F_SDPDA_TO_CFG_OPT__push_target_state)
   apply(force)
  apply(rename_tac qI ka e c)(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__l3_approx_intro)
   apply(rename_tac qI ka e c)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac qI ka e c)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_OPT__l3_approx_1_def)
  apply(simp add: l3_derivation_MAX_def)
  apply(clarsimp)
  apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
   prefer 2
   apply(rule_tac k="k" and G="G" and i="i-ka" and j="Suc (i + j) - (i-ka)" in F_EPDA_AIA__fp_strong_dependency)
       apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
       apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
      apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
      apply(force)
     apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
     apply(force)
    apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
   apply(force)
  apply(rename_tac ka e c e1 c1 e2 c2)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
  apply(subgoal_tac "\<forall>e c. d (i + 0 - ka) = Some (pair e c) \<longrightarrow>
                w ! 0 =
                cons_tuple2 (epdaH_conf_state c)
                 (take (F_EPDA_AIA__fp_computed_stack_approximation d (i + 0 - ka) k)
                   (epdaH_conf_stack c))")
   apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
   prefer 2
   apply(erule_tac x="0" in allE)+
   apply(erule impE)
    apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
   apply(erule impE)
    apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
   apply(erule impE)
    apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
   apply(force)
  apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
  apply(case_tac w)
   apply(rename_tac ka e c e1 c1 e2 c2 w)(*strict*)
   apply(force)
  apply(rename_tac ka e c e1 c1 e2 c2 w a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e c e1 c1 e2 c2 list)(*strict*)
  apply(rename_tac \<omega>)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
  apply(rule_tac x="Some(cons_tuple3 (epdaH_conf_state c1)
        (take (F_EPDA_AIA__fp_computed_stack_approximation d (i - ka) k)
          (A # epdaH_conf_stack c2)) (Some(Suc 0)))" in exI)
  apply(rule conjI)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_OPT__step_closure__l3_init_def)
   apply(case_tac "(F_EPDA_AIA__fp_computed_stack_approximation d (i - ka) k)")
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
    prefer 2
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nat)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
   apply(clarsimp)
   apply(case_tac "i-ka")
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
    apply(clarsimp)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nat)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nat)(*strict*)
    prefer 2
    apply(rule_tac
      d="d" and
      n="nat" and
      m="Suc nat"
      in epdaH.step_detail_before_some_position)
      apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nat)(*strict*)
      apply(rule epdaH.derivation_initial_is_derivation)
      apply(force)
     apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nat)(*strict*)
     apply(force)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nat)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X)(*strict*)
   apply(simp add: epdaH_step_relation_def)
   apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (nat)) k =
  min k (F_EPDA_AIA__fp_computed_stack_approximation d (nat) k - length [X] + length [A,X])")
    apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X)(*strict*)
    prefer 2
    apply(rule F_EPDA_AIA__fp_computed_stack_approximation_unfold)
      apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X)(*strict*)
      apply(force)
     apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X)(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
     apply(clarsimp)
     apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X w)(*strict*)
     apply(erule_tac x="e2a" in ballE)
      apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X w)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X w)(*strict*)
     apply(erule_tac x="e2a" in ballE)
      apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X w)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X w)(*strict*)
     apply(case_tac e2a)
     apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X w edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
     apply(rename_tac q r po pu q')
     apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X w q r po pu q')(*strict*)
     apply(clarsimp)
     apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a c1a X w r po)(*strict*)
     apply(case_tac r)
      apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a c1a X w r po)(*strict*)
      prefer 2
      apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a c1a X w r po a)(*strict*)
      apply(clarsimp)
     apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a c1a X w r po)(*strict*)
     apply(force)
    apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X)(*strict*)
    apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 \<omega> nat e1a e2a c1a X)(*strict*)
   apply(clarsimp)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
  apply(rule_tac x="take (F_EPDA_AIA__fp_computed_stack_approximation d i k) (A#(epdaH_conf_stack c2))" in exI)
  apply(rule_tac x="F_EPDA_AIA__fp_computed_stack_approximationX d (i-ka) i k" in exI)
  apply(rule extract_ex_conj)
  apply(rule_tac x="take (F_EPDA_AIA__fp_computed_stack_approximation d (Suc(i+j)) k) (epdaH_conf_stack c2)" in exI)
  apply(rule extract_ex_conj)
  apply(rule_tac x="F_EPDA_AIA__fp_computed_stack_approximationX d (i-ka) (Suc(i+j)) k" in exI)
  apply(subgoal_tac "X" for X)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
   prefer 2
   apply(rule_tac j="j+ka" and i="i-ka" in F_SDPDA_TO_CFG_OPT__step_closure__fp_strong_dependency)
        apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
        apply(force)
       apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
       apply(force)
      apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
      apply(force)
     apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
     apply(force)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
   apply(simp add: l3_derivation_MAX_def)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
  apply(subgoal_tac "c1 \<in> epdaH_configurations G")
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
   prefer 2
   apply(rule epdaH.belongs_configurations)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
    apply(rule epdaH.derivation_initial_belongs)
     apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
   apply(force)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
  apply(subgoal_tac "A \<in> epda_gamma G \<and>
       (take (F_EPDA_AIA__fp_computed_stack_approximation d i k) (A # epdaH_conf_stack c2) = [] \<or>
        [A] \<sqsubseteq> take (F_EPDA_AIA__fp_computed_stack_approximation d i k) (A # epdaH_conf_stack c2))")
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
   prefer 2
   apply(rule conjI)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
    apply(simp add: epdaH_configurations_def)
    apply(clarsimp)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
   apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d i k")
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nat)(*strict*)
   apply(simp add: prefix_def)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega>)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
  apply(subgoal_tac "
        (F_EPDA_AIA__fp_computed_stack_approximationX d (i - ka) (Suc (i+j)) k)
       \<in> {Some 0, None}")
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
   prefer 2
   apply(subgoal_tac "case sel_tuple3_3 (\<xi> ! (Suc(j+ka))) of None \<Rightarrow> True
          | Some 0 \<Rightarrow>
              epdaH_conf_stack (the (get_configuration (d (i - ka)))) =
              A # epdaH_conf_stack (the (get_configuration (d (i - ka + (Suc(j+ka))))))
          | Some (Suc n) \<Rightarrow>
              \<exists>w. length w = n \<and>
                  w @ epdaH_conf_stack (the (get_configuration (d (i - ka)))) =
                  epdaH_conf_stack (the (get_configuration (d (i - ka + (Suc(j+ka))))))")
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
    prefer 2
    apply(erule_tac x="(Suc(j+ka))" in allE)+
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
   apply(rule_tac xs="\<xi>" in rev_cases)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> ys y)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> ys y ya)(*strict*)
   apply(rename_tac \<xi> \<xi>L n)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> \<xi>L n)(*strict*)
   apply(case_tac n)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> \<xi>L n)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> \<xi>L n nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> \<xi>L w)(*strict*)
   apply(rename_tac n)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> \<xi>L n)(*strict*)
   apply(simp add: suffix_def)
   apply(case_tac c2)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> \<xi>L n epdaH_conf_statea epdaH_conf_history epdaH_conf_stacka)(*strict*)
   apply(rename_tac q h s)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> \<xi>L n q h s)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h s)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h s)(*strict*)
    prefer 2
    apply(rule_tac i="(Suc (i+j))" in epda_box_stays_at_bottom_epdaH)
      apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h s)(*strict*)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
      apply(force)
     apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h s)(*strict*)
     apply(force)
    apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h s)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h s)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h w)(*strict*)
   apply(subgoal_tac "epda_box G \<notin> set (A#w)")
    apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h w)(*strict*)
    prefer 2
    apply(subgoal_tac "X" for X)
     apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h w)(*strict*)
     prefer 2
     apply(rule_tac d="d" in epdaH_epda_stack_is_must_terminated_by_prime)
       apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h w)(*strict*)
       apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
       apply(force)
      apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h w)(*strict*)
      apply(force)
     apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h w)(*strict*)
     apply(force)
    apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h w)(*strict*)
    apply(simp add: must_terminated_by_def append_language_def kleene_star_def)
    apply(clarsimp)
    apply (metis nset_diff)
   apply(rename_tac ka e c e1 c1 e2 \<omega> \<xi> \<xi>L n q h w)(*strict*)
   apply(simp add: get_configuration_def)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
  apply(rule third_conjI)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
   apply(force)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
  apply(case_tac "F_EPDA_AIA__fp_computed_stack_approximation d (i - ka) k")
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
   apply(subgoal_tac "False")
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
   apply(case_tac "i-ka")
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nat)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nat)(*strict*)
    prefer 2
    apply(rule_tac
      d="d" and
      n="nat" and
      m="Suc nat"
      in epdaH.step_detail_before_some_position)
      apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nat)(*strict*)
      apply(rule epdaH.derivation_initial_is_derivation)
      apply(force)
     apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nat)(*strict*)
     apply(force)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nat)(*strict*)
    apply(force)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X)(*strict*)
   apply(simp add: epdaH_step_relation_def)
   apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
   apply(subgoal_tac "F_EPDA_AIA__fp_computed_stack_approximation d (Suc (nat)) k =
  min k (F_EPDA_AIA__fp_computed_stack_approximation d (nat) k - length [X] + length [A,X])")
    apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
    prefer 2
    apply(rule F_EPDA_AIA__fp_computed_stack_approximation_unfold)
      apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
      apply(force)
     apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
     apply(clarsimp)
     apply(erule_tac x="e2a" in ballE)
      apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
     apply(erule_tac x="e2a" in ballE)
      apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
     apply(case_tac e2a)
     apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
     apply(rename_tac q r po pu q')
     apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w q r po pu q')(*strict*)
     apply(clarsimp)
     apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a c1a X w r po)(*strict*)
     apply(case_tac r)
      apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a c1a X w r po)(*strict*)
      prefer 2
      apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a c1a X w r po a)(*strict*)
      apply(clarsimp)
     apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a c1a X w r po)(*strict*)
     apply(force)
    apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
    apply(clarsimp)
   apply(rename_tac ka e c c1 e2 c2 \<omega> \<xi> nat e1a e2a c1a X w)(*strict*)
   apply(clarsimp)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nat)(*strict*)
  apply(rename_tac nXX)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
  apply(rule_tac k="ka" and w="map Some \<xi>" in F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp_intro_seq2)
         apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
         apply(rule finite_F_SDPDA_TO_CFG_OPT__step_closure__fp)
         apply(rule F_SDPDA_TO_CFG_OPT__step_closure__l3_init_satisfies_F_SDPDA_TO_CFG_OPT__step_closure__fp_TERM_ARGS_TEST)
          apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
          apply(rule F_EPDA_AIA__fp_preserves_F_EPDA_AIA__fp_valid_input)
          apply(rule F_EPDA_AIA__fp_valid_input_with_F_EPDA_AIA__fp_start)
          apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
         apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
         apply(force)
        apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
        prefer 2
        apply(force)
       apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
       prefer 2
       apply(force)
      apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
     apply(clarsimp)
     apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX ia)(*strict*)
     apply(erule_tac x="ia" in allE)+
     apply(force)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
    apply(clarsimp)
    apply(case_tac \<xi>)
     apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
     apply(clarsimp)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nXX a list)(*strict*)
    apply(rename_tac \<xi>0 \<xi>)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nXX \<xi>0 \<xi>)(*strict*)
    apply(erule_tac x="0" in allE)+
    apply(clarsimp)
    apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nXX \<xi>)(*strict*)
    apply(simp add: F_EPDA_AIA__fp_computed_stack_approximationX_def)
    apply(simp add: nat_seqEmpty)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
   apply(force)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
  apply(rule_tac xs="\<xi>" in rev_cases)
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX)(*strict*)
   apply(clarsimp)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi> nXX ys y)(*strict*)
  apply(rename_tac \<xi> \<xi>L)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> \<xi>' nXX \<xi> \<xi>L)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nXX \<xi> \<xi>L)(*strict*)
  apply(thin_tac "\<forall>k\<le>j + ka.
          \<forall>e c. d (i + k - ka) = Some (pair e c) \<longrightarrow>
                epdaH_conf_stack c \<sqsupseteq> (A # epdaH_conf_stack c2)")
  apply(erule_tac x="Suc (j + ka)" in allE)+
  apply(clarsimp)
  apply(subgoal_tac "(\<xi> @ [\<xi>L]) ! Suc (j + ka) = \<xi>L")
   apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nXX \<xi> \<xi>L)(*strict*)
   apply(force)
  apply(rename_tac ka e c e1 c1 e2 c2 \<omega> nXX \<xi> \<xi>L)(*strict*)
  apply (metis nth_append_length)
  done

theorem F_SDPDA_TO_CFG_OPT__l3_approx_contains_all_relevant_nonterminals2: "
  valid_simple_dpda G
  \<Longrightarrow> k > 0
  \<Longrightarrow> Some GO = F_SDPDA_TO_CFG_OPT G k
  \<Longrightarrow> l3_derivation G d w q A q' i j
  \<Longrightarrow> cons_l3 q A q' \<in> cfg_nonterminals GO"
  apply(rule_tac A="F_SDPDA_TO_CFG_OPT__l3_approx G k ReachS CL" for ReachS CL in set_mp)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__l3_approx_contains_all_relevant_nonterminals)
       apply(force)
      apply(blast)
     apply(force)
    apply(force)
   apply(force)
  apply(simp add: F_SDPDA_TO_CFG_OPT_def Let_def F_SDPDA_TO_CFG_OPT__nonterminals_def)
  apply(erule if_option_simp)
  apply(case_tac "cons_l2 (epda_initial G) (epda_box G)
    \<in> F_SDPDA_TO_CFG_OPT__l2_approx G k (F_EPDA_AIA G k)
        (\<lambda>x. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
               (F_SDPDA_TO_CFG_OPT__step_closure__fp G
                 (F_SDPDA_TO_CFG_OPT__step_closure__l2_init G x (F_EPDA_AIA G k)) k))")
   prefer 2
   apply(force)
  apply(case_tac "F_SDPDA_TO_CFG_OPT__nonterminals G k")
  apply(rename_tac x1 x2)(*strict*)
  apply(clarsimp)
  apply(rename_tac x1 x2 x)(*strict*)
  apply(subgoal_tac "x \<in> F_SDPDA_TO_CFG_OPT__l3_approx G k (F_EPDA_AIA G k)
             (\<lambda>x. F_SDPDA_TO_CFG_OPT__transitive_reflexive_closure__fp
                    (F_SDPDA_TO_CFG_OPT__step_closure__fp G
                      (F_SDPDA_TO_CFG_OPT__step_closure__l3_init G x (F_EPDA_AIA G k)) k))")
   apply(rename_tac x1 x2 x)(*strict*)
   apply(force)
  apply(simp add: F_EPDA_AIA_def)
  done

definition state_adjacency_and_no_l2_before_l3 :: "
  ('state, 'stack) DT_l2_l3_nonterminals list
  \<Rightarrow> bool"
  where
    "state_adjacency_and_no_l2_before_l3 w \<equiv>
  \<forall>w1 A B w2.
    w = w1 @ [A, B] @ w2
    \<longrightarrow> (case A of
        cons_l2 q X \<Rightarrow> False
        | cons_l3 q1 AX q2 \<Rightarrow> (case B of
            cons_l2 q3 Y \<Rightarrow> q2 = q3
            | cons_l3 q3 BX q4 \<Rightarrow> q2 = q3))"

lemma cfgLM_reachable_have_state_adjacency_and_no_l2_before_l3: "
  valid_cfg G
  \<Longrightarrow> LR1ProdForm G
  \<Longrightarrow> cfgLM.derivation_initial G d
  \<Longrightarrow> d n = Some (pair e1 c1)
  \<Longrightarrow> cfg_conf c1 = (liftB v) @ teA B1 # (liftA r1)
  \<Longrightarrow> state_adjacency_and_no_l2_before_l3 (B1 # r1)"
  apply(induct n arbitrary: e1 c1 v B1 r1)
   apply(rename_tac e1 c1 v B1 r1)(*strict*)
   apply(simp add: cfgLM.derivation_initial_def cfg_initial_configurations_def)
   apply(clarsimp)
   apply(rename_tac v B1 r1)(*strict*)
   apply(case_tac v)
    apply(rename_tac v B1 r1)(*strict*)
    apply(clarsimp)
    apply(rename_tac r1)(*strict*)
    apply(case_tac r1)
     apply(rename_tac r1)(*strict*)
     prefer 2
     apply(rename_tac r1 a list)(*strict*)
     apply(clarsimp)
    apply(rename_tac r1)(*strict*)
    apply(clarsimp)
    apply(simp add: state_adjacency_and_no_l2_before_l3_def)
   apply(rename_tac v B1 r1 a list)(*strict*)
   apply(force)
  apply(rename_tac n e1 c1 v B1 r1)(*strict*)
  apply(clarsimp)
  apply(case_tac c1)
  apply(rename_tac n e1 c1 v B1 r1 cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n e1 v B1 r1)(*strict*)
  apply(subgoal_tac "\<exists>e1 e2 c1 c2. d n = Some (pair e1 c1) \<and> d (Suc n) = Some (pair (Some e2) c2) \<and> cfgLM_step_relation G c1 e2 c2")
   apply(rename_tac n e1 v B1 r1)(*strict*)
   prefer 2
   apply(rule_tac
      m="Suc n"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac n e1 v B1 r1)(*strict*)
     apply(rule cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac n e1 v B1 r1)(*strict*)
    apply(force)
   apply(rename_tac n e1 v B1 r1)(*strict*)
   apply(force)
  apply(rename_tac n e1 v B1 r1)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 c1)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 c1 l r)(*strict*)
  apply(erule_tac
      x="e1a"
      in meta_allE)
  apply(clarsimp)
  apply(erule_tac
      x="c1"
      in meta_allE)
  apply(clarsimp)
  apply(case_tac c1)
  apply(rename_tac n v B1 r1 e1a e2 c1 l r cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 l r)(*strict*)
  apply(subgoal_tac "\<exists>w1 w2. l @ teA (prod_lhs e2) # r=w1@w2 \<and> setA w1={} \<and> setB w2={}")
   apply(rename_tac n v B1 r1 e1a e2 l r)(*strict*)
   prefer 2
   apply(rule singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac n v B1 r1 e1a e2 l r)(*strict*)
      apply(force)
     apply(rename_tac n v B1 r1 e1a e2 l r)(*strict*)
     apply(force)
    apply(rename_tac n v B1 r1 e1a e2 l r)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(force)
   apply(rename_tac n v B1 r1 e1a e2 l r)(*strict*)
   apply(force)
  apply(rename_tac n v B1 r1 e1a e2 l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 l r w1 w2)(*strict*)
  apply(subgoal_tac "l=w1")
   apply(rename_tac n v B1 r1 e1a e2 l r w1 w2)(*strict*)
   prefer 2
   apply(rule terminal_prefix_eq)
       apply(rename_tac n v B1 r1 e1a e2 l r w1 w2)(*strict*)
       apply (metis)
      apply(rename_tac n v B1 r1 e1a e2 l r w1 w2)(*strict*)
      apply(force)
     apply(rename_tac n v B1 r1 e1a e2 l r w1 w2)(*strict*)
     prefer 3
     apply(force)
    apply(rename_tac n v B1 r1 e1a e2 l r w1 w2)(*strict*)
    apply(force)
   apply(rename_tac n v B1 r1 e1a e2 l r w1 w2)(*strict*)
   apply(case_tac w2)
    apply(rename_tac n v B1 r1 e1a e2 l r w1 w2)(*strict*)
    apply(force)
   apply(rename_tac n v B1 r1 e1a e2 l r w1 w2 a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a e2 l r w1 a list)(*strict*)
   apply(case_tac a)
    apply(rename_tac n v B1 r1 e1a e2 l r w1 a list aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a e2 l r w1 a list b)(*strict*)
   apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 l r w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
  apply(simp add: LR1ProdForm_def)
  apply(erule_tac
      x="e2"
      in ballE)
   apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
  apply(erule disjE)
   apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "liftB v=w1")
    apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
    prefer 2
    apply(rule terminal_prefix_eq)
        apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
        apply (metis setA_liftB)
       apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
       apply(force)
      apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
      prefer 3
      apply(force)
     apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
     apply(force)
    apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
    apply(case_tac r)
     apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
     apply(force)
    apply(rename_tac n v B1 r1 e1a e2 r w1 a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v B1 r1 e1a e2 w1 a list)(*strict*)
    apply(case_tac a)
     apply(rename_tac n v B1 r1 e1a e2 w1 a list aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac n v B1 r1 e1a e2 w1 a list b)(*strict*)
    apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a e2)(*strict*)
   apply(erule_tac
      x="v"
      in meta_allE)
   apply(clarsimp)
   apply(erule_tac
      x="prod_lhs e2"
      in meta_allE)
   apply(clarsimp)
   apply(erule_tac
      x="B1#r1"
      in meta_allE)
   apply(simp add: liftA_commutes_over_concat)
   apply(simp add: state_adjacency_and_no_l2_before_l3_def)
   apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a e2 w1 A B w2)(*strict*)
   apply(case_tac A)
    apply(rename_tac n v B1 r1 e1a e2 w1 A B w2 q b)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v B1 r1 e1a e2 w1 B w2 q b)(*strict*)
    apply(case_tac w1)
     apply(rename_tac n v B1 r1 e1a e2 w1 B w2 q b)(*strict*)
     apply(clarsimp)
     apply(rename_tac n v e1a e2 B w2 q b)(*strict*)
     apply(erule_tac
      x="[prod_lhs e2]"
      in allE)
     apply(clarsimp)
    apply(rename_tac n v B1 r1 e1a e2 w1 B w2 q b a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v e1a e2 B w2 q b a list)(*strict*)
    apply(erule_tac
      x="[prod_lhs e2,a]@list"
      in allE)
    apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a e2 w1 A B w2 q1 b q2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a e2 w1 B w2 q1 b q2)(*strict*)
   apply(case_tac B)
    apply(rename_tac n v B1 r1 e1a e2 w1 B w2 q1 b q2 q ba)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v B1 r1 e1a e2 w1 w2 q1 b q2 q ba)(*strict*)
    apply(erule_tac
      x="prod_lhs e2 # w1"
      in allE)
    apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a e2 w1 B w2 q1 b q2 q1a ba q2a)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a e2 w1 w2 q1 b q2 q1a ba q2a)(*strict*)
   apply(erule_tac
      x="prod_lhs e2 # w1"
      in allE)
   apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 r w1)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 r w1 b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac n v B1 r1 e1a e2 r w1 b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 A1)(*strict*)
   apply(subgoal_tac "liftB v=w1@[teB b]")
    apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 A1)(*strict*)
    prefer 2
    apply(rule terminal_prefix_eq)
        apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 A1)(*strict*)
        apply (metis setA_liftB)
       apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 A1)(*strict*)
       apply(simp add: setAConcat)
      apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 A1)(*strict*)
      prefer 3
      apply(force)
     apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 A1)(*strict*)
     apply(force)
    apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 A1)(*strict*)
    apply(force)
   apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v r1 e1a w1 b q1 q2 A1)(*strict*)
   apply(case_tac v)
    apply(rename_tac n v r1 e1a w1 b q1 q2 A1)(*strict*)
    apply(force)
   apply(rename_tac n v r1 e1a w1 b q1 q2 A1 a list)(*strict*)
   apply(subgoal_tac "\<exists>w' x'. v=w'@[x']")
    apply(rename_tac n v r1 e1a w1 b q1 q2 A1 a list)(*strict*)
    prefer 2
    apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
    apply(force)
   apply(rename_tac n v r1 e1a w1 b q1 q2 A1 a list)(*strict*)
   apply(thin_tac "v=a#list")
   apply(clarsimp)
   apply(rename_tac n r1 e1a w1 b q1 q2 A1 w' x')(*strict*)
   apply(simp add: liftB_commutes_over_concat)
   apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 A1 w')(*strict*)
   apply(erule_tac
      x="w'"
      in meta_allE)
   apply(clarsimp)
   apply(erule_tac
      x="cons_l2 q1 A1"
      in meta_allE)
   apply(clarsimp)
   apply(erule_tac
      x="r1"
      in meta_allE)
   apply(clarsimp)
   apply(simp add: state_adjacency_and_no_l2_before_l3_def)
   apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 A1 w' w1 A B w2)(*strict*)
   apply(case_tac A)
    apply(rename_tac n r1 e1a b q1 q2 A1 w' w1 A B w2 q ba)(*strict*)
    apply(clarsimp)
    apply(rename_tac n r1 e1a b q1 q2 A1 w' w1 B w2 q ba)(*strict*)
    apply(case_tac w1)
     apply(rename_tac n r1 e1a b q1 q2 A1 w' w1 B w2 q ba)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1a b q1 w' B w2 q ba)(*strict*)
     apply(erule_tac
      x="[]"
      in allE)
     apply(clarsimp)
    apply(rename_tac n r1 e1a b q1 q2 A1 w' w1 B w2 q ba a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1a b q1 q2 A1 w' B w2 q ba list)(*strict*)
    apply(erule_tac
      x="cons_l2 q1 A1 # list"
      in allE)
    apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 A1 w' w1 A B w2 q1a ba q2a)(*strict*)
   apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 A1 w' w1 B w2 q1a ba q2a)(*strict*)
   apply(case_tac w1)
    apply(rename_tac n r1 e1a b q1 q2 A1 w' w1 B w2 q1a ba q2a)(*strict*)
    apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 A1 w' w1 B w2 q1a ba q2a a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1a b q1 q2 A1 w' B w2 q1a ba q2a list)(*strict*)
   apply(erule_tac
      x="cons_l2 q1 A1 # list"
      in allE)
   apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 r w1 b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac n v B1 r1 e1a e2 r w1 b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 q3 A1)(*strict*)
   apply(subgoal_tac "liftB v=w1@[teB b]")
    apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 q3 A1)(*strict*)
    prefer 2
    apply(rule terminal_prefix_eq)
        apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 q3 A1)(*strict*)
        apply (metis setA_liftB)
       apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 q3 A1)(*strict*)
       apply(simp add: setAConcat)
      apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 q3 A1)(*strict*)
      prefer 3
      apply(force)
     apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 q3 A1)(*strict*)
     apply(force)
    apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 q3 A1)(*strict*)
    apply(force)
   apply(rename_tac n v B1 r1 e1a r w1 b q1 q2 q3 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v r1 e1a w1 b q1 q2 q3 A1)(*strict*)
   apply(case_tac v)
    apply(rename_tac n v r1 e1a w1 b q1 q2 q3 A1)(*strict*)
    apply(force)
   apply(rename_tac n v r1 e1a w1 b q1 q2 q3 A1 a list)(*strict*)
   apply(subgoal_tac "\<exists>w' x'. v=w'@[x']")
    apply(rename_tac n v r1 e1a w1 b q1 q2 q3 A1 a list)(*strict*)
    prefer 2
    apply(rule_tac
      n="length list"
      in NonEmptyListHasTailElem)
    apply(force)
   apply(rename_tac n v r1 e1a w1 b q1 q2 q3 A1 a list)(*strict*)
   apply(thin_tac "v=a#list")
   apply(clarsimp)
   apply(rename_tac n r1 e1a w1 b q1 q2 q3 A1 w' x')(*strict*)
   apply(simp add: liftB_commutes_over_concat)
   apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 q3 A1 w')(*strict*)
   apply(erule_tac
      x="w'"
      in meta_allE)
   apply(clarsimp)
   apply(erule_tac
      x="cons_l3 q1 A1 q2"
      in meta_allE)
   apply(clarsimp)
   apply(erule_tac
      x="r1"
      in meta_allE)
   apply(clarsimp)
   apply(simp add: state_adjacency_and_no_l2_before_l3_def)
   apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 q3 A1 w' w1 A B w2)(*strict*)
   apply(case_tac A)
    apply(rename_tac n r1 e1a b q1 q2 q3 A1 w' w1 A B w2 q ba)(*strict*)
    apply(clarsimp)
    apply(rename_tac n r1 e1a b q1 q2 q3 A1 w' w1 B w2 q ba)(*strict*)
    apply(case_tac w1)
     apply(rename_tac n r1 e1a b q1 q2 q3 A1 w' w1 B w2 q ba)(*strict*)
     apply(clarsimp)
    apply(rename_tac n r1 e1a b q1 q2 q3 A1 w' w1 B w2 q ba a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1a b q1 q2 q3 A1 w' B w2 q ba list)(*strict*)
    apply(erule_tac
      x="cons_l3 q1 A1 q2 # list"
      in allE)
    apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 q3 A1 w' w1 A B w2 q1a ba q2a)(*strict*)
   apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 q3 A1 w' w1 B w2 q1a ba q2a)(*strict*)
   apply(case_tac w1)
    apply(rename_tac n r1 e1a b q1 q2 q3 A1 w' w1 B w2 q1a ba q2a)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1a b q1 w' B w2 q1a ba q2a)(*strict*)
    apply(case_tac B)
     apply(rename_tac n e1a b q1 w' B w2 q1a ba q2a q bb)(*strict*)
     apply(clarsimp)
     apply(rename_tac n e1a b q1 w' w2 q1a ba q2a q bb)(*strict*)
     apply(erule_tac
      x="[]"
      in allE)
     apply(clarsimp)
    apply(rename_tac n e1a b q1 w' B w2 q1a ba q2a q1b bb q2)(*strict*)
    apply(clarsimp)
    apply(rename_tac n e1a b q1 w' w2 q1a ba q2a q1b bb q2)(*strict*)
    apply(erule_tac
      x="[]"
      in allE)
    apply(clarsimp)
   apply(rename_tac n r1 e1a b q1 q2 q3 A1 w' w1 B w2 q1a ba q2a a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n e1a b q1 q2 q3 A1 w' B w2 q1a ba q2a list)(*strict*)
   apply(erule_tac
      x="cons_l3 q1 A1 q2 # list"
      in allE)
   apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 r w1 b q1 q2 q3 q4 A1)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 r w1 q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac n v B1 r1 e1a e2 r w1 q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a r w1 q1 q2 A1 A2)(*strict*)
   apply(subgoal_tac "liftB v=w1")
    apply(rename_tac n v B1 r1 e1a r w1 q1 q2 A1 A2)(*strict*)
    prefer 2
    apply(rule terminal_prefix_eq)
        apply(rename_tac n v B1 r1 e1a r w1 q1 q2 A1 A2)(*strict*)
        apply (metis setA_liftB)
       apply(rename_tac n v B1 r1 e1a r w1 q1 q2 A1 A2)(*strict*)
       apply(simp add: setAConcat)
      apply(rename_tac n v B1 r1 e1a r w1 q1 q2 A1 A2)(*strict*)
      prefer 3
      apply(force)
     apply(rename_tac n v B1 r1 e1a r w1 q1 q2 A1 A2)(*strict*)
     apply(force)
    apply(rename_tac n v B1 r1 e1a r w1 q1 q2 A1 A2)(*strict*)
    apply(force)
   apply(rename_tac n v B1 r1 e1a r w1 q1 q2 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v r1 e1a q1 q2 A1 A2)(*strict*)
   apply(erule_tac
      x="v"
      in meta_allE)
   apply(clarsimp)
   apply(erule_tac
      x="cons_l2 q1 A1"
      in meta_allE)
   apply(clarsimp)
   apply(erule_tac
      x="r1"
      in meta_allE)
   apply(clarsimp)
   apply(simp add: state_adjacency_and_no_l2_before_l3_def)
   apply(clarsimp)
   apply(rename_tac n v r1 e1a q1 q2 A1 A2 w1 A B w2)(*strict*)
   apply(case_tac A)
    apply(rename_tac n v r1 e1a q1 q2 A1 A2 w1 A B w2 q b)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v r1 e1a q1 q2 A1 A2 w1 B w2 q b)(*strict*)
    apply(case_tac w1)
     apply(rename_tac n v r1 e1a q1 q2 A1 A2 w1 B w2 q b)(*strict*)
     apply(clarsimp)
     apply(rename_tac n v e1a q1 A1 B w2 q b)(*strict*)
     apply(erule_tac
      x="[]"
      in allE)
     apply(clarsimp)
    apply(rename_tac n v r1 e1a q1 q2 A1 A2 w1 B w2 q b a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v e1a q1 q2 A1 A2 B w2 q b list)(*strict*)
    apply(erule_tac
      x="cons_l2 q1 A1 # list"
      in allE)
    apply(clarsimp)
   apply(rename_tac n v r1 e1a q1 q2 A1 A2 w1 A B w2 q1a b q2a)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v r1 e1a q1 q2 A1 A2 w1 B w2 q1a b q2a)(*strict*)
   apply(case_tac w1)
    apply(rename_tac n v r1 e1a q1 q2 A1 A2 w1 B w2 q1a b q2a)(*strict*)
    apply(clarsimp)
   apply(rename_tac n v r1 e1a q1 q2 A1 A2 w1 B w2 q1a b q2a a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 A1 A2 B w2 q1a b q2a list)(*strict*)
   apply(erule_tac
      x="cons_l2 q1 A1 # list"
      in allE)
   apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 r w1 q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac n v B1 r1 e1a e2 r w1 q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 A1 A2)(*strict*)
   apply(subgoal_tac "liftB v=w1")
    apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 A1 A2)(*strict*)
    prefer 2
    apply(rule terminal_prefix_eq)
        apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 A1 A2)(*strict*)
        apply (metis setA_liftB)
       apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 A1 A2)(*strict*)
       apply(simp add: setAConcat)
      apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 A1 A2)(*strict*)
      prefer 3
      apply(force)
     apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 A1 A2)(*strict*)
     apply(force)
    apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 A1 A2)(*strict*)
    apply(force)
   apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v r1 e1a r q1 q2 q3 A1 A2)(*strict*)
   apply(erule_tac
      x="v"
      in meta_allE)
   apply(clarsimp)
   apply(subgoal_tac "\<exists>x' y'. liftA x'=[teA (cons_l2   q3 A1)] \<and> liftA y'=r \<and> r1=x'@y'")
    apply(rename_tac n v r1 e1a r q1 q2 q3 A1 A2)(*strict*)
    prefer 2
    apply(rule liftA_decompose)
    apply(clarsimp)
   apply(rename_tac n v r1 e1a r q1 q2 q3 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 x' y')(*strict*)
   apply(erule_tac
      x="cons_l2 q1 A1"
      in meta_allE)
   apply(clarsimp)
   apply(erule_tac
      x="y'"
      in meta_allE)
   apply(clarsimp)
   apply(case_tac x')
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 x' y')(*strict*)
    apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 x' y' a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' list)(*strict*)
   apply(case_tac list)
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' list)(*strict*)
    prefer 2
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' list a lista)(*strict*)
    apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 y')(*strict*)
   apply(simp add: state_adjacency_and_no_l2_before_l3_def)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' w1 A B w2)(*strict*)
   apply(case_tac A)
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' w1 A B w2 q b)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' w1 B w2 q b)(*strict*)
    apply(case_tac w1)
     apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' w1 B w2 q b)(*strict*)
     apply(clarsimp)
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' w1 B w2 q b a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' B w2 q b list)(*strict*)
    apply(case_tac list)
     apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' B w2 q b list)(*strict*)
     apply(clarsimp)
     apply(rename_tac n v e1a q1 q2 A2 B w2 q b)(*strict*)
     apply(erule_tac
      x="[]"
      in allE)
     apply(clarsimp)
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' B w2 q b list a lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 B w2 q b lista)(*strict*)
    apply(erule_tac
      x="cons_l2 q1 A1 # lista"
      in allE)
    apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' w1 A B w2 q1a b q2a)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' w1 B w2 q1a b q2a)(*strict*)
   apply(case_tac w1)
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' w1 B w2 q1a b q2a)(*strict*)
    apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' w1 B w2 q1a b q2a a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' B w2 q1a b q2a list)(*strict*)
   apply(case_tac list)
    apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' B w2 q1a b q2a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 y' B w2 q1a b q2a list a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 A1 A2 B w2 q1a b q2a lista)(*strict*)
   apply(erule_tac
      x="cons_l2 q1 A1 # lista"
      in allE)
   apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a e2 r w1 q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 q4 A1 A2)(*strict*)
  apply(subgoal_tac "liftB v=w1")
   apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 q4 A1 A2)(*strict*)
   prefer 2
   apply(rule terminal_prefix_eq)
       apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 q4 A1 A2)(*strict*)
       apply (metis setA_liftB)
      apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 q4 A1 A2)(*strict*)
      apply(simp add: setAConcat)
     apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 q4 A1 A2)(*strict*)
     prefer 3
     apply(force)
    apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 q4 A1 A2)(*strict*)
    apply(force)
   apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 q4 A1 A2)(*strict*)
   apply(force)
  apply(rename_tac n v B1 r1 e1a r w1 q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v r1 e1a r q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule_tac
      x="v"
      in meta_allE)
  apply(clarsimp)
  apply(subgoal_tac "\<exists>x' y'. liftA x'=[teA (cons_l3   q3 A1 q4)] \<and> liftA y'=r \<and> r1=x'@y'")
   apply(rename_tac n v r1 e1a r q1 q2 q3 q4 A1 A2)(*strict*)
   prefer 2
   apply(rule liftA_decompose)
   apply(clarsimp)
  apply(rename_tac n v r1 e1a r q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 x' y')(*strict*)
  apply(erule_tac
      x="cons_l3 q1 A1 q4"
      in meta_allE)
  apply(clarsimp)
  apply(erule_tac
      x="y'"
      in meta_allE)
  apply(clarsimp)
  apply(case_tac x')
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 x' y')(*strict*)
   apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 x' y' a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' list)(*strict*)
  apply(case_tac list)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' list)(*strict*)
   prefer 2
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' list a lista)(*strict*)
   apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' list)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y')(*strict*)
  apply(simp add: state_adjacency_and_no_l2_before_l3_def)
  apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w1 A B w2)(*strict*)
  apply(case_tac A)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w1 A B w2 q b)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w1 B w2 q b)(*strict*)
   apply(case_tac w1)
    apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w1 B w2 q b)(*strict*)
    apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w1 B w2 q b a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' B w2 q b list)(*strict*)
   apply(case_tac list)
    apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' B w2 q b list)(*strict*)
    apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' B w2 q b list a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 B w2 q b lista)(*strict*)
   apply(erule_tac
      x="cons_l3 q1 A1 q4 # lista"
      in allE)
   apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w1 A B w2 q1a b q2a)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w1 B w2 q1a b q2a)(*strict*)
  apply(case_tac w1)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w1 B w2 q1a b q2a)(*strict*)
   apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w1 B w2 q1a b q2a a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' B w2 q1a b q2a list)(*strict*)
  apply(case_tac B)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' B w2 q1a b q2a list q ba)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w2 q1a b q2a list q ba)(*strict*)
   apply(case_tac list)
    apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w2 q1a b q2a list q ba)(*strict*)
    apply(clarsimp)
    apply(rename_tac n v e1a q1 q2 A2 w2 q1a b q2a q ba)(*strict*)
    apply(erule_tac
      x="[]"
      in allE)
    apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w2 q1a b q2a list q ba a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 w2 q1a b q2a q ba lista)(*strict*)
   apply(erule_tac
      x="cons_l3 q1 A1 q4 # lista"
      in allE)
   apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' B w2 q1a b q2a list q1b ba q2b)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w2 q1a b q2a list q1b ba q2b)(*strict*)
  apply(case_tac list)
   apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w2 q1a b q2a list q1b ba q2b)(*strict*)
   apply(clarsimp)
   apply(rename_tac n v e1a q1 q2 A2 w2 q1a b q2a q1b ba q2b)(*strict*)
   apply(erule_tac
      x="[]"
      in allE)
   apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 y' w2 q1a b q2a list q1b ba q2b a lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac n v e1a q1 q2 q3 q4 A1 A2 w2 q1a b q2a q1b ba q2b lista)(*strict*)
  apply(erule_tac
      x="cons_l3 q1 A1 q4 # lista"
      in allE)
  apply(clarsimp)
  done

lemma equal_extension_for_backtransfer: "
  valid_simple_dpda G
  \<Longrightarrow> valid_cfg (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G) dR
  \<Longrightarrow> epdaH.derivation_initial G dL
  \<Longrightarrow> (\<forall>k \<le> n. \<exists>eL cL eR cR. dL k = Some (pair eL cL) \<and> dR k = Some (pair eR cR) \<and> (case eR of None \<Rightarrow> True | Some eR' \<Rightarrow> eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G) (epda_gamma G) \<longrightarrow> (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and> (\<exists>w. set w \<subseteq> epda_gamma G \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w))
  \<Longrightarrow> (\<forall>k. m \<le> k \<and> k \<le> n \<longrightarrow> (\<exists>eR cR q A q'. dR k = Some (pair eR cR) \<and> cons_l3 q A q' \<in> setA (cfg_conf cR)))
  \<Longrightarrow> dL m = Some (pair eL cL)
  \<Longrightarrow> dR m = Some (pair eR cR)
  \<Longrightarrow> set w \<subseteq> epda_gamma G
  \<Longrightarrow> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w
  \<Longrightarrow> m \<le> k
  \<Longrightarrow> k \<le> n
  \<Longrightarrow> dL k = Some (pair eLk cLk)
  \<Longrightarrow> dR k = Some (pair eRk cRk)
  \<Longrightarrow> cLk = F_SDPDA_TO_CFG_STD__configuration_basic_RL cRk w"
  apply(induct "k-m" arbitrary: k eLk cLk eRk cRk)
   apply(rename_tac k eLk cLk eRk cRk)(*strict*)
   apply(clarsimp)
  apply(rename_tac x k eLk cLk eRk cRk)(*strict*)
  apply(case_tac k)
   apply(rename_tac x k eLk cLk eRk cRk)(*strict*)
   apply(force)
  apply(rename_tac x k eLk cLk eRk cRk nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac x eLk cLk eRk cRk nat)(*strict*)
  apply(rename_tac k)
  apply(rename_tac x eLk cLk eRk cRk k)(*strict*)
  apply(erule_tac x="k" in meta_allE)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   apply(rename_tac x eLk cLk eRk cRk k)(*strict*)
   prefer 2
   apply(rule_tac
      n="k"
      and m="Suc k"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac x eLk cLk eRk cRk k)(*strict*)
     apply(rule_tac d="dL" in epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac x eLk cLk eRk cRk k)(*strict*)
    apply(force)
   apply(rename_tac x eLk cLk eRk cRk k)(*strict*)
   apply(force)
  apply(rename_tac x eLk cLk eRk cRk k)(*strict*)
  apply(clarsimp)
  apply(rename_tac x cLk eRk cRk k e1 e2 c1)(*strict*)
  apply(simp add: epdaH_step_relation_def suffix_def)
  apply(subgoal_tac "X" for X)
   apply(rename_tac x cLk eRk cRk k e1 e2 c1)(*strict*)
   prefer 2
   apply(rule_tac
      n="k"
      and m="Suc k"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac x cLk eRk cRk k e1 e2 c1)(*strict*)
     apply(rule_tac d="dR" in cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac x cLk eRk cRk k e1 e2 c1)(*strict*)
    apply(force)
   apply(rename_tac x cLk eRk cRk k e1 e2 c1)(*strict*)
   apply(force)
  apply(rename_tac x cLk eRk cRk k e1 e2 c1)(*strict*)
  apply(clarsimp)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(case_tac e2a)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa prod_lhsa prod_rhsa)(*strict*)
  apply(rename_tac A r)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa A r)(*strict*)
  apply(case_tac c1)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa A r epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac q1 h1 s1)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa A r q1 h1 s1)(*strict*)
  apply(case_tac cLk)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa A r q1 h1 s1 epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac q2 h2 s2)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa A r q1 h1 s1 q2 h2 s2)(*strict*)
  apply(case_tac c1a)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa A r q1 h1 s1 q2 h2 s2 cfg_confa)(*strict*)
  apply(rename_tac w1)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa A r q1 h1 s1 q2 h2 s2 w1)(*strict*)
  apply(case_tac cRk)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa A r q1 h1 s1 q2 h2 s2 w1 cfg_confa)(*strict*)
  apply(rename_tac w2)
  apply(rename_tac x cLk cRk k e1 e2 c1 e1a e2a c1a wa A r q1 h1 s1 q2 h2 s2 w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra)(*strict*)
  apply(erule_tac x="e1" in meta_allE)
  apply(erule_tac x="\<lparr>epdaH_conf_state = edge_src e2, epdaH_conf_history = h1,
              epdaH_conf_stack = edge_pop e2 @ wa\<rparr>" in meta_allE)
  apply(erule_tac x="e1a" in meta_allE)
  apply(erule_tac x="\<lparr>cfg_conf = l @ teA A # ra\<rparr>" in meta_allE)
  apply(clarsimp)
  apply(erule meta_impE)
   apply(rename_tac x k e1 e2 e1a wa A r h1 l ra)(*strict*)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra)(*strict*)
  apply(erule meta_impE)
   apply(rename_tac x k e1 e2 e1a wa A r h1 l ra)(*strict*)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra)(*strict*)
  apply(erule_tac x="k" in allE')
  apply(erule_tac x="k" in allE')
  apply(erule_tac x="Suc k" in allE)
  apply(erule_tac x="Suc k" in allE)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' waa wb)(*strict*)
  apply(subgoal_tac "waa=w")
   apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' waa wb)(*strict*)
   prefer 2
   apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' waa wb)(*strict*)
  apply(clarify)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb)(*strict*)
  apply(subgoal_tac "wb=w")
   apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb)(*strict*)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb)(*strict*)
  apply(subgoal_tac "(\<exists>q Aa q'. cons_l3 q Aa q' \<in> setA (l @ teA A # ra))")
   apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb)(*strict*)
   prefer 2
   apply(case_tac "m\<le>k")
    apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb)(*strict*)
    apply(force)
   apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb)(*strict*)
   apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb qa Aaa q'a)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= l")
   apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb qa Aaa q'a)(*strict*)
   prefer 2
   apply(rule_tac x="filterB l" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r h1 l ra q Aa q' wb qa Aaa q'a)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r h1 ra q Aa q' wb qa Aaa q'a waa)(*strict*)
  apply(simp add: setAConcat)
  apply(thin_tac "setA (liftB waa) = {}")
  apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(fold event_stack_separation_def)
  apply(fold stack_def)
  apply(thin_tac "case e1a of None \<Rightarrow> True
       | Some eR' \<Rightarrow>
           eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G) (epda_gamma G) \<longrightarrow>
           (case e1 of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')")
  apply(subgoal_tac "Suc x+m=Suc k")
   apply(rename_tac x k e1 e2 e1a wa A r h1 ra q Aa q' wb qa Aaa q'a waa)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r h1 ra q Aa q' wb qa Aaa q'a waa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa)(*strict*)
   prefer 2
   apply(rule_tac n="k" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa)(*strict*)
      apply(force)
     apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa)(*strict*)
     apply(force)
    apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa)(*strict*)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2)(*strict*)
   prefer 2
   apply(rule_tac n="Suc k" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2)(*strict*)
      apply(force)
     apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2)(*strict*)
     apply(force)
    apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2)(*strict*)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2 w1a w2a)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= w1")
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2 w1a w2a)(*strict*)
   prefer 2
   apply(rule_tac x="filterB w1" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w1 w2 w1a w2a)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w2 w1a w2a wc)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= w1a")
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w2 w1a w2a wc)(*strict*)
   prefer 2
   apply(rule_tac x="filterB w1a" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w2 w1a w2a wc)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w2 w2a wc wd)(*strict*)
  apply(subgoal_tac "\<exists>w. liftA w= w2a")
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w2 w2a wc wd)(*strict*)
   prefer 2
   apply(rule_tac x="filterA w2a" in exI)
   apply(rule sym)
   apply(rule setB_empty_then_liftA_vs_filterA)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w2 w2a wc wd)(*strict*)
  apply(subgoal_tac "\<exists>w. liftA w= w2")
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w2 w2a wc wd)(*strict*)
   prefer 2
   apply(rule_tac x="filterA w2" in exI)
   apply(rule sym)
   apply(rule setB_empty_then_liftA_vs_filterA)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa w2 w2a wc wd)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa wc wd we wf)(*strict*)
  apply(thin_tac "setA (liftB wd) = {}")
  apply(thin_tac "setB (liftA we) = {}")
  apply(thin_tac "setA (liftB wc) = {}")
  apply(thin_tac "setB (liftA wf) = {}")
  apply(thin_tac "(THE w. \<exists>v. liftB wc @ liftA wf = liftB w @ liftA v) @
       option_to_list (edge_event e2) =
       (THE w. \<exists>v. liftB wd @ liftA we = liftB w @ liftA v)")
  apply(subgoal_tac "waa=wc")
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa wc wd we wf)(*strict*)
   prefer 2
   apply (metis equal_left_liftB)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a waa wc wd we wf)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a wc wd we wf)(*strict*)
  apply(case_tac wf)
   apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a wc wd we wf)(*strict*)
   apply(force)
  apply(rename_tac x k e1 e2 e1a wa A r ra q Aa q' wb qa Aaa q'a wc wd we wf a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa r q Aa q' wb qa Aaa q'a wc wd we a list)(*strict*)
  apply(subgoal_tac "event_stack_separation (liftB wd @ liftA we) = we")
   apply(rename_tac x k e1 e2 e1a wa r q Aa q' wb qa Aaa q'a wc wd we a list)(*strict*)
   prefer 2
   apply(rule_tac w="wd" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac x k e1 e2 e1a wa r q Aa q' wb qa Aaa q'a wc wd we a list)(*strict*)
  apply(clarsimp)
  apply(thin_tac "event_stack_separation (liftB wd @ liftA we) = we")
  apply(subgoal_tac "event_stack_separation (liftB wc @ teA a # liftA list) = a#list")
   apply(rename_tac x k e1 e2 e1a wa r q Aa q' wb qa Aaa q'a wc wd we a list)(*strict*)
   prefer 2
   apply(rule_tac w="wc" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac x k e1 e2 e1a wa r q Aa q' wb qa Aaa q'a wc wd we a list)(*strict*)
  apply(clarsimp)
  apply(thin_tac "event_stack_separation (liftB wc @ teA a # liftA list) = a#list")
  apply(case_tac e2)
  apply(rename_tac x k e1 e2 e1a wa r q Aa q' wb qa Aaa q'a wc wd we a list edge_srca edge_event edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac qs r po pu qt)
  apply(rename_tac x k e1 e2 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list qs r po pu qt)(*strict*)
  apply(subgoal_tac "\<exists>x. po=[x]")
   apply(rename_tac x k e1 e2 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list qs r po pu qt)(*strict*)
   prefer 2
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(clarsimp)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r po pu)(*strict*)
   apply(erule_tac x="\<lparr>edge_src = qs, edge_event = r, edge_pop = po, edge_push = pu, edge_trg = qt\<rparr>" for qs qt in ballE)
    apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r po pu)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r po pu)(*strict*)
   apply(erule_tac x="\<lparr>edge_src = qs, edge_event = r, edge_pop = po, edge_push = pu, edge_trg = qt\<rparr>" for qs qt in ballE)
    apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r po pu)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r po pu)(*strict*)
   apply(case_tac po)
    apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r po pu)(*strict*)
    apply(force)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r po pu aa lista)(*strict*)
   apply(clarsimp)
  apply(rename_tac x k e1 e2 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list qs r po pu qt)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa)(*strict*)
  apply(subgoal_tac "state_adjacency_and_no_l2_before_l3 (a#list)")
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa)(*strict*)
   prefer 2
   apply(rule_tac n="k" and G="F_SDPDA_TO_CFG_STD G" and d="dR" in cfgLM_reachable_have_state_adjacency_and_no_l2_before_l3)
       apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa)(*strict*)
       apply(force)
      apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa)(*strict*)
      apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
      apply(rule cfg_sub_reflexive)
     apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa)(*strict*)
     apply(force)
    apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa)(*strict*)
    apply(force)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa)(*strict*)
   apply(force)
  apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa)(*strict*)
  apply(case_tac we)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa)(*strict*)
   apply(clarsimp)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a list r pu xa)(*strict*)
   apply(rule_tac xs="list" in rev_cases)
    apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a list r pu xa)(*strict*)
    prefer 2
    apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a list r pu xa ys y)(*strict*)
    apply(clarsimp)
    apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a r pu xa ys y)(*strict*)
    apply(rule_tac xs="wd" in rev_cases)
     apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a r pu xa ys y)(*strict*)
     prefer 2
     apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a r pu xa ys y ysa ya)(*strict*)
     apply(clarsimp)
     apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc a r pu xa ys y ysa ya)(*strict*)
     apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
    apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a r pu xa ys y)(*strict*)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a list r pu xa)(*strict*)
   apply(clarsimp)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd r pu xa)(*strict*)
   apply (metis setA_liftB_empty setA_setmp_concat_2 empty_iff empty_subsetI)
  apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa aa lista)(*strict*)
  apply(subgoal_tac "state_adjacency_and_no_l2_before_l3 (aa # lista)")
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa aa lista)(*strict*)
   prefer 2
   apply(rule_tac n="Suc k" and G="F_SDPDA_TO_CFG_STD G" and d="dR" in cfgLM_reachable_have_state_adjacency_and_no_l2_before_l3)
       apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa aa lista)(*strict*)
       apply(force)
      apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa aa lista)(*strict*)
      apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
      apply(rule cfg_sub_reflexive)
     apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa aa lista)(*strict*)
     apply(force)
    apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa aa lista)(*strict*)
    apply(force)
   apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa aa lista)(*strict*)
   apply(force)
  apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd we a list r pu xa aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac x k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a list r pu xa aa lista)(*strict*)
  apply(thin_tac "Suc x = Suc k - m")
  apply(clarsimp)
  apply(rename_tac k e1 e1a wa ra q Aa q' wb qa Aaa q'a wc wd a list r pu xa aa lista)(*strict*)
  apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 B wB r pu po A wA)
  apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 B wB r pu po A wA)(*strict*)
  apply(case_tac B)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 B wB r pu po A wA state stacka)(*strict*)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA state stacka)(*strict*)
   apply(subgoal_tac "wB=[]")
    apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA state stacka)(*strict*)
    apply(clarsimp)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA state stacka)(*strict*)
   apply(thin_tac "state_adjacency_and_no_l2_before_l3 (A # wA)")
   apply(case_tac wB)
    apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA state stacka)(*strict*)
    apply(force)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA state stacka a list)(*strict*)
   apply(simp add: state_adjacency_and_no_l2_before_l3_def)
   apply(erule_tac x="[]" in allE)
   apply(clarsimp)
  apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 B wB r pu po A wA state1 stacka state2)(*strict*)
  apply(case_tac "\<lparr>prod_lhs = B, prod_rhs = rhs\<rparr>
       \<in> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G) (epda_gamma G) ")
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 B wB r pu po A wA state1 stacka state2)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def)
  apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 B wB r pu po A wA state1 stacka state2)(*strict*)
  apply(clarsimp)
  apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA state1 stacka state2)(*strict*)
  apply(thin_tac "\<lparr>prod_lhs = cons_l3 state1 stacka state2, prod_rhs = rhs\<rparr>
       \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G) (epda_gamma G)")
  apply(rename_tac qB B qB')
  apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA qB B qB')(*strict*)
  apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
  apply(erule_tac P="\<lparr>prod_lhs = cons_l3 qB B qB', prod_rhs = rhs\<rparr>
       \<in> F_SDPDA_TO_CFG_STD__edges_l3_read
           \<lparr>edge_src = qB, edge_event = r, edge_pop = [po], edge_push = pu,
              edge_trg = case A of cons_l2 q A \<Rightarrow> q | cons_l3 q A q' \<Rightarrow> q\<rparr>
           (epda_states G) \<and>
       (\<exists>y. r = Some y)" in disjE)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA qB B qB')(*strict*)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB' y)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB qB' y)(*strict*)
   apply(subgoal_tac "\<alpha>1@[y]=\<alpha>2")
    apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB qB' y)(*strict*)
    prefer 2
    apply(rule_tac ?w2.0="(cons_l3   (case A of cons_l2 q A \<Rightarrow> q | cons_l3 q A q' \<Rightarrow> q) po qB') # wB" and ?w4.0="A # wA"  in liftB_liftA_eq_liftB_liftA)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB qB' y)(*strict*)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 wB pu po A wA qB qB' y)(*strict*)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(subgoal_tac "wB=wA")
    apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 wB pu po A wA qB qB' y)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 wB pu po A wA qB qB' y)(*strict*)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 pu po A wA qB qB' y)(*strict*)
   apply(subgoal_tac "pu=[po]")
    apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 pu po A wA qB qB' y)(*strict*)
    prefer 2
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(clarsimp)
    apply(erule_tac x=" \<lparr>edge_src = qB, edge_event = Some y, edge_pop = [po],
                           edge_push = pu,
                           edge_trg = case A of cons_l2 q A \<Rightarrow> q | cons_l3 q A q' \<Rightarrow> q\<rparr>" in  ballE)
     apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 pu po A wA qB qB' y)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 pu po A wA qB qB' y)(*strict*)
    apply(erule_tac x=" \<lparr>edge_src = qB, edge_event = Some y, edge_pop = [po],
                           edge_push = pu,
                           edge_trg = case A of cons_l2 q A \<Rightarrow> q | cons_l3 q A q' \<Rightarrow> q\<rparr>" in  ballE)
     apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 pu po A wA qB qB' y)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 pu po A wA qB qB' y)(*strict*)
    apply(case_tac pu)
     apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 pu po A wA qB qB' y)(*strict*)
     apply(force)
    apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 pu po A wA qB qB' y a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 pu po A wA qB qB' y)(*strict*)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 po A wA qB qB' y)(*strict*)
   apply(simp add: stack_def)
  apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA qB B qB')(*strict*)
  apply(erule_tac P="\<lparr>prod_lhs = cons_l3 qB B qB', prod_rhs = rhs\<rparr>
       \<in> F_SDPDA_TO_CFG_STD__edges_l3_pop
           \<lparr>edge_src = qB, edge_event = r, edge_pop = [po], edge_push = pu,
              edge_trg = case A of cons_l2 q A \<Rightarrow> q | cons_l3 q A q' \<Rightarrow> q\<rparr> \<and>
       pu = []" in disjE)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA qB B qB')(*strict*)
   prefer 2
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB')(*strict*)
   apply(subgoal_tac "\<exists>y. pu=[y,po]")
    apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB')(*strict*)
    prefer 2
    apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(clarsimp)
    apply(erule_tac x="\<lparr>edge_src = qB, edge_event = None, edge_pop = [po],
                           edge_push = pu,
                           edge_trg = case A of cons_l2 q A \<Rightarrow> q | cons_l3 q A q' \<Rightarrow> q\<rparr>" in  ballE)
     apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB')(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB')(*strict*)
    apply(erule_tac x="\<lparr>edge_src = qB, edge_event = None, edge_pop = [po],
                           edge_push = pu,
                           edge_trg = case A of cons_l2 q A \<Rightarrow> q | cons_l3 q A q' \<Rightarrow> q\<rparr>" in  ballE)
     apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB')(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB')(*strict*)
    apply(case_tac pu)
     apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB')(*strict*)
     apply(force)
    apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB' a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB pu po A wA qB B qB')(*strict*)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB po A wA qB B qB' y)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB po A wA qB qB' y qs)(*strict*)
   apply(subgoal_tac "\<alpha>1=\<alpha>2")
    apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB po A wA qB qB' y qs)(*strict*)
    prefer 2
    apply(rule_tac ?w2.0=" (cons_l3   (case A of cons_l2 q A \<Rightarrow> q | cons_l3 q A q' \<Rightarrow> q) y qs) #
        (cons_l3 qs po qB') #  wB" and ?w4.0="A # wA"  in liftB_liftA_eq_liftB_liftA)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB po A wA qB qB' y qs)(*strict*)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>2 wB po A wA qB qB' y qs)(*strict*)
   apply(case_tac wA)
    apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>2 wB po A wA qB qB' y qs)(*strict*)
    apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>2 wB po A wA qB qB' y qs a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>2 wB po A qB qB' y qs list)(*strict*)
   apply(subgoal_tac "list=wB")
    apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>2 wB po A qB qB' y qs list)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(rule sym)
    apply(force)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>2 wB po A qB qB' y qs list)(*strict*)
   apply(clarify)
   apply(clarsimp)
   apply(rename_tac k eLk eRk wX qD D qD' wb qC C qC' \<alpha>2 wB po A qB qB' y qs)(*strict*)
   apply(simp add: stack_def)
  apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA qB B qB')(*strict*)
  apply(subgoal_tac "pu=[]")
   apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA qB B qB')(*strict*)
   prefer 2
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
  apply(rename_tac k eLk eRk wX rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r pu po A wA qB B qB')(*strict*)
  apply(clarsimp)
  apply(rename_tac k eLk eRk rhs qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r po A wA qB B qB')(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def)
  apply(clarsimp)
  apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r po A wA qB)(*strict*)
  apply(subgoal_tac "\<alpha>1=\<alpha>2")
   apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r po A wA qB)(*strict*)
   prefer 2
   apply(rule_tac ?w2.0="wB" and ?w4.0="A # wA"  in liftB_liftA_eq_liftB_liftA)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>1 \<alpha>2 wB r po A wA qB)(*strict*)
  apply(clarsimp)
  apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>2 wB r po A wA qB)(*strict*)
  apply(case_tac wB)
   apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>2 wB r po A wA qB)(*strict*)
   apply(clarsimp)
  apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>2 wB r po A wA qB a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>2 r po A wA qB list)(*strict*)
  apply(subgoal_tac "list=wA")
   apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>2 r po A wA qB list)(*strict*)
   prefer 2
   apply(rule liftA_inj)
   apply(force)
  apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>2 r po A wA qB list)(*strict*)
  apply(clarify)
  apply(clarsimp)
  apply(rename_tac k eLk eRk qD D qD' wb qC C qC' \<alpha>2 r po A wA qB)(*strict*)
  apply(simp add: stack_def)
  done

lemma stack_remains_in_cfgLM_derivation: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT G k = Some Gopt
  \<Longrightarrow> valid_cfg Gopt
  \<Longrightarrow> valid_cfg (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfg_sub Gopt (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G) d
  \<Longrightarrow> d (Suc (Suc (Suc (k1 + (k2 + k3))))) = Some (pair (Some e2a) \<lparr>cfg_conf = liftB wa\<rparr>)
  \<Longrightarrow> d (Suc k1) = Some (pair e1 \<lparr>cfg_conf = liftB v1 @ teA (cons_l3 qA A qA') # liftA s1\<rparr>)
  \<Longrightarrow> \<forall>x < Suc k2. \<forall>e c. d (Suc (k1 + x)) = Some (pair e c) \<longrightarrow> (\<forall>w1 w2. cfg_conf c = liftB w1 @ liftA w2 \<longrightarrow> \<not> length w2 < Suc (length s1))
  \<Longrightarrow> Suc (length s2) = length s1
  \<Longrightarrow> d (Suc (Suc (k1 + (k2 + k3)))) = Some (pair e1a c1)
  \<Longrightarrow> set wb \<subseteq> epda_gamma G
  \<Longrightarrow> ka \<le> k2
  \<Longrightarrow> d (Suc (k1 + ka)) = Some (pair eR cR)
  \<Longrightarrow> (stack (event_stack_separation (cfg_conf cR)) @ wb) \<sqsupseteq> (A # stack s1 @ wb)"
  apply(induct ka arbitrary: eR cR)
   apply(rename_tac eR cR)(*strict*)
   apply(clarsimp)
   apply(simp add: suffix_def)
   apply(rule_tac t="event_stack_separation (liftB v1 @ teA (cons_l3   qA A qA') # liftA s1)" and s="cons_l3 qA A qA'#s1" in ssubst)
    apply(rule_tac w="v1" in event_stack_separation_XX2)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(simp add: stack_def)
  apply(rename_tac ka eR cR)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   apply(rename_tac ka eR cR)(*strict*)
   prefer 2
   apply(rule_tac
      n="(Suc (k1 + ka))"
      and m="Suc (Suc (k1 + ka))"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac ka eR cR)(*strict*)
     apply(rule_tac d="d" in cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac ka eR cR)(*strict*)
    apply(force)
   apply(rename_tac ka eR cR)(*strict*)
   apply(force)
  apply(rename_tac ka eR cR)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka cR e1b e2 c1a)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac ka cR e1b e2 c1a l r)(*strict*)
  apply(case_tac c1a)
  apply(rename_tac ka cR e1b e2 c1a l r cfg_confa)(*strict*)
  apply(case_tac cR)
  apply(rename_tac ka cR e1b e2 c1a l r cfg_confa cfg_confaa)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b e2 l r)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac ka e1b e2 l r)(*strict*)
   prefer 2
   apply(rule_tac n="(Suc (k1 + ka))" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac ka e1b e2 l r)(*strict*)
      apply(force)
     apply(rename_tac ka e1b e2 l r)(*strict*)
     apply(force)
    apply(rename_tac ka e1b e2 l r)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac ka e1b e2 l r)(*strict*)
   apply(force)
  apply(rename_tac ka e1b e2 l r)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac ka e1b e2 l r)(*strict*)
   prefer 2
   apply(rule_tac n="Suc(Suc (k1 + ka))" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac ka e1b e2 l r)(*strict*)
      apply(force)
     apply(rename_tac ka e1b e2 l r)(*strict*)
     apply(force)
    apply(rename_tac ka e1b e2 l r)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac ka e1b e2 l r)(*strict*)
   apply(force)
  apply(rename_tac ka e1b e2 l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b e2 l r w1 w1a w2 w2a)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= w1a")
   apply(rename_tac ka e1b e2 l r w1 w1a w2 w2a)(*strict*)
   prefer 2
   apply(rule_tac x="filterB w1a" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac ka e1b e2 l r w1 w1a w2 w2a)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b e2 l r w1 w2 w2a w)(*strict*)
  apply(thin_tac "setA (liftB w) = {}")
  apply(subgoal_tac "\<exists>w. liftA w= w2a")
   apply(rename_tac ka e1b e2 l r w1 w2 w2a w)(*strict*)
   prefer 2
   apply(rule_tac x="filterA w2a" in exI)
   apply(rule sym)
   apply(rule setB_empty_then_liftA_vs_filterA)
   apply(force)
  apply(rename_tac ka e1b e2 l r w1 w2 w2a w)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b e2 l r w1 w2 w waa)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= w1")
   apply(rename_tac ka e1b e2 l r w1 w2 w waa)(*strict*)
   prefer 2
   apply(rule_tac x="filterB w1" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac ka e1b e2 l r w1 w2 w waa)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b e2 l r w2 w waa wba)(*strict*)
  apply(subgoal_tac "\<exists>w. liftA w= w2")
   apply(rename_tac ka e1b e2 l r w2 w waa wba)(*strict*)
   prefer 2
   apply(rule_tac x="filterA w2" in exI)
   apply(rule sym)
   apply(rule setB_empty_then_liftA_vs_filterA)
   apply(force)
  apply(rename_tac ka e1b e2 l r w2 w waa wba)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b e2 l r w waa wba wc)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= l")
   apply(rename_tac ka e1b e2 l r w waa wba wc)(*strict*)
   prefer 2
   apply(rule_tac x="filterB l" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac ka e1b e2 l r w waa wba wc)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b e2 r w waa wba wc wd)(*strict*)
  apply(thin_tac "setA (liftB wba) = {}")
  apply(thin_tac "setB (liftA wc) = {}")
  apply(thin_tac "setB (liftA waa) = {}")
  apply(thin_tac "setA (liftB wd) = {}")
  apply(subgoal_tac "wd=wba")
   apply(rename_tac ka e1b e2 r w waa wba wc wd)(*strict*)
   prefer 2
   apply (metis equal_left_liftB)
  apply(rename_tac ka e1b e2 r w waa wba wc wd)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b e2 r w waa wba wc)(*strict*)
  apply(case_tac wc)
   apply(rename_tac ka e1b e2 r w waa wba wc)(*strict*)
   apply(force)
  apply(rename_tac ka e1b e2 r w waa wba wc a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
  apply(rule_tac t="event_stack_separation (liftB w @ liftA waa)" and s="waa" in ssubst)
   apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
   apply(rule_tac w="w" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
  apply(erule_tac x="e1b" in meta_allE)
  apply(clarsimp)
  apply(erule_tac x="\<lparr>cfg_conf = liftB wba @ teA (prod_lhs e2) # liftA list\<rparr>" in meta_allE)
  apply(clarsimp)
  apply(subgoal_tac "event_stack_separation (liftB wba @ teA (prod_lhs e2) # liftA list) = (prod_lhs e2) #  list")
   apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
   prefer 2
   apply(rule_tac w="wba" in event_stack_separation_XX2)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
  apply(clarsimp)
  apply(thin_tac "event_stack_separation (liftB wba @ teA (prod_lhs e2) # liftA list) =
       prod_lhs e2 # list")
  apply(erule_tac x="ka" in allE')
  apply(erule_tac x="Suc ka" in allE)
  apply(clarsimp)
  apply(erule_tac x="wba" in allE)
  apply(erule_tac x="w" in allE)
  apply(clarsimp)
  apply(erule_tac x="prod_lhs e2 #  list" in allE)
  apply(erule_tac x="waa" in allE)
  apply(clarsimp)
  apply(subgoal_tac "length list \<ge> length s1")
   apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
  apply(subgoal_tac "length waa > length s1")
   apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
   prefer 2
   apply(rule_tac G="G" in sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
   apply(rule cfg_sub_reflexive)
  apply(rename_tac ka e1b e2 w waa wba list)(*strict*)
  apply(simp add: LR1ProdForm_def)
  apply(case_tac e2)
  apply(rename_tac ka e1b e2 w waa wba list prod_lhsa prod_rhsa)(*strict*)
  apply(rename_tac X rhs)
  apply(rename_tac ka e1b e2 w waa wba list X rhs)(*strict*)
  apply(erule_tac x="e2" in ballE)
   apply(rename_tac ka e1b e2 w waa wba list X rhs)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac ka e1b e2 w waa wba list X rhs)(*strict*)
  apply(erule disjE)
   apply(rename_tac ka e1b e2 w waa wba list X rhs)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w waa wba list X)(*strict*)
   apply(subgoal_tac "wba=w")
    apply(rename_tac ka e1b w waa wba list X)(*strict*)
    prefer 2
    apply(rule liftB_liftA_eq_liftB_liftA)
    apply(force)
   apply(rename_tac ka e1b w waa wba list X)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w waa list X)(*strict*)
   apply(subgoal_tac "list=waa")
    apply(rename_tac ka e1b w waa list X)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac ka e1b w waa list X)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w waa X)(*strict*)
   apply(simp add: suffix_def stack_def)
   apply(rename_tac ka e1aa w waa X)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1aa w waa X c)(*strict*)
   apply(case_tac c)
    apply(rename_tac ka e1aa w waa X c)(*strict*)
    prefer 2
    apply(rename_tac ka e1aa w waa X c a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac ka e1aa w waa X c)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1aa w waa X)(*strict*)
   apply(subgoal_tac "length waa=length s1")
    apply(rename_tac ka e1aa w waa X)(*strict*)
    apply(force)
   apply(rename_tac ka e1aa w waa X)(*strict*)
   apply(rule map_eq_imp_length_eq)
   apply(force)
  apply(rename_tac ka e1b e2 w waa wba list X rhs)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b w waa wba list X rhs b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac ka e1b w waa wba list X rhs b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w waa wba list b q1 q2 A1)(*strict*)
   apply(subgoal_tac "wba@[b]=w")
    apply(rename_tac ka e1b w waa wba list b q1 q2 A1)(*strict*)
    prefer 2
    apply(rule_tac ?w2.0="cons_l2 q2 A1#list" in liftB_liftA_eq_liftB_liftA)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac ka e1b w waa wba list b q1 q2 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b waa wba list b q1 q2 A1)(*strict*)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(case_tac waa)
    apply(rename_tac ka e1b waa wba list b q1 q2 A1)(*strict*)
    apply(force)
   apply(rename_tac ka e1b waa wba list b q1 q2 A1 a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b wba list b q1 q2 A1 lista)(*strict*)
   apply(subgoal_tac "list=lista")
    apply(rename_tac ka e1b wba list b q1 q2 A1 lista)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac ka e1b wba list b q1 q2 A1 lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b wba b q1 q2 A1 lista)(*strict*)
   apply(simp add: suffix_def stack_def)
  apply(rename_tac ka e1b w waa wba list X rhs b q1 q2 q3 q4 A1)(*strict*)
  apply(erule disjE)
   apply(rename_tac ka e1b w waa wba list X rhs b q1 q2 q3 q4 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w waa wba list b q1 q2 q3 A1)(*strict*)
   apply(subgoal_tac "wba@[b]=w")
    apply(rename_tac ka e1b w waa wba list b q1 q2 q3 A1)(*strict*)
    prefer 2
    apply(rule_tac ?w2.0="cons_l3 q3 A1 q2#list" in liftB_liftA_eq_liftB_liftA)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac ka e1b w waa wba list b q1 q2 q3 A1)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b waa wba list b q1 q2 q3 A1)(*strict*)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(case_tac waa)
    apply(rename_tac ka e1b waa wba list b q1 q2 q3 A1)(*strict*)
    apply(force)
   apply(rename_tac ka e1b waa wba list b q1 q2 q3 A1 a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b wba list b q1 q2 q3 A1 lista)(*strict*)
   apply(subgoal_tac "list=lista")
    apply(rename_tac ka e1b wba list b q1 q2 q3 A1 lista)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac ka e1b wba list b q1 q2 q3 A1 lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b wba b q1 q2 q3 A1 lista)(*strict*)
   apply(simp add: suffix_def stack_def)
  apply(rename_tac ka e1b w waa wba list X rhs b q1 q2 q3 q4 A1)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
  apply(subgoal_tac "state_adjacency_and_no_l2_before_l3 ( (cons_l3 qA A qA') # s1)")
   apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
   prefer 2
   apply(rule_tac n="Suc k1" and G="F_SDPDA_TO_CFG_STD G" and d="d" in cfgLM_reachable_have_state_adjacency_and_no_l2_before_l3)
       apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
       apply(force)
      apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
      apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
      apply(rule cfg_sub_reflexive)
     apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
     apply(force)
    apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
    apply(force)
   apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
   apply(force)
  apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
  apply(subgoal_tac "state_adjacency_and_no_l2_before_l3 (X#list)")
   apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
   prefer 2
   apply(rule_tac n="Suc (k1+ka)" and G="F_SDPDA_TO_CFG_STD G" and d="d" in cfgLM_reachable_have_state_adjacency_and_no_l2_before_l3)
       apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
       apply(force)
      apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
      apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
      apply(rule cfg_sub_reflexive)
     apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
     apply(force)
    apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
    apply(force)
   apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
   apply(force)
  apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w waa wba list q1 q2 A1 A2)(*strict*)
   apply(subgoal_tac "wba=w")
    apply(rename_tac ka e1b w waa wba list q1 q2 A1 A2)(*strict*)
    prefer 2
    apply(rule_tac ?w2.0="cons_l2 q2 A2#list" in liftB_liftA_eq_liftB_liftA)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac ka e1b w waa wba list q1 q2 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w waa list q1 q2 A1 A2)(*strict*)
   apply(case_tac waa)
    apply(rename_tac ka e1b w waa list q1 q2 A1 A2)(*strict*)
    apply(force)
   apply(rename_tac ka e1b w waa list q1 q2 A1 A2 a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w list q1 q2 A1 A2 lista)(*strict*)
   apply(subgoal_tac "list=lista")
    apply(rename_tac ka e1b w list q1 q2 A1 A2 lista)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac ka e1b w list q1 q2 A1 A2 lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w q1 q2 A1 A2 lista)(*strict*)
   apply(simp add: suffix_def stack_def)
   apply(clarsimp)
   apply(rename_tac ka e1b w q1 q2 A1 A2 lista c)(*strict*)
   apply(case_tac c)
    apply(rename_tac ka e1b w q1 q2 A1 A2 lista c)(*strict*)
    prefer 2
    apply(rename_tac ka e1b w q1 q2 A1 A2 lista c a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac ka e1b w q1 q2 A1 A2 lista c)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w q1 q2 A2 lista)(*strict*)
   apply(subgoal_tac "length lista=length s1")
    apply(rename_tac ka e1b w q1 q2 A2 lista)(*strict*)
    prefer 2
    apply(rule map_eq_imp_length_eq)
    apply(force)
   apply(rename_tac ka e1b w q1 q2 A2 lista)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "\<lparr>prod_lhs = cons_l2 q1 A, prod_rhs = [teA (cons_l2   q2 A2)]\<rparr> \<in> F_SDPDA_TO_CFG_STD__edges_l3 G \<or>
       \<lparr>prod_lhs = cons_l2 q1 A, prod_rhs = [teA (cons_l2   q2 A2)]\<rparr>
       \<in> F_SDPDA_TO_CFG_STD__edges_l2 G ")
    apply(rename_tac ka e1b w q1 q2 A2 lista)(*strict*)
    prefer 2
    apply(simp add: valid_cfg_def F_SDPDA_TO_CFG_STD_def )
   apply(rename_tac ka e1b w q1 q2 A2 lista)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_def F_SDPDA_TO_CFG_STD__edges_l2_def)
   apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
   apply(erule disjE)
    apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
    apply(case_tac "edge_event e")
     apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
     apply(clarsimp)
    apply(rename_tac ka e1aa w q1 q2 A2 lista e a)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_read_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
   apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
   apply(erule disjE)
    apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
    apply(case_tac "edge_push e")
     apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
     prefer 2
     apply(rename_tac ka e1aa w q1 q2 A2 lista e a list)(*strict*)
     apply(clarsimp)
    apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_read_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
   apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
   apply(erule disjE)
    apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
    apply(case_tac "edge_push e")
     apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
     apply(clarsimp)
    apply(rename_tac ka e1aa w q1 q2 A2 lista e a list)(*strict*)
    apply(clarsimp)
    apply(case_tac "edge_event e")
     apply(rename_tac ka e1aa w q1 q2 A2 lista e a list)(*strict*)
     prefer 2
     apply(rename_tac ka e1aa w q1 q2 A2 lista e a list aa)(*strict*)
     apply(clarsimp)
    apply(rename_tac ka e1aa w q1 q2 A2 lista e a list)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_read_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
   apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
   apply(erule disjE)
    apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
    apply(clarsimp)
    apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
    apply(case_tac "edge_event e")
     apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
     apply(clarsimp)
    apply(rename_tac ka e1aa w q1 q2 A2 lista e a)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_read_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
   apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
   apply(erule disjE)
    apply(rename_tac ka e1b w q1 q2 A2 lista)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_read_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
   apply(rename_tac ka e1aa w q1 q2 A2 lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
   apply(case_tac "edge_push e")
    apply(rename_tac ka e1aa w q1 q2 A2 lista e)(*strict*)
    apply(clarsimp)
   apply(rename_tac ka e1aa w q1 q2 A2 lista e a list)(*strict*)
   apply(clarsimp)
   apply(case_tac "edge_event e")
    apply(rename_tac ka e1aa w q1 q2 A2 lista e a list)(*strict*)
    prefer 2
    apply(rename_tac ka e1aa w q1 q2 A2 lista e a list aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac ka e1aa w q1 q2 A2 lista e a list)(*strict*)
   apply(case_tac "edge_push e")
    apply(rename_tac ka e1aa w q1 q2 A2 lista e a list)(*strict*)
    apply(clarsimp)
   apply(rename_tac ka e1aa w q1 q2 A2 lista e a list aa listb)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w q1 q2 A2 lista e a list)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def F_SDPDA_TO_CFG_STD__edges_l3_push_def F_SDPDA_TO_CFG_STD__edges_l3_pop_def F_SDPDA_TO_CFG_STD__edges_l3_read_def F_SDPDA_TO_CFG_STD__edges_l2_read_def F_SDPDA_TO_CFG_STD__edges_l2_push_def)
   apply(clarsimp)
   apply(rename_tac ka e1b w lista e a list)(*strict*)
   apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
   apply(rename_tac ka e1aa w lista e a list)(*strict*)
   apply(clarsimp)
   apply(erule_tac x="e" in ballE)
    apply(rename_tac ka e1aa w lista e a list)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac ka e1aa w lista e a list)(*strict*)
   apply(erule_tac x="e" in ballE)
    apply(rename_tac ka e1aa w lista e a list)(*strict*)
    prefer 2
    apply(rename_tac ka e1b w lista e a list)(*strict*)
    apply(force)
   apply(rename_tac ka e1aa w lista e a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w lista e a)(*strict*)
   apply(case_tac "edge_pop e")
    apply(rename_tac ka e1b w lista e a)(*strict*)
    apply(force)
   apply(rename_tac ka e1b w lista e a aa list)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w lista e a aa)(*strict*)
   apply(case_tac lista)
    apply(rename_tac ka e1b w lista e a aa)(*strict*)
    apply(simp add: state_adjacency_and_no_l2_before_l3_def)
   apply(rename_tac ka e1b w lista e a aa ab list)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1aa w e a aa ab list z zs)(*strict*)
   apply(simp add: state_adjacency_and_no_l2_before_l3_def)
   apply(erule_tac x="[]" in allE)+
   apply(clarsimp)
  apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
  apply(erule disjE)
   apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w waa wba list q1 q2 q3 A1 A2)(*strict*)
   apply(subgoal_tac "wba=w")
    apply(rename_tac ka e1b w waa wba list q1 q2 q3 A1 A2)(*strict*)
    prefer 2
    apply(rule_tac ?w2.0="cons_l3 q2 A2 q3 #  (cons_l2 q3 A1) #  list" in liftB_liftA_eq_liftB_liftA)
    apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
   apply(rename_tac ka e1b w waa wba list q1 q2 q3 A1 A2)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w waa list q1 q2 q3 A1 A2)(*strict*)
   apply(case_tac waa)
    apply(rename_tac ka e1b w waa list q1 q2 q3 A1 A2)(*strict*)
    apply(force)
   apply(rename_tac ka e1b w waa list q1 q2 q3 A1 A2 a lista)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w list q1 q2 q3 A1 A2 lista)(*strict*)
   apply(case_tac lista)
    apply(rename_tac ka e1b w list q1 q2 q3 A1 A2 lista)(*strict*)
    apply(force)
   apply(rename_tac ka e1b w list q1 q2 q3 A1 A2 lista a listb)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w list q1 q2 q3 A1 A2 listb)(*strict*)
   apply(subgoal_tac "list=listb")
    apply(rename_tac ka e1b w list q1 q2 q3 A1 A2 listb)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac ka e1b w list q1 q2 q3 A1 A2 listb)(*strict*)
   apply(clarsimp)
   apply(rename_tac ka e1b w q1 q2 q3 A1 A2 listb)(*strict*)
   apply(simp add: suffix_def stack_def)
   apply(clarsimp)
  apply(rename_tac ka e1b w waa wba list X rhs q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b w waa wba list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(subgoal_tac "wba=w")
   apply(rename_tac ka e1b w waa wba list q1 q2 q3 q4 A1 A2)(*strict*)
   prefer 2
   apply(rule_tac ?w2.0="cons_l3 q2 A2 q3 #  (cons_l3 q3 A1 q4) #  list" in liftB_liftA_eq_liftB_liftA)
   apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac ka e1b w waa wba list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b w waa list q1 q2 q3 q4 A1 A2)(*strict*)
  apply(case_tac waa)
   apply(rename_tac ka e1b w waa list q1 q2 q3 q4 A1 A2)(*strict*)
   apply(force)
  apply(rename_tac ka e1b w waa list q1 q2 q3 q4 A1 A2 a lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b w list q1 q2 q3 q4 A1 A2 lista)(*strict*)
  apply(case_tac lista)
   apply(rename_tac ka e1b w list q1 q2 q3 q4 A1 A2 lista)(*strict*)
   apply(force)
  apply(rename_tac ka e1b w list q1 q2 q3 q4 A1 A2 lista a listb)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b w list q1 q2 q3 q4 A1 A2 listb)(*strict*)
  apply(subgoal_tac "list=listb")
   apply(rename_tac ka e1b w list q1 q2 q3 q4 A1 A2 listb)(*strict*)
   prefer 2
   apply(rule liftA_inj)
   apply(force)
  apply(rename_tac ka e1b w list q1 q2 q3 q4 A1 A2 listb)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka e1b w q1 q2 q3 q4 A1 A2 listb)(*strict*)
  apply(simp add: suffix_def stack_def)
  apply(clarsimp)
  done

lemma nonterminal_in_nonterminal_free_list: "
  liftB v2 @ teA C # liftA s2 = liftB wa \<Longrightarrow> False"
  apply(induct v2 arbitrary: wa)
   apply(clarsimp)
   apply(case_tac wa)
    apply(clarsimp)
   apply(clarsimp)
  apply(clarsimp)
  apply(case_tac wa)
   apply(clarsimp)
  apply(clarsimp)
  apply(force)
  done

lemma F_SDPDA_TO_CFG_OPT__has_same_reachable_nonterminals: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT G k = Some Gopt
  \<Longrightarrow> valid_cfg (Gopt)
  \<Longrightarrow> valid_cfg (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfg_sub (Gopt) (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> cfg_marking_condition (F_SDPDA_TO_CFG_STD G) d
  \<Longrightarrow> cfgLM.derivation_initial (F_SDPDA_TO_CFG_STD G) d
  \<Longrightarrow> d i = Some (pair e c)
  \<Longrightarrow> setA (cfg_conf c) \<subseteq> cfg_nonterminals Gopt"
  apply(simp add: cfg_marking_condition_def cfg_marking_configuration_def)
  apply(clarsimp)
  apply(rename_tac x ia ea ca)(*strict*)
  apply(thin_tac "ca \<in> cfg_configurations (F_SDPDA_TO_CFG_STD G)")
  apply(case_tac ca)
  apply(rename_tac x ia ea ca cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x ia ea cfg_confa)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac x ia ea cfg_confa)(*strict*)
   prefer 2
   apply(rule_tac G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac x ia ea cfg_confa)(*strict*)
      apply(force)
     apply(rename_tac x ia ea cfg_confa)(*strict*)
     apply(force)
    apply(rename_tac x ia ea cfg_confa)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac x ia ea cfg_confa)(*strict*)
   apply(force)
  apply(rename_tac x ia ea cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x ia ea w1 w2)(*strict*)
  apply(simp add: setAConcat)
  apply(rename_tac A j ej v1j v2j)
  apply(rename_tac A j ej v1j v2j)(*strict*)
  apply(subgoal_tac "\<exists>k ek ck s \<alpha>. i\<le>k \<and> k<j \<and> d k = Some (pair ek ck) \<and> cfg_conf ck=liftB \<alpha>@teA A#s")
   apply(rename_tac A j ej v1j v2j)(*strict*)
   prefer 2
   apply(subgoal_tac "\<exists>l r. cfg_conf c=l@[teA A]@r")
    apply(rename_tac A j ej v1j v2j)(*strict*)
    prefer 2
    apply (metis setA_decomp)
   apply(rename_tac A j ej v1j v2j)(*strict*)
   apply(subgoal_tac "\<exists>w. liftB w= v1j")
    apply(rename_tac A j ej v1j v2j)(*strict*)
    prefer 2
    apply(rule_tac x="filterB v1j" in exI)
    apply(rule liftBDeConv2)
    apply(force)
   apply(rename_tac A j ej v1j v2j)(*strict*)
   apply(subgoal_tac "\<exists>w. liftB w= v2j")
    apply(rename_tac A j ej v1j v2j)(*strict*)
    prefer 2
    apply(rule_tac x="filterB v2j" in exI)
    apply(rule liftBDeConv2)
    apply(force)
   apply(rename_tac A j ej v1j v2j)(*strict*)
   apply(erule exE)+
   apply(rename_tac A j ej v1j v2j l w wa r)(*strict*)
   apply(rule_tac l="l" and r="r" and w="w@wa" in last_head_occurence_of_nonterminal)
      apply(rename_tac A j ej v1j v2j l w wa r)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac A j ej v1j v2j l w wa r)(*strict*)
     apply(force)
    apply(rename_tac A j ej v1j v2j l w wa r)(*strict*)
    apply(force)
   apply(rename_tac A j ej v1j v2j l w wa r)(*strict*)
   apply(simp add: liftB_commutes_over_concat)
  apply(rename_tac A j ej v1j v2j)(*strict*)
  apply(clarsimp)
  apply(rename_tac A j ej v1j v2j ka ek ck s \<alpha>)(*strict*)
  apply(case_tac ck)
  apply(rename_tac A j ej v1j v2j ka ek ck s \<alpha> cfg_confa)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac A j ej v1j v2j ka ek ck s \<alpha> cfg_confa)(*strict*)
   prefer 2
   apply(rule_tac n="ka" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
      apply(rename_tac A j ej v1j v2j ka ek ck s \<alpha> cfg_confa)(*strict*)
      apply(force)
     apply(rename_tac A j ej v1j v2j ka ek ck s \<alpha> cfg_confa)(*strict*)
     apply(force)
    apply(rename_tac A j ej v1j v2j ka ek ck s \<alpha> cfg_confa)(*strict*)
    apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
    apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac A j ej v1j v2j ka ek ck s \<alpha> cfg_confa)(*strict*)
   apply(force)
  apply(rename_tac A j ej v1j v2j ka ek ck s \<alpha> cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac A j ej v1j v2j ka ek s \<alpha> w1 w2)(*strict*)
  apply(subgoal_tac "liftB \<alpha> = w1 \<and> teA A # s = w2")
   apply(rename_tac A j ej v1j v2j ka ek s \<alpha> w1 w2)(*strict*)
   prefer 2
   apply (metis setA_liftB_exists setB_empty_then_liftA_vs_filterA equal_left_liftB same_append_eq)
  apply(rename_tac A j ej v1j v2j ka ek s \<alpha> w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac A j ej v1j v2j ka ek s \<alpha>)(*strict*)
  apply(thin_tac "setA (liftB \<alpha>) = {}")
  apply(subgoal_tac "\<exists>w. liftA w= s")
   apply(rename_tac A j ej v1j v2j ka ek s \<alpha>)(*strict*)
   prefer 2
   apply(rule_tac x="filterA s" in exI)
   apply(rule sym)
   apply(rule setB_empty_then_liftA_vs_filterA)
   apply(force)
  apply(rename_tac A j ej v1j v2j ka ek s \<alpha>)(*strict*)
  apply(clarsimp)
  apply(rename_tac A j ej v1j v2j ka ek \<alpha> w)(*strict*)
  apply(thin_tac "setB (liftA w) = {}")
  apply(rename_tac s)
  apply(rename_tac A j ej v1j v2j ka ek \<alpha> s)(*strict*)
  apply(case_tac v2j)
   apply(rename_tac A j ej v1j v2j ka ek \<alpha> s)(*strict*)
   prefer 2
   apply(rename_tac A j ej v1j v2j ka ek \<alpha> s a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac A j ej v1j ka ek \<alpha> s a list)(*strict*)
   apply(case_tac a)
    apply(rename_tac A j ej v1j ka ek \<alpha> s a list \<Sigma>)(*strict*)
    apply(clarsimp)
   apply(rename_tac A j ej v1j ka ek \<alpha> s a list b)(*strict*)
   apply(clarsimp)
  apply(rename_tac A j ej v1j v2j ka ek \<alpha> s)(*strict*)
  apply(clarsimp)
  apply(rename_tac A j ej v1j ka ek \<alpha> s)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac A j ej v1j ka ek \<alpha> s)(*strict*)
   prefer 2
   apply(rule_tac ?w2.0="A#s" and ?w1.0="\<alpha>" and n="ka" in cfgLM_reachable_conf_isl3_l2_separation_ALT_stack)
        apply(rename_tac A j ej v1j ka ek \<alpha> s)(*strict*)
        apply(force)
       apply(rename_tac A j ej v1j ka ek \<alpha> s)(*strict*)
       apply(force)
      apply(rename_tac A j ej v1j ka ek \<alpha> s)(*strict*)
      apply(force)
     apply(rename_tac A j ej v1j ka ek \<alpha> s)(*strict*)
     apply(force)
    apply(rename_tac A j ej v1j ka ek \<alpha> s)(*strict*)
    apply(force)
   apply(rename_tac A j ej v1j ka ek \<alpha> s)(*strict*)
   apply(clarsimp)
  apply(rename_tac A j ej v1j ka ek \<alpha> s)(*strict*)
  apply(case_tac A)
   apply(rename_tac A j ej v1j ka ek \<alpha> s state stack)(*strict*)
   apply(clarsimp)
   apply(rename_tac j ej v1j ka ek \<alpha> s state stack)(*strict*)
   apply(rename_tac q A)
   apply(rename_tac j ej v1j ka ek \<alpha> s q A)(*strict*)
   apply(subgoal_tac "s=[]")
    apply(rename_tac j ej v1j ka ek \<alpha> s q A)(*strict*)
    prefer 2
    apply(case_tac s)
     apply(rename_tac j ej v1j ka ek \<alpha> s q A)(*strict*)
     apply(force)
    apply(rename_tac j ej v1j ka ek \<alpha> s q A a list)(*strict*)
    apply(clarsimp)
    apply(rename_tac j ej v1j ka ek \<alpha> q A a list)(*strict*)
    apply(simp add: l3_l2_separation_ALT_def)
   apply(rename_tac j ej v1j ka ek \<alpha> s q A)(*strict*)
   apply(clarsimp)
   apply(rename_tac j ej v1j ka ek \<alpha> q A)(*strict*)
   apply(rule F_SDPDA_TO_CFG_OPT__contains_all_reachable_l2_nonterminals)
      apply(rename_tac j ej v1j ka ek \<alpha> q A)(*strict*)
      apply(force)
     apply(rename_tac j ej v1j ka ek \<alpha> q A)(*strict*)
     apply(force)
    apply(rename_tac j ej v1j ka ek \<alpha> q A)(*strict*)
    apply(clarsimp)
   apply(rename_tac j ej v1j ka ek \<alpha> q A)(*strict*)
   apply(clarsimp)
   apply(case_tac j)
    apply(rename_tac j ej v1j ka ek \<alpha> q A)(*strict*)
    apply(force)
   apply(rename_tac j ej v1j ka ek \<alpha> q A nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac ej v1j ka ek \<alpha> q A nat)(*strict*)
   apply(rename_tac j)
   apply(rename_tac ej v1j ka ek \<alpha> q A j)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac ej v1j ka ek \<alpha> q A j)(*strict*)
    prefer 2
    apply(rule_tac
      n="j"
      and m="Suc j"
      in cfgLM.step_detail_before_some_position)
      apply(rename_tac ej v1j ka ek \<alpha> q A j)(*strict*)
      apply(rule cfgLM.derivation_initial_is_derivation)
      apply(force)
     apply(rename_tac ej v1j ka ek \<alpha> q A j)(*strict*)
     apply(force)
    apply(rename_tac ej v1j ka ek \<alpha> q A j)(*strict*)
    apply(force)
   apply(rename_tac ej v1j ka ek \<alpha> q A j)(*strict*)
   apply(clarsimp)
   apply(rename_tac v1j ka ek \<alpha> q A j e1 e2 c1)(*strict*)
   apply(thin_tac "l3_l2_separation_ALT [cons_l2 q A]")
   apply(subgoal_tac "\<exists>x. i+x=ka")
    apply(rename_tac v1j ka ek \<alpha> q A j e1 e2 c1)(*strict*)
    prefer 2
    apply(rule_tac x="ka-i" in exI)
    apply(force)
   apply(rename_tac v1j ka ek \<alpha> q A j e1 e2 c1)(*strict*)
   apply(subgoal_tac "\<exists>x. ka+x=j")
    apply(rename_tac v1j ka ek \<alpha> q A j e1 e2 c1)(*strict*)
    prefer 2
    apply(rule_tac x="j-ka" in exI)
    apply(force)
   apply(rename_tac v1j ka ek \<alpha> q A j e1 e2 c1)(*strict*)
   apply(clarsimp)
   apply(rename_tac v1j ek \<alpha> q A e1 e2 c1 x xa)(*strict*)
   apply(rename_tac ka j)
   apply(rename_tac v1j ek \<alpha> q A e1 e2 c1 ka j)(*strict*)
   apply(thin_tac "d i = Some (pair e c)")
   apply(thin_tac "cons_l2 q A \<in> setA (cfg_conf c)")
   apply(subgoal_tac "\<exists>w. liftB w= v1j")
    apply(rename_tac v1j ek \<alpha> q A e1 e2 c1 ka j)(*strict*)
    prefer 2
    apply(rule_tac x="filterB v1j" in exI)
    apply(rule liftBDeConv2)
    apply(force)
   apply(rename_tac v1j ek \<alpha> q A e1 e2 c1 ka j)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 c1 ka j w)(*strict*)
   apply(thin_tac "setA (liftB w) = {}")
   apply(simp add: cfgLM_step_relation_def)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 c1 ka j w l r)(*strict*)
   apply(case_tac c1)
   apply(rename_tac ek \<alpha> q A e1 e2 c1 ka j w l r cfg_confa)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w l r)(*strict*)
   apply(subgoal_tac "\<exists>w. liftB w= l")
    apply(rename_tac ek \<alpha> q A e1 e2 ka j w l r)(*strict*)
    prefer 2
    apply(rule_tac x="filterB l" in exI)
    apply(rule liftBDeConv2)
    apply(force)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w l r)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa)(*strict*)
   apply(thin_tac "setA (liftB wa) = {}")
   apply(subgoal_tac "X" for X)
    apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa)(*strict*)
    prefer 2
    apply(rule_tac G="F_SDPDA_TO_CFG_STD G" and n="(i + ka + j)" in singleIsertionOfLM_rechable_conf_form)
       apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa)(*strict*)
       apply(force)
      apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa)(*strict*)
      apply(force)
     apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa)(*strict*)
     apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
     apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
     apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
     apply(rule cfg_sub_reflexive)
    apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa)(*strict*)
    apply(force)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa w1 w2)(*strict*)
   apply(subgoal_tac "\<exists>w. liftB w= w1")
    apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa w1 w2)(*strict*)
    prefer 2
    apply(rule_tac x="filterB w1" in exI)
    apply(rule liftBDeConv2)
    apply(force)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa w1 w2)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa w2 wb)(*strict*)
   apply(thin_tac "setA (liftB wb) = {}")
   apply(subgoal_tac "\<exists>w. liftA w= w2")
    apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa w2 wb)(*strict*)
    prefer 2
    apply(rule_tac x="filterA w2" in exI)
    apply(rule sym)
    apply(rule setB_empty_then_liftA_vs_filterA)
    apply(force)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa w2 wb)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa wb wc)(*strict*)
   apply(thin_tac "setB (liftA wc) = {}")
   apply(subgoal_tac "wb=wa")
    apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa wb wc)(*strict*)
    prefer 2
    apply(rule_tac ?v1.0="wc" and A="prod_lhs e2" and ?v2.0="r" in equal_left_liftB)
    apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa wb wc)(*strict*)
   apply(simp add: liftB_commutes_over_concat)
   apply(case_tac wc)
    apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa wb wc)(*strict*)
    apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w r wa wb wc a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w wa list)(*strict*)
   apply(case_tac e2)
   apply(rename_tac ek \<alpha> q A e1 e2 ka j w wa list prod_lhsa prod_rhsa)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q A e1 ka j w wa list prod_lhs prod_rhs)(*strict*)
   apply(rename_tac A w)
   apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa list A w)(*strict*)
   apply(rule_tac xs="list" in rev_cases)
    apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa list A w)(*strict*)
    prefer 2
    apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa list A w ys y)(*strict*)
    apply(clarsimp)
    apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa A w ys y)(*strict*)
    apply(rule_tac xs="wa" in rev_cases)
     apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa A w ys y)(*strict*)
     apply(clarsimp)
     apply(rename_tac ek \<alpha> q Aa e1 ka j waa A ys y)(*strict*)
     apply(simp add: liftB_commutes_over_concat liftA_commutes_over_concat setAConcat setA_liftB setB_liftA)
    apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa A w ys y ysa ya)(*strict*)
    apply(clarsimp)
    apply(rename_tac ek \<alpha> q Aa e1 ka j waa A w ys y ysa ya)(*strict*)
    apply(simp add: liftB_commutes_over_concat liftA_commutes_over_concat setAConcat setA_liftB setB_liftA)
   apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa list A w)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa A w)(*strict*)
   apply(subgoal_tac "\<exists>wX. liftB wX= w")
    apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa A w)(*strict*)
    prefer 2
    apply(rule_tac x="filterB w" in exI)
    apply(rule liftBDeConv2)
    apply(rule tail_is_nonterminal_free)
    apply(force)
   apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa A w)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa A wX)(*strict*)
   apply(subgoal_tac "wa=waa@wX")
    apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa A wX)(*strict*)
    prefer 2
    apply(rule liftB_inj)
    apply(simp add: liftB_commutes_over_concat liftA_commutes_over_concat setAConcat setA_liftB setB_liftA)
   apply(rename_tac ek \<alpha> q Aa e1 ka j wa waa A wX)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX)(*strict*)
   apply(thin_tac "liftB (waa @ wX) = liftB waa @ liftB wX")
   apply(subgoal_tac "X" for X)
    apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX)(*strict*)
    prefer 2
    apply(rule_tac ?w2.0="[A]" and ?w1.0="waa" and n="(i + ka + j)" in cfgLM_reachable_conf_isl3_l2_separation_ALT_stack)
         apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX)(*strict*)
         apply(force)
        apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX)(*strict*)
        apply(force)
       apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX)(*strict*)
       apply(force)
      apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX)(*strict*)
      apply(force)
     apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX)(*strict*)
     apply(force)
    apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX)(*strict*)
    apply(clarsimp)
   apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX)(*strict*)
   apply(case_tac A)
    apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX state stack)(*strict*)
    prefer 2
    apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX state1 stack state2)(*strict*)
    apply(simp add: l3_l2_separation_ALT_def)
   apply(rename_tac ek \<alpha> q Aa e1 ka j waa A wX state stack)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> q Aa e1 ka j waa wX state stack)(*strict*)
   apply(thin_tac "l3_l2_separation_ALT [cons_l2 state stack]")
   apply(rename_tac q s)
   apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
   apply(subgoal_tac "q \<in> epda_marking G \<and> wX=[]")
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
    prefer 2
    apply(subgoal_tac "\<lparr>prod_lhs = cons_l2 q s, prod_rhs = liftB wX\<rparr> \<in> F_SDPDA_TO_CFG_STD__edges_l3 G \<or>
       \<lparr>prod_lhs = cons_l2 q s, prod_rhs = liftB wX\<rparr> \<in> F_SDPDA_TO_CFG_STD__edges_l2 G")
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
     prefer 2
     apply(simp add: F_SDPDA_TO_CFG_STD_def cfg_sub_def)
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
    apply(simp add:  F_SDPDA_TO_CFG_STD__edges_l3_def F_SDPDA_TO_CFG_STD__edges_l2_def)
    apply(erule disjE)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
     apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
     apply(case_tac "edge_event e")
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
      apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a)(*strict*)
     apply(clarsimp)
     apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def)
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
    apply(erule disjE)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
     apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
     apply(case_tac "edge_push e")
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
      apply(clarsimp)
      apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list)(*strict*)
     apply(clarsimp)
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
    apply(erule disjE)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
     apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
     apply(case_tac "edge_push e")
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
      apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list)(*strict*)
     apply(clarsimp)
     apply(case_tac "edge_event e")
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list)(*strict*)
      apply(clarsimp)
      apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list aa)(*strict*)
     apply(case_tac "edge_event e")
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list aa)(*strict*)
      apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list aa ab)(*strict*)
     apply(clarsimp)
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
    apply(erule disjE)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
     apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
     apply(case_tac "edge_event e")
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
      apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a)(*strict*)
     apply(clarsimp)
     apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def)
     apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX e a)(*strict*)
     apply(case_tac wX)
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX e a)(*strict*)
      apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX e a aa list)(*strict*)
     apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa e a list)(*strict*)
     apply(case_tac list)
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa e a list)(*strict*)
      apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa e a list aa lista)(*strict*)
     apply(clarsimp)
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
    apply(erule disjE)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
     apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def)
     apply(case_tac wX)
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
      apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s a list)(*strict*)
     apply(clarsimp)
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
    apply(clarsimp)
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
    apply(case_tac "edge_push e")
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e)(*strict*)
     apply(clarsimp)
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list)(*strict*)
    apply(clarsimp)
    apply(case_tac "edge_event e")
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list)(*strict*)
     apply(clarsimp)
     apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def)
     apply(erule disjE)
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list)(*strict*)
      apply(clarsimp)
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX e a list)(*strict*)
      apply(case_tac wX)
       apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX e a list)(*strict*)
       apply(clarsimp)
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX e a list aa lista)(*strict*)
      apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list)(*strict*)
     apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX e a list qs)(*strict*)
     apply(case_tac wX)
      apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX e a list qs)(*strict*)
      apply(clarsimp)
     apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX e a list qs aa lista)(*strict*)
     apply(clarsimp)
    apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s e a list aa)(*strict*)
    apply(clarsimp)
   apply(rename_tac ek \<alpha> qa Aa e1 ka j waa wX q s)(*strict*)
   apply(clarsimp)
   apply(rename_tac ek \<alpha> qa Aa e1 ka j waa q s)(*strict*)
   apply(thin_tac "\<lparr>prod_lhs = cons_l2 q s, prod_rhs = []\<rparr> \<in> cfg_productions (F_SDPDA_TO_CFG_STD G)")
   apply(thin_tac "d (Suc (i + ka + j)) =
       Some (pair (Some \<lparr>prod_lhs = cons_l2 q s, prod_rhs = []\<rparr>)
              \<lparr>cfg_conf = liftB waa\<rparr>)")
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1)(*strict*)
    prefer 2
    apply(rule_tac n="i + n + m" in F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD__SOUND_back_hlp_prime_prime)
        apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1)(*strict*)
        apply(force)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1)(*strict*)
       apply(force)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1)(*strict*)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1)(*strict*)
     apply(force)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1)(*strict*)
    apply(simp add: setAConcat)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1)(*strict*)
   apply(erule exE)+
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
   apply(subgoal_tac "X" for X)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
    prefer 2
    apply(rule_tac k="i + n + m" and n="i+n+m" in F_SDPDA_TO_CFG_STD__configuration_basic_RL_transfer_with_dseq)
           apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
           apply(force)
          apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
          apply(force)
         apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
         apply(force)
        apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
        apply(force)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
       apply(simp add: setAConcat)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia)(*strict*)
     apply(erule_tac x="ia" in allE)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR cR)(*strict*)
     apply(rule propSym)
     apply(rule context_conjI)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR cR)(*strict*)
      apply(case_tac "setA (cfg_conf cR) \<noteq> {}")
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR cR)(*strict*)
       apply(clarsimp)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL eR cR w)(*strict*)
       apply(force)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR cR)(*strict*)
      apply(clarsimp)
      apply(case_tac cR)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR cR cfg_confa)(*strict*)
      apply(clarsimp)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR cfg_conf)(*strict*)
      apply(rename_tac l)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR l)(*strict*)
      apply(subgoal_tac "\<exists>w. liftB w= l")
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR l)(*strict*)
       prefer 2
       apply(rule_tac x="filterB l" in exI)
       apply(rule liftBDeConv2)
       apply(force)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR l)(*strict*)
      apply(clarsimp)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w)(*strict*)
      apply(thin_tac "setA (liftB w) = {}")
      apply(case_tac "ia=i+n+m")
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w)(*strict*)
       apply(clarsimp)
       apply(rename_tac e0 w1 q0 A0 n m w2 q1 A1 dL eL cL eR w)(*strict*)
       apply(rule_tac xs="w" in rev_cases)
        apply(rename_tac e0 w1 q0 A0 n m w2 q1 A1 dL eL cL eR w)(*strict*)
        apply(clarsimp)
       apply(rename_tac e0 w1 q0 A0 n m w2 q1 A1 dL eL cL eR w ys y)(*strict*)
       apply(clarsimp)
       apply(rename_tac e0 w1 q0 A0 n m w2 q1 A1 dL eL cL eR ys y)(*strict*)
       apply(simp add: liftB_commutes_over_concat liftA_commutes_over_concat setAConcat setA_liftB setB_liftA)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w)(*strict*)
      apply(subgoal_tac "X" for X)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w)(*strict*)
       prefer 2
       apply(rule_tac
      n="ia"
      and m="i+n+m"
      in cfgLM.step_detail_before_some_position)
         apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w)(*strict*)
         apply(rule cfgLM.derivation_initial_is_derivation)
         apply(force)
        apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w)(*strict*)
        apply(force)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w)(*strict*)
       apply(force)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w)(*strict*)
      apply(clarsimp)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w e2 c2)(*strict*)
      apply(simp add: cfgLM_step_relation_def)
      apply(clarsimp)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR w e2 c2 l r)(*strict*)
      apply (metis setA_liftB_empty elemInsetA empty_iff)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cL eR cR)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cR w eR')(*strict*)
     apply(case_tac ia)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cR w eR')(*strict*)
      apply(clarsimp)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL eL cR w eR')(*strict*)
      apply(simp add: cfgLM.derivation_initial_def epdaH.derivation_initial_def cfgLM.derivation_def)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL ia eL cR w eR' nat)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL eL cR w eR' nat)(*strict*)
     apply(subgoal_tac "X" for X)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL eL cR w eR' nat)(*strict*)
      prefer 2
      apply(rule_tac
      n="nat"
      and m="Suc nat"
      in epdaH.step_detail_before_some_position)
        apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL eL cR w eR' nat)(*strict*)
        apply(rule epdaH.derivation_initial_is_derivation)
        apply(force)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL eL cR w eR' nat)(*strict*)
       apply(force)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL eL cR w eR' nat)(*strict*)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL eL cR w eR' nat)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w eR' nat e1a e2 c1)(*strict*)
     apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A)(*strict*)
     apply(subgoal_tac "X" for X)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A)(*strict*)
      prefer 2
      apply(rule_tac
      n="nat"
      and m="i+n+m"
      in cfgLM.step_detail_before_some_position)
        apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A)(*strict*)
        apply(rule cfgLM.derivation_initial_is_derivation)
        apply(force)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A)(*strict*)
       apply(force)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A)(*strict*)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b c1a)(*strict*)
     apply(case_tac c1a)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b c1a cfg_confa)(*strict*)
     apply(subgoal_tac "X" for X)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b c1a cfg_confa)(*strict*)
      prefer 2
      apply(rule_tac n="nat" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
         apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b c1a cfg_confa)(*strict*)
         apply(force)
        apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b c1a cfg_confa)(*strict*)
        apply(force)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b c1a cfg_confa)(*strict*)
       apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
       apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
       apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
       apply(rule cfg_sub_reflexive)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b c1a cfg_confa)(*strict*)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b c1a cfg_confa)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b w1a w2a)(*strict*)
     apply(subgoal_tac "\<exists>w. liftB w= w1a")
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b w1a w2a)(*strict*)
      prefer 2
      apply(rule_tac x="filterB w1a" in exI)
      apply(rule liftBDeConv2)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b w1a w2a)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b w2a wa)(*strict*)
     apply(thin_tac "setA (liftB wa) = {}")
     apply(subgoal_tac "\<exists>w. liftA w= w2a")
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b w2a wa)(*strict*)
      prefer 2
      apply(rule_tac x="filterA w2a" in exI)
      apply(rule sym)
      apply(rule setB_empty_then_liftA_vs_filterA)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b w2a wa)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b wa wb)(*strict*)
     apply(thin_tac "setB (liftA wb) = {}")
     apply(simp add: cfgLM_step_relation_def)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b wa wb l r)(*strict*)
     apply(subgoal_tac "\<exists>w. liftB w= l")
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b wa wb l r)(*strict*)
      prefer 2
      apply(rule_tac x="filterB l" in exI)
      apply(rule liftBDeConv2)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b wa wb l r)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b wa wb r wc)(*strict*)
     apply(thin_tac "setA (liftB wc) = {}")
     apply(case_tac cR)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL cR w nat e1a e2 c1 ia A e1b wa wb r wc cfg_confa)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL w nat e1a e2 c1 ia A e1b wa wb r wc)(*strict*)
     apply(subgoal_tac "wa=wc")
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL w nat e1a e2 c1 ia A e1b wa wb r wc)(*strict*)
      prefer 2
      apply(rule_tac ?v1.0="wb" and A="cons_l2 ia A" and ?v2.0="r" in equal_left_liftB)
      apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL w nat e1a e2 c1 ia A e1b wa wb r wc)(*strict*)
     apply(simp add: liftB_commutes_over_concat)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL w nat e1a e2 c1 ia A e1b wb r wc)(*strict*)
     apply(case_tac wb)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL w nat e1a e2 c1 ia A e1b wb r wc)(*strict*)
      apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL w nat e1a e2 c1 ia A e1b wb r wc a list)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL w nat e1a e2 c1 ia A e1b wc list)(*strict*)
     apply(rename_tac w)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
     apply(subgoal_tac "X" for X)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
      prefer 2
      apply(rule_tac ?w2.0="cons_l2 ia A#w" and G="G" and ?w1.0="wc" and n="nat" in cfgLM_reachable_conf_isl3_l2_separation_ALT_stack)
           apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
           apply(force)
          apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
          apply(force)
         apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
         apply(force)
        apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
        apply(force)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
       apply(force)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
      apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
     apply(rule_tac xs="w" in rev_cases)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
      prefer 2
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w ys y)(*strict*)
      apply(clarsimp)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc ys y)(*strict*)
      apply(simp add: l3_l2_separation_ALT_def)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc w)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
     apply(case_tac "Suc nat=i+n+m")
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
      apply(clarsimp)
      apply(rename_tac e0 w1 q0 A0 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
      apply(rule_tac xs="wc" in rev_cases)
       apply(rename_tac e0 w1 q0 A0 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
       apply(clarsimp)
      apply(rename_tac e0 w1 q0 A0 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc ys y)(*strict*)
      apply(clarsimp)
      apply(rename_tac e0 w1 q0 A0 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b ys y)(*strict*)
      apply(simp add: liftB_commutes_over_concat liftA_commutes_over_concat setAConcat setA_liftB setB_liftA)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
     apply(subgoal_tac "X" for X)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
      prefer 2
      apply(rule_tac
      n="Suc nat"
      and m="i+n+m"
      in cfgLM.step_detail_before_some_position)
        apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
        apply(rule cfgLM.derivation_initial_is_derivation)
        apply(force)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
       apply(force)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc)(*strict*)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc e2a c2)(*strict*)
     apply(simp add: cfgLM_step_relation_def)
     apply(clarsimp)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL wa nat e1a e2 c1 ia A e1b wc e2a c2 l r)(*strict*)
     apply (metis setA_liftB_empty elemInsetA empty_iff)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
    apply(force)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL)(*strict*)
   apply(rule_tac x="dL" in exI)
   apply(clarsimp)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq)(*strict*)
   apply(thin_tac "\<forall>k\<le>i + n + m.
          \<exists>eL cL.
             dL k = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d k = Some (pair eR cR) \<and>
                 (case eR of None \<Rightarrow> True
                  | Some eR' \<Rightarrow>
                      eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G)
                              (epda_gamma G) \<longrightarrow>
                      (case eL of None \<Rightarrow> False
                       | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                 (setA (cfg_conf cR) \<noteq> {} \<longrightarrow>
                  (\<exists>w. set w \<subseteq> epda_gamma G \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
   apply(erule_tac x="i+n" and P="%ia. ia\<le>i + n + m \<longrightarrow> (
          \<exists>eL cL.
             dL ia = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d ia = Some (pair eR cR) \<and>
                 cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR (foldl (@) [] (rev (take ia dseq)))))" in allE')
   apply(erule_tac x="i+n+m" and P="%ia. ia\<le>i + n + m \<longrightarrow> (
          \<exists>eL cL.
             dL ia = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d ia = Some (pair eR cR) \<and>
                 cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR (foldl (@) [] (rev (take ia dseq)))))" in allE')
   apply(clarsimp)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
   apply(rule_tac x="i+n" in exI)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
    apply(fold event_stack_separation_def)
    apply(subgoal_tac "event_stack_separation (liftB w1 @ [teA (cons_l2   q0 A0)]) = [cons_l2 q0 A0]")
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
     prefer 2
     apply(rule_tac w="w1" in event_stack_separation_XX2)
     apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
    apply(clarsimp)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
   apply(rule conjI)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
    apply(fold event_stack_separation_def)
    apply(subgoal_tac "event_stack_separation (liftB w1 @ [teA (cons_l2   q0 A0)]) = [cons_l2 q0 A0]")
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
     prefer 2
     apply(rule_tac w="w1" in event_stack_separation_XX2)
     apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
    apply(clarsimp)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
   apply(rule_tac x="m" in exI)
   apply(clarsimp)
   apply(rule conjI)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
    apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
    apply(fold event_stack_separation_def)
    apply(subgoal_tac "event_stack_separation (liftB w2 @ [teA (cons_l2   q1 A1)]) = [cons_l2 q1 A1]")
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
     prefer 2
     apply(rule_tac w="w2" in event_stack_separation_XX2)
     apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
    apply(clarsimp)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa)(*strict*)
   apply(thin_tac "dL (i + n + m) =
       Some (pair eLa
              (F_SDPDA_TO_CFG_STD__configuration_basic_RL \<lparr>cfg_conf = liftB w2 @ [teA (cons_l2   q1 A1)]\<rparr>
                (foldl (@) [] (rev dseq))))")
   apply(thin_tac "q1 \<in> epda_marking G")
   apply(thin_tac "dL (i + n) =
       Some (pair eL
              (F_SDPDA_TO_CFG_STD__configuration_basic_RL \<lparr>cfg_conf = liftB w1 @ [teA (cons_l2   q0 A0)]\<rparr>
                (foldl (@) [] (rev (take (i + n) dseq)))))")
   apply(thin_tac "0 < k")
   apply(thin_tac "valid_cfg Gopt")
   apply(thin_tac "F_SDPDA_TO_CFG_OPT G k = Some Gopt")
   apply(thin_tac "cfg_sub Gopt (F_SDPDA_TO_CFG_STD G)")
   apply(rule allI)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
   apply(rule impI)
   apply(subgoal_tac "X" for X)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
    prefer 2
    apply(rule_tac k="k" and ?v1.0="[]" in F_SDPDA_TO_CFG_OPT__has_same_reachable_nonterminals_hlp2)
             apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
             apply(force)
            apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
            apply(force)
           apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
           apply(force)
          apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
          apply(force)
         apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
         apply(force)
        apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
        apply(force)
       apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
       apply(force)
      apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
      apply(force)
     apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
     apply(force)
    apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
    apply(force)
   apply(rename_tac e0 w1 q0 A0 e1 n m w2 q1 A1 dL dseq eL eLa k)(*strict*)
   apply(force)
  apply(rename_tac A j ej v1j ka ek \<alpha> s state1 stack state2)(*strict*)
  apply(rename_tac q A q')
  apply(rename_tac Aa j ej v1j ka ek \<alpha> s q A q')(*strict*)
  apply(thin_tac "d i = Some (pair e c)")
  apply(thin_tac "i\<le>ka")
  apply(thin_tac "Aa \<in> setA (cfg_conf c)")
  apply(subgoal_tac "\<exists>x. ka+x=j")
   apply(rename_tac Aa j ej v1j ka ek \<alpha> s q A q')(*strict*)
   prefer 2
   apply(rule_tac x="j-ka" in exI)
   apply(force)
  apply(rename_tac Aa j ej v1j ka ek \<alpha> s q A q')(*strict*)
  apply(clarsimp)
  apply(rename_tac ej v1j ka ek \<alpha> s q A q' x)(*strict*)
  apply(case_tac x)
   apply(rename_tac ej v1j ka ek \<alpha> s q A q' x)(*strict*)
   apply(force)
  apply(rename_tac ej v1j ka ek \<alpha> s q A q' x nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej v1j ka ek \<alpha> s q A q' nat)(*strict*)
  apply(rename_tac kb)
  apply(rename_tac ej v1j ka ek \<alpha> s q A q' kb)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= v1j")
   apply(rename_tac ej v1j ka ek \<alpha> s q A q' kb)(*strict*)
   prefer 2
   apply(rule_tac x="filterB v1j" in exI)
   apply(rule liftBDeConv2)
   apply(force)
  apply(rename_tac ej v1j ka ek \<alpha> s q A q' kb)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q A q' kb w)(*strict*)
  apply(thin_tac "setA (liftB w) = {}")
  apply(subgoal_tac "X" for X)
   apply(rename_tac ej ka ek \<alpha> s q A q' kb w)(*strict*)
   prefer 2
   apply(rule_tac P="%n. \<exists>e c w1 w2. d (ka+n) = Some (pair e c) \<and> cfg_conf c = liftB w1 @ liftA w2 \<and> length w2 < Suc(length s)" and n="Suc kb" in ex_least_nat_le_prime)
   apply(clarsimp)
   apply(rule_tac x="w" in exI)
   apply(rule_tac x="[]" in exI)
   apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q A q' kb w)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q A q' kb w kaa e c w1 w2)(*strict*)
  apply(case_tac c)
  apply(rename_tac ej ka ek \<alpha> s q A q' kb w kaa e c w1 w2 cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q A q' kb w kaa e w1 w2)(*strict*)
  apply(subgoal_tac "\<exists>x. kaa+x=Suc kb")
   apply(rename_tac ej ka ek \<alpha> s q A q' kb w kaa e w1 w2)(*strict*)
   prefer 2
   apply(rule_tac x="Suc kb-kaa" in exI)
   apply(force)
  apply(rename_tac ej ka ek \<alpha> s q A q' kb w kaa e w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q A q' kb w kaa e w1 w2 x)(*strict*)
  apply(case_tac kaa)
   apply(rename_tac ej ka ek \<alpha> s q A q' kb w kaa e w1 w2 x)(*strict*)
   apply(clarsimp)
   apply(rename_tac ej ka \<alpha> s q A q' kb w e w1 w2)(*strict*)
   apply(subgoal_tac "\<alpha>=w1")
    apply(rename_tac ej ka \<alpha> s q A q' kb w e w1 w2)(*strict*)
    prefer 2
    apply (metis equal_left_liftB)
   apply(rename_tac ej ka \<alpha> s q A q' kb w e w1 w2)(*strict*)
   apply(clarsimp)
   apply(rename_tac ej ka s q A q' kb w e w1 w2)(*strict*)
   apply(case_tac w2)
    apply(rename_tac ej ka s q A q' kb w e w1 w2)(*strict*)
    apply(clarsimp)
   apply(rename_tac ej ka s q A q' kb w e w1 w2 a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac ej ka s q A q' kb w e w1 list)(*strict*)
   apply(subgoal_tac "s=list")
    apply(rename_tac ej ka s q A q' kb w e w1 list)(*strict*)
    prefer 2
    apply(rule liftA_inj)
    apply(force)
   apply(rename_tac ej ka s q A q' kb w e w1 list)(*strict*)
   apply(force)
  apply(rename_tac ej ka ek \<alpha> s q A q' kb w kaa e w1 w2 x nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q A q' w e w1 w2 x nat)(*strict*)
  apply(rename_tac kc kb)
  apply(rename_tac ej ka ek \<alpha> s q A q' w e w1 w2 kc kb)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac ej ka ek \<alpha> s q A q' w e w1 w2 kc kb)(*strict*)
   prefer 2
   apply(rule_tac
      n="ka+kb"
      and m="Suc (ka+kb)"
      in cfgLM.step_detail_before_some_position)
     apply(rename_tac ej ka ek \<alpha> s q A q' w e w1 w2 kc kb)(*strict*)
     apply(rule cfgLM.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac ej ka ek \<alpha> s q A q' w e w1 w2 kc kb)(*strict*)
    apply(force)
   apply(rename_tac ej ka ek \<alpha> s q A q' w e w1 w2 kc kb)(*strict*)
   apply(force)
  apply(rename_tac ej ka ek \<alpha> s q A q' w e w1 w2 kc kb)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q A q' w w1 w2 kc kb e1 e2 c1)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac ej ka ek \<alpha> s q A q' w w1 w2 kc kb e1 e2 c1)(*strict*)
   prefer 2
   apply(rule_tac G="F_SDPDA_TO_CFG_STD G" in LR1ProdForm_implies_LR1ProdFormSimp)
   apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
   apply(rule cfg_sub_reflexive)
  apply(rename_tac ej ka ek \<alpha> s q A q' w w1 w2 kc kb e1 e2 c1)(*strict*)
  apply(simp add: LR1ProdFormSimp_def)
  apply(simp add: cfgLM_step_relation_def)
  apply(case_tac c1)
  apply(rename_tac ej ka ek \<alpha> s q A q' w w1 w2 kc kb e1 e2 c1 cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q A q' w w1 w2 kc kb e1 e2 l r)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= l")
  apply(rename_tac ej ka ek \<alpha> s q A q' w w1 w2 kc kb e1 e2 l r)(*strict*)
  prefer 2
  apply(rule_tac x="filterB l" in exI)
  apply(rule liftBDeConv2)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q A q' w w1 w2 kc kb e1 e2 l r)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q A q' w w1 w2 kc kb e1 e2 r wa)(*strict*)
  apply(thin_tac "setA (liftB wa) = {}")
  apply(case_tac e2)
  apply(rename_tac ej ka ek \<alpha> s q A q' w w1 w2 kc kb e1 e2 r wa prod_lhsa prod_rhsa)(*strict*)
  apply(rename_tac A w)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 e2 r waa A w)(*strict*)
  apply(erule_tac x="e2" in ballE)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 e2 r waa A w)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 e2 r waa A w)(*strict*)
  apply(erule disjE)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 e2 r waa A w)(*strict*)
  prefer 2
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w b Ab B)(*strict*)
  apply(erule disjE)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w b Ab B)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa b Ab B)(*strict*)
  apply(subgoal_tac "w1=waa@[b]")
   apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa b Ab B)(*strict*)
   prefer 2
   apply(rule_tac ?v1.0="w2" and A="B" and ?v2.0="r" in equal_left_liftB)
   apply(clarsimp)
   apply(simp add: liftB_commutes_over_concat)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa b Ab B)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w2 kc kb e1 r waa b Ab B)(*strict*)
  apply(simp add: liftB_commutes_over_concat)
  apply(case_tac w2)
   apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w2 kc kb e1 r waa b Ab B)(*strict*)
   apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w2 kc kb e1 r waa b Ab B a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa b Ab B list)(*strict*)
  apply(erule_tac x="kb" in allE)
  apply(clarsimp)
  apply(erule_tac x="waa" in allE)
  apply(erule_tac x="Ab#list" in allE)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w b Ab B)(*strict*)
  apply(erule disjE)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w b Ab B)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B)(*strict*)
  apply(subgoal_tac "w1=waa")
   apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B)(*strict*)
   prefer 2
   apply(rule_tac ?v1.0="w2" and A="B" and ?v2.0="r" in equal_left_liftB)
   apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B)(*strict*)
  apply(simp add: liftB_commutes_over_concat)
  apply(case_tac w2)
   apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B)(*strict*)
   apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa Ab B list)(*strict*)
  apply(erule_tac x="kb" in allE)
  apply(clarsimp)
  apply(erule_tac x="waa" in allE)
  apply(erule_tac x="Ab#list" in allE)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w b Ab B)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B C)(*strict*)
  apply(subgoal_tac "w1=waa")
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B C)(*strict*)
  prefer 2
  apply(rule_tac ?v1.0="w2" and A="B" and ?v2.0="teA C#r" in equal_left_liftB)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B C)(*strict*)
  apply(simp add: liftB_commutes_over_concat)
  apply(case_tac w2)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B C)(*strict*)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa Ab B C a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 r waa Ab B C list)(*strict*)
  apply(case_tac list)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 r waa Ab B C list)(*strict*)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 r waa Ab B C list a lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa Ab B C lista)(*strict*)
  apply(erule_tac x="kb" in allE)
  apply(clarsimp)
  apply(erule_tac x="waa" in allE)
  apply(erule_tac x="Ab#lista" in allE)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 e2 r waa A w)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A)(*strict*)
  apply(subgoal_tac "X" for X)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A)(*strict*)
  prefer 2
  apply(rule_tac n="ka+kb" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
    apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A)(*strict*)
    apply(force)
   apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A)(*strict*)
   apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A)(*strict*)
  apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
  apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
  apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
  apply(rule cfg_sub_reflexive)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A)(*strict*)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w1a w2a)(*strict*)
  apply(subgoal_tac "\<exists>w. liftB w= w1a")
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w1a w2a)(*strict*)
  prefer 2
  apply(rule_tac x="filterB w1a" in exI)
  apply(rule liftBDeConv2)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w1a w2a)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w2a w)(*strict*)
  apply(thin_tac "setA (liftB w) = {}")
  apply(subgoal_tac "\<exists>w. liftA w= w2a")
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w2a w)(*strict*)
  prefer 2
  apply(rule_tac x="filterA w2a" in exI)
  apply(rule sym)
  apply(rule setB_empty_then_liftA_vs_filterA)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w2a w)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w wb)(*strict*)
  apply(thin_tac "setB (liftA wb) = {}")
  apply(subgoal_tac "w=waa")
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w wb)(*strict*)
  prefer 2
  apply(rule_tac ?v1.0="wb" and A="A" and ?v2.0="r" in equal_left_liftB)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w wb)(*strict*)
  apply(simp add: liftB_commutes_over_concat)
  apply(case_tac wb)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w wb)(*strict*)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 r waa A w wb a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 waa a list)(*strict*)
  apply(subgoal_tac "w1=waa")
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 waa a list)(*strict*)
  prefer 2
  apply(rule liftB_liftA_eq_liftB_liftA)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w1 w2 kc kb e1 waa a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w2 kc kb e1 waa a list)(*strict*)
  apply(subgoal_tac "w2=list")
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w2 kc kb e1 waa a list)(*strict*)
  prefer 2
  apply(rule liftA_inj)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa w2 kc kb e1 waa a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a list)(*strict*)
  apply(case_tac list)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a)(*strict*)
  apply(case_tac kc)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a)(*strict*)
   prefer 2
   apply(rule_tac ?w2.0="[a]" and ?w1.0="wa" and n="ka+kb" in cfgLM_reachable_conf_isl3_l2_separation_ALT_stack)
        apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a)(*strict*)
        apply(force)
       apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a)(*strict*)
       apply(force)
      apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a)(*strict*)
      apply(force)
     apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a)(*strict*)
     apply(force)
    apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a)(*strict*)
    apply(force)
   apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a)(*strict*)
   apply(clarsimp)
  apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a)(*strict*)
  apply(simp add: l3_l2_separation_ALT_def)
  apply(case_tac a)
   apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a state stack)(*strict*)
   prefer 2
   apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a state1 stack state2)(*strict*)
   apply(force)
  apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa a state stack)(*strict*)
  apply(clarsimp)
  apply(rename_tac ka ek \<alpha> s q Aa q' wa kb e1 waa state stack)(*strict*)
  apply(rename_tac q A)
  apply(rename_tac ka ek \<alpha> s qa Aa q' wa kb e1 waa q A)(*strict*)
  apply(erule_tac x="kb" in allE)
  apply(clarsimp)
  apply(erule_tac x="wa" in allE)
  apply(clarsimp)
  apply(erule_tac x="[cons_l2 q A]" in allE)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a nat)(*strict*)
  apply(subgoal_tac "X" for X)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a nat)(*strict*)
  prefer 2
  apply(rule_tac
    n="Suc (ka+kb)"
    and m="Suc (ka + (kb + kc))"
    in cfgLM.step_detail_before_some_position)
    apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a nat)(*strict*)
    apply(rule cfgLM.derivation_initial_is_derivation)
    apply(force)
   apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a nat)(*strict*)
   apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a nat)(*strict*)
  apply(force)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kb e1 waa a nat e2 c2)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kb e1 waa a nat e2 c2 l r)(*strict*)
  apply (metis setA_liftB_empty elemInsetA empty_iff)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a list aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac ej ka ek \<alpha> s q Aa q' wa kc kb e1 waa a aa lista)(*strict*)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
  apply(erule_tac x="k2" in allE')
  apply(clarsimp)
  apply(erule_tac x="v2" in allE)
  apply(clarsimp)
  apply(erule_tac x="B#C#s2" in allE)
  apply(clarsimp)
  apply(subgoal_tac "Suc (length s2) = length s1")
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
  prefer 2
  apply(rule_tac ?w2.0="[B,C]@s2" and ?w1.0="v2" and n="k1+k2" in cfgLM_reachable_conf_isl3_l2_separation_ALT_stack)
      apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
      apply(force)
     apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
     apply(force)
    apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
    apply(force)
   apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
   apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
  apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
  apply(clarsimp)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2)(*strict*)
  apply(case_tac B)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2 state stack)(*strict*)
  apply(simp add: l3_l2_separation_ALT_def)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 B C s2 state1 stack state2)(*strict*)
  apply(clarsimp)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 state1 stack state2)(*strict*)
  apply(rename_tac qB B qB')
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB')(*strict*)
  apply(subgoal_tac "\<forall>x. x < Suc k2 \<longrightarrow>
       (\<forall>e c. d (k1 + x) = Some (pair e c) \<longrightarrow>
              (\<forall>w1 w2.
                  cfg_conf c = liftB w1 @ liftA w2 \<longrightarrow>
                  discard_font_state(event_stack_separation (cfg_conf c)) \<sqsupseteq> discard_font_state(event_stack_separation (teA (cons_l3   qA A qA') # liftA s1))))")
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB')(*strict*)
  prefer 2
  apply(rule allI)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
  apply(rule_tac  F_SDPDA_TO_CFG_OPT__has_same_reachable_nonterminals_hlp)
                apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
                apply(force)
               apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
               apply(force)
              apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
              apply(force)
             apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
             apply(force)
            apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
            apply(force)
           apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
           apply(force)
          apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
          apply(force)
         apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
         apply(force)
        apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
        apply(force)
       apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
       apply(force)
      apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
      apply(force)
     apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
     apply(force)
    apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
    apply(force)
   apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
   apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
  apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' x)(*strict*)
  apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB')(*strict*)
  apply(case_tac k3)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB')(*strict*)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB')(*strict*)
  apply(subgoal_tac "False")
  apply(rename_tac k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB')(*strict*)
  apply(force)
  apply(rename_tac k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB')(*strict*)
  apply (simp add: liftA.simps(1) liftA.simps(2) append_Nil2 list.distinct(1) event_stack_separation_XX2)
  apply(rule nonterminal_in_nonterminal_free_list)
  apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k3 k2 e2 v2 C s2 qB B qB' nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' nat)(*strict*)
  apply(rename_tac k3)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  apply(erule_tac x="k2" and P="%x. x<Suc k2 \<longrightarrow>
          (\<forall>e c. d (k1 + x) = Some (pair e c) \<longrightarrow>
                (\<forall>w1 w2.
                    cfg_conf c = liftB w1 @ liftA w2 \<longrightarrow>
                    discard_font_state (event_stack_separation (liftB w1 @ liftA w2)) \<sqsupseteq>
                    discard_font_state (event_stack_separation (teA (cons_l3   qA A qA') # liftA s1))))" in allE')
  apply(clarsimp)
  apply(erule_tac x="v2" in allE)
  apply(erule_tac x=" (cons_l3 qB B qB') #  C #  s2" in allE)
  apply(clarsimp)
  apply(subgoal_tac "A=B \<and> qA' = qB'")
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  prefer 2
  apply(subgoal_tac "event_stack_separation (liftB v2 @ teA (cons_l3   qB B qB') # teA C # liftA s2) = (cons_l3 qB B qB') # C # s2")
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  prefer 2
  apply(rule_tac w="v2" in event_stack_separation_XX2)
  apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  apply(subgoal_tac "event_stack_separation (teA (cons_l3   qA A qA') # liftA s1) = (cons_l3 qA A qA') # s1")
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  prefer 2
  apply(rule_tac w="[]" in event_stack_separation_XX2)
  apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "discard_font_state (cons_l3 qB B qB' # C # s2) \<sqsupseteq>
       discard_font_state (cons_l3 qA A qA' # s1)")
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  prefer 2
  apply(rule_tac t="(cons_l3 qA A qA' # s1)" and s="event_stack_separation (teA (cons_l3   qA A qA') # liftA s1)" in subst)
   apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
   apply(blast)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  apply(thin_tac "discard_font_state (cons_l3 qB B qB' # C # s2) \<sqsupseteq>
       discard_font_state (event_stack_separation (teA (cons_l3   qA A qA') # liftA s1))")
  apply(simp add: suffix_def)
  apply(clarsimp)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3 c)(*strict*)
  apply(simp add: discard_font_state_def)
  apply(case_tac c)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3 c)(*strict*)
  apply(clarsimp)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3 c a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB qB' k3 a list)(*strict*)
  apply(subgoal_tac "length ((case C of cons_l2 q A \<Rightarrow> (A, None) | cons_l3 q1 A q2 \<Rightarrow> (A, Some q2)) #
       map (case_DT_l2_l3_nonterminals (\<lambda>q A. (A, None)) (\<lambda>q1 A q2. (A, Some q2))) s2) \<noteq> length(
       list @
       (A, Some qA') #
       map (case_DT_l2_l3_nonterminals (\<lambda>q A. (A, None)) (\<lambda>q1 A q2. (A, Some q2))) s1)")
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB qB' k3 a list)(*strict*)
  apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB qB' k3 a list)(*strict*)
  apply(simp (no_asm_use))
  apply(rename_tac e4 k1 e1 v1 s1 qA A qA' wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  apply(clarsimp)
  apply(rename_tac e4 k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB B qB' k3)(*strict*)
  apply(rename_tac qB A qA' k3)
  apply(rename_tac e4 k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3)(*strict*)
  apply(subgoal_tac "X" for X)
  apply(rename_tac e4 k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3)(*strict*)
  prefer 2
  apply(rule_tac
    n="Suc(k1 + (k2 + k3))"
    and m="Suc(Suc (k1 + (k2 + k3)))"
    in cfgLM.step_detail_before_some_position)
   apply(rename_tac e4 k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3)(*strict*)
   apply(rule cfgLM.derivation_initial_is_derivation)
   apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3)(*strict*)
  apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3)(*strict*)
  apply(force)
  apply(rename_tac e4 k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3)(*strict*)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1)(*strict*)
  apply(subgoal_tac "X" for X)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1)(*strict*)
  prefer 2
  apply(rule_tac ?G1.0="G" and dR="d" and n="Suc(k1 + (k2 + k3))" in F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD__SOUND_back_hlp_prime_prime)
     apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1)(*strict*)
     apply(force)
    apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1)(*strict*)
    apply(force)
   apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1)(*strict*)
   apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1)(*strict*)
  apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1)(*strict*)
  apply(simp add: cfgLM_step_relation_def)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 l r)(*strict*)
  apply(simp add: setAConcat)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1)(*strict*)
  apply(erule exE)+
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL)(*strict*)
  apply(clarsimp)
  apply(erule_tac x="k1" and P="%k. k\<le>Suc(k1 + (k2 + k3)) \<longrightarrow>
          (\<exists>eL cL.
             dL k = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d k = Some (pair eR cR) \<and>
                 (case eR of None \<Rightarrow> True
                  | Some eR' \<Rightarrow>
                      eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G)
                              (epda_gamma G) \<longrightarrow>
                      (case eL of None \<Rightarrow> False
                       | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                 (setA (cfg_conf cR) \<noteq> {} \<longrightarrow>
                  (\<exists>w. set w \<subseteq> epda_gamma G \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w))))" in allE')
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL cL)(*strict*)
  apply(simp add: setAConcat)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(subgoal_tac "\<exists>d. l3_derivation G d (stack s1@w) qA A qA' k1 k2")
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w da)(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__l3_approx_contains_all_relevant_nonterminals2)
    apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w da)(*strict*)
    apply(force)
   apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w da)(*strict*)
   apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w da)(*strict*)
  apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w da)(*strict*)
  apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(rule_tac x="dL" in exI)
  apply(simp add: l3_derivation_def)
  apply(rule conjI)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(rule_tac t="(THE v. \<exists>w. liftB v1 @ teA (cons_l3   qA A qA') # liftA s1 =
                            liftB w @ liftA v)" and s="cons_l3 qA A qA' # s1" in ssubst)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(rule SPLIT_2_0)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(thin_tac "case e1 of None \<Rightarrow> True
       | Some eR' \<Rightarrow>
           eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G) (epda_gamma G) \<longrightarrow>
           (case eL of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')")
  apply(thin_tac "discard_font_state (event_stack_separation (liftB v2 @ teA (cons_l3   qB A qA') # teA C # liftA s2)) \<sqsupseteq>
       discard_font_state (event_stack_separation (teA (cons_l3   qA A qA') # liftA s1))")
  apply(thin_tac "l3_l2_separation_ALT (cons_l3 qB A qA' # C # s2)")
  apply(subgoal_tac "state_adjacency_and_no_l2_before_l3 (cons_l3 qB A qA' # C # s2)")
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  prefer 2
  apply(rule_tac n="k1 + k2" and G="F_SDPDA_TO_CFG_STD G" and d="d" in cfgLM_reachable_have_state_adjacency_and_no_l2_before_l3)
     apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
     apply(force)
    apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
    apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
    apply(rule cfg_sub_reflexive)
   apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
   apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(rule_tac t="epdaH_conf_stack
           (F_SDPDA_TO_CFG_STD__configuration_basic_RL
             \<lparr>cfg_conf = liftB v1 @ teA (cons_l3   qA A qA') # liftA s1\<rparr> w) =
          A # stack s1 @ w " and s="True" in ssubst)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(simp (no_asm) add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(rule_tac t="(THE v. \<exists>w. liftB v1 @ teA (cons_l3   qA A qA') # liftA s1 =
                            liftB w @ liftA v)" and s="cons_l3 qA A qA' # s1" in ssubst)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(rule SPLIT_2_0)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(clarsimp)
  apply(simp (no_asm) add: stack_def)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "\<forall>i\<le>k2. \<exists>eL cL. dL (k1+i) = Some (pair eL cL) \<and> (\<exists>eR cR. d (k1+i) = Some (pair eR cR) \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)")
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  prefer 2
  apply(rule allI)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i)(*strict*)
  apply(clarsimp)
  apply(erule_tac x="k1+i" and P="%x. x\<le>Suc (k1 + (k2 + k3)) \<longrightarrow> (
          \<exists>eL cL.
             dL x = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d x = Some (pair eR cR) \<and>
                 (case eR of None \<Rightarrow> True
                  | Some eR' \<Rightarrow>
                      eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G)
                              (epda_gamma G) \<longrightarrow>
                      (case eL of None \<Rightarrow> False
                       | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                 (setA (cfg_conf cR) \<noteq> {} \<longrightarrow>
                  (\<exists>w. set w \<subseteq> epda_gamma G \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w))))" in allE')
  apply(erule impE)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i)(*strict*)
  apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i)(*strict*)
  apply(erule exE)+
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL)(*strict*)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
  apply(rule_tac G="G" and dL="dL" and dR="d" and m="k1" and k="k1+i" and n="k1+k2" in equal_extension_for_backtransfer)
              apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
              apply(force)
             apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
             apply(force)
            apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
            apply(force)
           apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
           apply(force)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
          apply(clarsimp)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka)(*strict*)
          apply(erule_tac x="ka" and P="%x. x\<le>Suc (k1 + (k2 + k3)) \<longrightarrow> (
          \<exists>eL cL.
             dL x = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d x = Some (pair eR cR) \<and>
                 (case eR of None \<Rightarrow> True
                  | Some eR' \<Rightarrow>
                      eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G)
                              (epda_gamma G) \<longrightarrow>
                      (case eL of None \<Rightarrow> False
                       | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                 (setA (cfg_conf cR) \<noteq> {} \<longrightarrow>
                  (\<exists>w. set w \<subseteq> epda_gamma G \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w))))" in allE)
          apply(erule_tac P="ka \<le> Suc (k1 + (k2 + k3))" in impE)
           apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka)(*strict*)
           apply(force)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka)(*strict*)
          apply(erule exE)+
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka eLb cLa)(*strict*)
          apply(rule_tac x="eLb" in exI)
          apply(rule_tac x="cLa" in exI)
          apply(clarsimp)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka eLb cLa eRa cRa)(*strict*)
          apply(subgoal_tac "X" for X)
           apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka eLb cLa eRa cRa)(*strict*)
           prefer 2
           apply(rule_tac
    n="ka"
    and m="(Suc (Suc (k1 + (k2 + k3))))"
    in cfgLM.step_detail_before_some_position)
             apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka eLb cLa eRa cRa)(*strict*)
             apply(rule_tac d="d" in cfgLM.derivation_initial_is_derivation)
             apply(force)
            apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka eLb cLa eRa cRa)(*strict*)
            apply(force)
           apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka eLb cLa eRa cRa)(*strict*)
           apply(force)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka eLb cLa eRa cRa)(*strict*)
          apply(clarsimp)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka eLb cLa eRa cRa e2b c2)(*strict*)
          apply(simp add: cfgLM_step_relation_def)
          apply(clarsimp)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka eLb cLa eRa cRa e2b c2 l r la ra)(*strict*)
          apply(simp add: setAConcat)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
         apply(clarsimp)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR ka)(*strict*)
         apply(thin_tac "dL X = Y" for X Y)
         apply(thin_tac "dL X = Y" for X Y)
         apply(thin_tac "\<forall>x<Suc k2.
          \<forall>e c. d (k1 + x) = Some (pair e c) \<longrightarrow>
                (\<forall>w1 w2.
                    cfg_conf c = liftB w1 @ liftA w2 \<longrightarrow>
                    discard_font_state (event_stack_separation (liftB w1 @ liftA w2)) \<sqsupseteq>
                    discard_font_state (event_stack_separation (teA (cons_l3   qA A qA') # liftA s1)))")
         apply(thin_tac "\<forall>x\<le>Suc (k1 + (k2 + k3)).
          \<exists>eL cL.
             dL x = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d x = Some (pair eR cR) \<and>
                 (case eR of None \<Rightarrow> True
                  | Some eR' \<Rightarrow>
                      eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G)
                              (epda_gamma G) \<longrightarrow>
                      (case eL of None \<Rightarrow> False
                       | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                 (setA (cfg_conf cR) \<noteq> {} \<longrightarrow>
                  (\<exists>w. set w \<subseteq> epda_gamma G \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)))")
         apply(clarsimp)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa cL eR cR ka)(*strict*)
         apply(erule_tac x="ka-k1" in allE)
         apply(clarsimp)
         apply(thin_tac "setA (cfg_conf cR) \<noteq> {} \<longrightarrow>
       (\<exists>w. set w \<subseteq> epda_gamma G \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w)")
         apply(erule impE)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa cL eR cR ka)(*strict*)
          apply(force)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa cL eR cR ka)(*strict*)
         apply(clarsimp)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka)(*strict*)
         apply(subgoal_tac "X" for X)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka)(*strict*)
          prefer 2
          apply(rule_tac M="F_SDPDA_TO_CFG_STD G" and g="d" and n="ka" in cfgLM.pre_some_position_is_some_position)
            apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka)(*strict*)
            apply(simp add: cfgLM.derivation_initial_def)
           apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka)(*strict*)
           apply(force)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka)(*strict*)
          apply(force)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka)(*strict*)
         apply(clarsimp)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e c)(*strict*)
         apply(case_tac c)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e c cfg_confa)(*strict*)
         apply(subgoal_tac "X" for X)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e c cfg_confa)(*strict*)
          prefer 2
          apply(rule_tac n="ka" and G="F_SDPDA_TO_CFG_STD G" in singleIsertionOfLM_rechable_conf_form)
             apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e c cfg_confa)(*strict*)
             apply(force)
            apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e c cfg_confa)(*strict*)
            apply(force)
           apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e c cfg_confa)(*strict*)
           apply(rule LR1ProdFormSimp_implies_singleIsertionOfLM)
           apply(rule LR1ProdForm_implies_LR1ProdFormSimp)
           apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
           apply(rule cfg_sub_reflexive)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e c cfg_confa)(*strict*)
          apply(clarsimp)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e cfg_conf)(*strict*)
          apply(force)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e c cfg_confa)(*strict*)
         apply(clarsimp)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e w1 w2)(*strict*)
         apply(simp add: setAConcat)
         apply(subgoal_tac "\<exists>w. liftB w= w1")
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e w1 w2)(*strict*)
          prefer 2
          apply(rule_tac x="filterB w1" in exI)
          apply(rule liftBDeConv2)
          apply(force)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e w1 w2)(*strict*)
         apply(subgoal_tac "\<exists>w. liftA w= w2")
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e w1 w2)(*strict*)
          prefer 2
          apply(rule_tac x="filterA w2" in exI)
          apply(rule sym)
          apply(rule setB_empty_then_liftA_vs_filterA)
          apply(force)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e w1 w2)(*strict*)
         apply(clarsimp)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb wc)(*strict*)
         apply(erule_tac x="wb" in allE)
         apply(erule_tac x="wc" in allE)
         apply(clarsimp)
         apply(case_tac wc)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb wc)(*strict*)
          apply(force)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb wc a list)(*strict*)
         apply(clarsimp)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a list)(*strict*)
         apply(case_tac list)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a list)(*strict*)
          apply(force)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a list aa lista)(*strict*)
         apply(clarsimp)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista)(*strict*)
         apply(subgoal_tac "state_adjacency_and_no_l2_before_l3 (a#aa#lista)")
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista)(*strict*)
          prefer 2
          apply(rule_tac n="ka" and G="F_SDPDA_TO_CFG_STD G" and d="d" in cfgLM_reachable_have_state_adjacency_and_no_l2_before_l3)
              apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista)(*strict*)
              apply(force)
             apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista)(*strict*)
             apply(rule sub_of_F_SDPDA_TO_CFG_STD__implies_LR1ProdForm)
             apply(rule cfg_sub_reflexive)
            apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista)(*strict*)
            apply(force)
           apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista)(*strict*)
           apply(force)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista)(*strict*)
          apply(force)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista)(*strict*)
         apply(simp add: state_adjacency_and_no_l2_before_l3_def)
         apply(erule_tac x="[]" in allE)
         apply(clarsimp)
         apply(case_tac a)
          apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista state stack)(*strict*)
          apply(force)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb a aa lista state1 stack state2)(*strict*)
         apply(clarsimp)
         apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL w i eLa eR cR ka e wb aa lista state1 stack state2)(*strict*)
         apply(rule_tac x="state1" in exI)
         apply(rule_tac x="stack" in exI)
         apply(rule_tac x="state2" in exI)
         apply(simp (no_asm))
        apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
        apply(force)
       apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
       apply(force)
      apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
      apply(force)
     apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
     apply(force)
    apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
    apply(force)
   apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
   apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
  apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w i eLa cL eR cR)(*strict*)
  apply(force)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w)(*strict*)
  apply(erule_tac x="k2" and P="%i. i\<le>k2 \<longrightarrow> (\<exists>eL cL. dL (k1+i) = Some (pair eL cL) \<and> (\<exists>eR cR. d (k1+i) = Some (pair eR cR) \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w))" in allE')
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w eLa)(*strict*)
  apply(erule_tac x="(k1+k2)" and P="%k. k\<le>Suc(k1 + (k2 + k3)) \<longrightarrow>
          (\<exists>eL cL.
             dL k = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d k = Some (pair eR cR) \<and>
                 (case eR of None \<Rightarrow> True
                  | Some eR' \<Rightarrow>
                      eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G)
                              (epda_gamma G) \<longrightarrow>
                      (case eL of None \<Rightarrow> False
                       | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                 (setA (cfg_conf cR) \<noteq> {} \<longrightarrow>
                  (\<exists>w. set w \<subseteq> epda_gamma G \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w))))" in allE')
  apply(clarsimp)
  apply(simp add: setAConcat)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w eLa wb)(*strict*)
  apply(erule_tac x="Suc(k1+k2)" and P="%k. k\<le>Suc(k1 + (k2 + k3)) \<longrightarrow>
          (\<exists>eL cL.
             dL k = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d k = Some (pair eR cR) \<and>
                 (case eR of None \<Rightarrow> True
                  | Some eR' \<Rightarrow>
                      eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G)
                              (epda_gamma G) \<longrightarrow>
                      (case eL of None \<Rightarrow> False
                       | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                 (setA (cfg_conf cR) \<noteq> {} \<longrightarrow>
                  (\<exists>w. set w \<subseteq> epda_gamma G \<and> cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR w))))" in allE')
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w eLa wb eLb cL)(*strict*)
  apply(simp add: setAConcat)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w eLa wb eLb wc)(*strict*)
  apply(subgoal_tac "w=wb")
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w eLa wb eLb wc)(*strict*)
  prefer 2
  apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL w eLa wb eLb wc)(*strict*)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc)(*strict*)
  apply(case_tac k1)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc)(*strict*)
  apply(simp add: cfgLM.derivation_initial_def cfg_initial_configurations_def F_SDPDA_TO_CFG_STD_def)
  apply(clarsimp)
  apply(rename_tac v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc)(*strict*)
  apply(case_tac v1)
  apply(rename_tac v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc)(*strict*)
  apply(clarsimp)
  apply(rename_tac v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac k1 e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc nat)(*strict*)
  apply(rename_tac k1)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc k1)(*strict*)
  apply(subgoal_tac "wc=wb")
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc k1)(*strict*)
  prefer 2
  apply(thin_tac "dL (Suc k1) =
       Some (pair eL
              (F_SDPDA_TO_CFG_STD__configuration_basic_RL
                \<lparr>cfg_conf = liftB v1 @ teA (cons_l3   qA A qA') # liftA s1\<rparr> wb))")
  apply(thin_tac "d (Suc (Suc (k1 + (k2 + k3)))) = Some (pair e1a c1)")
  apply(thin_tac "case e2 of None \<Rightarrow> True
       | Some eR' \<Rightarrow>
           eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G) (epda_gamma G) \<longrightarrow>
           (case eLa of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')")
  apply(subgoal_tac "X" for X)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc k1)(*strict*)
  prefer 2
  apply(rule_tac
    n="Suc (k1 + k2)"
    and m="Suc (Suc (k1 + k2))"
    in epdaH.step_detail_before_some_position)
    apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc k1)(*strict*)
    apply(rule epdaH.derivation_initial_is_derivation)
    apply(force)
   apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc k1)(*strict*)
   apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc k1)(*strict*)
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc k1)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  apply(simp add: epdaH_step_relation_def)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(subgoal_tac "(THE v. \<exists>w. liftB v2 @ teA C # liftA s2 =
                                     liftB w @ liftA v) = C#s2")
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  prefer 2
  apply(rule SPLIT_2_0)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  apply(clarsimp)
  apply(fold stack_def)
  apply(simp add: F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1_def)
  apply(erule impE)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_final_def)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  apply(erule disjE)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_read_def)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  apply(erule disjE)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  prefer 2
  apply(erule disjE)
   apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_push_def)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  apply(erule disjE)
   apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
   apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_read_def)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l2_push_def)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b w)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__edges_l3_pop_def)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  apply(subgoal_tac "(THE v. \<exists>w. liftB v2 @
                    teA (cons_l3   (edge_src e2b) (edge_pop e2b ! 0) (edge_trg e2b)) #
                    teA C # liftA s2 =
                    liftB w @ liftA v) =  (cons_l3   (edge_src e2b) (edge_pop e2b ! 0) (edge_trg e2b)) #
                     C #  s2")
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  prefer 2
  apply(fold event_stack_separation_def)
  apply(rule_tac w="v2" in event_stack_separation_XX2)
  apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(simp add: stack_def)
  apply(fold stack_def)
  apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def valid_epda_def)
  apply(clarsimp)
  apply(erule_tac x="e2b" in ballE)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  apply(erule_tac x="e2b" in ballE)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  apply(erule_tac x="e2b" in ballE)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b)(*strict*)
  apply(case_tac e2b)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 e2b edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 edge_src edge_event edge_popa)(*strict*)
  apply(rename_tac qs r po)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 qs r po)(*strict*)
  apply(case_tac po)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 qs r po)(*strict*)
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 k3 e2a c1 dL eLa wb wc k1 qs r po a list)(*strict*)
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb wc k1)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1)(*strict*)
  apply(rule conjI)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1)(*strict*)
  apply(simp add: state_adjacency_and_no_l2_before_l3_def)
  apply(erule_tac x="[]" in allE)
  apply(clarsimp)
  apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(subgoal_tac " (THE v. \<exists>w. liftB v2 @ teA C # liftA s2 =
                            liftB w @ liftA v) =
                     C #  s2")
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1)(*strict*)
  prefer 2
  apply(fold event_stack_separation_def)
  apply(rule_tac w="v2" in event_stack_separation_XX2)
  apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1)(*strict*)
  apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(case_tac C)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1 state stack)(*strict*)
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1 state1 stack state2)(*strict*)
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1)(*strict*)
  apply(rule context_conjI)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1)(*strict*)
  prefer 2
  apply(thin_tac "dL (Suc k1) =
       Some (pair eL
              (F_SDPDA_TO_CFG_STD__configuration_basic_RL
                \<lparr>cfg_conf = liftB v1 @ teA (cons_l3   qA A qA') # liftA s1\<rparr> wb))")
  apply(thin_tac "d (Suc (Suc (k1 + (k2 + k3)))) = Some (pair e1a c1)")
  apply(thin_tac "case e2 of None \<Rightarrow> True
       | Some eR' \<Rightarrow>
           eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G) (epda_gamma G) \<longrightarrow>
           (case eLa of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')")
  apply(erule_tac x="k2" in allE)+
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(subgoal_tac "(THE v. \<exists>w. liftB v2 @ teA (cons_l3   qB A qA') # teA C # liftA s2 =
                     liftB w @ liftA v) =  (cons_l3 qB A qA') #  C #  s2")
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR)(*strict*)
  prefer 2
  apply(fold event_stack_separation_def)
  apply(rule_tac w="v2" in event_stack_separation_XX2)
  apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "(THE v. \<exists>w. liftB v2 @ teA C # liftA s2 = liftB w @ liftA v) =  C#s2")
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR)(*strict*)
  prefer 2
  apply(fold event_stack_separation_def)
  apply(rule_tac w="v2" in event_stack_separation_XX2)
  apply(simp add: liftA_commutes_over_concat liftB_commutes_over_concat)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR)(*strict*)
  apply(clarsimp)
  apply(simp add: suffix_def)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR c)(*strict*)
  apply(case_tac c)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR c)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR c a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR a list)(*strict*)
  apply(case_tac s1)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR a list)(*strict*)
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR a list aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 qA wa k2 e2 v2 C s2 qB qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR a list aa lista)(*strict*)
  apply(simp add: stack_def)
  apply(rule_tac X="(case C of cons_l2 q A \<Rightarrow> A | cons_l3 q A q' \<Rightarrow> A)" and ?w1.0="map (case_DT_l2_l3_nonterminals (\<lambda>q A. A) (\<lambda>q A q'. A)) s2" and ?v1.0="list" and a="a" in length_cmp_help)
  apply(rename_tac e1 v1 qA wa k2 e2 v2 C s2 qB qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR a list aa lista)(*strict*)
  prefer 2
  apply(force)
  apply(rename_tac e1 v1 qA wa k2 e2 v2 C s2 qB qA' k3 e2a c1 dL eLa wb eLb k1 eL cL eR cR a list aa lista)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1)(*strict*)
  apply(rule allI)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1 ka)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1 ka e c)(*strict*)
  apply(erule_tac x="ka" and P="%x. x\<le>k2 \<longrightarrow> (
          \<exists>eL cL.
             dL (Suc (k1 + x)) = Some (pair eL cL) \<and>
             (\<exists>eR cR.
                 d (Suc (k1 + x)) = Some (pair eR cR) \<and>
                 cL = F_SDPDA_TO_CFG_STD__configuration_basic_RL cR wb))" in allE)
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 e2 v2 C s2 qB A qA' k3 e1a e2a c1 dL eL eLa wb eLb k1 ka e eR cR)(*strict*)
  apply(simp add: F_SDPDA_TO_CFG_STD__configuration_basic_RL_def Let_def)
  apply(fold event_stack_separation_def stack_def)
  apply(thin_tac "dL Y = X" for X Y)
  apply(thin_tac "dL Y = X" for X Y)
  apply(thin_tac "dL Y = X" for X Y)
  apply(thin_tac "dL Y = X" for X Y)
  apply(thin_tac "\<forall>x\<le>Suc (Suc (k1 + (k2 + k3))).
              \<exists>eL cL.
                 dL x = Some (pair eL cL) \<and>
                 (\<exists>eR cR.
                     d x = Some (pair eR cR) \<and>
                     (case eR of None \<Rightarrow> True
                      | Some eR' \<Rightarrow>
                          eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G)
                                  (epda_gamma G) \<longrightarrow>
                          (case eL of None \<Rightarrow> False
                           | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')) \<and>
                     (setA (cfg_conf cR) \<noteq> {} \<longrightarrow>
                      (\<exists>w. set w \<subseteq> epda_gamma G \<and>
                           cL =
                           \<lparr>epdaH_conf_state =
                              case hd (event_stack_separation (cfg_conf cR)) of cons_l2 q A \<Rightarrow> q
                              | cons_l3 q A q' \<Rightarrow> q,
                              epdaH_conf_history =
                                THE w. \<exists>v. cfg_conf cR = liftB w @ liftA v,
                              epdaH_conf_stack =
                                stack (event_stack_separation (cfg_conf cR)) @ w\<rparr>)))")
  apply(thin_tac "case e2 of None \<Rightarrow> True
           | Some eR' \<Rightarrow>
               eR' \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G) (epda_gamma G) \<longrightarrow>
               (case eLa of None \<Rightarrow> False | Some eL' \<Rightarrow> eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G eR')")
  apply(thin_tac "epdaH.derivation_initial G
            dL")
  apply(thin_tac "\<lparr>prod_lhs = cons_l3 qB A qA', prod_rhs = []\<rparr>
           \<notin> F_SDPDA_TO_CFG_STD__edges_l2_final (epda_marking G) (epda_gamma G) \<longrightarrow>
           (case eLb of None \<Rightarrow> False
            | Some eL' \<Rightarrow>
                eL' \<in> F_DPDA_DRE__revert_F_SDPDA_TO_CFG_STD_1 G \<lparr>prod_lhs = cons_l3 qB A qA', prod_rhs = []\<rparr>)")
  apply(thin_tac "\<forall>x<Suc k2.
              \<forall>e c. d (Suc (k1 + x)) = Some (pair e c) \<longrightarrow>
                    (\<forall>w1 w2.
                        cfg_conf c = liftB w1 @ liftA w2 \<longrightarrow>
                        discard_font_state (event_stack_separation (liftB w1 @ liftA w2)) \<sqsupseteq>
                        discard_font_state (event_stack_separation (teA (cons_l3   qA A qA') # liftA s1)))")
  apply(thin_tac "cfgLM_step_relation (F_SDPDA_TO_CFG_STD G) c1 e2a
            \<lparr>cfg_conf = liftB wa\<rparr>")
  apply(thin_tac "d (Suc (Suc (k1 + k2))) =
           Some (pair (Some \<lparr>prod_lhs = cons_l3 qB A qA', prod_rhs = []\<rparr>)
                  \<lparr>cfg_conf = liftB v2 @ teA C # liftA s2\<rparr>)")
  apply(thin_tac "d (Suc (k1 + k2)) =
           Some (pair e2
                  \<lparr>cfg_conf =
                     liftB v2 @ teA (cons_l3   qB A qA') # teA C # liftA s2\<rparr>)")
  apply(thin_tac "l3_l2_separation_ALT (cons_l3 qA A qA' # s1)")
  apply(thin_tac "\<lparr>prod_lhs = cons_l3 qB A qA', prod_rhs = []\<rparr>
           \<in> cfg_productions (F_SDPDA_TO_CFG_STD G)")
  apply(thin_tac "state_adjacency_and_no_l2_before_l3 (cons_l3 qB A qA' # C # s2)")
  apply(clarsimp)
  apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
  apply(rule stack_remains_in_cfgLM_derivation)
              apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
              apply(force)
             apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
             apply(force)
            apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
            apply(force)
           apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
           apply(force)
          apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
          apply(force)
         apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
         apply(force)
        apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
        apply(force)
       apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
       apply(force)
      apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
      apply(force)
     apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
     apply(force)
    apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
    apply(force)
   apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
   apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
  apply(force)
  apply(rename_tac e1 v1 s1 qA wa k2 s2 A qA' k3 e1a e2a c1 wb k1 ka eR cR)(*strict*)
  apply(force)
  done

theorem F_SDPDA_TO_CFG_STD__vs_F_SDPDA_TO_CFG_OPT: "
  valid_simple_dpda G
  \<Longrightarrow> k > 0
  \<Longrightarrow> Gstd = F_SDPDA_TO_CFG_STD G
  \<Longrightarrow> F_SDPDA_TO_CFG_OPT G k = Some Gopt
  \<Longrightarrow> cfgLM.marked_language Gstd = cfgLM.marked_language Gopt"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__makes_valid_cfg)
     apply(force)
    apply(force)
   apply(force)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_STD__makes_CFG)
   apply(force)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__is_cfg_sub_of_F_SDPDA_TO_CFG_STD)
     apply(force)
    apply(force)
   apply(force)
  apply(rule sym)
  apply(rule cfg_sub_equal_marked_language)
      apply(force)
     apply(force)
    apply(force)
   apply(simp add: F_SDPDA_TO_CFG_OPT_def Let_def F_SDPDA_TO_CFG_STD_def)
   apply(case_tac "cons_l2 (epda_initial G) (epda_box G) \<in> (case F_SDPDA_TO_CFG_OPT__nonterminals G k of cons_tuple2 S2 S3 \<Rightarrow> S2)")
    apply(force)
   apply(force)
  apply(clarsimp)
  apply(rename_tac d)(*strict*)
  apply(rule cfg_sub_preserves_derivation_initial_reverse)
       apply(rename_tac d)(*strict*)
       apply(force)
      apply(rename_tac d)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac d)(*strict*)
     apply(force)
    apply(rename_tac d)(*strict*)
    apply(force)
   apply(rename_tac d)(*strict*)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__cfg_sub_by_nonterminals)
        apply(rename_tac d)(*strict*)
        apply(force)
       apply(rename_tac d)(*strict*)
       apply(force)
      apply(rename_tac d)(*strict*)
      apply(force)
     apply(rename_tac d)(*strict*)
     apply(force)
    apply(rename_tac d)(*strict*)
    apply(force)
   apply(rename_tac d)(*strict*)
   apply(force)
  apply(rename_tac d)(*strict*)
  apply(clarsimp del: subsetI)
  apply(rename_tac d i e c)(*strict*)
  apply(rule F_SDPDA_TO_CFG_OPT__has_same_reachable_nonterminals)
          apply(rename_tac d i e c)(*strict*)
          apply(force)
         apply(rename_tac d i e c)(*strict*)
         apply(force)
        apply(rename_tac d i e c)(*strict*)
        apply(force)
       apply(rename_tac d i e c)(*strict*)
       apply(force)
      apply(rename_tac d i e c)(*strict*)
      apply(force)
     apply(rename_tac d i e c)(*strict*)
     apply(force)
    apply(rename_tac d i e c)(*strict*)
    apply(force)
   apply(rename_tac d i e c)(*strict*)
   apply(force)
  apply(rename_tac d i e c)(*strict*)
  apply(force)
  done

lemma cfg_sub_preserves_cfgLM_initial_marking_derivations: "
  valid_cfg Gi
  \<Longrightarrow> valid_cfg Go
  \<Longrightarrow> cfg_sub Go Gi
  \<Longrightarrow> cfgLM.initial_marking_derivations Go \<subseteq> cfgLM.initial_marking_derivations Gi"
  apply(simp add: cfgLM.initial_marking_derivations_def)
  apply(clarsimp)
  apply(simp add: cfg_marking_condition_def)
  apply(rule conjI)
   apply (metis cfg_sub_preserves_derivation_initialLM)
  apply(clarsimp)
  apply(rule_tac x="i" in exI)
  apply(clarsimp)
  apply(simp add: cfg_marking_configuration_def cfg_configurations_def cfg_sub_def)
  apply(clarsimp)
  apply(force)
  done

lemma cfg_sub_preserves_initial_marking_derivations_reverse: "
  valid_cfg G1
  \<Longrightarrow> valid_cfg G2
  \<Longrightarrow> cfg_sub G1 G2
  \<Longrightarrow> cfg_events G1 = cfg_events G2
  \<Longrightarrow> (\<forall>d. cfgLM.derivation_initial G2 d \<longrightarrow> cfg_marking_condition G2 d \<longrightarrow> cfgLM.derivation_initial G1 d)
  \<Longrightarrow> cfgLM.initial_marking_derivations G2 \<subseteq> cfgLM.initial_marking_derivations G1"
  apply(clarsimp)
  apply(simp add: cfgLM.initial_marking_derivations_def)
  apply(clarsimp)
  apply(simp add: cfg_marking_condition_def)
  apply(clarsimp)
  apply(rule_tac x="i" in exI)
  apply(clarsimp)
  apply(simp add: cfg_marked_effect_def cfg_marking_configuration_def valid_cfg_def cfg_sub_def cfg_configurations_def)
  apply(clarsimp)
  done

lemma F_SDPDA_TO_CFG_STD_and_F_SDPDA_TO_CFG_OPT_preserves_initial_marking_derivations: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> Gstd = F_SDPDA_TO_CFG_STD G
  \<Longrightarrow> Some Gopt = F_SDPDA_TO_CFG_OPT G k
  \<Longrightarrow> valid_cfg Gopt
  \<Longrightarrow> cfg_sub Gopt (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> valid_cfg (F_SDPDA_TO_CFG_STD G) \<and> ATS_Language0.marked_language epdaS_initial_configurations epdaS_step_relation epdaS_marking_condition epdaS_marked_effect G = ATS_Language0.marked_language cfg_initial_configurations cfgSTD_step_relation cfg_marking_condition cfg_marked_effect (F_SDPDA_TO_CFG_STD G)
  \<Longrightarrow> ATS_Language0.initial_marking_derivations cfg_initial_configurations cfgLM_step_relation cfg_marking_condition (F_SDPDA_TO_CFG_STD G) \<subseteq> ATS_Language0.initial_marking_derivations cfg_initial_configurations cfgLM_step_relation cfg_marking_condition Gopt"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__makes_valid_cfg)
     apply(force)
    apply(force)
   apply(rule sym)
   apply(force)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_STD__makes_CFG)
   apply(force)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__is_cfg_sub_of_F_SDPDA_TO_CFG_STD)
     apply(force)
    apply(force)
   apply(rule sym)
   apply(force)
  apply(rule cfg_sub_preserves_initial_marking_derivations_reverse)
      apply(force)
     apply(force)
    apply(force)
   apply(simp add: F_SDPDA_TO_CFG_STD_def F_SDPDA_TO_CFG_OPT_def Let_def)
   apply(case_tac "cons_l2 (epda_initial G) (epda_box G)
           \<in> (case F_SDPDA_TO_CFG_OPT__nonterminals G k of
               cons_tuple2 S2 S3 \<Rightarrow> S2)")
    apply(force)
   apply(force)
  apply(clarsimp)
  apply(rule cfg_sub_preserves_derivation_initial_reverse)
       apply(force)
      prefer 2
      apply(force)
     apply(force)
    apply(force)
   prefer 2
   apply(rule F_SDPDA_TO_CFG_OPT__cfg_sub_by_nonterminals)
        apply(force)
       apply(force)
      apply(force)
     apply(force)
    apply(force)
   apply(force)
  apply(clarsimp del: subsetI)
  apply(rule F_SDPDA_TO_CFG_OPT__has_same_reachable_nonterminals)
          apply(force)
         apply(force)
        apply(force)
       apply(force)
      apply(force)
     apply(force)
    apply(force)
   apply(force)
  apply(force)
  done

lemma reach_k_mono: "
  reach_k_TERM_ARGS_TEST G k E
  \<Longrightarrow> E \<subseteq> reach_k G k E"
  apply(rule reach_k_Meta_Lift_prime)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(rule_tac B="reach_k_loop1 Ga ka N" in subset_trans)
    apply(rename_tac Ga ka N)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(simp add: reach_k_loop1_def)
  apply(rename_tac Ga ka N)(*strict*)
  apply(rule_tac ?x.0="Ga" and ?xa.0="ka" and ?xb.0="N" in reach_k.pelims)
    apply(rename_tac Ga ka N)(*strict*)
    apply(force)
   apply(rename_tac Ga ka N)(*strict*)
   apply(rule reach_k_termination)
   apply(force)
  apply(rename_tac Ga ka N Gaa kaa Ea)(*strict*)
  apply(clarsimp)
  done

corollary reach_k_identifies_only_useless_states: "
  valid_epda G
  \<Longrightarrow> Q = {q | x q s. cons_tuple2 x (Some (cons_tuple2 q s)) \<in> reach_k G k {reach_k_initial G k}}
  \<Longrightarrow> q \<in> epda_states G - Q
  \<Longrightarrow> epdaH.derivation_initial G d
  \<Longrightarrow> d i = Some (pair e c)
  \<Longrightarrow> epdaH_conf_state c = q
  \<Longrightarrow> False"
  apply(clarsimp)
  apply(case_tac i)
   apply(clarsimp)
   apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def)
   apply(clarsimp)
   apply(case_tac c)
   apply(rename_tac epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
   apply(clarsimp)
   apply(erule_tac x="None" in allE)
   apply(erule_tac x="take k [epda_box G]" in allE)
   apply(fold reach_k_initial_def)
   apply(subgoal_tac "reach_k_initial G k \<in> reach_k G k {reach_k_initial G k}")
    apply(force)
   apply(rule_tac A="{reach_k_initial G k}" in set_mp)
    prefer 2
    apply(force)
   apply(rule reach_k_mono)
   apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
   apply(force)
  apply(rename_tac nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   apply(rename_tac nat)(*strict*)
   prefer 2
   apply(rule_tac
      d="d" and
      n="nat" and
      m="Suc nat"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac nat)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac nat)(*strict*)
    apply(force)
   apply(rename_tac nat)(*strict*)
   apply(force)
  apply(rename_tac nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac nat e1 e2 c1)(*strict*)
  apply(subgoal_tac "reach_k_one_step_contained G k (reach_k G k {reach_k_initial G k}) {0}")
   apply(rename_tac nat e1 e2 c1)(*strict*)
   prefer 2
   apply(rule reach_k_enforces_reach_k_one_step_contained)
   apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
   apply(force)
  apply(rename_tac nat e1 e2 c1)(*strict*)
  apply(simp add: reach_k_one_step_contained_def)
  apply(erule_tac x="d" in allE)
  apply(clarsimp)
  apply(erule_tac x="nat" in allE)
  apply(force)
  done

corollary reach_k_contains_all_reachable_l2_nonterminals: "
  valid_epda G
  \<Longrightarrow> Qcomp = {cons_l2 q A | x q A s. cons_tuple2 x (Some (cons_tuple2 q s)) \<in> reach_k G k {reach_k_initial G k} \<and> A \<in> epda_gamma G \<and> (prefix [A] s \<or> s = []) }
  \<Longrightarrow> Qsem = {cons_l2 q A | q A d i e c. epdaH.derivation_initial G d \<and> d i = Some (pair e c) \<and> q = epdaH_conf_state c \<and> A = hd (epdaH_conf_stack c) }
  \<Longrightarrow> Qsem \<subseteq> Qcomp"
  apply(clarsimp)
  apply(rename_tac d i e c)(*strict*)
  apply(case_tac i)
   apply(rename_tac d i e c)(*strict*)
   apply(clarsimp)
   apply(rename_tac d e c)(*strict*)
   apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def)
   apply(clarsimp)
   apply(rename_tac d c)(*strict*)
   apply(case_tac c)
   apply(rename_tac d c epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
   apply(clarsimp)
   apply(rename_tac d)(*strict*)
   apply(rule_tac x="None" in exI)
   apply(rule_tac x="take k [epda_box G]" in exI)
   apply(fold reach_k_initial_def)
   apply(subgoal_tac "reach_k_initial G k \<in> reach_k G k {reach_k_initial G k}")
    apply(rename_tac d)(*strict*)
    prefer 2
    apply(rule_tac A="{reach_k_initial G k}" in set_mp)
     apply(rename_tac d)(*strict*)
     prefer 2
     apply(force)
    apply(rename_tac d)(*strict*)
    apply(rule reach_k_mono)
    apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
    apply(force)
   apply(rename_tac d)(*strict*)
   apply(clarsimp)
   apply(simp add: valid_epda_def prefix_def)
   apply(force)
  apply(rename_tac d i e c nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac d e c nat)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac d e c nat)(*strict*)
   prefer 2
   apply(rule_tac
      d="d" and
      n="nat" and
      m="Suc nat"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac d e c nat)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac d e c nat)(*strict*)
    apply(force)
   apply(rename_tac d e c nat)(*strict*)
   apply(force)
  apply(rename_tac d e c nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac d c nat e1 e2 c1)(*strict*)
  apply(subgoal_tac "reach_k_one_step_contained G k (reach_k G k {reach_k_initial G k}) {0}")
   apply(rename_tac d c nat e1 e2 c1)(*strict*)
   prefer 2
   apply(rule reach_k_enforces_reach_k_one_step_contained)
   apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
   apply(force)
  apply(rename_tac d c nat e1 e2 c1)(*strict*)
  apply(simp add: reach_k_one_step_contained_def)
  apply(erule_tac x="d" in allE)
  apply(clarsimp)
  apply(erule_tac x="nat" in allE)
  apply(clarsimp)
  apply(rename_tac d c nat e1 e2 c1 w1 w2)(*strict*)
  apply(rule_tac x="(Some (cons_tuple2 (epdaH_conf_state c1) (take k w1)))" in exI)
  apply(rule_tac x="(take k w2)" in exI)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   apply(rename_tac d c nat e1 e2 c1 w1 w2)(*strict*)
   prefer 2
   apply(rule_tac i="Suc nat" in epda_box_stays_at_bottom_epdaH)
     apply(rename_tac d c nat e1 e2 c1 w1 w2)(*strict*)
     apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
    apply(rename_tac d c nat e1 e2 c1 w1 w2)(*strict*)
    apply(force)
   apply(rename_tac d c nat e1 e2 c1 w1 w2)(*strict*)
   apply(force)
  apply(rename_tac d c nat e1 e2 c1 w1 w2)(*strict*)
  apply(clarsimp)
  apply(rename_tac d c nat e1 e2 c1 w1 w2 w)(*strict*)
  apply(rule conjI)
   apply(rename_tac d c nat e1 e2 c1 w1 w2 w)(*strict*)
   apply(case_tac w)
    apply(rename_tac d c nat e1 e2 c1 w1 w2 w)(*strict*)
    apply(clarsimp)
    apply(rename_tac d c nat e1 e2 c1 w1 w2)(*strict*)
    apply(simp add: valid_epda_def)
   apply(rename_tac d c nat e1 e2 c1 w1 w2 w a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac d c nat e1 e2 c1 w1 w2 a list)(*strict*)
   apply(subgoal_tac "c \<in> epdaH_configurations G")
    apply(rename_tac d c nat e1 e2 c1 w1 w2 a list)(*strict*)
    apply(simp add: epdaH_configurations_def)
    apply(force)
   apply(rename_tac d c nat e1 e2 c1 w1 w2 a list)(*strict*)
   apply(rule epdaH.belongs_configurations)
    apply(rename_tac d c nat e1 e2 c1 w1 w2 a list)(*strict*)
    apply(rule epdaH.derivation_initial_belongs)
     apply(rename_tac d c nat e1 e2 c1 w1 w2 a list)(*strict*)
     apply(force)
    apply(rename_tac d c nat e1 e2 c1 w1 w2 a list)(*strict*)
    apply(force)
   apply(rename_tac d c nat e1 e2 c1 w1 w2 a list)(*strict*)
   apply(force)
  apply(rename_tac d c nat e1 e2 c1 w1 w2 w)(*strict*)
  apply(clarsimp)
  apply(simp add: prefix_def)
  apply(clarsimp)
  apply(rename_tac d c nat e1 e2 c1 w1 w2 w ca cb)(*strict*)
  apply(case_tac k)
   apply(rename_tac d c nat e1 e2 c1 w1 w2 w ca cb)(*strict*)
   apply(force)
  apply(rename_tac d c nat e1 e2 c1 w1 w2 w ca cb nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac k)
  apply(rename_tac d c nat e1 e2 c1 w1 w2 w ca cb k)(*strict*)
  apply(case_tac w2)
   apply(rename_tac d c nat e1 e2 c1 w1 w2 w ca cb k)(*strict*)
   apply(clarsimp)
  apply(rename_tac d c nat e1 e2 c1 w1 w2 w ca cb k a list)(*strict*)
  apply(clarsimp)
  apply(rename_tac d c nat e1 e2 c1 w1 w ca cb k a list)(*strict*)
  apply(case_tac w)
   apply(rename_tac d c nat e1 e2 c1 w1 w ca cb k a list)(*strict*)
   apply(clarsimp)
  apply(rename_tac d c nat e1 e2 c1 w1 w ca cb k a list aa lista)(*strict*)
  apply(force)
  done

corollary reach_k_identifies_only_useless_edges: "
  valid_epda G
  \<Longrightarrow> D = {e | x q s e. cons_tuple2 x (Some (cons_tuple2 q s)) \<in> reach_k G k {reach_k_initial G k} \<and> edge_src e = q \<and> (prefix (edge_pop e) s \<or> prefix s (edge_pop e)) }
  \<Longrightarrow> e \<in> epda_delta G - D
  \<Longrightarrow> epdaH.derivation_initial G d
  \<Longrightarrow> d i = Some (pair (Some e) c)
  \<Longrightarrow> False"
  apply(clarsimp)
  apply(case_tac i)
   apply(clarsimp)
   apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def)
  apply(rename_tac nat)(*strict*)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   apply(rename_tac nat)(*strict*)
   prefer 2
   apply(rule_tac
      d="d" and
      n="nat" and
      m="Suc nat"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac nat)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac nat)(*strict*)
    apply(force)
   apply(rename_tac nat)(*strict*)
   apply(force)
  apply(rename_tac nat)(*strict*)
  apply(clarsimp)
  apply(rename_tac nat e1 c1)(*strict*)
  apply(subgoal_tac "reach_k_one_step_contained G k (reach_k G k {reach_k_initial G k}) {0}")
   apply(rename_tac nat e1 c1)(*strict*)
   prefer 2
   apply(rule reach_k_enforces_reach_k_one_step_contained)
   apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
   apply(force)
  apply(rename_tac nat e1 c1)(*strict*)
  apply(case_tac nat)
   apply(rename_tac nat e1 c1)(*strict*)
   apply(clarsimp)
   apply(rename_tac e1 c1)(*strict*)
   apply(simp add: reach_k_one_step_contained_def)
   apply(erule_tac x="d" in allE)
   apply(clarsimp)
   apply(erule_tac x="0" in allE)
   apply(clarsimp)
   apply(rename_tac e1 c1 w1 w2)(*strict*)
   apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def epdaH_step_relation_def)
   apply(clarsimp)
   apply(rename_tac c1 w1 w2 w)(*strict*)
   apply(case_tac e)
   apply(rename_tac c1 w1 w2 w edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
   apply(rename_tac q r po pu q')
   apply(rename_tac c1 w1 w2 w q r po pu q')(*strict*)
   apply(case_tac c)
   apply(rename_tac c1 w1 w2 w q r po pu q' epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
   apply(rename_tac q1 h1 s1)
   apply(rename_tac c1 w1 w2 w q r po pu q' q1 h1 s1)(*strict*)
   apply(case_tac c1)
   apply(rename_tac c1 w1 w2 w q r po pu q' q1 h1 s1 epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
   apply(rename_tac q2 h2 s2)
   apply(rename_tac c1 w1 w2 w q r po pu q' q1 h1 s1 q2 h2 s2)(*strict*)
   apply(clarsimp)
   apply(rename_tac w1 w2 w r po pu q')(*strict*)
   apply(erule_tac x="None" in allE)
   apply(erule_tac x="take k [epda_box G]" in allE)
   apply(erule impE)
    apply(rename_tac w1 w2 w r po pu q')(*strict*)
    apply(fold reach_k_initial_def)
    apply(rule_tac A="{reach_k_initial G k}" in set_mp)
     apply(rename_tac w1 w2 w r po pu q')(*strict*)
     apply(rule reach_k_mono)
     apply(rule reach_k_TERM_ARGS_TEST_with_reach_k_initial)
     apply(force)
    apply(rename_tac w1 w2 w r po pu q')(*strict*)
    apply(clarsimp)
   apply(rename_tac w1 w2 w r po pu q')(*strict*)
   apply(simp add: prefix_def)
   apply(clarsimp)
   apply(rename_tac w1 w2 w r po pu q' c ca)(*strict*)
   apply(case_tac po)
    apply(rename_tac w1 w2 w r po pu q' c ca)(*strict*)
    apply(rename_tac w1 w2 r pu q' c ca)(*strict*)
    apply(force)
   apply(rename_tac w1 w2 w r po pu q' c ca a list)(*strict*)
   apply(clarsimp)
   apply(rename_tac w1 w2 r q' c ca)(*strict*)
   apply(case_tac k)
    apply(rename_tac w1 w2 r q' c ca)(*strict*)
    apply(clarsimp)
   apply(rename_tac w1 w2 r q' c ca nat)(*strict*)
   apply(force)
  apply(rename_tac nat e1 c1 nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac e1 c1 nata)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac e1 c1 nata)(*strict*)
   prefer 2
   apply(rule_tac
      d="d" and
      n="nata" and
      m="Suc nata"
      in epdaH.step_detail_before_some_position)
     apply(rename_tac e1 c1 nata)(*strict*)
     apply(rule epdaH.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac e1 c1 nata)(*strict*)
    apply(force)
   apply(rename_tac e1 c1 nata)(*strict*)
   apply(force)
  apply(rename_tac e1 c1 nata)(*strict*)
  apply(clarsimp)
  apply(rename_tac c1 nata e1a e2 c1a)(*strict*)
  apply(simp add: reach_k_one_step_contained_def)
  apply(erule_tac x="d" in allE)
  apply(clarsimp)
  apply(erule_tac x="nata" in allE)
  apply(clarsimp)
  apply(rename_tac c1 nata e1a e2 c1a w1 w2)(*strict*)
  apply(simp add: epdaH_step_relation_def)
  apply(clarsimp)
  apply(rename_tac c1 nata e1a e2 c1a w1 w2 w wa)(*strict*)
  apply(case_tac e)
  apply(rename_tac c1 nata e1a e2 c1a w1 w2 w wa edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac q2 r2 po2 pu2 q2')
  apply(rename_tac c1 nata e1a e2 c1a w1 w2 w wa q2 r2 po2 pu2 q2')(*strict*)
  apply(case_tac e2)
  apply(rename_tac c1 nata e1a e2 c1a w1 w2 w wa q2 r2 po2 pu2 q2' edge_srca edge_eventa edge_popa edge_pusha edge_trga)(*strict*)
  apply(rename_tac q1 r1 po1 pu1 q1')
  apply(rename_tac c1 nata e1a e2 c1a w1 w2 w wa q2 r2 po2 pu2 q2' q1 r1 po1 pu1 q1')(*strict*)
  apply(case_tac c)
  apply(rename_tac c1 nata e1a e2 c1a w1 w2 w wa q2 r2 po2 pu2 q2' q1 r1 po1 pu1 q1' epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac p1 h1 s1)
  apply(rename_tac c1 nata e1a e2 c1a w1 w2 w wa q2 r2 po2 pu2 q2' q1 r1 po1 pu1 q1' p1 h1 s1)(*strict*)
  apply(case_tac c1)
  apply(rename_tac c1 nata e1a e2 c1a w1 w2 w wa q2 r2 po2 pu2 q2' q1 r1 po1 pu1 q1' p1 h1 s1 epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac p2 h2 s2)
  apply(rename_tac c1 nata e1a e2 c1a w1 w2 w wa q2 r2 po2 pu2 q2' q1 r1 po1 pu1 q1' p1 h1 s1 p2 h2 s2)(*strict*)
  apply(clarsimp)
  apply(rename_tac nata e1a c1a w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1')(*strict*)
  apply(case_tac c1a)
  apply(rename_tac nata e1a c1a w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' epdaH_conf_statea epdaH_conf_historya epdaH_conf_stacka)(*strict*)
  apply(rename_tac p3 h3 s3)
  apply(rename_tac nata e1a c1a w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 h3 s3)(*strict*)
  apply(clarsimp)
  apply(rename_tac nata e1a w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 h3)(*strict*)
  apply(erule_tac x="(Some (cons_tuple2 p3 (take k w1)))" in allE)
  apply(erule_tac x="take k w2" in allE)
  apply(clarsimp)
  apply(simp add: prefix_def)
  apply(clarsimp)
  apply(rename_tac nata e1a w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 h3 c ca)(*strict*)
  apply(thin_tac "d i = y" for i y)
  apply(thin_tac "d i = y" for i y)
  apply(thin_tac "d i = y" for i y)
  apply(subgoal_tac "prefix w2 po2 \<or> SSX" for SSX)
   apply(rename_tac nata e1a w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 h3 c ca)(*strict*)
   prefer 2
   apply(rule mutual_prefix_prefix)
   apply(force)
  apply(rename_tac nata e1a w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 h3 c ca)(*strict*)
  apply(erule disjE)
   apply(rename_tac nata e1a w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 h3 c ca)(*strict*)
   apply(simp add: prefix_def)
   apply(rename_tac w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 c ca)(*strict*)
   apply(clarsimp)
   apply(rename_tac w1 w2 w wa r2 pu2 q2' r1 po1 pu1 q1' p3 c cb)(*strict*)
   apply(erule_tac x="drop k w2 @ cb" in allE)+
   apply(clarsimp)
  apply(rename_tac nata e1a w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 h3 c ca)(*strict*)
  apply(simp add: prefix_def)
  apply(rename_tac w1 w2 w wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 c ca)(*strict*)
  apply(clarsimp)
  apply(rename_tac w1 wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 c ca cb)(*strict*)
  apply(subgoal_tac "X" for X)
   apply(rename_tac w1 wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 c ca cb)(*strict*)
   prefer 2
   apply(rule_tac a="(length po2)" and b="k" in min_alt)
  apply(rename_tac w1 wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 c ca cb)(*strict*)
  apply(erule disjE)
   apply(rename_tac w1 wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 c ca cb)(*strict*)
   apply(force)
  apply(rename_tac w1 wa r2 po2 pu2 q2' r1 po1 pu1 q1' p3 c ca cb)(*strict*)
  apply(clarsimp)
  apply(erule_tac x="drop k po2" in allE)+
  apply(force)
  done

lemma F_SDPDA_TO_CFG_STD_and_F_SDPDA_TO_CFG_OPT_equal_initial_marking_derivations: "
  valid_simple_dpda G
  \<Longrightarrow> 0 < k
  \<Longrightarrow> Gstd = F_SDPDA_TO_CFG_STD G
  \<Longrightarrow> Some Gopt = F_SDPDA_TO_CFG_OPT G k
  \<Longrightarrow> valid_cfg Gopt
  \<Longrightarrow> cfg_sub Gopt Gstd
  \<Longrightarrow> cfgLM.initial_marking_derivations Gstd = cfgLM.initial_marking_derivations Gopt"
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac G="G" in F_SDPDA_TO_CFG_STD__SOUND)
   apply(simp add: F_SDPDA_TO_CFG_STD__SpecInput_def)
  apply(simp add: F_SDPDA_TO_CFG_STD__SpecOutput_def)
  apply(rule sym)
  apply(rule antisym)
   apply(rule cfg_sub_preserves_cfgLM_initial_marking_derivations)
     apply(force)
    apply(force)
   apply(force)
  apply(rule F_SDPDA_TO_CFG_STD_and_F_SDPDA_TO_CFG_OPT_preserves_initial_marking_derivations)
        apply(force)
       apply(force)
      apply(force)
     apply(force)
    apply(force)
   apply(force)
  apply(force)
  done

theorem F_SDPDA_TO_CFG_OPT__SOUND: "
  valid_simple_dpda G
  \<Longrightarrow> k > 0
  \<Longrightarrow> Gstd = F_SDPDA_TO_CFG_STD G
  \<Longrightarrow> Some Gopt = F_SDPDA_TO_CFG_OPT G k
  \<Longrightarrow> valid_cfg Gopt \<and> cfg_sub Gopt Gstd \<and> cfgLM.initial_marking_derivations Gstd = cfgLM.initial_marking_derivations Gopt \<and> cfgLM.marked_language Gstd = cfgLM.marked_language Gopt"
  apply(rule context_conjI)
   apply(metis F_SDPDA_TO_CFG_OPT__makes_valid_cfg)
  apply(rule context_conjI)
   apply(metis F_SDPDA_TO_CFG_OPT__is_cfg_sub_of_F_SDPDA_TO_CFG_STD)
  apply(rule conjI)
   prefer 2
   apply(metis F_SDPDA_TO_CFG_STD__vs_F_SDPDA_TO_CFG_OPT)
  apply(rule F_SDPDA_TO_CFG_STD_and_F_SDPDA_TO_CFG_OPT_equal_initial_marking_derivations)
       apply(force)
      apply(force)
     apply(force)
    apply(force)
   apply(force)
  apply(force)
  done

theorem F_SDPDA_TO_CFG_OPT__SOUND2: "
  valid_simple_dpda G
  \<Longrightarrow> k > 0
  \<Longrightarrow> None = F_SDPDA_TO_CFG_OPT G k
  \<Longrightarrow> epdaH.marked_language G = {}"
  apply(simp add: epdaH.marked_language_def epdaH_marked_effect_def epdaH_marking_configurations_def)
  apply(clarsimp)
  apply(thin_tac "c \<in> epdaH_configurations G")
  apply(case_tac c)
  apply(rename_tac q h s)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule_tac G="G" and k="k" and q="epda_initial G" and A="epda_box G" in F_SDPDA_TO_CFG_OPT__contains_all_reachable_l2_nonterminals_BASIC)
     apply(force)
    apply(force)
   apply(clarsimp)
   apply(rule_tac x="d" in exI)
   apply(clarsimp)
   apply(rule_tac x="0" in exI)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule epdaH.some_position_has_details_at_0)
    apply(simp add: epdaH.derivation_initial_def)
   apply(clarsimp)
   apply(rule conjI)
    apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def)
   apply(rule conjI)
    apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def)
   apply(rule_tac x="i" in exI)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule_tac n="i" in epdaH_epda_box_stays_at_bottom)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
      apply(force)
     apply(force)
    apply(force)
   apply(simp add: suffix_def get_configuration_def)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule_tac M="G" and g="d" and n="ka" and m="i"  in epdaH.pre_some_position_is_some_position)
      apply(force)
     apply(force)
    apply(force)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule_tac n="ka" in epdaH_epda_box_stays_at_bottom)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
      apply(force)
     apply(force)
    apply(force)
   apply(simp add: suffix_def get_configuration_def)
   apply(clarsimp)
   apply(subgoal_tac "X" for X)
    prefer 2
    apply(rule_tac n="0" in epdaH_epda_box_stays_at_bottom)
      apply(simp add: valid_simple_dpda_def valid_dpda_def valid_pda_def)
      apply(force)
     apply(force)
    apply(force)
   apply(simp add: suffix_def get_configuration_def)
   apply(clarsimp)
   apply(simp add: epdaH.derivation_initial_def epdaH_initial_configurations_def)
  apply(simp add: F_SDPDA_TO_CFG_OPT_def Let_def)
  done

end