[STATEMENT]
lemma preamble_prefix_tests_refined[code] :
  fixes t1 :: "(('a ::ccompare,'b::ccompare,'c::ccompare) traversal_path \<times> ('a set \<times> 'a set)) set_rbt"
  and   t2 :: "'a set_rbt"
shows "preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID CCOMPARE((('a,'b,'c) traversal_path \<times> ('a set \<times> 'a set))) of
Some _ \<Rightarrow> (case ID CCOMPARE('a) of
  Some _ \<Rightarrow> set (concat (map (\<lambda> (p,(rd,dr)) .
                 (concat (map (\<lambda> (p1,q2) . [(q,p1,q2), (q2,[],(target q p1))])
                             (filter (\<lambda> (p1,q2) . (target q p1) \<noteq> q2 \<and> (target q p1) \<in> rd \<and> q2 \<in> rd)
                                     (List.product (prefixes p) (RBT_Set2.keys t2))))))
                 (RBT_Set2.keys t1))) |
  None \<Rightarrow> Code.abort (STR ''prefix_pair_tests RBT_set: ccompare = None'') (\<lambda>_. (preamble_prefix_tests q (RBT_set t1) (RBT_set t2)))) |
None \<Rightarrow> Code.abort (STR ''prefix_pair_tests RBT_set: ccompare = None'') (\<lambda>_. (preamble_prefix_tests q (RBT_set t1) (RBT_set t2))))"
  (is "preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = ?C")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
proof (cases "ID CCOMPARE((('a,'b,'c) traversal_path \<times> ('a set \<times> 'a set)))")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ID ccompare = None \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
 2. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
case None
[PROOF STATE]
proof (state)
this:
ID ccompare = None

goal (2 subgoals):
 1. ID ccompare = None \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
 2. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ID ccompare = None
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ID ccompare = None

goal (1 subgoal):
 1. preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))

goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
case (Some a)
[PROOF STATE]
proof (state)
this:
ID ccompare = Some a

goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ID ccompare = Some a
[PROOF STEP]
have k1: "(RBT_set t1) = set (RBT_Set2.keys t1)"
[PROOF STATE]
proof (prove)
using this:
ID ccompare = Some a

goal (1 subgoal):
 1. RBT_set t1 = set (RBT_Set2.keys t1)
[PROOF STEP]
by (simp add: RBT_set_conv_keys)
[PROOF STATE]
proof (state)
this:
RBT_set t1 = set (RBT_Set2.keys t1)

goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
proof (cases "ID CCOMPARE('a)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ID ccompare = None \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
 2. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
case None
[PROOF STATE]
proof (state)
this:
ID ccompare = None

goal (2 subgoals):
 1. ID ccompare = None \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
 2. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ID ccompare = None
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ID ccompare = None

goal (1 subgoal):
 1. preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
using Some
[PROOF STATE]
proof (prove)
using this:
ID ccompare = None
ID ccompare = Some a

goal (1 subgoal):
 1. preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))

goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
case (Some b)
[PROOF STATE]
proof (state)
this:
ID ccompare = Some b

goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ID ccompare = Some b
[PROOF STEP]
have k2: "(RBT_set t2) = set (RBT_Set2.keys t2)"
[PROOF STATE]
proof (prove)
using this:
ID ccompare = Some b

goal (1 subgoal):
 1. RBT_set t2 = set (RBT_Set2.keys t2)
[PROOF STEP]
by (simp add: RBT_set_conv_keys)
[PROOF STATE]
proof (state)
this:
RBT_set t2 = set (RBT_Set2.keys t2)

goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
have "preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (\<Union>(p, rd, dr)\<in> set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> (set (RBT_Set2.keys t2))). {(q, p1, q2), (q2, [], target q p1)})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
unfolding preamble_prefix_tests_code  k1 k2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
have "?C = (\<Union>(p, rd, dr)\<in> set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> (set (RBT_Set2.keys t2))). {(q, p1, q2), (q2, [], target q p1)})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
let ?S1 = "set (concat (map (\<lambda> (p,(rd,dr)) . (concat (map (\<lambda> (p1,q2) . [(q,p1,q2), (q2,[],(target q p1))]) (filter (\<lambda> (p1,q2) . (target q p1) \<in> rd \<and> q2 \<in> rd \<and> (target q p1) \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))) (RBT_Set2.keys t1)))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
let ?S2 = "(\<Union>(p, rd, dr)\<in> set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> (set (RBT_Set2.keys t2))). {(q, p1, q2), (q2, [], target q p1)})"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
have *: "?C = ?S1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
have *: "\<And> rd p . (filter (\<lambda> (p1,q2) . (target q p1) \<noteq> q2 \<and> (target q p1) \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))) = (filter (\<lambda> (p1,q2) . (target q p1) \<in> rd \<and> q2 \<in> rd \<and> (target q p1) \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>rd p. filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2)) = filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> ?rd \<and> q2 \<in> ?rd) (List.product (prefixes ?p) (RBT_Set2.keys t2)) = filter (\<lambda>(p1, q2). target q p1 \<in> ?rd \<and> q2 \<in> ?rd \<and> target q p1 \<noteq> q2) (List.product (prefixes ?p) (RBT_Set2.keys t2))

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
have "?C = set (concat (map (\<lambda> (p,(rd,dr)) . (concat (map (\<lambda> (p1,q2) . [(q,p1,q2), (q2,[],(target q p1))]) (filter (\<lambda> (p1,q2) . (target q p1) \<noteq> q2 \<and> (target q p1) \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2)))))) (RBT_Set2.keys t1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
using Some \<open>ID ccompare = Some a\<close>
[PROOF STATE]
proof (prove)
using this:
ID ccompare = Some b
ID ccompare = Some a

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
unfolding *
[PROOF STATE]
proof (prove)
using this:
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
have union_filter_helper: "\<And> xs f x1 x2  y . y \<in> f (x1,x2) \<Longrightarrow> (x1,x2) \<in> set xs \<Longrightarrow> y \<in> \<Union> (set (map f xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xs f x1 x2 y. \<lbrakk>y \<in> f (x1, x2); (x1, x2) \<in> set xs\<rbrakk> \<Longrightarrow> y \<in> \<Union> (set (map f xs))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>?y \<in> ?f (?x1.0, ?x2.0); (?x1.0, ?x2.0) \<in> set ?xs\<rbrakk> \<Longrightarrow> ?y \<in> \<Union> (set (map ?f ?xs))

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
have concat_set_helper : "\<And> xss xs x . x \<in> set xs \<Longrightarrow> xs \<in> set xss \<Longrightarrow> x \<in> set (concat xss)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xss xs x. \<lbrakk>x \<in> set xs; xs \<in> set xss\<rbrakk> \<Longrightarrow> x \<in> set (concat xss)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x1 \<in> set ?xs1; ?xs1 \<in> set ?xss1\<rbrakk> \<Longrightarrow> ?x1 \<in> set (concat ?xss1)

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
have "\<And> x . x \<in> ?S1 \<Longrightarrow> x \<in> ?S2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
assume "x \<in> ?S1"
[PROOF STATE]
proof (state)
this:
x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
obtain prddr where "prddr \<in> set (RBT_Set2.keys t1)"
                            and   "x \<in> set ((\<lambda> (p,(rd,dr)) . (concat (map (\<lambda> (p1,q2) . [(q,p1,q2), (q2,[],(target q p1))]) (filter (\<lambda> (p1,q2) . (target q p1) \<in> rd \<and> q2 \<in> rd \<and> (target q p1) \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))) prddr)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>prddr. \<lbrakk>prddr \<in> set (RBT_Set2.keys t1); x \<in> set (case prddr of (p, rd, dr) \<Rightarrow> concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using concat_map_elem[OF \<open>x \<in> ?S1\<close>]
[PROOF STATE]
proof (prove)
using this:
(\<And>xa. \<lbrakk>xa \<in> set (RBT_Set2.keys t1); x \<in> set (case xa of (p, rd, dr) \<Rightarrow> concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>prddr. \<lbrakk>prddr \<in> set (RBT_Set2.keys t1); x \<in> set (case prddr of (p, rd, dr) \<Rightarrow> concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
prddr \<in> set (RBT_Set2.keys t1)
x \<in> set (case prddr of (p, rd, dr) \<Rightarrow> concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))

goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
prddr \<in> set (RBT_Set2.keys t1)
x \<in> set (case prddr of (p, rd, dr) \<Rightarrow> concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))

goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
obtain p rd dr where "prddr = (p,(rd,dr))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p rd dr. prddr = (p, rd, dr) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using prod_cases3
[PROOF STATE]
proof (prove)
using this:
(\<And>a b c. ?y = (a, b, c) \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>p rd dr. prddr = (p, rd, dr) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
prddr = (p, rd, dr)

goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
prddr \<in> set (RBT_Set2.keys t1)
x \<in> set (case prddr of (p, rd, dr) \<Rightarrow> concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))
prddr = (p, rd, dr)
[PROOF STEP]
have "(p,(rd,dr)) \<in> set (RBT_Set2.keys t1)"
                   and  "x \<in> set ((concat (map (\<lambda> (p1,q2) . [(q,p1,q2), (q2,[],(target q p1))]) (filter (\<lambda> (p1,q2) . (target q p1) \<in> rd \<and> q2 \<in> rd \<and> (target q p1) \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))))"
[PROOF STATE]
proof (prove)
using this:
prddr \<in> set (RBT_Set2.keys t1)
x \<in> set (case prddr of (p, rd, dr) \<Rightarrow> concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))
prddr = (p, rd, dr)

goal (1 subgoal):
 1. (p, rd, dr) \<in> set (RBT_Set2.keys t1) &&& x \<in> set (concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(p, rd, dr) \<in> set (RBT_Set2.keys t1)
x \<in> set (concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))

goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(p, rd, dr) \<in> set (RBT_Set2.keys t1)
x \<in> set (concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))
[PROOF STEP]
obtain p1 q2 where "(p1,q2) \<in> set ((filter (\<lambda> (p1,q2) . (target q p1) \<in> rd \<and> q2 \<in> rd \<and> (target q p1) \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))"
                          and   "x \<in> set [(q,p1,q2), (q2,[],(target q p1))]"
[PROOF STATE]
proof (prove)
using this:
(p, rd, dr) \<in> set (RBT_Set2.keys t1)
x \<in> set (concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))

goal (1 subgoal):
 1. (\<And>p1 q2. \<lbrakk>(p1, q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))); x \<in> set [(q, p1, q2), (q2, [], target q p1)]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(p1, q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))
x \<in> set [(q, p1, q2), (q2, [], target q p1)]

goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(p1, q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))
x \<in> set [(q, p1, q2), (q2, [], target q p1)]
[PROOF STEP]
have "x \<in> {(q,p1,q2), (q2,[],(target q p1))}"
[PROOF STATE]
proof (prove)
using this:
(p1, q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))
x \<in> set [(q, p1, q2), (q2, [], target q p1)]

goal (1 subgoal):
 1. x \<in> {(q, p1, q2), (q2, [], target q p1)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> {(q, p1, q2), (q2, [], target q p1)}

goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {(q, p1, q2), (q2, [], target q p1)}
[PROOF STEP]
have "x \<in> \<Union> (set (map (\<lambda>(p1, q2). {(q, p1, q2), (q2, [], target q p1)}) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))"
[PROOF STATE]
proof (prove)
using this:
x \<in> {(q, p1, q2), (q2, [], target q p1)}

goal (1 subgoal):
 1. x \<in> \<Union> (set (map (\<lambda>(p1, q2). {(q, p1, q2), (q2, [], target q p1)}) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))
[PROOF STEP]
using union_filter_helper[OF _ \<open>(p1,q2) \<in> set ((filter (\<lambda> (p1,q2) . (target q p1) \<in> rd \<and> q2 \<in> rd \<and> (target q p1) \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))\<close>, of x "(\<lambda> (p1,q2) . {(q,p1,q2), (q2,[],(target q p1))})"]
[PROOF STATE]
proof (prove)
using this:
x \<in> {(q, p1, q2), (q2, [], target q p1)}
x \<in> (case (p1, q2) of (p1, q2) \<Rightarrow> {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> \<Union> (set (map (\<lambda>(p1, q2). {(q, p1, q2), (q2, [], target q p1)}) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))

goal (1 subgoal):
 1. x \<in> \<Union> (set (map (\<lambda>(p1, q2). {(q, p1, q2), (q2, [], target q p1)}) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x \<in> \<Union> (set (map (\<lambda>(p1, q2). {(q, p1, q2), (q2, [], target q p1)}) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))

goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> \<Union> (set (map (\<lambda>(p1, q2). {(q, p1, q2), (q2, [], target q p1)}) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))
[PROOF STEP]
have "x \<in> (\<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> (set (RBT_Set2.keys t2))). {(q, p1, q2), (q2, [], target q p1)})"
[PROOF STATE]
proof (prove)
using this:
x \<in> \<Union> (set (map (\<lambda>(p1, q2). {(q, p1, q2), (q2, [], target q p1)}) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))

goal (1 subgoal):
 1. x \<in> (\<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> (\<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. \<And>x. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> (\<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
show "x \<in> ?S2"
[PROOF STATE]
proof (prove)
using this:
x \<in> (\<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
using \<open>(p,(rd,dr)) \<in> set (RBT_Set2.keys t1)\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> (\<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
(p, rd, dr) \<in> set (RBT_Set2.keys t1)

goal (1 subgoal):
 1. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x2 \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> ?x2 \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?x2 \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> ?x2 \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
have "\<And> x . x \<in> ?S2 \<Longrightarrow> x \<in> ?S1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
assume "x \<in> ?S2"
[PROOF STATE]
proof (state)
this:
x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. \<And>x. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
obtain p rd dr p1 q2 where "(p, rd, dr)\<in> set (RBT_Set2.keys t1)"
                                  and   "(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> (set (RBT_Set2.keys t2)))"
                                  and   "x \<in> {(q, p1, q2), (q2, [], target q p1)}"
[PROOF STATE]
proof (prove)
using this:
x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. (\<And>p rd dr p1 q2. \<lbrakk>(p, rd, dr) \<in> set (RBT_Set2.keys t1); (p1, q2) \<in> Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)); x \<in> {(q, p1, q2), (q2, [], target q p1)}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(p, rd, dr) \<in> set (RBT_Set2.keys t1)
(p1, q2) \<in> Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2))
x \<in> {(q, p1, q2), (q2, [], target q p1)}

goal (1 subgoal):
 1. \<And>x. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(p, rd, dr) \<in> set (RBT_Set2.keys t1)
(p1, q2) \<in> Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2))
x \<in> {(q, p1, q2), (q2, [], target q p1)}
[PROOF STEP]
have *:"x \<in> set [(q, p1, q2), (q2, [], target q p1)]"
[PROOF STATE]
proof (prove)
using this:
(p, rd, dr) \<in> set (RBT_Set2.keys t1)
(p1, q2) \<in> Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2))
x \<in> {(q, p1, q2), (q2, [], target q p1)}

goal (1 subgoal):
 1. x \<in> set [(q, p1, q2), (q2, [], target q p1)]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set [(q, p1, q2), (q2, [], target q p1)]

goal (1 subgoal):
 1. \<And>x. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
have "(p1,q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p1, q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))
[PROOF STEP]
using \<open>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> (set (RBT_Set2.keys t2)))\<close>
[PROOF STATE]
proof (prove)
using this:
(p1, q2) \<in> Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2))

goal (1 subgoal):
 1. (p1, q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(p1, q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))

goal (1 subgoal):
 1. \<And>x. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(p1, q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))
[PROOF STEP]
have **:"[(q, p1, q2), (q2, [], target q p1)] \<in> set ((map (\<lambda> (p1,q2) . [(q,p1,q2), (q2,[],(target q p1))]) (filter (\<lambda> (p1,q2) . (target q p1) \<in> rd \<and> q2 \<in> rd \<and> (target q p1) \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))"
[PROOF STATE]
proof (prove)
using this:
(p1, q2) \<in> set (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))

goal (1 subgoal):
 1. [(q, p1, q2), (q2, [], target q p1)] \<in> set (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
[(q, p1, q2), (q2, [], target q p1)] \<in> set (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))

goal (1 subgoal):
 1. \<And>x. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
have ***: "(concat (map (\<lambda> (p1,q2) . [(q,p1,q2), (q2,[],(target q p1))]) (filter (\<lambda> (p1,q2) . (target q p1) \<in> rd \<and> q2 \<in> rd \<and> (target q p1) \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) \<in> set (map (\<lambda> (p,(rd,dr)) . (concat (map (\<lambda> (p1,q2) . [(q,p1,q2), (q2,[],(target q p1))]) (filter (\<lambda> (p1,q2) . (target q p1) \<in> rd \<and> q2 \<in> rd \<and> (target q p1) \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))))) (RBT_Set2.keys t1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))) \<in> set (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))
[PROOF STEP]
using \<open>(p, rd, dr)\<in> set (RBT_Set2.keys t1)\<close>
[PROOF STATE]
proof (prove)
using this:
(p, rd, dr) \<in> set (RBT_Set2.keys t1)

goal (1 subgoal):
 1. concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))) \<in> set (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2)))) \<in> set (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))

goal (1 subgoal):
 1. \<And>x. x \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
show "x \<in> ?S1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
using concat_set_helper[OF concat_set_helper[OF * **] ***]
[PROOF STATE]
proof (prove)
using this:
x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal (1 subgoal):
 1. x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
by assumption
[PROOF STATE]
proof (state)
this:
x \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x2 \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> ?x2 \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?x2 \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> ?x2 \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
?x2 \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> ?x2 \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?x2 \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> ?x2 \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
?x2 \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> ?x2 \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal (1 subgoal):
 1. (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
unfolding *
[PROOF STATE]
proof (prove)
using this:
?x2 \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) \<Longrightarrow> ?x2 \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
?x2 \<in> (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)}) \<Longrightarrow> ?x2 \<in> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))

goal (1 subgoal):
 1. set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. \<And>a. ID ccompare = Some a \<Longrightarrow> preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})
(case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1)))) = (\<Union>(p, rd, dr)\<in>set (RBT_Set2.keys t1). \<Union>(p1, q2)\<in>Set.filter (\<lambda>(p1, q2). target q p1 \<in> rd \<and> q2 \<in> rd \<and> target q p1 \<noteq> q2) (set (prefixes p) \<times> set (RBT_Set2.keys t2)). {(q, p1, q2), (q2, [], target q p1)})

goal (1 subgoal):
 1. preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
preamble_prefix_tests q (RBT_set t1) (RBT_set t2) = (case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> case ID ccompare of None \<Rightarrow> Code.abort STR ''prefix_pair_tests RBT_set: ccompare = None'' (\<lambda>_. preamble_prefix_tests q (RBT_set t1) (RBT_set t2)) | Some x \<Rightarrow> set (concat (map (\<lambda>(p, rd, dr). concat (map (\<lambda>(p1, q2). [(q, p1, q2), (q2, [], target q p1)]) (filter (\<lambda>(p1, q2). target q p1 \<noteq> q2 \<and> target q p1 \<in> rd \<and> q2 \<in> rd) (List.product (prefixes p) (RBT_Set2.keys t2))))) (RBT_Set2.keys t1))))

goal:
No subgoals!
[PROOF STEP]
qed