section {*FUNCTION\_CFG\_ENFORCE\_ACCESSIBILITY\_cfgSTD*}
theory
  FUNCTION_CFG_ENFORCE_ACCESSIBILITY_cfgSTD

imports
  FUNCTION_CFG_ENFORCE_ACCESSIBILITY_cfgLM

begin

definition cfgSTD_SPEC_CFGEA__Productions :: "
  ('nonterminal, 'event) cfg
  \<Rightarrow> ('nonterminal, 'event) cfg"
  where
    "cfgSTD_SPEC_CFGEA__Productions G \<equiv>
  let
    N = cfgSTD_accessible_nonterminals G
  in
    \<lparr>cfg_nonterminals = N,
    cfg_events = cfg_events G,
    cfg_initial = cfg_initial G,
    cfg_productions = {p \<in> cfg_productions G. prod_lhs p \<in> N}\<rparr>"

definition F_CFG_EASTD__fp_valid_input :: "
  ('nonterminal, 'event) cfg
  \<Rightarrow> 'nonterminal set
  \<Rightarrow> bool"
  where
    "F_CFG_EASTD__fp_valid_input G N \<equiv>
  valid_cfg G
  \<and> N \<subseteq> cfg_nonterminals G"

definition F_CFG_EASTD__fp_invariant_01 :: "
  ('nonterminal, 'event) cfg
  \<Rightarrow> 'nonterminal set
  \<Rightarrow> bool"
  where
    "F_CFG_EASTD__fp_invariant_01 G N \<equiv>
  \<forall>p \<in> cfg_productions G.
    prod_lhs p \<in> N
    \<longrightarrow> setA (prod_rhs p) \<subseteq> F_CFG_EASTD__fp_one G N"

definition F_CFG_EASTD__fp_invariant_02 :: "
  ('nonterminal, 'event) cfg
  \<Rightarrow> 'nonterminal set
  \<Rightarrow> bool"
  where
    "F_CFG_EASTD__fp_invariant_02 G N \<equiv>
  N \<subseteq> cfg_nonterminals G
  \<and> cfg_initial G \<in> N"

definition F_CFG_EASTD__fp_invariant_03 :: "
  ('nonterminal, 'event) cfg
  \<Rightarrow> 'nonterminal set
  \<Rightarrow> bool"
  where
    "F_CFG_EASTD__fp_invariant_03 G N \<equiv>
  N \<subseteq> cfgSTD_accessible_nonterminals G"

definition F_CFG_EASTD__fp_invariants :: "
  ('nonterminal, 'event) cfg
  \<Rightarrow> 'nonterminal set
  \<Rightarrow> bool"
  where
    "F_CFG_EASTD__fp_invariants G N \<equiv>
  F_CFG_EASTD__fp_invariant_03 G N
  \<and> F_CFG_EASTD__fp_invariant_01 G N
  \<and> F_CFG_EASTD__fp_invariant_02 G N
  \<and> F_CFG_EASTD__fp_valid_input G N"

lemma F_CFG_EASTD__fp_invariants_AT_kleene_starT: "
  F_CFG_EASTD__fp_valid_input G {cfg_initial G}
  \<Longrightarrow> F_CFG_EASTD__fp_invariants G {cfg_initial G}"
  apply(simp add: F_CFG_EASTD__fp_invariants_def F_CFG_EASTD__fp_valid_input_def)
  apply(simp add: F_CFG_EASTD__fp_invariant_03_def F_CFG_EASTD__fp_invariant_01_def F_CFG_EASTD__fp_invariant_02_def )
  apply(clarsimp)
  apply(rule conjI)
   apply(simp add: cfgSTD_accessible_nonterminals_def)
   apply(rule_tac
      x="der1 \<lparr>cfg_conf=[teA (cfg_initial G)]\<rparr>"
      in exI)
   apply(rule conjI)
    apply(simp add: cfgSTD.derivation_initial_def)
    apply(rule conjI)
     apply(rule cfgSTD.der1_is_derivation)
    apply(simp add: der1_def)
    apply(simp add: cfg_initial_configurations_def)
    apply(simp add: cfg_configurations_def valid_cfg_def)
   apply(simp add: get_configuration_def der1_def)
  apply(clarsimp)
  apply(rename_tac p x)(*strict*)
  apply(simp add: F_CFG_EASTD__fp_one_def)
  apply(clarsimp)
  done

lemma F_CFG_EASTD_termLem1: "
  F_CFG_EASTD__fp_one G N \<noteq> N
  \<Longrightarrow> F_CFG_EASTD__fp_valid_input G N
  \<Longrightarrow> F_CFG_EASTD__fp_valid_input G (F_CFG_EASTD__fp_one G N)"
  apply(unfold F_CFG_EASTD__fp_valid_input_def F_CFG_EASTD__fp_one_def)
  apply(auto)
  apply(rename_tac x p xa pa)(*strict*)
  apply (metis valid_cfg_def valid_cfg_step_label_def subsetD)
  done

lemma F_CFG_EASTD__fp_one_preserves_F_CFG_EASTD__fp_valid_input: "
  F_CFG_EASTD__fp_valid_input G N
  \<Longrightarrow> F_CFG_EASTD__fp_valid_input G (F_CFG_EASTD__fp_one G N)"
  apply(case_tac "F_CFG_EASTD__fp_one G N = N")
   apply(clarsimp)
  apply(rule F_CFG_EASTD_termLem1)
   apply(auto)
  done

lemma F_CFG_EASTD_sumSmaller: "
  F_CFG_EASTD__fp_one G N \<noteq> N
  \<Longrightarrow> F_CFG_EASTD__fp_valid_input G N
  \<Longrightarrow> card (cfg_nonterminals G - F_CFG_EASTD__fp_one G N) < card (cfg_nonterminals G - N)"
  apply(auto)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_CFG_EASTD__fp_valid_input_def)
   apply(subgoal_tac "N=F_CFG_EASTD__fp_one G N")
    apply(rename_tac x)(*strict*)
    apply(clarsimp)
   apply(rename_tac x)(*strict*)
   apply(rule card_seteq)
     apply(rename_tac x)(*strict*)
     apply(rule_tac
      B="cfg_nonterminals G"
      in finite_subset)
      apply(rename_tac x)(*strict*)
      apply(simp add: F_CFG_EASTD__fp_one_def)
      apply(clarsimp)
      apply(rename_tac x xa p)(*strict*)
      apply(simp add: valid_cfg_def)
      apply (metis insert_absorb insert_subset)
     apply(rename_tac x)(*strict*)
     apply (metis valid_cfg_def)
    apply(rename_tac x)(*strict*)
    apply(simp add: F_CFG_EASTD__fp_one_def)
   apply(rename_tac x)(*strict*)
   apply(auto)
   apply(subgoal_tac "card (cfg_nonterminals G - F_CFG_EASTD__fp_one G N) \<ge> card (cfg_nonterminals G - N)")
    apply(rename_tac x)(*strict*)
    apply(auto)
   apply(rename_tac x)(*strict*)
   apply(subgoal_tac "card (cfg_nonterminals G - F_CFG_EASTD__fp_one G N) = card (cfg_nonterminals G) - card (F_CFG_EASTD__fp_one G N)")
    apply(rename_tac x)(*strict*)
    apply(auto)
    apply(subgoal_tac "card (cfg_nonterminals G - N) = card (cfg_nonterminals G) - card N")
     apply(rename_tac x)(*strict*)
     apply(auto)
     apply(subgoal_tac "card (cfg_nonterminals G) - card (F_CFG_EASTD__fp_one G N) \<ge> card (cfg_nonterminals G) - card N")
      apply(rename_tac x)(*strict*)
      apply(auto)
     apply(rename_tac x)(*strict*)
     apply(rule_tac
      a="card (cfg_nonterminals G)"
      in XXXsmaller)
       apply(rename_tac x)(*strict*)
       apply(rule_tac
      B="cfg_nonterminals G"
      in card_mono)
        apply(rename_tac x)(*strict*)
        apply(simp add: valid_cfg_def)
       apply(rename_tac x)(*strict*)
       apply(simp)
      apply(rename_tac x)(*strict*)
      apply(rule card_mono)
       apply(rename_tac x)(*strict*)
       apply(simp add: valid_cfg_def)
      apply(rename_tac x)(*strict*)
      apply(simp add: F_CFG_EASTD__fp_one_def)
      apply(clarsimp)
      apply(rename_tac x xa p)(*strict*)
      apply(simp add: valid_cfg_def)
      apply(clarsimp)
      apply(erule_tac
      x="p"
      in ballE)
       apply(rename_tac x xa p)(*strict*)
       prefer 2
       apply(force)
      apply(rename_tac x xa p)(*strict*)
      apply(clarsimp)
      apply(force)
     apply(rename_tac x)(*strict*)
     apply(force)
    apply(rename_tac x)(*strict*)
    apply(rule card_Diff_subset)
     apply(rename_tac x)(*strict*)
     apply(rule_tac
      B="cfg_nonterminals G"
      in finite_subset)
      apply(rename_tac x)(*strict*)
      apply(simp add: valid_cfg_def)
     apply(rename_tac x)(*strict*)
     apply(simp add: valid_cfg_def)
    apply(rename_tac x)(*strict*)
    apply(simp)
   apply(rename_tac x)(*strict*)
   apply(rule card_Diff_subset)
    apply(rename_tac x)(*strict*)
    apply(rule_tac
      B="cfg_nonterminals G"
      in finite_subset)
     apply(rename_tac x)(*strict*)
     apply(simp add: F_CFG_EASTD__fp_one_def)
     apply(clarsimp)
     apply(rename_tac x xa p)(*strict*)
     apply(simp add: valid_cfg_def)
     apply(clarsimp)
     apply(erule_tac
      x="p"
      in ballE)
      apply(rename_tac x xa p)(*strict*)
      prefer 2
      apply(force)
     apply(rename_tac x xa p)(*strict*)
     apply(clarsimp)
     apply(force)
    apply(rename_tac x)(*strict*)
    apply(simp add: valid_cfg_def)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_CFG_EASTD__fp_one_def)
   apply(clarsimp)
   apply(rename_tac x xa p)(*strict*)
   apply(simp add: valid_cfg_def)
   apply(clarsimp)
   apply(erule_tac
      x="p"
      in ballE)
    apply(rename_tac x xa p)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac x xa p)(*strict*)
   apply(clarsimp)
   apply(force)
  apply(rename_tac x)(*strict*)
  apply(simp add: F_CFG_EASTD__fp_one_def)
  done

lemma F_CFG_EASTD__fp_one_TRANSFER_TRANSFERS_SOUND: "
  F_CFG_EASTD__fp_valid_input G (F_CFG_EASTD__fp_one G N)
  \<Longrightarrow> F_CFG_EASTD__fp_valid_input G N
  \<Longrightarrow> F_CFG_EASTD__fp_invariants G N
  \<Longrightarrow> F_CFG_EASTD__fp_invariant_03 G (F_CFG_EASTD__fp_one G N)"
  apply(subgoal_tac "F_CFG_EASTD__fp_invariant_03 G N")
   defer
   apply(simp add: F_CFG_EASTD__fp_invariants_def)
  apply(subgoal_tac "valid_cfg G")
   defer
   apply(simp add: F_CFG_EASTD__fp_invariants_def F_CFG_EASTD__fp_valid_input_def)
  apply(simp add: F_CFG_EASTD__fp_invariant_03_def)
  apply(simp add: F_CFG_EASTD__fp_one_def)
  apply(simp add: cfgSTD_accessible_nonterminals_def)
  apply(clarsimp)
  apply(rename_tac x p)(*strict*)
  apply(rule conjI)
   apply(rename_tac x p)(*strict*)
   apply(simp add: valid_cfg_def)
   apply(clarsimp)
   apply(erule_tac
      x="p"
      in ballE)
    apply(rename_tac x p)(*strict*)
    prefer 2
    apply(force)
   apply(rename_tac x p)(*strict*)
   apply(clarsimp)
   apply(force)
  apply(rename_tac x p)(*strict*)
  apply(subgoal_tac "prod_lhs p \<in> {A \<in> cfg_nonterminals G. \<exists>d. cfgSTD.derivation_initial G d \<and> (\<exists>n c. get_configuration (d n) = Some c \<and> A \<in> setA (cfg_conf c))}")
   apply(rename_tac x p)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac x p)(*strict*)
  apply(thin_tac "N \<subseteq> {A \<in> cfg_nonterminals G. \<exists>d. cfgSTD.derivation_initial G d \<and> (\<exists>n c. get_configuration (d n) = Some c \<and> A \<in> setA (cfg_conf c))}")
  apply(rename_tac x p)(*strict*)
  apply(clarsimp)
  apply(rename_tac x p d n c)(*strict*)
  apply(case_tac "d n")
   apply(rename_tac x p d n c)(*strict*)
   apply(simp add: get_configuration_def)
  apply(rename_tac x p d n c a)(*strict*)
  apply(case_tac a)
  apply(rename_tac x p d n c a option b)(*strict*)
  apply(simp add: get_configuration_def)
  apply(clarsimp)
  apply(rename_tac x p d n c option)(*strict*)
  apply(rename_tac e)
  apply(rename_tac x p d n c e)(*strict*)
  apply(case_tac c)
  apply(rename_tac x p d n c e cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac x p d n e cfg_confa)(*strict*)
  apply(rename_tac w)
  apply(rename_tac x p d n e w)(*strict*)
  apply(subgoal_tac "\<exists>w1 w2. w1@[teA (prod_lhs p)]@w2=w")
   apply(rename_tac x p d n e w)(*strict*)
   prefer 2
   apply(rule setA_decomp)
   apply(force)
  apply(rename_tac x p d n e w)(*strict*)
  apply(clarsimp)
  apply(rename_tac x p d n e w1 w2)(*strict*)
  apply(rule_tac
      x="derivation_append d (der2 \<lparr>cfg_conf = w1 @ teA (prod_lhs p) # w2\<rparr> p \<lparr>cfg_conf = w1 @ (prod_rhs p) @ w2\<rparr>) n"
      in exI)
  apply(rule conjI)
   apply(rename_tac x p d n e w1 w2)(*strict*)
   apply(rule cfgSTD.derivation_append_preserves_derivation_initial)
     apply(rename_tac x p d n e w1 w2)(*strict*)
     apply(force)
    apply(rename_tac x p d n e w1 w2)(*strict*)
    apply(force)
   apply(rename_tac x p d n e w1 w2)(*strict*)
   apply(rule cfgSTD.derivation_append_preserves_derivation)
     apply(rename_tac x p d n e w1 w2)(*strict*)
     apply(simp add: cfgSTD.derivation_initial_def)
    apply(rename_tac x p d n e w1 w2)(*strict*)
    apply(rule cfgSTD.der2_is_derivation)
    apply(simp add: cfgSTD_step_relation_def)
    apply(force)
   apply(rename_tac x p d n e w1 w2)(*strict*)
   apply(clarsimp)
   apply(simp add: der2_def)
  apply(rename_tac x p d n e w1 w2)(*strict*)
  apply(rule_tac
      x="Suc n"
      in exI)
  apply(simp add: der2_def derivation_append_def)
  apply(simp add: setAConcat)
  done

lemma F_CFG_EASTD__fp_one_TRANSFER_TRANSFERS_EXTRA_01: "
  F_CFG_EASTD__fp_valid_input G (F_CFG_EASTD__fp_one G N)
  \<Longrightarrow> F_CFG_EASTD__fp_valid_input G N
  \<Longrightarrow> F_CFG_EASTD__fp_invariants G N
  \<Longrightarrow> F_CFG_EASTD__fp_invariant_01 G (F_CFG_EASTD__fp_one G N)"
  apply(simp add: F_CFG_EASTD__fp_invariant_01_def)
  apply(auto)
  apply(rename_tac p x)(*strict*)
  apply(simp add: F_CFG_EASTD__fp_one_def)
  apply(auto)
  done

lemma F_CFG_EASTD__fp_one_TRANSFER_TRANSFERS_EXTRA_02: "
  F_CFG_EASTD__fp_valid_input G (F_CFG_EASTD__fp_one G N)
  \<Longrightarrow> F_CFG_EASTD__fp_valid_input G N
  \<Longrightarrow> F_CFG_EASTD__fp_invariants G N
  \<Longrightarrow> F_CFG_EASTD__fp_invariant_02 G (F_CFG_EASTD__fp_one G N)"
  apply(simp add: F_CFG_EASTD__fp_invariant_02_def F_CFG_EASTD__fp_invariants_def)
  apply(auto)
   apply(rename_tac x)(*strict*)
   apply(simp add: F_CFG_EASTD__fp_one_def)
   apply(auto)
   apply(rename_tac x p)(*strict*)
   apply(simp add: F_CFG_EASTD__fp_valid_input_def valid_cfg_def)
   apply(force)
  apply(simp add: F_CFG_EASTD__fp_one_def)
  done

lemma F_CFG_EASTD__fp_one_TRANSFER_TRANSFERS_ALL: "
  F_CFG_EASTD__fp_valid_input G (F_CFG_EASTD__fp_one G N)
  \<Longrightarrow> F_CFG_EASTD__fp_valid_input G N
  \<Longrightarrow> F_CFG_EASTD__fp_invariants G N
  \<Longrightarrow> F_CFG_EASTD__fp_invariants G (F_CFG_EASTD__fp_one G N)"
  apply(simp (no_asm) add: F_CFG_EASTD__fp_invariants_def)
  apply(rule conjI)
   apply(rule F_CFG_EASTD__fp_one_TRANSFER_TRANSFERS_SOUND)
     apply(blast)+
  apply(rule conjI)
   apply(rule F_CFG_EASTD__fp_one_TRANSFER_TRANSFERS_EXTRA_01)
     apply(blast+)
  apply(rule conjI)
   apply(rule F_CFG_EASTD__fp_one_TRANSFER_TRANSFERS_EXTRA_02)
     apply(blast+)
  done

lemma F_CFG_EASTD__fp_Meta_Lift: "
  F_CFG_EASTD__fp_valid_input G {cfg_initial G}
  \<Longrightarrow> (\<And>G N. F_CFG_EASTD__fp_valid_input G (F_CFG_EASTD__fp_one G N)\<Longrightarrow> F_CFG_EASTD__fp_valid_input G N\<Longrightarrow> F_CFG_EASTD__fp_invariants G N\<Longrightarrow> P (F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N)) G \<Longrightarrow> P (F_CFG_EASTD__fp G N) G)
  \<Longrightarrow> (\<And>G N. F_CFG_EASTD__fp_one G N = N\<Longrightarrow> F_CFG_EASTD__fp_valid_input G N\<Longrightarrow> F_CFG_EASTD__fp_invariants G N \<Longrightarrow> P (F_CFG_EASTD__fp G N) G)
  \<Longrightarrow> P (F_CFG_EASTD__fp G {cfg_initial G}) G"
  apply(subgoal_tac "(\<lambda>G N. F_CFG_EASTD__fp_invariants G N \<longrightarrow> (P (F_CFG_EASTD__fp G N) G)) G {cfg_initial G}")
   apply(erule impE)
    prefer 2
    apply(blast)
   apply(rule F_CFG_EASTD__fp_invariants_AT_kleene_starT)
   apply(blast)
  apply(subgoal_tac "(\<lambda>(G,N). F_CFG_EASTD__fp_invariants G N \<longrightarrow> (P (F_CFG_EASTD__fp G N) G)) (G,{cfg_initial G})")
   apply(blast)
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>(G,N). F_CFG_EASTD__fp_valid_input G N"
      and RECURSIVE_COND = "\<lambda>(G,N). F_CFG_EASTD__fp_one G N\<noteq>N"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>(G,N). (G,F_CFG_EASTD__fp_one G N)"
      and MEASURE = "\<lambda>(G,N). card (cfg_nonterminals G - N)"
      and TERM_FUN = "(\<lambda>(G,N). F_CFG_EASTD__fp_invariants G N \<longrightarrow> (P (F_CFG_EASTD__fp G N) G))"
      and y = "(G,{cfg_initial G})"
      in partial_termination_wf)
      apply(rule allI)
      apply(rename_tac x)(*strict*)
      apply(clarify)
      apply(rename_tac a b)(*strict*)
      apply(thin_tac "F_CFG_EASTD__fp_valid_input G {cfg_initial G}")
      apply(rename_tac G N)
      apply(rename_tac G N)(*strict*)
      apply(rule F_CFG_EASTD__fp_one_preserves_F_CFG_EASTD__fp_valid_input)
      apply(blast)
     apply(thin_tac "F_CFG_EASTD__fp_valid_input G {cfg_initial G}")
     apply(clarsimp)
     apply(rename_tac a b)(*strict*)
     apply(rename_tac G N)
     apply(rename_tac G N)(*strict*)
     apply(rule F_CFG_EASTD_sumSmaller)
      apply(rename_tac G N)(*strict*)
      apply(force)
     apply(rename_tac G N)(*strict*)
     apply(force)
    apply(force)
   prefer 2
   apply(clarsimp)
  apply(clarsimp)
  apply(rename_tac a b)(*strict*)
  apply(erule impE)
   apply(rename_tac a b)(*strict*)
   apply(rule F_CFG_EASTD__fp_one_TRANSFER_TRANSFERS_ALL)
     apply(rename_tac a b)(*strict*)
     apply(blast)+
  done

lemma F_CFG_EASTD__fp_termination: "
  F_CFG_EASTD__fp_valid_input G N
  \<Longrightarrow> F_CFG_EASTD__fp_dom (G,N)"
  apply(rule_tac
      TERM_ARGS_TEST = "\<lambda>(G,N). F_CFG_EASTD__fp_valid_input G N"
      and RECURSIVE_COND = "\<lambda>(G,N). F_CFG_EASTD__fp_one G N\<noteq>N"
      and MODIFY_ARGS_FOR_REC_CALL = "\<lambda>(G,N). (G,F_CFG_EASTD__fp_one G N)"
      and MEASURE = "\<lambda>(G,f). card (cfg_nonterminals G - f)"
      in partial_termination_wf)
      apply(clarsimp)
      apply(rename_tac a b)(*strict*)
      apply(rule F_CFG_EASTD_termLem1)
       apply(rename_tac a b)(*strict*)
       apply(blast,blast)
     defer
     apply(clarsimp)
     apply(rename_tac a b)(*strict*)
     apply(rule F_CFG_EASTD__fp.domintros,blast,blast)
    apply(clarsimp)
    apply(rename_tac a b)(*strict*)
    apply(rule F_CFG_EASTD__fp.domintros,blast,blast)
   apply(blast)
  apply(clarsimp)
  apply(rename_tac a b)(*strict*)
  apply(rule F_CFG_EASTD_sumSmaller)
   apply(rename_tac a b)(*strict*)
   apply(blast)
  apply(rename_tac a b)(*strict*)
  apply(blast)
  done

lemma F_CFG_EASTD_F_CFG_EASTD__fp_invariant_02_unfold: "
  F_CFG_EASTD__fp_valid_input G {cfg_initial G}
  \<Longrightarrow> F_CFG_EASTD__fp G {cfg_initial G} \<subseteq> cfg_nonterminals G \<and> cfg_initial G \<in> F_CFG_EASTD__fp G {cfg_initial G}"
  apply(rule F_CFG_EASTD__fp_Meta_Lift)
    apply(blast)
   apply(rename_tac Ga N)(*strict*)
   defer
   apply(thin_tac "F_CFG_EASTD__fp_valid_input G {cfg_initial G}")
   apply(rename_tac G N)(*strict*)
   apply(subgoal_tac "F_CFG_EASTD__fp G N=N")
    apply(rename_tac G N)(*strict*)
    apply(clarsimp)
    apply(simp add: F_CFG_EASTD__fp_invariants_def F_CFG_EASTD__fp_invariant_02_def)
   apply(rename_tac G N)(*strict*)
   apply(rule_tac
      s="(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      and t="F_CFG_EASTD__fp G N"
      in ssubst)
    apply(rename_tac G N)(*strict*)
    apply(rule F_CFG_EASTD__fp.psimps)
    apply(rule F_CFG_EASTD__fp_termination)
    apply(blast)
   apply(rename_tac G N)(*strict*)
   apply(clarsimp)
  apply(rename_tac Ga N)(*strict*)
  apply(thin_tac "F_CFG_EASTD__fp_valid_input G {cfg_initial G}")
  apply(rename_tac G N)(*strict*)
  apply(case_tac "F_CFG_EASTD__fp_one G N = N")
   apply(rename_tac G N)(*strict*)
   apply(clarsimp)
  apply(rename_tac G N)(*strict*)
  apply(rule_tac
      t = "F_CFG_EASTD__fp G N"
      and s = "(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      in ssubst)
   apply(rename_tac G N)(*strict*)
   apply(rule F_CFG_EASTD__fp.psimps)
   apply(rule F_CFG_EASTD__fp_termination)
   apply(blast)
  apply(rename_tac G N)(*strict*)
  apply(clarsimp)
  done

lemma F_CFG_EASTD_F_CFG_EASTD__fp_invariant_01_unfold: "
  F_CFG_EASTD__fp_valid_input G {cfg_initial G}
  \<Longrightarrow> \<forall>p \<in> cfg_productions G. prod_lhs p \<in> F_CFG_EASTD__fp G {cfg_initial G} \<longrightarrow> setA (prod_rhs p) \<subseteq> F_CFG_EASTD__fp G {cfg_initial G}"
  apply(rule F_CFG_EASTD__fp_Meta_Lift)
    apply(blast)
   apply(rename_tac Ga N)(*strict*)
   defer
   apply(thin_tac "F_CFG_EASTD__fp_valid_input G {cfg_initial G}")
   apply(rename_tac G N)(*strict*)
   apply(rename_tac G N)
   apply(clarsimp)
   apply(rename_tac G N p x)(*strict*)
   apply(subgoal_tac "F_CFG_EASTD__fp G N=N")
    apply(rename_tac G N p x)(*strict*)
    apply(clarsimp)
    apply(simp add: F_CFG_EASTD__fp_invariants_def F_CFG_EASTD__fp_invariant_01_def)
    apply(rule_tac
      s="(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      and t="F_CFG_EASTD__fp G N"
      in ssubst)
     apply(rename_tac G N p x)(*strict*)
     apply(rule F_CFG_EASTD__fp.psimps)
     apply(rule F_CFG_EASTD__fp_termination)
     apply(blast)
    apply(rename_tac G N p x)(*strict*)
    apply(clarsimp)
    apply(rename_tac G N p x)(*strict*)
    apply(force)
   apply(rename_tac G N p x)(*strict*)
   apply(rule_tac
      P = "\<lambda>x. x = N"
      and t = "F_CFG_EASTD__fp G N"
      and s = "(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      in ssubst)
    apply(rename_tac G N p x)(*strict*)
    apply(rule F_CFG_EASTD__fp.psimps)
    apply(rule F_CFG_EASTD__fp_termination)
    apply(blast)
   apply(rename_tac G N p x)(*strict*)
   apply(clarsimp)
  apply(rename_tac Ga N)(*strict*)
  apply(clarsimp)
  apply(rename_tac Ga N p x)(*strict*)
  apply(thin_tac "F_CFG_EASTD__fp_valid_input G {cfg_initial G}")
  apply(rename_tac G N p x)(*strict*)
  apply(erule_tac
      x="p"
      in ballE)
   apply(rename_tac G N p x)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac G N p x)(*strict*)
  apply(erule impE)
   apply(rename_tac G N p x)(*strict*)
   apply(rule_tac
      t = "F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N)"
      and s = "F_CFG_EASTD__fp G N"
      in ssubst)
    apply(rename_tac G N p x)(*strict*)
    apply(rule sym)
    apply(rule_tac
      P = "\<lambda>x. x = F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N)"
      and t = "F_CFG_EASTD__fp G N"
      and s = "(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      in ssubst)
     apply(rename_tac G N p x)(*strict*)
     apply(rule F_CFG_EASTD__fp.psimps)
     apply(rule F_CFG_EASTD__fp_termination)
     apply(blast)
    apply(rename_tac G N p x)(*strict*)
    apply(clarsimp)
    apply(rule sym)
    apply(rule_tac
      P = "\<lambda>x. x=N"
      and t = "F_CFG_EASTD__fp G N"
      and s = "(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      in ssubst)
     apply(rename_tac G N p x)(*strict*)
     apply(rule F_CFG_EASTD__fp.psimps)
     apply(rule F_CFG_EASTD__fp_termination)
     apply(blast)
    apply(rename_tac G N p x)(*strict*)
    apply(clarsimp)
   apply(rename_tac G N p x)(*strict*)
   apply(force)
  apply(rename_tac G N p x)(*strict*)
  apply(rule_tac
      A="setA (prod_rhs p)"
      in set_mp)
   apply(rename_tac G N p x)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac G N p x)(*strict*)
  apply(rule_tac
      s = "F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N)"
      and t = "F_CFG_EASTD__fp G N"
      in ssubst)
   apply(rename_tac G N p x)(*strict*)
   apply(rule_tac
      P = "\<lambda>x. x = F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N)"
      and t = "F_CFG_EASTD__fp G N"
      and s = "(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      in ssubst)
    apply(rename_tac G N p x)(*strict*)
    apply(rule F_CFG_EASTD__fp.psimps)
    apply(rule F_CFG_EASTD__fp_termination)
    apply(blast)
   apply(rename_tac G N p x)(*strict*)
   apply(clarsimp)
   apply(rule sym)
   apply(rule_tac
      P = "\<lambda>x. x=N"
      and t = "F_CFG_EASTD__fp G N"
      and s = "(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      in ssubst)
    apply(rename_tac G N p x)(*strict*)
    apply(rule F_CFG_EASTD__fp.psimps)
    apply(rule F_CFG_EASTD__fp_termination)
    apply(blast)
   apply(rename_tac G N p x)(*strict*)
   apply(clarsimp)
  apply(rename_tac G N p x)(*strict*)
  apply(force)
  done

lemma F_CFG_EASTDSound0_1: "
  valid_cfg G
  \<Longrightarrow> F_CFG_EASTD__fp G {cfg_initial G} = N
  \<Longrightarrow> cfgSTD.derivation_initial G d
  \<Longrightarrow> d n = Some (pair e c)
  \<Longrightarrow> setA (cfg_conf c) \<subseteq> N"
  apply(induct n arbitrary: e c)
   apply(rename_tac e c)(*strict*)
   apply(clarsimp)
   apply(rename_tac e c x)(*strict*)
   apply(case_tac c)
   apply(rename_tac e c x cfg_confa)(*strict*)
   apply(rename_tac w)
   apply(rename_tac e c x w)(*strict*)
   apply(subgoal_tac "\<exists>w1 w2. w1@[teA x]@w2=w")
    apply(rename_tac e c x w)(*strict*)
    prefer 2
    apply(rule setA_decomp)
    apply(force)
   apply(rename_tac e c x w)(*strict*)
   apply(clarsimp)
   apply(rename_tac e x w1 w2)(*strict*)
   apply(thin_tac "x \<in> setA (w1 @ teA x # w2)")
   apply(simp add: cfgSTD.derivation_initial_def cfg_initial_configurations_def)
   apply(clarsimp)
   apply(rename_tac x w1 w2)(*strict*)
   apply(case_tac w1)
    apply(rename_tac x w1 w2)(*strict*)
    prefer 2
    apply(rename_tac x w1 w2 a list)(*strict*)
    apply(force)
   apply(rename_tac x w1 w2)(*strict*)
   apply(case_tac w2)
    apply(rename_tac x w1 w2)(*strict*)
    prefer 2
    apply(rename_tac x w1 w2 a list)(*strict*)
    apply(force)
   apply(rename_tac x w1 w2)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "F_CFG_EASTD__fp G {cfg_initial G} \<subseteq> cfg_nonterminals G \<and> cfg_initial G \<in> F_CFG_EASTD__fp G {cfg_initial G}")
    prefer 2
    apply(rule F_CFG_EASTD_F_CFG_EASTD__fp_invariant_02_unfold)
    apply(simp add: F_CFG_EASTD__fp_valid_input_def)
    apply(simp add: valid_cfg_def)
   apply(clarsimp)
  apply(rename_tac n e 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> cfgSTD_step_relation G c1 e2 c2")
   apply(rename_tac n e c)(*strict*)
   prefer 2
   apply(rule_tac
      m="Suc n"
      in cfgSTD.step_detail_before_some_position)
     apply(rename_tac n e c)(*strict*)
     apply(rule cfgSTD.derivation_initial_is_derivation)
     apply(force)
    apply(rename_tac n e c)(*strict*)
    apply(force)
   apply(rename_tac n e c)(*strict*)
   apply(force)
  apply(rename_tac n e c)(*strict*)
  apply(clarsimp)
  apply(rename_tac n c x e1 e2 c1)(*strict*)
  apply(erule_tac
      x="e1"
      in meta_allE)
  apply(erule_tac
      x="c1"
      in meta_allE)
  apply(clarsimp)
  apply(case_tac c)
  apply(rename_tac n c x e1 e2 c1 cfg_confa)(*strict*)
  apply(rename_tac w)
  apply(rename_tac n c x e1 e2 c1 w)(*strict*)
  apply(subgoal_tac "\<exists>w1 w2. w1@[teA x]@w2=w")
   apply(rename_tac n c x e1 e2 c1 w)(*strict*)
   prefer 2
   apply(rule setA_decomp)
   apply(force)
  apply(rename_tac n c x e1 e2 c1 w)(*strict*)
  apply(clarsimp)
  apply(rename_tac n x e1 e2 c1 w1 w2)(*strict*)
  apply(thin_tac "x \<in> setA (w1 @ teA x # w2)")
  apply(simp add: cfgSTD_step_relation_def)
  apply(clarsimp)
  apply(rename_tac n x e1 e2 c1 w1 w2 l r)(*strict*)
  apply(case_tac c1)
  apply(rename_tac n x e1 e2 c1 w1 w2 l r cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n x e1 e2 w1 w2 l r)(*strict*)
  apply(case_tac e2)
  apply(rename_tac n x e1 e2 w1 w2 l r prod_lhsa prod_rhsa)(*strict*)
  apply(clarsimp)
  apply(rename_tac n x e1 w1 w2 l r prod_lhs prod_rhs)(*strict*)
  apply(rename_tac A w)
  apply(rename_tac n x e1 w1 w2 l r A w)(*strict*)
  apply(case_tac "x \<in> setA w")
   apply(rename_tac n x e1 w1 w2 l r A w)(*strict*)
   prefer 2
   apply(subgoal_tac "prefix w1 l \<or> prefix l w1")
    apply(rename_tac n x e1 w1 w2 l r A w)(*strict*)
    apply(erule disjE)
     apply(rename_tac n x e1 w1 w2 l r A w)(*strict*)
     apply(simp add: prefix_def)
     apply(clarsimp)
     apply(rename_tac n x e1 w1 w2 r A w c)(*strict*)
     apply(case_tac c)
      apply(rename_tac n x e1 w1 w2 r A w c)(*strict*)
      apply(clarsimp)
      apply(rename_tac n x e1 w1 w2 r A w)(*strict*)
      apply(case_tac w)
       apply(rename_tac n x e1 w1 w2 r A w)(*strict*)
       apply(clarsimp)
       apply(rename_tac n x e1 w1 w2 A)(*strict*)
       apply(rule_tac
      A="setA (w1 @ teA A # teA x # w2)"
      in set_mp)
        apply(rename_tac n x e1 w1 w2 A)(*strict*)
        apply(force)
       apply(rename_tac n x e1 w1 w2 A)(*strict*)
       apply (metis ConsApp setAConcat UnCI elemInsetA)
      apply(rename_tac n x e1 w1 w2 r A w a list)(*strict*)
      apply(clarsimp)
     apply(rename_tac n x e1 w1 w2 r A w c a list)(*strict*)
     apply(clarsimp)
     apply(rename_tac n x e1 w1 r A w list)(*strict*)
     apply(rule_tac
      A="setA (w1 @ teA x # list @ teA A # r)"
      in set_mp)
      apply(rename_tac n x e1 w1 r A w list)(*strict*)
      apply(force)
     apply(rename_tac n x e1 w1 r A w list)(*strict*)
     apply (metis elemInsetA)
    apply(rename_tac n x e1 w1 w2 l r A w)(*strict*)
    apply(simp add: prefix_def)
    apply(clarsimp)
    apply(rename_tac n x e1 w2 l r A w c)(*strict*)
    apply(subgoal_tac "prefix c w \<or> prefix w c")
     apply(rename_tac n x e1 w2 l r A w c)(*strict*)
     apply(erule disjE)
      apply(rename_tac n x e1 w2 l r A w c)(*strict*)
      apply(simp add: prefix_def)
      apply(clarsimp)
      apply(rename_tac n x e1 w2 l r A c ca)(*strict*)
      apply(case_tac ca)
       apply(rename_tac n x e1 w2 l r A c ca)(*strict*)
       apply(clarsimp)
       apply(rename_tac n x e1 w2 l A c)(*strict*)
       apply(rule_tac
      A="setA (l @ teA A # teA x # w2)"
      in set_mp)
        apply(rename_tac n x e1 w2 l A c)(*strict*)
        apply(force)
       apply(rename_tac n x e1 w2 l A c)(*strict*)
       apply (metis ConsApp setAConcat UnCI elemInsetA)
      apply(rename_tac n x e1 w2 l r A c ca a list)(*strict*)
      apply(clarsimp)
      apply(rename_tac n x e1 l r A c list)(*strict*)
      apply (metis elemInsetA)
     apply(rename_tac n x e1 w2 l r A w c)(*strict*)
     apply(simp add: prefix_def)
     apply(clarsimp)
     apply(rename_tac n x e1 w2 l A w ca)(*strict*)
     apply(rule_tac
      A="setA (l @ teA A # ca @ teA x # w2)"
      in set_mp)
      apply(rename_tac n x e1 w2 l A w ca)(*strict*)
      apply(force)
     apply(rename_tac n x e1 w2 l A w ca)(*strict*)
     apply (metis ConsApp setAConcat UnCI elemInsetA)
    apply(rename_tac n x e1 w2 l r A w c)(*strict*)
    apply (metis mutual_prefix_prefix)
   apply(rename_tac n x e1 w1 w2 l r A w)(*strict*)
   apply (metis mutual_prefix_prefix)
  apply(rename_tac n x e1 w1 w2 l r A w)(*strict*)
  apply(subgoal_tac "\<exists>w1 w2. w1@[teA x]@w2=w")
   apply(rename_tac n x e1 w1 w2 l r A w)(*strict*)
   prefer 2
   apply(rule setA_decomp)
   apply(force)
  apply(rename_tac n x e1 w1 w2 l r A w)(*strict*)
  apply(clarsimp)
  apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
  apply(thin_tac "x \<in> setA (w1a @ teA x # w2a)")
  apply(subgoal_tac "(\<forall>p\<in> cfg_productions G. (prod_lhs p \<in> F_CFG_EASTD__fp G {cfg_initial G}) \<longrightarrow> (setA(prod_rhs p)) \<subseteq> F_CFG_EASTD__fp G {cfg_initial G})")
   apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
   prefer 2
   apply(rule F_CFG_EASTD_F_CFG_EASTD__fp_invariant_01_unfold)
   apply(simp add: F_CFG_EASTD__fp_valid_input_def)
   apply(simp add: valid_cfg_def)
  apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
  apply(erule_tac
      x="\<lparr>prod_lhs = A, prod_rhs = w1a @ teA x # w2a\<rparr>"
      in ballE)
   apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
  apply(clarsimp)
  apply(erule impE)
   apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
   prefer 2
   apply(rule_tac
      A="setA (w1a @ teA x # w2a)"
      in set_mp)
    apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
    apply(force)
   apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
   apply (metis elemInsetA)
  apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
  apply(rule_tac
      A="setA (l @ teA A # r)"
      in set_mp)
   apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
   apply(force)
  apply(rename_tac n x e1 w1 w2 l r A w1a w2a)(*strict*)
  apply (metis elemInsetA)
  done

lemma F_CFG_EASTDSoundL1: "
  valid_cfg G
  \<Longrightarrow> cfgSTD_accessible_nonterminals G \<subseteq> F_CFG_EASTD__fp G {cfg_initial G}"
  apply(simp add: cfgSTD_accessible_nonterminals_def get_configuration_def)
  apply(auto)
  apply(rename_tac x d n c)(*strict*)
  apply(case_tac "d n")
   apply(rename_tac x d n c)(*strict*)
   apply(force)
  apply(rename_tac x d n c a)(*strict*)
  apply(case_tac a)
  apply(rename_tac x d n c a option b)(*strict*)
  apply(clarsimp)
  apply(rename_tac x d n c option)(*strict*)
  apply(rule_tac
      A="setA (cfg_conf c)"
      in set_mp)
   apply(rename_tac x d n c option)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac x d n c option)(*strict*)
  apply(rule F_CFG_EASTDSound0_1)
     apply(rename_tac x d n c option)(*strict*)
     apply(force)
    apply(rename_tac x d n c option)(*strict*)
    apply(force)
   apply(rename_tac x d n c option)(*strict*)
   apply(force)
  apply(rename_tac x d n c option)(*strict*)
  apply(force)
  done

lemma F_CFG_EASTD_F_CFG_EASTD__fp_invariant_03_unfold: "
  F_CFG_EASTD__fp_valid_input G {cfg_initial G}
  \<Longrightarrow> F_CFG_EASTD__fp G {cfg_initial G} \<subseteq> cfgSTD_accessible_nonterminals G"
  apply(rule F_CFG_EASTD__fp_Meta_Lift)
    apply(blast)
   apply(rename_tac Ga N)(*strict*)
   defer
   apply(thin_tac "F_CFG_EASTD__fp_valid_input G {cfg_initial G}")
   apply(rename_tac G N)(*strict*)
   apply(rename_tac G N)
   apply(clarsimp)
   apply(rename_tac G N x)(*strict*)
   apply(subgoal_tac "F_CFG_EASTD__fp G N=N")
    apply(rename_tac G N x)(*strict*)
    apply(clarsimp)
    apply(simp add: F_CFG_EASTD__fp_invariants_def F_CFG_EASTD__fp_invariant_03_def)
    apply(rule_tac
      A="F_CFG_EASTD__fp G N"
      in set_mp)
     apply(rename_tac G N x)(*strict*)
     apply(force)
    apply(rename_tac G N x)(*strict*)
    apply(clarsimp)
   apply(rename_tac G N x)(*strict*)
   apply(rule_tac
      s="(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      and t="F_CFG_EASTD__fp G N"
      in ssubst)
    apply(rename_tac G N x)(*strict*)
    apply(rule F_CFG_EASTD__fp.psimps)
    apply(rule F_CFG_EASTD__fp_termination)
    apply(blast)
   apply(rename_tac G N x)(*strict*)
   apply(clarsimp)
  apply(rename_tac Ga N)(*strict*)
  apply(thin_tac "F_CFG_EASTD__fp_valid_input G {cfg_initial G}")
  apply(rename_tac G N)(*strict*)
  apply(clarsimp)
  apply(rename_tac G N x)(*strict*)
  apply(case_tac "N = F_CFG_EASTD__fp_one G N")
   apply(rename_tac G N x)(*strict*)
   apply(clarsimp)
   apply(force)
  apply(rename_tac G N x)(*strict*)
  apply(rule_tac
      A = "F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N)"
      in set_mp)
   apply(rename_tac G N x)(*strict*)
   apply(blast)
  apply(rename_tac G N x)(*strict*)
  apply(rule_tac
      t = "F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N)"
      and s = "F_CFG_EASTD__fp G N"
      in ssubst)
   apply(rename_tac G N x)(*strict*)
   apply(rule sym)
   apply(rule_tac
      P = "\<lambda>x. x = F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N)"
      and t = "F_CFG_EASTD__fp G N"
      and s = "(if F_CFG_EASTD__fp_one G N = N then N else F_CFG_EASTD__fp G (F_CFG_EASTD__fp_one G N))"
      in ssubst)
    apply(rename_tac G N x)(*strict*)
    apply(rule F_CFG_EASTD__fp.psimps)
    apply(rule F_CFG_EASTD__fp_termination)
    apply(blast)
   apply(rename_tac G N x)(*strict*)
   apply(clarsimp)
  apply(rename_tac G N x)(*strict*)
  apply(clarsimp)
  done

lemma F_CFG_EASTDSoundL2: "
  valid_cfg G
  \<Longrightarrow> cfgSTD_accessible_nonterminals G \<supseteq> F_CFG_EASTD__fp G {cfg_initial G}"
  apply(rule F_CFG_EASTD_F_CFG_EASTD__fp_invariant_03_unfold)
  apply(simp add: F_CFG_EASTD__fp_valid_input_def valid_cfg_def)
  done

lemma F_CFG_EASTDSoundL: "
  valid_cfg G
  \<Longrightarrow> cfgSTD_accessible_nonterminals G = F_CFG_EASTD__fp G {cfg_initial G}"
  apply(rule order_antisym)
   apply(rule F_CFG_EASTDSoundL1)
   apply(blast)
  apply(rule F_CFG_EASTDSoundL2)
  apply(blast)
  done

theorem F_CFG_EASTD_vs_cfgSTD_SPEC_CFGEA__Productions: "
  valid_cfg G
  \<Longrightarrow> F_CFG_EASTD G = cfgSTD_SPEC_CFGEA__Productions G"
  apply(subgoal_tac "cfgSTD_accessible_nonterminals G = F_CFG_EASTD__fp G {cfg_initial G}")
   apply(simp add: F_CFG_EASTD_def cfgSTD_SPEC_CFGEA__Productions_def Let_def)
  apply(rule F_CFG_EASTDSoundL)
  apply(force)
  done

theorem F_CFG_EASTD_preserves_CFG: "
  valid_cfg G
  \<Longrightarrow> valid_cfg (cfgSTD_SPEC_CFGEA__Productions G)"
  apply(simp (no_asm) add: valid_cfg_def cfgSTD_SPEC_CFGEA__Productions_def Let_def)
  apply(rule conjI)
   apply(simp add: valid_cfg_def cfgSTD_SPEC_CFGEA__Productions_def Let_def)
  apply(rule conjI)
   apply(simp add: valid_cfg_def cfgSTD_SPEC_CFGEA__Productions_def Let_def)
   apply(simp add: cfgSTD_accessible_nonterminals_def)
  apply(rule conjI)
   apply(simp add: cfgSTD_accessible_nonterminals_def)
   apply(simp add: valid_cfg_def cfgSTD_SPEC_CFGEA__Productions_def Let_def)
   apply(rule_tac
      x="der1 \<lparr>cfg_conf=[teA (cfg_initial G)]\<rparr>"
      in exI)
   apply(rule conjI)
    apply(simp add: cfgSTD.derivation_initial_def)
    apply(rule conjI)
     apply(rule cfgSTD.der1_is_derivation)
    apply(simp add: der1_def)
    apply(simp add: cfg_initial_configurations_def)
    apply(simp add: cfg_configurations_def valid_cfg_def)
   apply(simp add: get_configuration_def der1_def)
  apply(rule conjI)
   apply(simp add: valid_cfg_def cfgSTD_SPEC_CFGEA__Productions_def Let_def)
  apply(clarsimp)
  apply(rename_tac e)(*strict*)
  apply(rule conjI)
   apply(rename_tac e)(*strict*)
   prefer 2
   apply(simp add: valid_cfg_def cfgSTD_SPEC_CFGEA__Productions_def Let_def)
  apply(rename_tac e)(*strict*)
  apply(subgoal_tac "(\<forall>e\<in> cfg_productions G. prod_lhs e \<in> cfg_nonterminals G \<and> setA (prod_rhs e) \<subseteq> cfg_nonterminals G \<and> setB (prod_rhs e) \<subseteq> cfg_events G)")
   apply(rename_tac e)(*strict*)
   prefer 2
   apply(simp add: valid_cfg_def cfgSTD_SPEC_CFGEA__Productions_def Let_def)
  apply(rename_tac e)(*strict*)
  apply(erule_tac
      x="e"
      in ballE)
   apply(rename_tac e)(*strict*)
   prefer 2
   apply(force)
  apply(rename_tac e)(*strict*)
  apply(simp add: cfgSTD_accessible_nonterminals_def)
  apply(clarsimp)
  apply(rename_tac e x d n c)(*strict*)
  apply(rule conjI)
   apply(rename_tac e x d n c)(*strict*)
   apply(force)
  apply(rename_tac e x d n c)(*strict*)
  apply(case_tac "d n")
   apply(rename_tac e x d n c)(*strict*)
   apply(simp add: get_configuration_def)
  apply(rename_tac e x d n c a)(*strict*)
  apply(case_tac a)
  apply(rename_tac e x d n c a option b)(*strict*)
  apply(simp add: get_configuration_def)
  apply(clarsimp)
  apply(rename_tac e x d n c option)(*strict*)
  apply(rename_tac e)
  apply(rename_tac ea x d n c e)(*strict*)
  apply(case_tac c)
  apply(rename_tac ea x d n c e cfg_confa)(*strict*)
  apply(clarsimp)
  apply(rename_tac ea x d n e cfg_confa)(*strict*)
  apply(rename_tac w)
  apply(rename_tac ea x d n e w)(*strict*)
  apply(subgoal_tac "\<exists>w1 w2. w1@[teA (prod_lhs ea)]@w2=w")
   apply(rename_tac ea x d n e w)(*strict*)
   prefer 2
   apply(rule setA_decomp)
   apply(force)
  apply(rename_tac ea x d n e w)(*strict*)
  apply(clarsimp)
  apply(rename_tac ea x d n e w1 w2)(*strict*)
  apply(rule_tac
      x="derivation_append d (der2 \<lparr>cfg_conf = w1 @ teA (prod_lhs ea) # w2\<rparr> ea \<lparr>cfg_conf = w1 @ (prod_rhs ea) @ w2\<rparr>) n"
      in exI)
  apply(rule conjI)
   apply(rename_tac ea x d n e w1 w2)(*strict*)
   apply(rule cfgSTD.derivation_append_preserves_derivation_initial)
     apply(rename_tac ea x d n e w1 w2)(*strict*)
     apply(force)
    apply(rename_tac ea x d n e w1 w2)(*strict*)
    apply(force)
   apply(rename_tac ea x d n e w1 w2)(*strict*)
   apply(rule cfgSTD.derivation_append_preserves_derivation)
     apply(rename_tac ea x d n e w1 w2)(*strict*)
     apply(simp add: cfgSTD.derivation_initial_def)
    apply(rename_tac ea x d n e w1 w2)(*strict*)
    apply(rule cfgSTD.der2_is_derivation)
    apply(simp add: cfgSTD_step_relation_def)
    apply(force)
   apply(rename_tac ea x d n e w1 w2)(*strict*)
   apply(clarsimp)
   apply(simp add: der2_def)
  apply(rename_tac ea x d n e w1 w2)(*strict*)
  apply(rule_tac
      x="Suc n"
      in exI)
  apply(simp add: der2_def derivation_append_def)
  apply(simp add: setAConcat)
  done

lemma cfgSTD_SPEC_CFGEA__Productions_makes_cfg_sub: "
  valid_cfg G
  \<Longrightarrow> cfg_sub (cfgSTD_SPEC_CFGEA__Productions G) G"
  apply(simp add: cfgSTD_SPEC_CFGEA__Productions_def cfg_sub_def Let_def)
  apply(rule conjI)
   apply(simp add: cfgSTD_accessible_nonterminals_def)
   apply(force)
  apply(force)
  done

lemma CFG_cfgSTD_SPEC_CFGEA__Productions_preserves_Nonblockingness_branching: "
  valid_cfg G
  \<Longrightarrow> cfgSTD.Nonblockingness_branching G
  \<Longrightarrow> cfgSTD.Nonblockingness_branching (cfgSTD_SPEC_CFGEA__Productions G)"
  apply(simp add: cfgSTD.Nonblockingness_branching_def)
  apply(clarsimp)
  apply(rename_tac dh n)(*strict*)
  apply(erule_tac
      x="dh"
      in allE)
  apply(subgoal_tac "cfgSTD.derivation_initial G dh")
   apply(rename_tac dh n)(*strict*)
   prefer 2
   apply(rule cfg_sub_preserves_derivation_initial)
     apply(rename_tac dh n)(*strict*)
     apply(force)
    apply(rename_tac dh n)(*strict*)
    apply(force)
   apply(rename_tac dh n)(*strict*)
   apply(rule cfgSTD_SPEC_CFGEA__Productions_makes_cfg_sub)
   apply(force)
  apply(rename_tac dh n)(*strict*)
  apply(clarsimp)
  apply(erule_tac
      x="n"
      in allE)
  apply(clarsimp)
  apply(rename_tac dh n dc x)(*strict*)
  apply(rule_tac
      x="dc"
      in exI)
  apply(clarsimp)
  apply(rule context_conjI)
   apply(rename_tac dh n dc x)(*strict*)
   apply(simp (no_asm) add: cfgSTD.derivation_def)
   apply(clarsimp)
   apply(rename_tac dh n dc x i)(*strict*)
   apply(case_tac i)
    apply(rename_tac dh n dc x i)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x)(*strict*)
    apply(simp add: cfgSTD.derivation_def derivation_append_fit_def maximum_of_domain_def)
    apply(case_tac "dc 0")
     apply(rename_tac dh n dc x)(*strict*)
     apply(clarsimp)
     apply(rename_tac dh n dc x y ya)(*strict*)
     apply(case_tac y)
     apply(rename_tac dh n dc x y ya option b)(*strict*)
     apply(clarsimp)
    apply(rename_tac dh n dc x a)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x a y ya)(*strict*)
    apply(case_tac a)
    apply(rename_tac dh n dc x a y ya option b)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x y ya option b)(*strict*)
    apply(case_tac option)
     apply(rename_tac dh n dc x y ya option b)(*strict*)
     apply(clarsimp)
    apply(rename_tac dh n dc x y ya option b a)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x y ya b a)(*strict*)
    apply(case_tac y)
    apply(rename_tac dh n dc x y ya b a option ba)(*strict*)
    apply(clarsimp)
   apply(rename_tac dh n dc x i nat)(*strict*)
   apply(clarsimp)
   apply(rename_tac dh n dc x nat)(*strict*)
   apply(case_tac "dc (Suc nat)")
    apply(rename_tac dh n dc x nat)(*strict*)
    apply(clarsimp)
   apply(rename_tac dh n dc x nat a)(*strict*)
   apply(clarsimp)
   apply(subgoal_tac "\<exists>e1 e2 c1 c2. dc nat = Some (pair e1 c1) \<and> SSd (Suc SSn) = Some (pair (Some e2) c2) \<and> cfgSTD_step_relation SSG c1 e2 c2" for SSd SSn SSG)
    apply(rename_tac dh n dc x nat a)(*strict*)
    prefer 2
    apply(rule cfgSTD.step_detail_before_some_position)
      apply(rename_tac dh n dc x nat a)(*strict*)
      apply(simp add: cfgSTD.derivation_initial_def)
     apply(rename_tac dh n dc x nat a)(*strict*)
     apply(force)
    apply(rename_tac dh n dc x nat a)(*strict*)
    apply(force)
   apply(rename_tac dh n dc x nat a)(*strict*)
   apply(clarsimp)
   apply(rename_tac dh n dc x nat e1 e2 c1 c2)(*strict*)
   apply(simp add: cfgSTD_step_relation_def)
   apply(simp add: cfgSTD_SPEC_CFGEA__Productions_def Let_def)
   apply(clarsimp)
   apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
   apply(simp add: cfgSTD_accessible_nonterminals_def)
   apply(rule conjI)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
    apply(simp add: valid_cfg_def)
   apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
   apply(rule_tac
      x="derivation_append dh dc n"
      in exI)
   apply(rule conjI)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
    apply(rule cfgSTD.derivation_append_preserves_derivation_initial)
      apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
      apply(force)
     apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
     apply(force)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
    apply(rule cfgSTD.derivation_append_preserves_derivation)
      apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
      apply(simp add: cfgSTD.derivation_initial_def)
     apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
     apply(force)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
    apply(simp add: derivation_append_fit_def)
    apply(case_tac "dh n")
     apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
     apply(clarsimp)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r a)(*strict*)
    apply(clarsimp)
    apply(case_tac a)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r a option b)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r option b)(*strict*)
    apply(case_tac "dc 0")
     apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r option b)(*strict*)
     apply(clarsimp)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r option b a)(*strict*)
    apply(clarsimp)
    apply(case_tac a)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r option b a optiona ba)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r option b optiona ba)(*strict*)
    apply(case_tac optiona)
     apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r option b optiona ba)(*strict*)
     apply(clarsimp)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r option b optiona ba a)(*strict*)
    apply(clarsimp)
   apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
   apply(rule_tac
      x="n+nat"
      in exI)
   apply(simp add: derivation_append_def get_configuration_def)
   apply(case_tac nat)
    apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x e1 e2 c1 c2 l r)(*strict*)
    apply(simp add: derivation_append_fit_def)
    apply(case_tac "dh n")
     apply(rename_tac dh n dc x e1 e2 c1 c2 l r)(*strict*)
     apply(clarsimp)
    apply(rename_tac dh n dc x e1 e2 c1 c2 l r a)(*strict*)
    apply(clarsimp)
    apply(case_tac a)
    apply(rename_tac dh n dc x e1 e2 c1 c2 l r a option b)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x e1 e2 c1 c2 l r option b)(*strict*)
    apply(case_tac "dc 0")
     apply(rename_tac dh n dc x e1 e2 c1 c2 l r option b)(*strict*)
     apply(clarsimp)
    apply(rename_tac dh n dc x e1 e2 c1 c2 l r option b a)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x e1 e2 c1 c2 l r option b)(*strict*)
    apply(case_tac e1)
     apply(rename_tac dh n dc x e1 e2 c1 c2 l r option b)(*strict*)
     apply(clarsimp)
     apply(rename_tac dh n dc x e2 c1 c2 l r option)(*strict*)
     apply (metis elemInsetA)
    apply(rename_tac dh n dc x e1 e2 c1 c2 l r option b a)(*strict*)
    apply(clarsimp)
   apply(rename_tac dh n dc x nat e1 e2 c1 c2 l r nata)(*strict*)
   apply(clarsimp)
   apply(rename_tac dh n dc x e1 e2 c1 c2 l r nata)(*strict*)
   apply (metis elemInsetA)
  apply(rename_tac dh n dc x)(*strict*)
  apply(rule context_conjI)
   apply(rename_tac dh n dc x)(*strict*)
   apply(case_tac "dc 0")
    apply(rename_tac dh n dc x)(*strict*)
    apply(simp add: derivation_append_fit_def)
    apply(case_tac "dh n")
     apply(rename_tac dh n dc x)(*strict*)
     apply(clarsimp)
    apply(rename_tac dh n dc x a)(*strict*)
    apply(clarsimp)
    apply(case_tac a)
    apply(rename_tac dh n dc x a option b)(*strict*)
    apply(clarsimp)
   apply(rename_tac dh n dc x a)(*strict*)
   apply(case_tac "dc 0")
    apply(rename_tac dh n dc x a)(*strict*)
    apply(clarsimp)
   apply(rename_tac dh n dc x a aa)(*strict*)
   apply(clarsimp)
   apply(rename_tac dh n dc x a)(*strict*)
   apply(case_tac a)
   apply(rename_tac dh n dc x a option b)(*strict*)
   apply(clarsimp)
   apply(rename_tac dh n dc x option b)(*strict*)
   apply(case_tac "option")
    apply(rename_tac dh n dc x option b)(*strict*)
    apply(clarsimp)
    apply(rename_tac dh n dc x b)(*strict*)
    apply(rule cfgSTD.derivation_belongs)
       apply(rename_tac dh n dc x b)(*strict*)
       apply(rule F_CFG_EASTD_preserves_CFG)
       apply(force)
      apply(rename_tac dh n dc x b)(*strict*)
      apply(force)
     apply(rename_tac dh n dc x b)(*strict*)
     apply(simp add: derivation_append_fit_def)
     apply(case_tac "dh n")
      apply(rename_tac dh n dc x b)(*strict*)
      apply(clarsimp)
     apply(rename_tac dh n dc x b a)(*strict*)
     apply(clarsimp)
     apply(case_tac a)
     apply(rename_tac dh n dc x b a option ba)(*strict*)
     apply(clarsimp)
     apply(rename_tac dh n dc x b option)(*strict*)
     apply(case_tac "dc 0")
      apply(rename_tac dh n dc x b option)(*strict*)
      apply(clarsimp)
     apply(rename_tac dh n dc x b option a)(*strict*)
     apply(clarsimp)
     apply(rename_tac dh n dc x b option)(*strict*)
     apply(rule cfgSTD.derivation_initial_configurations)
       apply(rename_tac dh n dc x b option)(*strict*)
       apply(rule F_CFG_EASTD_preserves_CFG)
       apply(force)
      apply(rename_tac dh n dc x b option)(*strict*)
      apply(force)
     apply(rename_tac dh n dc x b option)(*strict*)
     apply(force)
    apply(rename_tac dh n dc x b)(*strict*)
    apply(force)
   apply(rename_tac dh n dc x option b a)(*strict*)
   apply(clarsimp)
   apply(rename_tac dh n dc x b a)(*strict*)
   apply(simp add: cfgSTD.derivation_def)
   apply(erule_tac
      x="0"
      in allE)+
   apply(clarsimp)
  apply(rename_tac dh n dc x)(*strict*)
  apply(rule conjI)
   apply(rename_tac dh n dc x)(*strict*)
   apply(rule_tac
      x="x"
      in exI)
   apply(force)
  apply(rename_tac dh n dc x)(*strict*)
  apply(simp add: cfg_marking_condition_def)
  apply(clarsimp)
  apply(rename_tac dh n dc x i e c)(*strict*)
  apply(rule_tac
      x="i"
      in exI)
  apply(rule_tac
      x="e"
      in exI)
  apply(rule_tac
      x="c"
      in exI)
  apply(clarsimp)
  apply(simp add: cfg_marking_configuration_def cfg_configurations_def cfgSTD_SPEC_CFGEA__Productions_def Let_def)
  apply(clarsimp)
  done

theorem F_CFG_EASTD_vs_F_CFG_EASTD_ALT: "
  F_CFG_EASTD__SpecInput G
  \<Longrightarrow> F_CFG_EASTD G = F_CFG_EASTD_ALT G"
  apply(rule_tac t="F_CFG_EASTD G" in ssubst)
   apply(rule F_CFG_EASTD_vs_cfgSTD_SPEC_CFGEA__Productions)
   apply(simp add: F_CFG_EASTD__SpecInput_def F_CFG_EASTD__SpecOutput_def)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule SOUND_FUN_CFGLMACX)
   apply(force)
  apply(simp add: F_CFG_EASTD__SpecInput_def F_CFG_EASTD__SpecOutput_def)
  apply(clarsimp)
  apply(subgoal_tac "cfgSTD_accessible_nonterminals G =
    F_CFG_APLM__fp G (cfgSTD_Nonblockingness_nonterminals G) {cfg_initial G}")
   apply(simp add: F_CFG_EASTD_ALT_def Let_def cfgSTD_SPEC_CFGEA__Productions_def)
  apply(thin_tac "cfg_sub (F_CFG_EASTD_ALT G) G")
  apply(thin_tac "valid_cfg (F_CFG_EASTD_ALT G)")
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule F_CFG_APLMSoundL)
   apply(force)
  apply(subgoal_tac "cfg_nonterminals (F_CFG_EASTD_ALT G) = F_CFG_APLM__fp G (cfgSTD_Nonblockingness_nonterminals G) {cfg_initial G}")
   prefer 2
   apply(simp add: F_CFG_EASTD_ALT_def Let_def)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule F_CFG_EASTD_ALT_idemp_cfgLM_accessible_nonterminals)
    apply(force)
   apply(force)
  apply(clarsimp)
  apply(subgoal_tac "X" for X)
   prefer 2
   apply(rule cfgSTD_accessible_nonterminals_vs_cfgLM_accessible_nonterminals)
    apply(force)
   apply(force)
  apply(force)
  done

theorem SOUND_FUN_CFGLMACX_STD: "
  F_CFG_EASTD__SpecInput G
  \<Longrightarrow> F_CFG_EASTD__SpecOutput G (F_CFG_EASTD G)"
  apply(rule_tac t="F_CFG_EASTD G" in ssubst)
   apply(rule F_CFG_EASTD_vs_F_CFG_EASTD_ALT)
   apply(simp add: F_CFG_EASTD__SpecInput_def F_CFG_EASTD__SpecOutput_def)
  apply(metis SOUND_FUN_CFGLMACX)
  done

end


theory dropWhile
imports Main
        "../data/list"
        "$HIPSTER_HOME/IsaHipster"

begin

fun dropWhilet :: "('a => bool) => 'a list => 'a list" where
  "dropWhilet x (Nil2) = Nil2"
| "dropWhilet x (Cons2 z xs) =
     (if x z then dropWhilet x xs else Cons2 z xs)"

hipster dropWhilet
lemma lemma_a [thy_expl]: "dropWhilet x5 (dropWhilet x5 y5) = dropWhilet x5 y5"
by (hipster_induct_schemes dropWhilet.simps)

end


theory Llist_of_stream_iterate
  imports Main "$HIPSTER_HOME/IsaHipster"
    Literate
    Siterate
    Stream_of_llist_of_stream
begin
setup Tactic_Data.set_coinduct_sledgehammer
setup Misc_Data.set_noisy
(*cohipster llist_of_stream siterate literate*)
(*ca 20 sec*)
lemma lemma_ac [thy_expl]: "llist_of_stream (siterate y z) = literate y z"
 by (coinduction arbitrary: y z rule: Llist.Llist.coinduct_strong)
    auto
end


section \<open>CFG well-formedness\<close>

theory CFG_wf imports CFG begin

subsection \<open>Well-formedness of the abstract CFG\<close>

locale CFG_wf = CFG sourcenode targetnode kind valid_edge Entry
  for sourcenode :: "'edge \<Rightarrow> 'node" and targetnode :: "'edge \<Rightarrow> 'node"
  and kind :: "'edge \<Rightarrow> 'state edge_kind" and valid_edge :: "'edge \<Rightarrow> bool"
  and Entry :: "'node" ("'('_Entry'_')") +
  fixes Def::"'node \<Rightarrow> 'var set"
  fixes Use::"'node \<Rightarrow> 'var set"
  fixes state_val::"'state \<Rightarrow> 'var \<Rightarrow> 'val"
  assumes Entry_empty:"Def (_Entry_) = {} \<and> Use (_Entry_) = {}"
  and CFG_edge_no_Def_equal:
    "\<lbrakk>valid_edge a; V \<notin> Def (sourcenode a); pred (kind a) s\<rbrakk>
     \<Longrightarrow> state_val (transfer (kind a) s) V = state_val s V"
  and CFG_edge_transfer_uses_only_Use:
    "\<lbrakk>valid_edge a; \<forall>V \<in> Use (sourcenode a). state_val s V = state_val s' V;
      pred (kind a) s; pred (kind a) s'\<rbrakk>
      \<Longrightarrow> \<forall>V \<in> Def (sourcenode a). state_val (transfer (kind a) s) V =
                                     state_val (transfer (kind a) s') V"
  and CFG_edge_Uses_pred_equal:
    "\<lbrakk>valid_edge a; pred (kind a) s;
      \<forall>V \<in> Use (sourcenode a). state_val s V = state_val s' V\<rbrakk>
       \<Longrightarrow> pred (kind a) s'"
  and deterministic:"\<lbrakk>valid_edge a; valid_edge a'; sourcenode a = sourcenode a';
    targetnode a \<noteq> targetnode a'\<rbrakk>
  \<Longrightarrow> \<exists>Q Q'. kind a = (Q)\<^sub>\<surd> \<and> kind a' = (Q')\<^sub>\<surd> \<and>
             (\<forall>s. (Q s \<longrightarrow> \<not> Q' s) \<and> (Q' s \<longrightarrow> \<not> Q s))"

begin

lemma [dest!]: "V \<in> Use (_Entry_) \<Longrightarrow> False"
by(simp add:Entry_empty)

lemma [dest!]: "V \<in> Def (_Entry_) \<Longrightarrow> False"
by(simp add:Entry_empty)

lemma CFG_path_no_Def_equal:
  "\<lbrakk>n -as\<rightarrow>* n'; \<forall>n \<in> set (sourcenodes as). V \<notin> Def n; preds (kinds as) s\<rbrakk>
    \<Longrightarrow> state_val (transfers (kinds as) s) V = state_val s V"
proof(induct arbitrary:s rule:path.induct)
  case (empty_path n)
  thus ?case by(simp add:sourcenodes_def kinds_def)
next
  case (Cons_path n'' as n' a n)
  note IH = \<open>\<And>s. \<lbrakk>\<forall>n\<in>set (sourcenodes as). V \<notin> Def n; preds (kinds as) s\<rbrakk> \<Longrightarrow>
            state_val (transfers (kinds as) s) V = state_val s V\<close>
  from \<open>preds (kinds (a#as)) s\<close> have "pred (kind a) s"
    and "preds (kinds as) (transfer (kind a) s)" by(simp_all add:kinds_def)
  from \<open>\<forall>n\<in>set (sourcenodes (a#as)). V \<notin> Def n\<close>
    have noDef:"V \<notin> Def (sourcenode a)"
    and all:"\<forall>n\<in>set (sourcenodes as). V \<notin> Def n"
    by(auto simp:sourcenodes_def)
  from \<open>valid_edge a\<close> noDef \<open>pred (kind a) s\<close>
  have "state_val (transfer (kind a) s) V = state_val s V"
    by(rule CFG_edge_no_Def_equal)
  with IH[OF all \<open>preds (kinds as) (transfer (kind a) s)\<close>] show ?case
    by(simp add:kinds_def)
qed

end

end


theory Prelude_Ord
imports "$HETS_ISABELLE_LIB/MainHC"
uses "$HETS_ISABELLE_LIB/prelude"
begin

setup "Header.initialize
       [\"NotFalse\", \"NotTrue\", \"AndFalse\", \"AndTrue\", \"AndSym\",
        \"OrDef\", \"OtherwiseDef\", \"NotFalse1\", \"NotTrue1\",
        \"notNot1\", \"notNot2\", \"EqualTDef\", \"EqualSymDef\",
        \"EqualReflex\", \"EqualTransT\", \"DiffDef\", \"DiffSymDef\",
        \"DiffTDef\", \"DiffFDef\", \"TE1\", \"TE2\", \"TE3\", \"TE4\",
        \"IUE1\", \"IUE2\", \"IBE1\", \"IBE2\", \"IBE3\", \"IBE4\",
        \"IBE5\", \"IBE6\", \"IBE7\", \"IBE8\", \"IOE04\", \"IOE05\",
        \"IOE06\", \"LeIrreflexivity\", \"LeTTransitive\", \"LeTTotal\",
        \"GeDef\", \"LeqDef\", \"GeqDef\", \"EqTSOrdRel\", \"EqFSOrdRel\",
        \"EqTOrdRel\", \"EqFOrdRel\", \"EqTOrdTSubstE\", \"EqTOrdFSubstE\",
        \"EqTOrdTSubstD\", \"EqTOrdFSubstD\", \"LeTGeFEqFRel\",
        \"LeFGeTEqTRel\", \"CmpLTDef\", \"CmpEQDef\", \"CmpGTDef\",
        \"MaxYDef\", \"MaxXDef\", \"MinXDef\", \"MinYDef\", \"IOO13\",
        \"IOO14\", \"IOO15\", \"IBO5\", \"IOE01\", \"IOE02\", \"IOE03\",
        \"IOE07\", \"IOE08\", \"IOE09\", \"LeTAsymmetry\",
        \"GeIrreflexivity\", \"GeTAsymmetry\", \"GeTTransitive\",
        \"GeTTotal\", \"LeqReflexivity\", \"LeqTTransitive\",
        \"LeqTTotal\", \"GeqReflexivity\", \"GeqTTransitive\",
        \"GeqTTotal\", \"LeTGeTRel\", \"LeFGeFRel\", \"LeqTGetTRel\",
        \"LeqFGetFRel\", \"GeTLeTRel\", \"GeFLeFRel\", \"GeqTLeqTRel\",
        \"GeqFLeqFRel\", \"LeqTGeFRel\", \"LeqFGeTRel\", \"GeTLeFEqFRel\",
        \"GeFLeTEqTRel\", \"GeqTLeFRel\", \"GeqFLeTRel\",
        \"LeqTLeTEqTRel\", \"LeqFLeFEqFRel\", \"GeqTGeTEqTRel\",
        \"GeqFGeFEqFRel\", \"LeTGeqFRel\", \"GeTLeqFRel\", \"LeLeqDiff\",
        \"MaxSym\", \"MinSym\", \"TO1\", \"TO3\", \"TO4\", \"TO5\",
        \"TO6\", \"IUO01\", \"IUO02\", \"IUO03\", \"IUO04\", \"IUO05\",
        \"IUO06\", \"IUO07\", \"IOO16\", \"IOO17\", \"IOO18\", \"IOO19\",
        \"IOO20\", \"IOO21\", \"IOO22\", \"IOO23\", \"IOO24\", \"IOO25\",
        \"IOO26\", \"IOO27\", \"IOO28\", \"IOO29\", \"IOO30\", \"IOO31\",
        \"IOO32\", \"IOO33\", \"IBO6\", \"IBO7\", \"IBO8\", \"IBO9\",
        \"IBO10\", \"IBO11\", \"IBO12\"]"

typedecl Bool
typedecl Unit
typedecl X_Nat

datatype Ordering = EQ | GT | LT

consts
X__XAmpXAmp__X :: "bool => bool => bool" ("(_/ &&/ _)" [54,54] 52)
X__XEqXEq__X :: "'a partial => 'a partial => bool" ("(_/ ==''/ _)" [54,54] 52)
X__XGtXEq__X :: "'a partial => 'a partial => bool" ("(_/ >=''/ _)" [54,54] 52)
X__XGt__X :: "'a partial => 'a partial => bool" ("(_/ >''/ _)" [54,54] 52)
X__XLtXEq__X :: "'a partial => 'a partial => bool" ("(_/ <=''/ _)" [54,54] 52)
X__XLt__X :: "'a partial => 'a partial => bool" ("(_/ <''/ _)" [54,54] 52)
X__XSlashXEq__X :: "'a partial => 'a partial => bool" ("(_/ '/=/ _)" [54,54] 52)
X__XVBarXVBar__X :: "bool => bool => bool" ("(_/ ||/ _)" [54,54] 52)
X_max :: "'a partial => 'a partial => 'a partial"
X_min :: "'a partial => 'a partial => 'a partial"
compare :: "'a partial => 'a partial => Ordering partial"
notH__X :: "bool => bool" ("(notH/ _)" [56] 56)
otherwiseH :: "bool"

axioms
NotFalse [rule_format] : "notH False"

NotTrue [rule_format] : "~ notH True"

AndFalse [rule_format] : "ALL (x :: bool). ~ False && x"

AndTrue [rule_format] : "ALL (x :: bool). True && x = x"

AndSym [rule_format] :
"ALL (x :: bool). ALL (y :: bool). x && y = y && x"

OrDef [rule_format] :
"ALL (x :: bool).
 ALL (y :: bool). x || y = notH (notH x && notH y)"

OtherwiseDef [rule_format] : "otherwiseH"

NotFalse1 [rule_format] : "ALL (x :: bool). notH x = (~ x)"

NotTrue1 [rule_format] : "ALL (x :: bool). ~ notH x = x"

notNot1 [rule_format] : "ALL (x :: bool). (~ x) = notH x"

notNot2 [rule_format] : "ALL (x :: bool). (~ ~ x) = (~ notH x)"

EqualTDef [rule_format] :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x = y --> x ==' y"

EqualSymDef [rule_format] :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x ==' y = y ==' x"

EqualReflex [rule_format] : "ALL (x :: 'a partial). x ==' x"

EqualTransT [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). x ==' y & y ==' z --> x ==' z"

DiffDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x /= y = notH (x ==' y)"

DiffSymDef [rule_format] :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x /= y = y /= x"

DiffTDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x /= y = notH (x ==' y)"

DiffFDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x /= y) = x ==' y"

TE1 [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). ~ x ==' y --> ~ x = y"

TE2 [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). notH (x ==' y) = (~ x ==' y)"

TE3 [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ notH (x ==' y)) = x ==' y"

TE4 [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x ==' y) = (~ x ==' y)"

IUE1 [rule_format] : "makePartial () ==' makePartial ()"

IUE2 [rule_format] : "~ makePartial () /= makePartial ()"

IBE1 [rule_format] : "makePartial () ==' makePartial ()"

IBE2 [rule_format] : "undefinedOp ==' undefinedOp"

IBE3 [rule_format] : "~ undefinedOp ==' makePartial ()"

IBE4 [rule_format] : "~ makePartial () ==' undefinedOp"

IBE5 [rule_format] : "makePartial () /= undefinedOp"

IBE6 [rule_format] : "undefinedOp /= makePartial ()"

IBE7 [rule_format] : "notH (makePartial () ==' undefinedOp)"

IBE8 [rule_format] : "~ notH notH (makePartial () ==' undefinedOp)"

IOE04 [rule_format] : "~ makePartial LT ==' makePartial EQ"

IOE05 [rule_format] : "~ makePartial LT ==' makePartial GT"

IOE06 [rule_format] : "~ makePartial EQ ==' makePartial GT"

LeIrreflexivity [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x ==' y --> ~ x <' y"

LeTTransitive [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). x <' y & y <' z --> x <' z"

LeTTotal [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (x <' y | y <' x) | x ==' y"

GeDef [rule_format] :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x >' y = y <' x"

LeqDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x <=' y = (x <' y) || (x ==' y)"

GeqDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x >=' y = (x >' y) || (x ==' y)"

EqTSOrdRel [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x ==' y = (~ x <' y & ~ x >' y)"

EqFSOrdRel [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x ==' y) = (x <' y | x >' y)"

EqTOrdRel [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x ==' y = (x <=' y & x >=' y)"

EqFOrdRel [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x ==' y) = (x <=' y | x >=' y)"

EqTOrdTSubstE [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). x ==' y & y <' z --> x <' z"

EqTOrdFSubstE [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). x ==' y & ~ y <' z --> ~ x <' z"

EqTOrdTSubstD [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). x ==' y & z <' y --> z <' x"

EqTOrdFSubstD [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). x ==' y & ~ z <' y --> ~ z <' x"

LeTGeFEqFRel [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x <' y = (~ x >' y & ~ x ==' y)"

LeFGeTEqTRel [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x <' y) = (x >' y | x ==' y)"

CmpLTDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). compare x y ==' makePartial LT = x <' y"

CmpEQDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). compare x y ==' makePartial EQ = x ==' y"

CmpGTDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). compare x y ==' makePartial GT = x >' y"

MaxYDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). X_max x y ==' y = x <=' y"

MaxXDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). X_max x y ==' x = y <=' x"

MinXDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). X_min x y ==' x = x <=' y"

MinYDef [rule_format] :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). X_min x y ==' y = y <=' x"

IOO13 [rule_format] : "makePartial LT <' makePartial EQ"

IOO14 [rule_format] : "makePartial EQ <' makePartial GT"

IOO15 [rule_format] : "makePartial LT <' makePartial GT"

IBO5 [rule_format] : "undefinedOp <' makePartial ()"

declare NotFalse [simp]
declare NotTrue [simp]
declare AndFalse [simp]
declare AndTrue [simp]
declare OtherwiseDef [simp]
declare NotTrue1 [simp]
declare EqualReflex [simp]
declare IUE1 [simp]
declare IUE2 [simp]
declare IBE1 [simp]
declare IBE2 [simp]
declare IBE3 [simp]
declare IBE4 [simp]
declare IBE5 [simp]
declare IBE6 [simp]
declare IBE7 [simp]
declare IBE8 [simp]
declare IOE04 [simp]
declare IOE05 [simp]
declare IOE06 [simp]
declare LeIrreflexivity [simp]
declare CmpLTDef [simp]
declare CmpEQDef [simp]
declare CmpGTDef [simp]
declare MaxYDef [simp]
declare MaxXDef [simp]
declare MinXDef [simp]
declare MinYDef [simp]
declare IOO13 [simp]
declare IOO14 [simp]
declare IOO15 [simp]
declare IBO5 [simp]

theorem IOE01 : "makePartial LT ==' makePartial LT"
by (auto)

setup "Header.record \"IOE01\""

theorem IOE02 : "makePartial EQ ==' makePartial EQ"
by (auto)

setup "Header.record \"IOE02\""

theorem IOE03 : "makePartial GT ==' makePartial GT"
by (auto)

setup "Header.record \"IOE03\""

theorem IOE07 : "makePartial LT /= makePartial EQ"
apply(simp add: DiffDef)
done

setup "Header.record \"IOE07\""

theorem IOE08 : "makePartial LT /= makePartial GT"
apply(simp add: DiffDef)
done

setup "Header.record \"IOE08\""

theorem IOE09 : "makePartial EQ /= makePartial GT"
apply(simp add: DiffDef)
done

setup "Header.record \"IOE09\""

lemma LeIrreflContra : " x <' x ==> False"
by (auto)

theorem LeTAsymmetry :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x <' y --> ~ y <' x"
apply(auto)
apply(rule ccontr)
apply(simp add: notNot2 NotTrue1)
apply(rule_tac x="x" in LeIrreflContra)
apply(rule_tac y = "y" in LeTTransitive)
by (auto)

setup "Header.record \"LeTAsymmetry\""

theorem GeIrreflexivity :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x ==' y --> ~ x >' y"
apply(auto)
apply(simp add: GeDef)
apply(simp add: EqualSymDef LeTAsymmetry)
done

setup "Header.record \"GeIrreflexivity\""

theorem GeTAsymmetry :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x >' y --> ~ y >' x"
apply(auto)
apply(simp add: GeDef)
apply(simp add: EqualSymDef LeTAsymmetry)
done

setup "Header.record \"GeTAsymmetry\""

theorem GeTTransitive :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). (x >' y) && (y >' z) --> x >' z"
apply(auto)
apply(simp add: GeDef)
apply(rule_tac x="z" and y="y" and z="x" in  LeTTransitive)
apply(auto)
apply(case_tac  "y <' x")
apply(auto)
apply(case_tac  "y <' x")
by(auto)

setup "Header.record \"GeTTransitive\""

theorem GeTTotal :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). ((x >' y) || (y >' x)) || (x ==' y)"
apply(auto)
apply(simp add: OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "y >' x")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeDef)
apply(simp add: LeFGeTEqTRel)
apply(auto)
apply(simp add: GeDef)
apply(simp add: LeTAsymmetry)
apply(simp add: EqualSymDef)
done

setup "Header.record \"GeTTotal\""

theorem LeqReflexivity : "ALL (x :: 'a partial). x <=' x"
apply(auto)
apply(simp add: LeqDef)
apply(simp add: OrDef)
done

setup "Header.record \"LeqReflexivity\""

lemma EqualL1 [rule_format]:
"ALL a b ab bb.
 (x ==' z) & ~ (x ==' z) \<longrightarrow> False"
by(auto)

lemma EqualL2 [rule_format]:
"ALL a b aa ab ba bb.
(x ==' y) & (y ==' z) \<longrightarrow> ~ (x ==' z) \<longrightarrow> False"
apply(simp add: EqualL1)
apply(auto)
apply(rule EqualTransT)
by(auto)

lemma EqualL3 [rule_format]:
"ALL a b aa ab ba bb.
~ (x ==' y) | ~ (y ==' z) | ~ (x ==' z) \<longrightarrow> False \<longrightarrow> False"
by(auto)

lemma Le1E [rule_format]:
"ALL a b aa ab ba bb.
(y ==' x) & (x <' z) \<longrightarrow> (y <' z)"
apply (auto)
apply(rule EqTOrdTSubstE)
by(auto)

lemma Le2 [rule_format]:
"ALL a b aa ab ba bb.
(x <' y) \<longrightarrow> ~ (x <' y) \<longrightarrow> False"
by auto

lemma Le3E [rule_format]:
"ALL a b aa ab ba bb.
(y ==' x) & (x <' z) \<longrightarrow> ~ (y <' z) \<longrightarrow> False"
apply (auto)
apply(rule EqTOrdTSubstE)
by(auto)

lemma Le3D [rule_format]:
"ALL a b aa ab ba bb.
(y ==' x) & (z <' x) \<longrightarrow> ~ (z <' y) \<longrightarrow> False"
apply (auto)
apply(rule EqTOrdTSubstD)
apply(auto)
done

lemma Le4E [rule_format]:
"ALL a b aa ab ba bb.
(y ==' x) & ~ (x <' z) \<longrightarrow> ~ (y <' z)"
apply (auto)
apply(rule Le3E)
apply(auto)
apply(simp add: EqualSymDef)
done

lemma Le4D [rule_format]:
"ALL a b aa ab ba bb.
(y ==' x) & ~ (z <' x) \<longrightarrow> ~ (z <' y)"
apply (auto)
apply(rule Le3D)
apply(auto)
apply(simp add: EqualSymDef)
done

lemma Le5 [rule_format]:
"ALL a b aa ab ba bb.
~ (x <' y) \<longrightarrow> (x <' y) \<longrightarrow> False"
by auto

lemma Le6E [rule_format]:
"ALL a b aa ab ba bb.
(y ==' x) & ~ (x <' z) \<longrightarrow> (y <' z) \<longrightarrow> False"
apply (auto)
apply(rule Le5)
apply(rule EqTOrdFSubstE)
apply(auto)
done

lemma Le7 [rule_format]:
"ALL a b aa ab ba bb.
x <' y & ~ x <' y \<longrightarrow> False"
by auto

lemma Le8 [rule_format]:
"ALL a b aa ab ba bb.
z ==' y & x <' y \<longrightarrow> x <' z"
apply auto
apply(rule EqTOrdTSubstD)
apply(rule conjI)
by(auto)

lemma Le9 [rule_format]:
"ALL a b aa ab ba bb.
x <' y & y ==' z \<longrightarrow> ~ x <' z \<longrightarrow> False"
apply auto
apply(rule Le8)
apply(auto)
apply (simp add: EqualSymDef)
done

lemma Le10 [rule_format]:
"ALL a b aa ab ba bb.
y <' z & x ==' y \<longrightarrow> ~ x <' z \<longrightarrow> False"
apply auto
apply(rule EqTOrdTSubstE)
apply(rule conjI)
by(auto)

lemma Le11 [rule_format]:
"ALL a b aa ab ba bb.
z <' y & y <' x \<longrightarrow> ~ z <' x \<longrightarrow> False"
apply(auto)
apply(rule LeTTransitive)
apply(auto)
done

lemma Le12 [rule_format]:
"ALL a b aa ab ba bb.
y <' x & y ==' z \<longrightarrow> ~ z <' x \<longrightarrow> False"
apply(auto)
apply(rule EqTOrdTSubstE)
apply(rule conjI)
apply(auto)
apply(simp add: EqualSymDef)
done

lemma Le13 [rule_format]:
"ALL a b aa ab ba bb.
x <' z & z <' y \<longrightarrow> ~ x <' y \<longrightarrow> False"
apply(auto)
apply(rule LeTTransitive)
apply(rule conjI)
apply(auto)
done

lemma Le14 [rule_format]:
"ALL a b aa ab ba bb.
~ x <' x"
by(auto)

lemma Le15 [rule_format]:
"ALL a b aa ab ba bb.
x <' z & z <' y \<longrightarrow> x <' y & y <' x \<longrightarrow> False"
apply(auto)
apply(simp add: LeTAsymmetry)
done

lemma Le16 [rule_format]:
"ALL a b aa ab ba bb.
x ==' y & z <' y \<longrightarrow> z <' x & ~ z <' x \<longrightarrow> False"
by(auto)

lemma Le17 [rule_format]:
"ALL a b aa ab ba bb.
z <' y & x ==' y \<longrightarrow> z <' x"
apply(auto)
apply(rule EqTOrdTSubstD)
apply(rule conjI)
apply(auto)
done

lemma Le18 [rule_format]:
"ALL a b aa ab ba bb.
x <' z & ~ x <' z \<longrightarrow> False"
by(auto)

lemma Le19 [rule_format]:
"ALL a b aa ab ba bb.
x ==' y & y <' z \<longrightarrow> ~ x <' z \<longrightarrow> False"
apply(auto)
apply(rule EqTOrdTSubstE)
apply(auto)
done

lemma Le20 [rule_format]:
"ALL a b aa ab ba bb.
x ==' y & z <' y \<longrightarrow> ~ z <' x \<longrightarrow> False"
apply(auto)
apply(rule EqTOrdTSubstD)
apply(auto)
done

theorem LeqTTransitive :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). (x <=' y) && (y <=' z) --> x <=' z"
apply(auto)
apply(simp add: LeqDef)
apply(simp add: OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "y <' z")
apply(auto)
apply(case_tac "x <' z")
apply(auto)
apply(case_tac "x ==' z")
apply(auto)
(*Here we needed the first aux lemma*)
apply(rule Le18)
apply(rule conjI)
apply(rule LeTTransitive)
apply(auto)
apply(case_tac "y ==' z")
apply(auto)
apply(case_tac "x <' z")
apply(auto)
apply(case_tac "x ==' z")
apply(auto)
apply(rule Le9)
apply(rule conjI)
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(case_tac "y <' z")
apply(auto)
apply(case_tac "x <' z")
apply(auto)
apply(case_tac "x ==' z")
apply(auto)
apply(rule Le19)
apply(auto)
apply(case_tac "y ==' z")
apply(auto)
apply(case_tac "x <' z")
apply(auto)
apply(case_tac "x ==' z")
apply(auto)
apply(rule EqualL2)
by(auto)

setup "Header.record \"LeqTTransitive\""

theorem LeqTTotal :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (x <=' y) && (y <=' x) = x ==' y"
apply(auto)
apply(simp add: LeqDef)
apply(simp add: OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "y <' x")
apply(auto)
apply(simp add: LeTAsymmetry)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: LeqDef)
apply(simp add: OrDef)
apply(case_tac "y <' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef EqualL1)
done

setup "Header.record \"LeqTTotal\""

theorem GeqReflexivity : "ALL (x :: 'a partial). x >=' x"
apply(auto)
apply(simp add: GeqDef)
apply(simp add: OrDef)
apply(simp add: AndSym)
done

setup "Header.record \"GeqReflexivity\""

theorem GeqTTransitive :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). (x >=' y) && (y >=' z) --> x >=' z"
apply(auto)
apply(simp add: GeqDef)
apply(simp add: OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "y >' z")
apply(auto)
apply(case_tac "x >' z")
apply(auto)
apply(case_tac "x ==' z")
apply(auto)
(*Here we needed the first aux lemma*)
apply(simp add: GeDef)
apply(rule Le18)
apply(rule conjI)
apply(rule LeTTransitive)
apply(auto)
apply(case_tac "y ==' z")
apply(auto)
apply(case_tac "x >' z")
apply(auto)
apply(case_tac "x ==' z")
apply(auto)
apply(simp add: GeDef)
apply(rule Le10)
apply(rule conjI)
apply(simp add: EqualSymDef)+
apply(case_tac "x ==' y")
apply(auto)
apply(case_tac "y >' z")
apply(auto)
apply(case_tac "x >' z")
apply(auto)
apply(case_tac "x ==' z")
apply(auto)
apply(simp add: GeDef)
apply(rule Le20)
apply(rule conjI)
apply(simp add: EqualSymDef)+
apply(case_tac "y ==' z")
apply(auto)
apply(case_tac "x >' z")
apply(auto)
apply(case_tac "x ==' z")
apply(auto)
apply(rule EqualL2)
by(auto)

setup "Header.record \"GeqTTransitive\""

theorem GeqTTotal :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (x >=' y) && (y >=' x) = x ==' y"
apply(auto)
apply(simp add: GeqDef)
apply(simp add: OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "y >' x")
apply(auto)
apply(simp add: GeDef)
apply(simp add: LeTAsymmetry)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeqDef)
apply(simp add: OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "y >' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef EqualL1)
apply(case_tac "y >' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef EqualL1)
done

setup "Header.record \"GeqTTotal\""

theorem LeTGeTRel :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x <' y = y >' x"
apply(auto)
apply(simp add: GeDef)+
done

setup "Header.record \"LeTGeTRel\""

theorem LeFGeFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x <' y) = (~ y >' x)"
apply(auto)
apply(simp add: GeDef)+
done

setup "Header.record \"LeFGeFRel\""

theorem LeqTGetTRel :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x <=' y = y >=' x"
apply(auto)
apply(simp add: GeqDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "y >' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef)
apply(simp add: GeDef)
apply(case_tac "x ==' y")
apply(auto)
apply(case_tac "y >' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef)
apply(simp add: GeqDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "y >' x")
apply(auto)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeDef)
apply(case_tac "y ==' x")
apply(auto)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: EqualSymDef)
done

setup "Header.record \"LeqTGetTRel\""

theorem LeqFGetFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x <=' y) = (~ y >=' x)"
apply(auto)
apply(simp add: GeqDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "y >' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: GeDef)
apply(case_tac "x ==' y")
apply(auto)
apply(case_tac "y >' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef)
apply(simp add: GeqDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "y >' x")
apply(auto)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeDef)
apply(case_tac "y ==' x")
apply(auto)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: EqualSymDef)
done

setup "Header.record \"LeqFGetFRel\""

theorem GeTLeTRel :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x >' y = y <' x"
apply(auto)
apply(simp add: GeDef)+
done

setup "Header.record \"GeTLeTRel\""

theorem GeFLeFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x >' y) = (~ y <' x)"
apply(auto)
apply(simp add: GeDef)+
done

setup "Header.record \"GeFLeFRel\""

theorem GeqTLeqTRel :
"ALL (x :: 'a partial). ALL (y :: 'a partial). x >=' y = y <=' x"
apply(auto)
apply(simp add: GeqDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "y <' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: GeDef)
apply(case_tac "x ==' y")
apply(auto)
apply(case_tac "y <' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef)
apply(simp add: GeqDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "y <' x")
apply(auto)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeDef)
apply(case_tac "y ==' x")
apply(auto)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: EqualSymDef)
done

setup "Header.record \"GeqTLeqTRel\""

theorem GeqFLeqFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x >=' y) = (~ y <=' x)"
apply(auto)
apply(simp add: GeqDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "y <' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: GeDef)
apply(case_tac "x ==' y")
apply(auto)
apply(case_tac "y <' x")
apply(auto)
apply(case_tac "y ==' x")
apply(auto)
apply(simp add: EqualSymDef)
apply(simp add: GeqDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "y <' x")
apply(auto)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeDef)
apply(case_tac "y ==' x")
apply(auto)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: EqualSymDef)
done

setup "Header.record \"GeqFLeqFRel\""

theorem LeqTGeFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x <=' y = (~ x >' y)"
apply(auto)
apply(simp add: GeqDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(simp add: GeDef)
apply(simp add: LeTAsymmetry)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeDef)
apply(simp add: EqualSymDef)
apply(simp add: GeDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: LeFGeTEqTRel)
apply(simp add: EqFSOrdRel)
apply(auto)
apply(simp add: GeDef)
apply(simp add: LeTAsymmetry)
apply(simp add: GeDef)
done

setup "Header.record \"LeqTGeFRel\""

theorem LeqFGeTRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x <=' y) = x >' y"
apply(auto)
apply(simp add: GeDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: LeFGeTEqTRel)
apply(simp add: EqFSOrdRel)
apply(simp add: GeDef)
apply(simp add: GeDef LeqDef)
apply(simp add: OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(simp add: LeTAsymmetry)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: EqualSymDef LeTAsymmetry)
done

setup "Header.record \"LeqFGeTRel\""

theorem GeTLeFEqFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x >' y = (~ x <' y & ~ x ==' y)"
apply(auto)
apply(simp add: GeDef LeTAsymmetry)
apply(simp add: GeDef)
apply(simp add: EqualSymDef LeTAsymmetry)
apply(simp add: EqFSOrdRel)
done

setup "Header.record \"GeTLeFEqFRel\""

theorem GeFLeTEqTRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x >' y) = (x <' y | x ==' y)"
apply(auto)
apply(simp add: LeTGeFEqFRel)
apply(simp add: GeDef LeTAsymmetry)
apply(simp add: GeDef)
apply(simp add: EqualSymDef)
done

setup "Header.record \"GeFLeTEqTRel\""

theorem GeqTLeFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x >=' y = (~ x <' y)"
apply(auto)
apply(simp add: GeqDef OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(simp add: GeDef LeTAsymmetry)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeqDef OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(simp add: GeDef LeTAsymmetry)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: LeFGeTEqTRel)
apply(simp add: EqFSOrdRel)
apply(simp add: GeDef LeTAsymmetry)
done

setup "Header.record \"GeqTLeFRel\""

theorem GeqFLeTRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x >=' y) = x <' y"
apply(auto)
apply(simp add: GeqDef OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(simp add: GeDef LeTAsymmetry)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: LeFGeTEqTRel)
apply(simp add: EqFSOrdRel)
apply(simp add: GeDef LeTAsymmetry)
apply(rule disjE)
apply(auto)
apply(simp add: GeqDef OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(simp add: GeDef LeTAsymmetry)
apply(case_tac "x ==' y")
by(auto)

setup "Header.record \"GeqFLeTRel\""

theorem LeqTLeTEqTRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x <=' y = (x <' y | x ==' y)"
apply(auto)
apply(simp add: LeqDef OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(simp add: LeqDef OrDef LeTAsymmetry)+
done

setup "Header.record \"LeqTLeTEqTRel\""

theorem LeqFLeFEqFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x <=' y) = (~ x <' y & ~ x ==' y)"
apply(auto)
apply(simp add: LeqDef OrDef)+
done

setup "Header.record \"LeqFLeFEqFRel\""

theorem GeqTGeTEqTRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x >=' y = (x >' y | x ==' y)"
apply(auto)
apply(simp add: GeqDef OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(simp add: GeqDef OrDef)+
apply(case_tac "x >' y")
apply(auto)
done

setup "Header.record \"GeqTGeTEqTRel\""

theorem GeqFGeFEqFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (~ x >=' y) = (~ x >' y & ~ x ==' y)"
apply(auto)
apply(simp add: GeqDef OrDef)+
apply(case_tac "x >' y")
apply(auto)
apply(simp add: GeqDef OrDef)+
done

setup "Header.record \"GeqFGeFEqFRel\""

theorem LeTGeqFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x <' y = (~ x >=' y)"
apply(auto)
apply(simp add: GeqDef OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(simp add: GeDef LeTAsymmetry)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeqDef OrDef)
apply(case_tac "x >' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeDef)
apply(simp add: LeFGeTEqTRel)
apply(simp add: EqFSOrdRel)
apply(simp add: GeDef LeTAsymmetry)
apply(rule disjE)
by(auto)

setup "Header.record \"LeTGeqFRel\""

theorem GeTLeqFRel :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x >' y = (~ x <=' y)"
apply(auto)
apply(simp add: GeDef LeqDef OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(simp add: LeTAsymmetry)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: EqualSymDef)
apply(simp add: LeqDef OrDef)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: GeDef)
apply(simp add: LeFGeTEqTRel)
apply(simp add: EqFSOrdRel)
apply(simp add: GeDef LeTAsymmetry)
done

setup "Header.record \"GeTLeqFRel\""

theorem LeLeqDiff :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x <' y = (x <=' y) && (x /= y)"
apply(auto)
apply(simp add: LeqDef OrDef)
apply(simp add: DiffDef)
apply(case_tac "x ==' y")
apply(auto)
apply(simp add: LeqDef OrDef)
apply(simp add: DiffDef)
apply(case_tac "x <' y")
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
done

setup "Header.record \"LeLeqDiff\""

theorem MaxSym :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). X_max x y ==' y = X_max y x ==' y"
by (auto)

setup "Header.record \"MaxSym\""

theorem MinSym :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). X_min x y ==' y = X_min y x ==' y"
by (auto)

setup "Header.record \"MinSym\""

theorem TO1 :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). (x ==' y | x <' y) = x <=' y"
apply(auto)
apply(simp add: LeqDef OrDef)+
apply(case_tac "x ==' y")
apply(auto)
done

setup "Header.record \"TO1\""

theorem TO3 :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). notH notH (x <' y) | notH (x <' y)"
by (auto)

setup "Header.record \"TO3\""

theorem TO4 :
"ALL (x :: 'a partial).
 ALL (y :: 'a partial). x <' y --> notH (x ==' y)"
apply(auto)
apply(case_tac "x ==' y")
apply(auto)
done

setup "Header.record \"TO4\""

theorem TO5 :
"ALL (w :: 'a partial).
 ALL (x :: 'a partial).
 ALL (y :: 'a partial).
 ALL (z :: 'a partial). (x <' y & y <' z) & z <' w --> x <' w"
apply(auto)
apply(rule_tac y="z" in LeTTransitive)
apply(auto)
apply(rule_tac y="y" in LeTTransitive)
by auto

setup "Header.record \"TO5\""

theorem TO6 :
"ALL (x :: 'a partial).
 ALL (z :: 'a partial). z <' x --> notH (x <' z)"
apply(auto)
apply(case_tac "x <' z")
apply(auto)
apply(simp add: LeTAsymmetry)
done

setup "Header.record \"TO6\""

theorem IUO01 : "makePartial () <=' makePartial ()"
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IUO01\""

theorem IUO02 : "~ makePartial () <' makePartial ()"
by (auto)

setup "Header.record \"IUO02\""

theorem IUO03 : "makePartial () >=' makePartial ()"
apply(simp add: GeqDef OrDef)
apply(case_tac "makePartial () >' makePartial ()")
apply(auto)
done

setup "Header.record \"IUO03\""

theorem IUO04 : "~ makePartial () >' makePartial ()"
apply(simp add: GeDef)
done

setup "Header.record \"IUO04\""

theorem IUO05 :
"X_max (makePartial ()) (makePartial ()) ==' makePartial ()"
apply(simp add: MaxYDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IUO05\""

theorem IUO06 :
"X_min (makePartial ()) (makePartial ()) ==' makePartial ()"
apply(simp add: MinXDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IUO06\""

theorem IUO07 :
"compare (makePartial ()) (makePartial ()) ==' makePartial EQ"
by (auto)

setup "Header.record \"IUO07\""

theorem IOO16 : "makePartial LT <=' makePartial EQ"
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IOO16\""

theorem IOO17 : "makePartial EQ <=' makePartial GT"
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IOO17\""

theorem IOO18 : "makePartial LT <=' makePartial GT"
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IOO18\""

theorem IOO19 : "makePartial EQ >=' makePartial LT"
apply(simp add: GeqDef OrDef GeDef)
done

setup "Header.record \"IOO19\""

theorem IOO20 : "makePartial GT >=' makePartial EQ"
apply(simp add: GeqDef OrDef GeDef)
done

setup "Header.record \"IOO20\""

theorem IOO21 : "makePartial GT >=' makePartial LT"
apply(simp add: GeqDef OrDef GeDef)
done

setup "Header.record \"IOO21\""

theorem IOO22 : "makePartial EQ >' makePartial LT"
apply(simp add: GeDef OrDef)
done

setup "Header.record \"IOO22\""

theorem IOO23 : "makePartial GT >' makePartial EQ"
apply(simp add: GeDef OrDef)
done

setup "Header.record \"IOO23\""

theorem IOO24 : "makePartial GT >' makePartial LT"
apply(simp add: GeDef OrDef)
done

setup "Header.record \"IOO24\""

theorem IOO25 :
"X_max (makePartial LT) (makePartial EQ) ==' makePartial EQ"
apply(simp add: MaxYDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IOO25\""

theorem IOO26 :
"X_max (makePartial EQ) (makePartial GT) ==' makePartial GT"
apply(simp add: MaxYDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IOO26\""

theorem IOO27 :
"X_max (makePartial LT) (makePartial GT) ==' makePartial GT"
apply(simp add: MaxYDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IOO27\""

theorem IOO28 :
"X_min (makePartial LT) (makePartial EQ) ==' makePartial LT"
apply(simp add: MinXDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IOO28\""

theorem IOO29 :
"X_min (makePartial EQ) (makePartial GT) ==' makePartial EQ"
apply(simp add: MinXDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IOO29\""

theorem IOO30 :
"X_min (makePartial LT) (makePartial GT) ==' makePartial LT"
apply(simp add: MinXDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IOO30\""

theorem IOO31 :
"compare (makePartial LT) (makePartial LT) ==' makePartial EQ"
by (auto)

setup "Header.record \"IOO31\""

theorem IOO32 :
"compare (makePartial EQ) (makePartial EQ) ==' makePartial EQ"
by (auto)

setup "Header.record \"IOO32\""

theorem IOO33 :
"compare (makePartial GT) (makePartial GT) ==' makePartial EQ"
by (auto)

setup "Header.record \"IOO33\""

theorem IBO6 : "~ undefinedOp >=' makePartial ()"
apply(simp add: GeqDef OrDef GeDef)
apply (case_tac "makePartial () <' undefinedOp")
apply(auto)
apply(simp add: LeTGeFEqFRel)
apply(simp add: GeDef)
done

setup "Header.record \"IBO6\""

theorem IBO7 : "makePartial () >=' undefinedOp"
apply(simp add: GeqDef OrDef GeDef)
done

setup "Header.record \"IBO7\""

theorem IBO8 : "~ makePartial () <' undefinedOp"
apply(simp add: LeFGeTEqTRel)
apply(simp add: GeDef)
done

setup "Header.record \"IBO8\""

theorem IBO9 :
"X_max undefinedOp (makePartial ()) ==' makePartial ()"
apply(simp add: MaxYDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IBO9\""

theorem IBO10 :
"X_min undefinedOp (makePartial ()) ==' undefinedOp"
apply(simp add: MaxYDef)
apply(simp add: LeqDef OrDef)
done

setup "Header.record \"IBO10\""

theorem IBO11 :
"compare (makePartial ()) (makePartial ()) ==' makePartial EQ"
by (auto)

setup "Header.record \"IBO11\""

theorem IBO12 :
"compare undefinedOp undefinedOp ==' makePartial EQ"
by (auto)

setup "Header.record \"IBO12\""

end