[STATEMENT]
lemma vec_of_basis_enum_ket:
  "vec_of_basis_enum (ket i) = unit_vec (CARD('a)) (enum_idx i)"
  for i::"'a::enum"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_basis_enum (ket i) = unit_vec CARD('a) (enum_idx i)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vec_of_basis_enum (ket i) = unit_vec CARD('a) (enum_idx i)
[PROOF STEP]
have "dim_vec (vec_of_basis_enum (ket i))
      = dim_vec (unit_vec (CARD('a)) (enum_idx i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
[PROOF STEP]
have "dim_vec (unit_vec (CARD('a)) (enum_idx i))
      = CARD('a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (unit_vec CARD('a) (enum_idx i)) = CARD('a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_vec (unit_vec CARD('a) (enum_idx i)) = CARD('a)

goal (1 subgoal):
 1. dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dim_vec (unit_vec CARD('a) (enum_idx i)) = CARD('a)

goal (1 subgoal):
 1. dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
[PROOF STEP]
have "dim_vec (vec_of_basis_enum (ket i)) = CARD('a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (vec_of_basis_enum (ket i)) = CARD('a)
[PROOF STEP]
unfolding vec_of_basis_enum_def vec_of_basis_enum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (vec_of_list (map (crepresentation (set canonical_basis) (ket i)) canonical_basis)) = CARD('a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_vec (vec_of_basis_enum (ket i)) = CARD('a)

goal (1 subgoal):
 1. dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
dim_vec (unit_vec CARD('a) (enum_idx i)) = CARD('a)
dim_vec (vec_of_basis_enum (ket i)) = CARD('a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dim_vec (unit_vec CARD('a) (enum_idx i)) = CARD('a)
dim_vec (vec_of_basis_enum (ket i)) = CARD('a)

goal (1 subgoal):
 1. dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) = unit_vec CARD('a) (enum_idx i)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) = unit_vec CARD('a) (enum_idx i)
[PROOF STEP]
have "vec_of_basis_enum (ket i) $ j =
    (unit_vec (CARD('a)) (enum_idx i)) $ j"
    if "j < dim_vec (vec_of_basis_enum (ket i))"
    for j
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
have j_bound: "j < length (canonical_basis::'a ell2 list)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length canonical_basis
[PROOF STEP]
by (metis dim_vec_of_basis_enum' that)
[PROOF STATE]
proof (state)
this:
j < length canonical_basis

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
have y1: "cindependent (set (canonical_basis::'a ell2 list))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindependent (set canonical_basis)
[PROOF STEP]
using is_cindependent_set
[PROOF STATE]
proof (prove)
using this:
cindependent (set canonical_basis)

goal (1 subgoal):
 1. cindependent (set canonical_basis)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
cindependent (set canonical_basis)

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
have y2: "canonical_basis ! j \<in> set (canonical_basis::'a ell2 list)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. canonical_basis ! j \<in> set canonical_basis
[PROOF STEP]
using j_bound
[PROOF STATE]
proof (prove)
using this:
j < length canonical_basis

goal (1 subgoal):
 1. canonical_basis ! j \<in> set canonical_basis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
canonical_basis ! j \<in> set canonical_basis

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
have p1: "enum_class.enum ! enum_idx i = i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enum_class.enum ! enum_idx i = i
[PROOF STEP]
using enum_idx_correct
[PROOF STATE]
proof (prove)
using this:
enum_class.enum ! enum_idx ?i = ?i

goal (1 subgoal):
 1. enum_class.enum ! enum_idx i = i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
enum_class.enum ! enum_idx i = i

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
enum_class.enum ! enum_idx i = i

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
have p2: "(canonical_basis::'a ell2 list) ! t  = ket ((enum_class.enum::'a list) ! t)"
      if "t < length (enum_class.enum::'a list)"
      for t
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. canonical_basis ! t = ket (enum_class.enum ! t)
[PROOF STEP]
unfolding canonical_basis_ell2_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map ket enum_class.enum ! t = ket (enum_class.enum ! t)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
t < length enum_class.enum

goal (1 subgoal):
 1. map ket enum_class.enum ! t = ket (enum_class.enum ! t)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?t1 < length enum_class.enum \<Longrightarrow> canonical_basis ! ?t1 = ket (enum_class.enum ! ?t1)

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?t1 < length enum_class.enum \<Longrightarrow> canonical_basis ! ?t1 = ket (enum_class.enum ! ?t1)

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
have p3: "enum_idx i < length (enum_class.enum::'a list)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enum_idx i < length enum_class.enum
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. enum_idx i < length enum_class.enum
[PROOF STEP]
have "set (enum_class.enum::'a list) = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set enum_class.enum = UNIV
[PROOF STEP]
using UNIV_enum
[PROOF STATE]
proof (prove)
using this:
UNIV = set enum_class.enum

goal (1 subgoal):
 1. set enum_class.enum = UNIV
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
set enum_class.enum = UNIV

goal (1 subgoal):
 1. enum_idx i < length enum_class.enum
[PROOF STEP]
hence "i \<in> set (enum_class.enum::'a list)"
[PROOF STATE]
proof (prove)
using this:
set enum_class.enum = UNIV

goal (1 subgoal):
 1. i \<in> set enum_class.enum
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
i \<in> set enum_class.enum

goal (1 subgoal):
 1. enum_idx i < length enum_class.enum
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i \<in> set enum_class.enum

goal (1 subgoal):
 1. enum_idx i < length enum_class.enum
[PROOF STEP]
unfolding enum_idx_def
[PROOF STATE]
proof (prove)
using this:
i \<in> set enum_class.enum

goal (1 subgoal):
 1. index_of i enum_class.enum < length enum_class.enum
[PROOF STEP]
by (metis index_of_bound length_greater_0_conv length_pos_if_in_set)
[PROOF STATE]
proof (state)
this:
enum_idx i < length enum_class.enum

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
enum_idx i < length enum_class.enum

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
enum_class.enum ! enum_idx i = i
?t1 < length enum_class.enum \<Longrightarrow> canonical_basis ! ?t1 = ket (enum_class.enum ! ?t1)
enum_idx i < length enum_class.enum
[PROOF STEP]
have p4: "(canonical_basis::'a ell2 list) ! (enum_idx i)  = ket i"
[PROOF STATE]
proof (prove)
using this:
enum_class.enum ! enum_idx i = i
?t1 < length enum_class.enum \<Longrightarrow> canonical_basis ! ?t1 = ket (enum_class.enum ! ?t1)
enum_idx i < length enum_class.enum

goal (1 subgoal):
 1. canonical_basis ! enum_idx i = ket i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
canonical_basis ! enum_idx i = ket i

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
have "enum_idx i < length (enum_class.enum::'a list)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enum_idx i < length enum_class.enum
[PROOF STEP]
using p3
[PROOF STATE]
proof (prove)
using this:
enum_idx i < length enum_class.enum

goal (1 subgoal):
 1. enum_idx i < length enum_class.enum
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
enum_idx i < length enum_class.enum

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
enum_idx i < length enum_class.enum

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
have "length (enum_class.enum::'a list) = dim_vec (vec_of_basis_enum (ket i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length enum_class.enum = dim_vec (vec_of_basis_enum (ket i))
[PROOF STEP]
unfolding vec_of_basis_enum_def canonical_basis_ell2_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length enum_class.enum = dim_vec (vec_of_list (map (crepresentation (set (map ket enum_class.enum)) (ket i)) (map ket enum_class.enum)))
[PROOF STEP]
using dim_vec_of_basis_enum'[where v = "ket i"]
[PROOF STATE]
proof (prove)
using this:
dim_vec (vec_of_basis_enum (ket i)) = length canonical_basis

goal (1 subgoal):
 1. length enum_class.enum = dim_vec (vec_of_list (map (crepresentation (set (map ket enum_class.enum)) (ket i)) (map ket enum_class.enum)))
[PROOF STEP]
unfolding canonical_basis_ell2_def
[PROOF STATE]
proof (prove)
using this:
dim_vec (vec_of_basis_enum (ket i)) = length (map ket enum_class.enum)

goal (1 subgoal):
 1. length enum_class.enum = dim_vec (vec_of_list (map (crepresentation (set (map ket enum_class.enum)) (ket i)) (map ket enum_class.enum)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length enum_class.enum = dim_vec (vec_of_basis_enum (ket i))

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
enum_idx i < length enum_class.enum
length enum_class.enum = dim_vec (vec_of_basis_enum (ket i))
[PROOF STEP]
have enum_i_dim_vec: "enum_idx i < dim_vec (unit_vec (CARD('a)) (enum_idx i))"
[PROOF STATE]
proof (prove)
using this:
enum_idx i < length enum_class.enum
length enum_class.enum = dim_vec (vec_of_basis_enum (ket i))

goal (1 subgoal):
 1. enum_idx i < dim_vec (unit_vec CARD('a) (enum_idx i))
[PROOF STEP]
using \<open>dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec (CARD('a)) (enum_idx i))\<close>
[PROOF STATE]
proof (prove)
using this:
enum_idx i < length enum_class.enum
length enum_class.enum = dim_vec (vec_of_basis_enum (ket i))
dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))

goal (1 subgoal):
 1. enum_idx i < dim_vec (unit_vec CARD('a) (enum_idx i))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
enum_idx i < dim_vec (unit_vec CARD('a) (enum_idx i))

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
hence r1: "(unit_vec (CARD('a)) (enum_idx i)) $ j
        = (if enum_idx i = j then 1 else 0)"
[PROOF STATE]
proof (prove)
using this:
enum_idx i < dim_vec (unit_vec CARD('a) (enum_idx i))

goal (1 subgoal):
 1. unit_vec CARD('a) (enum_idx i) $ j = (if enum_idx i = j then 1::'b else (0::'b))
[PROOF STEP]
using \<open>dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec (CARD('a)) (enum_idx i))\<close> that
[PROOF STATE]
proof (prove)
using this:
enum_idx i < dim_vec (unit_vec CARD('a) (enum_idx i))
dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
j < dim_vec (vec_of_basis_enum (ket i))

goal (1 subgoal):
 1. unit_vec CARD('a) (enum_idx i) $ j = (if enum_idx i = j then 1::'b else (0::'b))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
unit_vec CARD('a) (enum_idx i) $ j = (if enum_idx i = j then 1::?'b3 else (0::?'b3))

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
unit_vec CARD('a) (enum_idx i) $ j = (if enum_idx i = j then 1::?'b3 else (0::?'b3))

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
have "vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
proof(cases "enum_idx i = j")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. enum_idx i = j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
 2. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
enum_idx i = j

goal (2 subgoals):
 1. enum_idx i = j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
 2. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
have "crepresentation (set (canonical_basis::'a ell2 list))
          ((canonical_basis::'a ell2 list) ! j) ((canonical_basis::'a ell2 list) ! j) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. crepresentation (set canonical_basis) (canonical_basis ! j) (canonical_basis ! j) = 1
[PROOF STEP]
using y1 y2 complex_vector.representation_basis[where
            basis = "set (canonical_basis::'a ell2 list)"
            and b = "(canonical_basis::'a ell2 list) ! j"]
[PROOF STATE]
proof (prove)
using this:
cindependent (set canonical_basis)
canonical_basis ! j \<in> set canonical_basis
\<lbrakk>cindependent (set canonical_basis); canonical_basis ! j \<in> set canonical_basis\<rbrakk> \<Longrightarrow> crepresentation (set canonical_basis) (canonical_basis ! j) = (\<lambda>v. if v = canonical_basis ! j then 1 else 0)

goal (1 subgoal):
 1. crepresentation (set canonical_basis) (canonical_basis ! j) (canonical_basis ! j) = 1
[PROOF STEP]
by smt
[PROOF STATE]
proof (state)
this:
crepresentation (set canonical_basis) (canonical_basis ! j) (canonical_basis ! j) = 1

goal (2 subgoals):
 1. enum_idx i = j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
 2. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
hence "vec_of_basis_enum ((canonical_basis::'a ell2 list) ! j) $ j = 1"
[PROOF STATE]
proof (prove)
using this:
crepresentation (set canonical_basis) (canonical_basis ! j) (canonical_basis ! j) = 1

goal (1 subgoal):
 1. vec_of_basis_enum (canonical_basis ! j) $ j = 1
[PROOF STEP]
unfolding vec_of_basis_enum_def
[PROOF STATE]
proof (prove)
using this:
crepresentation (set canonical_basis) (canonical_basis ! j) (canonical_basis ! j) = 1

goal (1 subgoal):
 1. vec_of_list (map (crepresentation (set canonical_basis) (canonical_basis ! j)) canonical_basis) $ j = 1
[PROOF STEP]
by (metis j_bound nth_map vec_of_list_index)
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (canonical_basis ! j) $ j = 1

goal (2 subgoals):
 1. enum_idx i = j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
 2. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
hence "vec_of_basis_enum ((canonical_basis::'a ell2 list) ! (enum_idx i))
            $ enum_idx i = 1"
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (canonical_basis ! j) $ j = 1

goal (1 subgoal):
 1. vec_of_basis_enum (canonical_basis ! enum_idx i) $ enum_idx i = 1
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (canonical_basis ! j) $ j = 1
enum_idx i = j

goal (1 subgoal):
 1. vec_of_basis_enum (canonical_basis ! enum_idx i) $ enum_idx i = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (canonical_basis ! enum_idx i) $ enum_idx i = 1

goal (2 subgoals):
 1. enum_idx i = j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
 2. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
hence "vec_of_basis_enum (ket i) $ enum_idx i = 1"
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (canonical_basis ! enum_idx i) $ enum_idx i = 1

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ enum_idx i = 1
[PROOF STEP]
using p4
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (canonical_basis ! enum_idx i) $ enum_idx i = 1
canonical_basis ! enum_idx i = ket i

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ enum_idx i = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (ket i) $ enum_idx i = 1

goal (2 subgoals):
 1. enum_idx i = j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
 2. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (ket i) $ enum_idx i = 1

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (ket i) $ enum_idx i = 1
enum_idx i = j

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
unfolding vec_of_basis_enum_def
[PROOF STATE]
proof (prove)
using this:
vec_of_list (map (crepresentation (set canonical_basis) (ket i)) canonical_basis) $ enum_idx i = 1
enum_idx i = j

goal (1 subgoal):
 1. vec_of_list (map (crepresentation (set canonical_basis) (ket i)) canonical_basis) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)

goal (1 subgoal):
 1. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
enum_idx i \<noteq> j

goal (1 subgoal):
 1. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
have "crepresentation (set (canonical_basis::'a ell2 list))
          ((canonical_basis::'a ell2 list) ! (enum_idx i)) ((canonical_basis::'a ell2 list) ! j) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. crepresentation (set canonical_basis) (canonical_basis ! enum_idx i) (canonical_basis ! j) = 0
[PROOF STEP]
using y1 y2 complex_vector.representation_basis[where
            basis = "set (canonical_basis::'a ell2 list)"
            and b = "(canonical_basis::'a ell2 list) ! j"]
[PROOF STATE]
proof (prove)
using this:
cindependent (set canonical_basis)
canonical_basis ! j \<in> set canonical_basis
\<lbrakk>cindependent (set canonical_basis); canonical_basis ! j \<in> set canonical_basis\<rbrakk> \<Longrightarrow> crepresentation (set canonical_basis) (canonical_basis ! j) = (\<lambda>v. if v = canonical_basis ! j then 1 else 0)

goal (1 subgoal):
 1. crepresentation (set canonical_basis) (canonical_basis ! enum_idx i) (canonical_basis ! j) = 0
[PROOF STEP]
by (metis (mono_tags, opaque_lifting) False enum_i_dim_vec basis_enum_of_vec_inverse
            basis_enum_of_vec_unit_vec canonical_basis_length_ell2 index_unit_vec(3) j_bound
            list_of_vec_index list_vec nth_map r1 vec_of_basis_enum_def)
[PROOF STATE]
proof (state)
this:
crepresentation (set canonical_basis) (canonical_basis ! enum_idx i) (canonical_basis ! j) = 0

goal (1 subgoal):
 1. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
hence "vec_of_basis_enum ((canonical_basis::'a ell2 list) ! (enum_idx i)) $ j = 0"
[PROOF STATE]
proof (prove)
using this:
crepresentation (set canonical_basis) (canonical_basis ! enum_idx i) (canonical_basis ! j) = 0

goal (1 subgoal):
 1. vec_of_basis_enum (canonical_basis ! enum_idx i) $ j = 0
[PROOF STEP]
unfolding vec_of_basis_enum_def
[PROOF STATE]
proof (prove)
using this:
crepresentation (set canonical_basis) (canonical_basis ! enum_idx i) (canonical_basis ! j) = 0

goal (1 subgoal):
 1. vec_of_list (map (crepresentation (set canonical_basis) (canonical_basis ! enum_idx i)) canonical_basis) $ j = 0
[PROOF STEP]
by (smt j_bound nth_map vec_of_list_index)
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (canonical_basis ! enum_idx i) $ j = 0

goal (1 subgoal):
 1. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
hence "vec_of_basis_enum ((canonical_basis::'a ell2 list) ! (enum_idx i)) $ j = 0"
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (canonical_basis ! enum_idx i) $ j = 0

goal (1 subgoal):
 1. vec_of_basis_enum (canonical_basis ! enum_idx i) $ j = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (canonical_basis ! enum_idx i) $ j = 0

goal (1 subgoal):
 1. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
hence "vec_of_basis_enum (ket i) $ j = 0"
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (canonical_basis ! enum_idx i) $ j = 0

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = 0
[PROOF STEP]
using p4
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (canonical_basis ! enum_idx i) $ j = 0
canonical_basis ! enum_idx i = ket i

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (ket i) $ j = 0

goal (1 subgoal):
 1. enum_idx i \<noteq> j \<Longrightarrow> vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (ket i) $ j = 0

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum (ket i) $ j = 0
enum_idx i \<noteq> j

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
unfolding vec_of_basis_enum_def
[PROOF STATE]
proof (prove)
using this:
vec_of_list (map (crepresentation (set canonical_basis) (ket i)) canonical_basis) $ j = 0
enum_idx i \<noteq> j

goal (1 subgoal):
 1. vec_of_list (map (crepresentation (set canonical_basis) (ket i)) canonical_basis) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
unit_vec CARD('a) (enum_idx i) $ j = (if enum_idx i = j then 1::?'b3 else (0::?'b3))
vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
unit_vec CARD('a) (enum_idx i) $ j = (if enum_idx i = j then 1::?'b3 else (0::?'b3))
vec_of_basis_enum (ket i) $ j = (if enum_idx i = j then 1 else 0)

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (ket i) $ j = unit_vec CARD('a) (enum_idx i) $ j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?j1 < dim_vec (vec_of_basis_enum (ket i)) \<Longrightarrow> vec_of_basis_enum (ket i) $ ?j1 = unit_vec CARD('a) (enum_idx i) $ ?j1

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) = unit_vec CARD('a) (enum_idx i)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
?j1 < dim_vec (vec_of_basis_enum (ket i)) \<Longrightarrow> vec_of_basis_enum (ket i) $ ?j1 = unit_vec CARD('a) (enum_idx i) $ ?j1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
?j1 < dim_vec (vec_of_basis_enum (ket i)) \<Longrightarrow> vec_of_basis_enum (ket i) $ ?j1 = unit_vec CARD('a) (enum_idx i) $ ?j1

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) = unit_vec CARD('a) (enum_idx i)
[PROOF STEP]
using Matrix.eq_vecI
[PROOF STATE]
proof (prove)
using this:
dim_vec (vec_of_basis_enum (ket i)) = dim_vec (unit_vec CARD('a) (enum_idx i))
?j1 < dim_vec (vec_of_basis_enum (ket i)) \<Longrightarrow> vec_of_basis_enum (ket i) $ ?j1 = unit_vec CARD('a) (enum_idx i) $ ?j1
\<lbrakk>\<And>i. i < dim_vec ?w \<Longrightarrow> ?v $ i = ?w $ i; dim_vec ?v = dim_vec ?w\<rbrakk> \<Longrightarrow> ?v = ?w

goal (1 subgoal):
 1. vec_of_basis_enum (ket i) = unit_vec CARD('a) (enum_idx i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (ket i) = unit_vec CARD('a) (enum_idx i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prob_Max_IID_geometric_greaterThan:
  assumes "p \<in> {0<..1}"
  shows "measure_pmf.prob (H\<^sub>N n) {i<..} =
         1 - (1 - q ^ (i + 1)) ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
have "UNIV - {..i} = {i<..}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV - {..i} = {i<..}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
UNIV - {..i} = {i<..}

goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
UNIV - {..i} = {i<..}
[PROOF STEP]
have "measure_pmf.prob (H\<^sub>N n) {i<..} = measure_pmf.prob (H\<^sub>N n) (space (measure_pmf (H\<^sub>N n)) - {..i})"
[PROOF STATE]
proof (prove)
using this:
UNIV - {..i} = {i<..}

goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = measure_pmf.prob (H\<^sub>N n) (space (measure_pmf (H\<^sub>N n)) - {..i})
[PROOF STEP]
by (auto)
[PROOF STATE]
proof (state)
this:
measure_pmf.prob (H\<^sub>N n) {i<..} = measure_pmf.prob (H\<^sub>N n) (space (measure_pmf (H\<^sub>N n)) - {..i})

goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.prob (H\<^sub>N n) {i<..} = measure_pmf.prob (H\<^sub>N n) (space (measure_pmf (H\<^sub>N n)) - {..i})

goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
have "\<dots> = 1 - (measure_pmf.prob (geometric_pmf p) {..i}) ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) (space (measure_pmf (H\<^sub>N n)) - {..i}) = 1 - measure_pmf.prob (geometric_pmf p) {..i} ^ n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
p \<in> {0<..1}

goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) (space (measure_pmf (H\<^sub>N n)) - {..i}) = 1 - measure_pmf.prob (geometric_pmf p) {..i} ^ n
[PROOF STEP]
by (subst measure_pmf.prob_compl) (auto simp add: prob_Max_IID_geometric_atMost)
[PROOF STATE]
proof (state)
this:
measure_pmf.prob (H\<^sub>N n) (space (measure_pmf (H\<^sub>N n)) - {..i}) = 1 - measure_pmf.prob (geometric_pmf p) {..i} ^ n

goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.prob (H\<^sub>N n) (space (measure_pmf (H\<^sub>N n)) - {..i}) = 1 - measure_pmf.prob (geometric_pmf p) {..i} ^ n

goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
have "\<dots> =   1 - (1 - q ^ (i + 1)) ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 - measure_pmf.prob (geometric_pmf p) {..i} ^ n = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
p \<in> {0<..1}

goal (1 subgoal):
 1. 1 - measure_pmf.prob (geometric_pmf p) {..i} ^ n = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
unfolding q_def
[PROOF STATE]
proof (prove)
using this:
p \<in> {0<..1}

goal (1 subgoal):
 1. 1 - measure_pmf.prob (geometric_pmf p) {..i} ^ n = 1 - (1 - (1 - p) ^ (i + 1)) ^ n
[PROOF STEP]
by (subst geometric_pmf_prob_atMost) auto
[PROOF STATE]
proof (state)
this:
1 - measure_pmf.prob (geometric_pmf p) {..i} ^ n = 1 - (1 - q ^ (i + 1)) ^ n

goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n

goal (1 subgoal):
 1. measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
measure_pmf.prob (H\<^sub>N n) {i<..} = 1 - (1 - q ^ (i + 1)) ^ n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finiteFreshVar: "finite A ==> freshVar A ~: A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> freshVar A \<notin> A
[PROOF STEP]
apply(simp add: freshVar_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> X (LEAST n. n \<notin> deX ` A) \<notin> A
[PROOF STEP]
apply(simp add: X_deX_connection)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> (LEAST n. n \<notin> deX ` A) \<notin> deX ` A
[PROOF STEP]
apply(rule_tac LeastI_ex)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> \<exists>x. x \<notin> deX ` A
[PROOF STEP]
apply(rule_tac x="(Suc (Max (deX ` A)))" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> Suc (Max (deX ` A)) \<notin> deX ` A
[PROOF STEP]
apply(rule natset_finite_max)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> finite (deX ` A)
[PROOF STEP]
by force


[STATEMENT]
lemma minimal_witness_ex:
  assumes k: "P (k::nat)"
  shows "\<exists> k0. k0 \<le> k \<and> P k0 \<and> (\<forall> k. k < k0 \<longrightarrow> \<not> (P k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
let ?K = "{ h. h \<le> k \<and> P h }"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
have finite_K: "finite ?K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {h. h \<le> k \<and> P h}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite {h. h \<le> k \<and> P h}

goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
have "k \<in> ?K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<in> {h. h \<le> k \<and> P h}
[PROOF STEP]
by (simp add: k)
[PROOF STATE]
proof (state)
this:
k \<in> {h. h \<le> k \<and> P h}

goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k \<in> {h. h \<le> k \<and> P h}
[PROOF STEP]
have nonempty_K: "?K \<noteq> {}"
[PROOF STATE]
proof (prove)
using this:
k \<in> {h. h \<le> k \<and> P h}

goal (1 subgoal):
 1. {h. h \<le> k \<and> P h} \<noteq> {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{h. h \<le> k \<and> P h} \<noteq> {}

goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
let ?k = "Min ?K"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
have witness: "?k \<le> k \<and> P ?k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Min {h. h \<le> k \<and> P h} \<le> k \<and> P (Min {h. h \<le> k \<and> P h})
[PROOF STEP]
by (metis (mono_tags, lifting) Min_in finite_K mem_Collect_eq nonempty_K)
[PROOF STATE]
proof (state)
this:
Min {h. h \<le> k \<and> P h} \<le> k \<and> P (Min {h. h \<le> k \<and> P h})

goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
have minimal: "\<forall> h. h < ?k \<longrightarrow> \<not> (P h)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>h<Min {h. h \<le> k \<and> P h}. \<not> P h
[PROOF STEP]
by (metis Min_le witness dual_order.strict_implies_order
        dual_order.trans finite_K leD mem_Collect_eq)
[PROOF STATE]
proof (state)
this:
\<forall>h<Min {h. h \<le> k \<and> P h}. \<not> P h

goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
from witness minimal
[PROOF STATE]
proof (chain)
picking this:
Min {h. h \<le> k \<and> P h} \<le> k \<and> P (Min {h. h \<le> k \<and> P h})
\<forall>h<Min {h. h \<le> k \<and> P h}. \<not> P h
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Min {h. h \<le> k \<and> P h} \<le> k \<and> P (Min {h. h \<le> k \<and> P h})
\<forall>h<Min {h. h \<le> k \<and> P h}. \<not> P h

goal (1 subgoal):
 1. \<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>k0\<le>k. P k0 \<and> (\<forall>k<k0. \<not> P k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Bseq_monoseq_convergent: "Bseq X \<Longrightarrow> monoseq X \<Longrightarrow> convergent X"
  for X :: "nat \<Rightarrow> real"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Bseq X; monoseq X\<rbrakk> \<Longrightarrow> convergent X
[PROOF STEP]
by (auto simp: monoseq_iff convergent_def intro: LIMSEQ_decseq_INF LIMSEQ_incseq_SUP
      dest: Bseq_bdd_above Bseq_bdd_below)


[STATEMENT]
lemma bind_refine[refine]:
  fixes R' :: "('a\<times>'b) set" and R::"('c\<times>'d) set"
  assumes R1: "M \<le> \<Down> R' M'"
  assumes R2: "\<And>x x'. \<lbrakk> (x,x')\<in>R' \<rbrakk>
    \<Longrightarrow> f x \<le> \<Down> R (f' x')"
  shows "bind M (\<lambda>x. f x) \<le> \<Down> R (bind M' (\<lambda>x'. f' x'))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M \<bind> f \<le> \<Down> R (M' \<bind> f')
[PROOF STEP]
apply (rule bind_refine')
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. M \<le> \<Down> ?R' M'
 2. \<And>x x'. \<lbrakk>(x, x') \<in> ?R'; inres M x; inres M' x'; nofail M; nofail M'\<rbrakk> \<Longrightarrow> f x \<le> \<Down> R (f' x')
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
M \<le> \<Down> R' M'
(?x, ?x') \<in> R' \<Longrightarrow> f ?x \<le> \<Down> R (f' ?x')

goal (2 subgoals):
 1. M \<le> \<Down> ?R' M'
 2. \<And>x x'. \<lbrakk>(x, x') \<in> ?R'; inres M x; inres M' x'; nofail M; nofail M'\<rbrakk> \<Longrightarrow> f x \<le> \<Down> R (f' x')
[PROOF STEP]
by auto


[STATEMENT]
lemma two_inequalities:"\<lbrakk>\<forall>(n::nat). x < n \<longrightarrow> P n; \<forall>(n::nat). y < n \<longrightarrow> Q n\<rbrakk>
 \<Longrightarrow>  \<forall>n. (max x y) < n \<longrightarrow> (P n) \<and> (Q n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>n>x. P n; \<forall>n>y. Q n\<rbrakk> \<Longrightarrow> \<forall>n>max x y. P n \<and> Q n
[PROOF STEP]
by auto


[STATEMENT]
theorem exists_prime [resolve]: "\<exists>p. prime p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>p. prime p
[PROOF STEP]
@proof
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>p. prime p
[PROOF STEP]
@have "prime 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>p. prime p
[PROOF STEP]
@qed


[STATEMENT]
lemma padic_simps:
"padic_zero p n = \<zero>\<^bsub>residue_ring (p^n)\<^esub>"
"padic_a_inv p f n \<equiv> \<ominus>\<^bsub>residue_ring (p^n)\<^esub> (f n)"
"(padic_mult p f g) n = (f n) \<otimes>\<^bsub>(residue_ring (p^n))\<^esub> (g n)"
"(padic_add p f g) n = (f n) \<oplus>\<^bsub>(residue_ring (p^n))\<^esub> (g n)"
"n>0 \<Longrightarrow>padic_one p n =  \<one>\<^bsub>residue_ring (p^n)\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (padic_zero p n = \<zero>\<^bsub>residue_ring (p ^ n)\<^esub> &&& padic_a_inv p f n \<equiv> \<ominus>\<^bsub>residue_ring (p ^ n)\<^esub> f n) &&& padic_mult p f g n = f n \<otimes>\<^bsub>residue_ring (p ^ n)\<^esub> g n &&& padic_add p f g n = f n \<oplus>\<^bsub>residue_ring (p ^ n)\<^esub> g n &&& (0 < n \<Longrightarrow> padic_one p n = \<one>\<^bsub>residue_ring (p ^ n)\<^esub>)
[PROOF STEP]
apply (simp add: padic_zero_simp)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. padic_a_inv p f n \<equiv> \<ominus>\<^bsub>residue_ring (p ^ n)\<^esub> f n
 2. padic_mult p f g n = f n \<otimes>\<^bsub>residue_ring (p ^ n)\<^esub> g n
 3. padic_add p f g n = f n \<oplus>\<^bsub>residue_ring (p ^ n)\<^esub> g n
 4. 0 < n \<Longrightarrow> padic_one p n = \<one>\<^bsub>residue_ring (p ^ n)\<^esub>
[PROOF STEP]
apply (simp add: padic_a_inv_simp)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. padic_mult p f g n = f n \<otimes>\<^bsub>residue_ring (p ^ n)\<^esub> g n
 2. padic_add p f g n = f n \<oplus>\<^bsub>residue_ring (p ^ n)\<^esub> g n
 3. 0 < n \<Longrightarrow> padic_one p n = \<one>\<^bsub>residue_ring (p ^ n)\<^esub>
[PROOF STEP]
apply (simp add: padic_mult_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. padic_add p f g n = f n \<oplus>\<^bsub>residue_ring (p ^ n)\<^esub> g n
 2. 0 < n \<Longrightarrow> padic_one p n = \<one>\<^bsub>residue_ring (p ^ n)\<^esub>
[PROOF STEP]
apply (simp add: padic_add_res)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n \<Longrightarrow> padic_one p n = \<one>\<^bsub>residue_ring (p ^ n)\<^esub>
[PROOF STEP]
using padic_one_simp
[PROOF STATE]
proof (prove)
using this:
0 < ?n \<Longrightarrow> padic_one ?p ?n = \<one>\<^bsub>residue_ring (?p ^ ?n)\<^esub>
0 < ?n \<Longrightarrow> padic_one ?p ?n = 1

goal (1 subgoal):
 1. 0 < n \<Longrightarrow> padic_one p n = \<one>\<^bsub>residue_ring (p ^ n)\<^esub>
[PROOF STEP]
by auto


[STATEMENT]
lemma pairs_sup_dist_inf:
  "(x,y) \<in> pairs \<Longrightarrow> (z,w) \<in> pairs \<Longrightarrow> (u,v) \<in> pairs \<Longrightarrow> pairs_sup (x,y) (pairs_inf (z,w) (u,v)) = pairs_inf (pairs_sup (x,y) (z,w)) (pairs_sup (x,y) (u,v))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(x, y) \<in> pairs; (z, w) \<in> pairs; (u, v) \<in> pairs\<rbrakk> \<Longrightarrow> pairs_sup (x, y) (pairs_inf (z, w) (u, v)) = pairs_inf (pairs_sup (x, y) (z, w)) (pairs_sup (x, y) (u, v))
[PROOF STEP]
using sup_inf_distrib1 inf_sup_distrib1
[PROOF STATE]
proof (prove)
using this:
?x \<squnion> ?y \<sqinter> ?z = (?x \<squnion> ?y) \<sqinter> (?x \<squnion> ?z)
?x \<sqinter> (?y \<squnion> ?z) = ?x \<sqinter> ?y \<squnion> ?x \<sqinter> ?z

goal (1 subgoal):
 1. \<lbrakk>(x, y) \<in> pairs; (z, w) \<in> pairs; (u, v) \<in> pairs\<rbrakk> \<Longrightarrow> pairs_sup (x, y) (pairs_inf (z, w) (u, v)) = pairs_inf (pairs_sup (x, y) (z, w)) (pairs_sup (x, y) (u, v))
[PROOF STEP]
by auto


[STATEMENT]
lemma bij_betw_linorders_on:
  assumes "finite A"
  shows   "bij_betw linorder_of_list (permutations_of_set A) (linorders_on A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw linorder_of_list (permutations_of_set A) (linorders_on A)
[PROOF STEP]
using bij_betw_linorder_of_list[of A] assms
[PROOF STATE]
proof (prove)
using this:
finite A \<Longrightarrow> bij_betw linorder_of_list (permutations_of_set A) {R. linorder_on A R}
finite A

goal (1 subgoal):
 1. bij_betw linorder_of_list (permutations_of_set A) (linorders_on A)
[PROOF STEP]
unfolding linorders_on_def
[PROOF STATE]
proof (prove)
using this:
finite A \<Longrightarrow> bij_betw linorder_of_list (permutations_of_set A) {R. linorder_on A R}
finite A

goal (1 subgoal):
 1. bij_betw linorder_of_list (permutations_of_set A) (Collect (linorder_on A))
[PROOF STEP]
by simp


[STATEMENT]
lemma mcont_case_prod_iff [simp]:
  "\<lbrakk> class.preorder orda (mk_less orda); lub_singleton luba;
     class.preorder ordb (mk_less ordb); lub_singleton lubb \<rbrakk>
  \<Longrightarrow> mcont (prod_lub luba lubb) (rel_prod orda ordb) lub leq (case_prod f) \<longleftrightarrow>
   (\<forall>x. mcont lubb ordb lub leq (\<lambda>y. f x y)) \<and> (\<forall>y. mcont luba orda lub leq (\<lambda>x. f x y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>class.preorder orda (mk_less orda); lub_singleton luba; class.preorder ordb (mk_less ordb); lub_singleton lubb\<rbrakk> \<Longrightarrow> mcont (prod_lub luba lubb) (rel_prod orda ordb) lub leq (\<lambda>(x, y). f x y) = ((\<forall>x. mcont lubb ordb lub leq (f x)) \<and> (\<forall>y. mcont luba orda lub leq (\<lambda>x. f x y)))
[PROOF STEP]
unfolding mcont_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>class.preorder orda (mk_less orda); lub_singleton luba; class.preorder ordb (mk_less ordb); lub_singleton lubb\<rbrakk> \<Longrightarrow> (monotone (rel_prod orda ordb) leq (\<lambda>(x, y). f x y) \<and> cont (prod_lub luba lubb) (rel_prod orda ordb) lub leq (\<lambda>(x, y). f x y)) = ((\<forall>x. monotone ordb leq (f x) \<and> cont lubb ordb lub leq (f x)) \<and> (\<forall>y. monotone orda leq (\<lambda>x. f x y) \<and> cont luba orda lub leq (\<lambda>x. f x y)))
[PROOF STEP]
by(auto simp add: cont_case_prod_iff)


[STATEMENT]
lemma sylvester_vec_poly:
  fixes p q :: "'a :: comm_semiring_0 poly"
  defines "m \<equiv> degree p"
      and "n \<equiv> degree q"
  assumes v: "v \<in> carrier_vec (m+n)"
  shows "poly_of_vec (transpose_mat (sylvester_mat p q) *\<^sub>v v) =
    poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q" (is "?l = ?r")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v) = poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q
[PROOF STEP]
proof (rule poly_eqI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) na = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) na
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) na = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) na
[PROOF STEP]
note mn[simp] = m_def[symmetric] n_def[symmetric]
[PROOF STATE]
proof (state)
this:
degree p \<equiv> m
degree q \<equiv> n

goal (1 subgoal):
 1. \<And>na. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) na = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) na
[PROOF STEP]
let ?Tv = "transpose_mat (sylvester_mat p q) *\<^sub>v v"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>na. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) na = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) na
[PROOF STEP]
have dim: "dim_vec (vec_first v n) = n" "dim_vec (vec_last v m) = m" "dim_vec ?Tv = n + m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (vec_first v n) = n &&& dim_vec (vec_last v m) = m &&& dim_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v) = n + m
[PROOF STEP]
using v
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec (m + n)

goal (1 subgoal):
 1. dim_vec (vec_first v n) = n &&& dim_vec (vec_last v m) = m &&& dim_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v) = n + m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_vec (vec_first v n) = n
dim_vec (vec_last v m) = m
dim_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v) = n + m

goal (1 subgoal):
 1. \<And>na. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) na = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) na
[PROOF STEP]
have if_distrib: "\<And> x y z. (if x then y else (0 :: 'a)) * z = (if x then y * z else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y z. (if x then y else (0::'a)) * z = (if x then y * z else (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if ?x then ?y else (0::'a)) * ?z = (if ?x then ?y * ?z else (0::'a))

goal (1 subgoal):
 1. \<And>na. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) na = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) na
[PROOF STEP]
show "coeff ?l i = coeff ?r i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
proof (cases "i < m+n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> i < m + n

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
hence i_mn: "i \<ge> m+n"
        and i_n: "\<And>x. x \<le> i \<and> x < n \<longleftrightarrow> x < n"
        and i_m: "\<And>x. x \<le> i \<and> x < m \<longleftrightarrow> x < m"
[PROOF STATE]
proof (prove)
using this:
\<not> i < m + n

goal (1 subgoal):
 1. m + n \<le> i &&& (\<And>x. (x \<le> i \<and> x < n) = (x < n)) &&& (\<And>x. (x \<le> i \<and> x < m) = (x < m))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
m + n \<le> i
(?x \<le> i \<and> ?x < n) = (?x < n)
(?x \<le> i \<and> ?x < m) = (?x < m)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
have "coeff ?r i =
            (\<Sum> x < n. vec_first v n $ (n - Suc x) * coeff p (i - x)) +
            (\<Sum> x < m. vec_last v m $ (m - Suc x) * coeff q (i - x))"
        (is "_ = sum ?f _ + sum ?g _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))
[PROOF STEP]
unfolding coeff_add coeff_mult Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<le>i. coeff (poly_of_vec (vec_first v n)) ia * coeff p (i - ia)) + (\<Sum>ia\<le>i. coeff (poly_of_vec (vec_last v m)) ia * coeff q (i - ia)) = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))
[PROOF STEP]
unfolding coeff_poly_of_vec dim if_distrib
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<le>i. if ia < n then vec_first v n $ (n - Suc ia) * coeff p (i - ia) else (0::'a)) + (\<Sum>ia\<le>i. if ia < m then vec_last v m $ (m - Suc ia) * coeff q (i - ia) else (0::'a)) = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))
[PROOF STEP]
unfolding atMost_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{x. x \<le> i}. if ia < n then vec_first v n $ (n - Suc ia) * coeff p (i - ia) else (0::'a)) + (\<Sum>ia\<in>{x. x \<le> i}. if ia < m then vec_last v m $ (m - Suc ia) * coeff q (i - ia) else (0::'a)) = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))
[PROOF STEP]
apply(subst sum.inter_filter[symmetric],simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{x \<in> {x. x \<le> i}. x < n}. vec_first v n $ (n - Suc ia) * coeff p (i - ia)) + (\<Sum>ia\<in>{x. x \<le> i}. if ia < m then vec_last v m $ (m - Suc ia) * coeff q (i - ia) else (0::'a)) = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))
[PROOF STEP]
apply(subst sum.inter_filter[symmetric],simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{x \<in> {x. x \<le> i}. x < n}. vec_first v n $ (n - Suc ia) * coeff p (i - ia)) + (\<Sum>ia\<in>{x \<in> {x. x \<le> i}. x < m}. vec_last v m $ (m - Suc ia) * coeff q (i - ia)) = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))
[PROOF STEP]
unfolding mem_Collect_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{x. x \<le> i \<and> x < n}. vec_first v n $ (n - Suc ia) * coeff p (i - ia)) + (\<Sum>ia\<in>{x. x \<le> i \<and> x < m}. vec_last v m $ (m - Suc ia) * coeff q (i - ia)) = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))
[PROOF STEP]
unfolding i_n i_m
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{x. x < n}. vec_first v n $ (n - Suc ia) * coeff p (i - ia)) + (\<Sum>ia\<in>{x. x < m}. vec_last v m $ (m - Suc ia) * coeff q (i - ia)) = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))
[PROOF STEP]
unfolding lessThan_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{x. x < n}. vec_first v n $ (n - Suc ia) * coeff p (i - ia)) + (\<Sum>ia\<in>{x. x < m}. vec_last v m $ (m - Suc ia) * coeff q (i - ia)) = (\<Sum>x | x < n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x | x < m. vec_last v m $ (m - Suc x) * coeff q (i - x))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) + (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x))

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
assume x: "x < n"
[PROOF STATE]
proof (state)
this:
x < n

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
have "coeff p (i-x) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff p (i - x) = (0::'a)
[PROOF STEP]
apply(rule coeff_eq_0)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree p < i - x
[PROOF STEP]
using i_mn x
[PROOF STATE]
proof (prove)
using this:
m + n \<le> i
x < n

goal (1 subgoal):
 1. degree p < i - x
[PROOF STEP]
unfolding m_def
[PROOF STATE]
proof (prove)
using this:
degree p + n \<le> i
x < n

goal (1 subgoal):
 1. degree p < i - x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeff p (i - x) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
hence "?f x = 0"
[PROOF STATE]
proof (prove)
using this:
coeff p (i - x) = (0::'a)

goal (1 subgoal):
 1. vec_first v n $ (n - Suc x) * coeff p (i - x) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_first v n $ (n - Suc x) * coeff p (i - x) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?x2 < n \<Longrightarrow> vec_first v n $ (n - Suc ?x2) * coeff p (i - ?x2) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
hence "sum ?f {..<n} = 0"
[PROOF STATE]
proof (prove)
using this:
?x2 < n \<Longrightarrow> vec_first v n $ (n - Suc ?x2) * coeff p (i - ?x2) = (0::'a)

goal (1 subgoal):
 1. (\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
(\<Sum>x<n. vec_first v n $ (n - Suc x) * coeff p (i - x)) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
assume x: "x < m"
[PROOF STATE]
proof (state)
this:
x < m

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
have "coeff q (i-x) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff q (i - x) = (0::'a)
[PROOF STEP]
apply(rule coeff_eq_0)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree q < i - x
[PROOF STEP]
using i_mn x
[PROOF STATE]
proof (prove)
using this:
m + n \<le> i
x < m

goal (1 subgoal):
 1. degree q < i - x
[PROOF STEP]
unfolding n_def
[PROOF STATE]
proof (prove)
using this:
m + degree q \<le> i
x < m

goal (1 subgoal):
 1. degree q < i - x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeff q (i - x) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
hence "?g x = 0"
[PROOF STATE]
proof (prove)
using this:
coeff q (i - x) = (0::'a)

goal (1 subgoal):
 1. vec_last v m $ (m - Suc x) * coeff q (i - x) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec_last v m $ (m - Suc x) * coeff q (i - x) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?x2 < m \<Longrightarrow> vec_last v m $ (m - Suc ?x2) * coeff q (i - ?x2) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
hence "sum ?g {..<m} = 0"
[PROOF STATE]
proof (prove)
using this:
?x2 < m \<Longrightarrow> vec_last v m $ (m - Suc ?x2) * coeff q (i - ?x2) = (0::'a)

goal (1 subgoal):
 1. (\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>x<m. vec_last v m $ (m - Suc x) * coeff q (i - x)) = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = (0::'a) + (0::'a)
[PROOF STEP]
have "coeff ?r i = 0"
[PROOF STATE]
proof (prove)
using this:
coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = (0::'a) + (0::'a)

goal (1 subgoal):
 1. coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = (0::'a)

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
\<not> i < m + n
[PROOF STEP]
have "0 = coeff ?l i"
[PROOF STATE]
proof (prove)
using this:
\<not> i < m + n

goal (1 subgoal):
 1. (0::'a) = coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i
[PROOF STEP]
unfolding coeff_poly_of_vec dim sum.distrib[symmetric]
[PROOF STATE]
proof (prove)
using this:
\<not> i < m + n

goal (1 subgoal):
 1. (0::'a) = (if i < n + m then ((sylvester_mat p q)\<^sup>T *\<^sub>v v) $ (n + m - Suc i) else (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(0::'a) = coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i

goal (2 subgoals):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
 2. \<not> i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i = coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i

goal (1 subgoal):
 1. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i

goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i < m + n

goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
hence "coeff ?l i = (transpose_mat (sylvester_mat p q) *\<^sub>v v) $ (n + m - Suc i)"
[PROOF STATE]
proof (prove)
using this:
i < m + n

goal (1 subgoal):
 1. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = ((sylvester_mat p q)\<^sup>T *\<^sub>v v) $ (n + m - Suc i)
[PROOF STEP]
unfolding coeff_poly_of_vec dim sum.distrib[symmetric]
[PROOF STATE]
proof (prove)
using this:
i < m + n

goal (1 subgoal):
 1. (if i < n + m then ((sylvester_mat p q)\<^sup>T *\<^sub>v v) $ (n + m - Suc i) else (0::'a)) = ((sylvester_mat p q)\<^sup>T *\<^sub>v v) $ (n + m - Suc i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = ((sylvester_mat p q)\<^sup>T *\<^sub>v v) $ (n + m - Suc i)

goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = ((sylvester_mat p q)\<^sup>T *\<^sub>v v) $ (n + m - Suc i)

goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
have "... = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((sylvester_mat p q)\<^sup>T *\<^sub>v v) $ (n + m - Suc i) = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply(subst index_mult_mat_vec)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. n + m - Suc i < dim_row (sylvester_mat p q)\<^sup>T
 2. row (sylvester_mat p q)\<^sup>T (n + m - Suc i) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
i < m + n

goal (2 subgoals):
 1. n + m - Suc i < dim_row (sylvester_mat p q)\<^sup>T
 2. row (sylvester_mat p q)\<^sup>T (n + m - Suc i) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (sylvester_mat p q)\<^sup>T (n + m - Suc i) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply(subst row_transpose)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. n + m - Suc i < dim_col (sylvester_mat p q)
 2. col (sylvester_mat p q) (n + m - Suc i) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
i < m + n

goal (2 subgoals):
 1. n + m - Suc i < dim_col (sylvester_mat p q)
 2. col (sylvester_mat p q) (n + m - Suc i) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (sylvester_mat p q) (n + m - Suc i) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply(subst col_sylvester)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. n + m - Suc i < degree p + degree q
 2. (vec_of_poly_rev_shifted p (degree q) (n + m - Suc i) @\<^sub>v vec_of_poly_rev_shifted q (degree p) (n + m - Suc i)) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
unfolding mn
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. n + m - Suc i < m + n
 2. (vec_of_poly_rev_shifted p n (n + m - Suc i) @\<^sub>v vec_of_poly_rev_shifted q m (n + m - Suc i)) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
i < m + n

goal (2 subgoals):
 1. n + m - Suc i < m + n
 2. (vec_of_poly_rev_shifted p n (n + m - Suc i) @\<^sub>v vec_of_poly_rev_shifted q m (n + m - Suc i)) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec_of_poly_rev_shifted p n (n + m - Suc i) @\<^sub>v vec_of_poly_rev_shifted q m (n + m - Suc i)) \<bullet> v = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply(subst vec_first_last_append[of v n m,symmetric])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. v \<in> carrier_vec (n + m)
 2. (vec_of_poly_rev_shifted p n (n + m - Suc i) @\<^sub>v vec_of_poly_rev_shifted q m (n + m - Suc i)) \<bullet> (vec_first v n @\<^sub>v vec_last v m) = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
using v
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec (m + n)

goal (2 subgoals):
 1. v \<in> carrier_vec (n + m)
 2. (vec_of_poly_rev_shifted p n (n + m - Suc i) @\<^sub>v vec_of_poly_rev_shifted q m (n + m - Suc i)) \<bullet> (vec_first v n @\<^sub>v vec_last v m) = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply(simp add: add.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec_of_poly_rev_shifted p n (n + m - Suc i) @\<^sub>v vec_of_poly_rev_shifted q m (n + m - Suc i)) \<bullet> (vec_first v n @\<^sub>v vec_last v m) = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply(subst scalar_prod_append)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. vec_of_poly_rev_shifted p n (n + m - Suc i) \<in> carrier_vec ?n1.55
 2. vec_of_poly_rev_shifted q m (n + m - Suc i) \<in> carrier_vec ?n2.55
 3. vec_first v n \<in> carrier_vec ?n1.55
 4. vec_last v m \<in> carrier_vec ?n2.55
 5. vec_of_poly_rev_shifted p n (n + m - Suc i) \<bullet> vec_first v n + vec_of_poly_rev_shifted q m (n + m - Suc i) \<bullet> vec_last v m = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply (rule carrier_vecI,simp)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_poly_rev_shifted p n (n + m - Suc i) \<bullet> vec_first v n + vec_of_poly_rev_shifted q m (n + m - Suc i) \<bullet> vec_last v m = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply (subst vec_of_poly_rev_shifted_scalar_prod,simp,simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. i < m + n
 2. coeff (p * poly_of_vec (vec_first v n)) i + vec_of_poly_rev_shifted q m (n + m - Suc i) \<bullet> vec_last v m = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
i < m + n

goal (2 subgoals):
 1. i < m + n
 2. coeff (p * poly_of_vec (vec_first v n)) i + vec_of_poly_rev_shifted q m (n + m - Suc i) \<bullet> vec_last v m = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * poly_of_vec (vec_first v n)) i + vec_of_poly_rev_shifted q m (n + m - Suc i) \<bullet> vec_last v m = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply (subst add.commute[of n m])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * poly_of_vec (vec_first v n)) i + vec_of_poly_rev_shifted q m (m + n - Suc i) \<bullet> vec_last v m = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply (subst vec_of_poly_rev_shifted_scalar_prod,simp,simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. i < n + m
 2. coeff (p * poly_of_vec (vec_first v n)) i + coeff (q * poly_of_vec (vec_last v m)) i = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
i < m + n

goal (2 subgoals):
 1. i < n + m
 2. coeff (p * poly_of_vec (vec_first v n)) i + coeff (q * poly_of_vec (vec_last v m)) i = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * poly_of_vec (vec_first v n)) i + coeff (q * poly_of_vec (vec_last v m)) i = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((sylvester_mat p q)\<^sup>T *\<^sub>v v) $ (n + m - Suc i) = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i

goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((sylvester_mat p q)\<^sup>T *\<^sub>v v) $ (n + m - Suc i) = coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i

goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
have "... =
        (\<Sum>x\<le>i. (if x < n then vec_first v n $ (n - Suc x) else 0) * coeff p (i - x)) +
        (\<Sum>x\<le>i. (if x < m then vec_last v m $ (m - Suc x) else 0) * coeff q (i - x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i = (\<Sum>x\<le>i. (if x < n then vec_first v n $ (n - Suc x) else (0::'a)) * coeff p (i - x)) + (\<Sum>x\<le>i. (if x < m then vec_last v m $ (m - Suc x) else (0::'a)) * coeff q (i - x))
[PROOF STEP]
unfolding coeff_poly_of_vec[of "vec_first v n",unfolded dim_vec_first,symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i = (\<Sum>x\<le>i. coeff (poly_of_vec (vec_first v n)) x * coeff p (i - x)) + (\<Sum>x\<le>i. (if x < m then vec_last v m $ (m - Suc x) else (0::'a)) * coeff q (i - x))
[PROOF STEP]
unfolding coeff_poly_of_vec[of "vec_last v m",unfolded dim_vec_last,symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i = (\<Sum>x\<le>i. coeff (poly_of_vec (vec_first v n)) x * coeff p (i - x)) + (\<Sum>x\<le>i. coeff (poly_of_vec (vec_last v m)) x * coeff q (i - x))
[PROOF STEP]
unfolding coeff_mult[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i = coeff (poly_of_vec (vec_first v n) * p) i + coeff (poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
by (simp add: mult.commute)
[PROOF STATE]
proof (state)
this:
coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i = (\<Sum>x\<le>i. (if x < n then vec_first v n $ (n - Suc x) else (0::'a)) * coeff p (i - x)) + (\<Sum>x\<le>i. (if x < m then vec_last v m $ (m - Suc x) else (0::'a)) * coeff q (i - x))

goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeff (p * poly_of_vec (vec_first v n) + q * poly_of_vec (vec_last v m)) i = (\<Sum>x\<le>i. (if x < n then vec_first v n $ (n - Suc x) else (0::'a)) * coeff p (i - x)) + (\<Sum>x\<le>i. (if x < m then vec_last v m $ (m - Suc x) else (0::'a)) * coeff q (i - x))

goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
have "... = coeff ?r i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<le>i. (if x < n then vec_first v n $ (n - Suc x) else (0::'a)) * coeff p (i - x)) + (\<Sum>x\<le>i. (if x < m then vec_last v m $ (m - Suc x) else (0::'a)) * coeff q (i - x)) = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
unfolding coeff_add coeff_mult Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<le>i. (if x < n then vec_first v n $ (n - Suc x) else (0::'a)) * coeff p (i - x)) + (\<Sum>x\<le>i. (if x < m then vec_last v m $ (m - Suc x) else (0::'a)) * coeff q (i - x)) = (\<Sum>ia\<le>i. coeff (poly_of_vec (vec_first v n)) ia * coeff p (i - ia)) + (\<Sum>ia\<le>i. coeff (poly_of_vec (vec_last v m)) ia * coeff q (i - ia))
[PROOF STEP]
unfolding coeff_poly_of_vec dim
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<le>i. (if x < n then vec_first v n $ (n - Suc x) else (0::'a)) * coeff p (i - x)) + (\<Sum>x\<le>i. (if x < m then vec_last v m $ (m - Suc x) else (0::'a)) * coeff q (i - x)) = (\<Sum>ia\<le>i. (if ia < n then vec_first v n $ (n - Suc ia) else (0::'a)) * coeff p (i - ia)) + (\<Sum>ia\<le>i. (if ia < m then vec_last v m $ (m - Suc ia) else (0::'a)) * coeff q (i - ia))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<le>i. (if x < n then vec_first v n $ (n - Suc x) else (0::'a)) * coeff p (i - x)) + (\<Sum>x\<le>i. (if x < m then vec_last v m $ (m - Suc x) else (0::'a)) * coeff q (i - x)) = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i

goal (1 subgoal):
 1. i < m + n \<Longrightarrow> coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i

goal (1 subgoal):
 1. coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coeff (poly_of_vec ((sylvester_mat p q)\<^sup>T *\<^sub>v v)) i = coeff (poly_of_vec (vec_first v n) * p + poly_of_vec (vec_last v m) * q) i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma test_comp_test_inf:
  "(x \<sqinter> 1) * y * (z \<sqinter> 1) = (x \<sqinter> 1) * y \<sqinter> y * (z \<sqinter> 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<sqinter> (1::'a)) * y * (z \<sqinter> (1::'a)) = (x \<sqinter> (1::'a)) * y \<sqinter> y * (z \<sqinter> (1::'a))
[PROOF STEP]
by (smt comp_right_one comp_right_subdist_inf coreflexive_comp_top_inf inf.left_commute inf.orderE inf_le2 mult_assoc)


[STATEMENT]
lemma n_Elem_NatInterval[rule_format]: "\<forall>q. q \<le> m \<longrightarrow> Elem (nat2Nat (n+q)) (NatInterval n m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>q\<le>m. Elem (nat2Nat (n + q)) (NatInterval n m)
[PROOF STEP]
apply (induct m)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<forall>q\<le>0. Elem (nat2Nat (n + q)) (NatInterval n 0)
 2. \<And>m. \<forall>q\<le>m. Elem (nat2Nat (n + q)) (NatInterval n m) \<Longrightarrow> \<forall>q\<le>Suc m. Elem (nat2Nat (n + q)) (NatInterval n (Suc m))
[PROOF STEP]
apply (auto simp add: Singleton union)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m q. \<lbrakk>\<forall>q\<le>m. Elem (nat2Nat (n + q)) (NatInterval n m); q \<le> Suc m; nat2Nat (n + q) \<noteq> SucNat (nat2Nat (n + m))\<rbrakk> \<Longrightarrow> Elem (nat2Nat (n + q)) (NatInterval n m)
[PROOF STEP]
apply (case_tac "q <= m")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>m q. \<lbrakk>\<forall>q\<le>m. Elem (nat2Nat (n + q)) (NatInterval n m); q \<le> Suc m; nat2Nat (n + q) \<noteq> SucNat (nat2Nat (n + m)); q \<le> m\<rbrakk> \<Longrightarrow> Elem (nat2Nat (n + q)) (NatInterval n m)
 2. \<And>m q. \<lbrakk>\<forall>q\<le>m. Elem (nat2Nat (n + q)) (NatInterval n m); q \<le> Suc m; nat2Nat (n + q) \<noteq> SucNat (nat2Nat (n + m)); \<not> q \<le> m\<rbrakk> \<Longrightarrow> Elem (nat2Nat (n + q)) (NatInterval n m)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m q. \<lbrakk>\<forall>q\<le>m. Elem (nat2Nat (n + q)) (NatInterval n m); q \<le> Suc m; nat2Nat (n + q) \<noteq> SucNat (nat2Nat (n + m)); \<not> q \<le> m\<rbrakk> \<Longrightarrow> Elem (nat2Nat (n + q)) (NatInterval n m)
[PROOF STEP]
apply (subgoal_tac "q = Suc m")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>m q. \<lbrakk>\<forall>q\<le>m. Elem (nat2Nat (n + q)) (NatInterval n m); q \<le> Suc m; nat2Nat (n + q) \<noteq> SucNat (nat2Nat (n + m)); \<not> q \<le> m; q = Suc m\<rbrakk> \<Longrightarrow> Elem (nat2Nat (n + q)) (NatInterval n m)
 2. \<And>m q. \<lbrakk>\<forall>q\<le>m. Elem (nat2Nat (n + q)) (NatInterval n m); q \<le> Suc m; nat2Nat (n + q) \<noteq> SucNat (nat2Nat (n + m)); \<not> q \<le> m\<rbrakk> \<Longrightarrow> q = Suc m
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma list_appendI:
  "\<lbrakk>a \<in> list x A; b \<in> list y A\<rbrakk> \<Longrightarrow> a @ b \<in> list (x+y) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> list x A; b \<in> list y A\<rbrakk> \<Longrightarrow> a @ b \<in> list (x + y) A
[PROOF STEP]
apply (unfold list_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> {xs. length xs = x \<and> set xs \<subseteq> A}; b \<in> {xs. length xs = y \<and> set xs \<subseteq> A}\<rbrakk> \<Longrightarrow> a @ b \<in> {xs. length xs = x + y \<and> set xs \<subseteq> A}
[PROOF STEP]
apply (simp (no_asm))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> {xs. length xs = x \<and> set xs \<subseteq> A}; b \<in> {xs. length xs = y \<and> set xs \<subseteq> A}\<rbrakk> \<Longrightarrow> length a + length b = x + y \<and> set a \<subseteq> A \<and> set b \<subseteq> A
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma multisetUnionLeMono1:
assumes
  "trans r"
  "multiset_le a1 a2 r"
shows
  "multiset_le (a1 + b) (a2 + b) r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. multiset_le (a1 + b) (a2 + b) r
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
trans r
multiset_le a1 a2 r

goal (1 subgoal):
 1. multiset_le (a1 + b) (a2 + b) r
[PROOF STEP]
unfolding multiset_le_def
[PROOF STATE]
proof (prove)
using this:
trans r
a1 = a2 \<or> (a1, a2) \<in> mult r

goal (1 subgoal):
 1. a1 + b = a2 + b \<or> (a1 + b, a2 + b) \<in> mult r
[PROOF STEP]
using multisetUnionLessMono1[of "r" "a1" "a2" "b"]
[PROOF STATE]
proof (prove)
using this:
trans r
a1 = a2 \<or> (a1, a2) \<in> mult r
\<lbrakk>trans r; (a1, a2) \<in> mult r\<rbrakk> \<Longrightarrow> (a1 + b, a2 + b) \<in> mult r

goal (1 subgoal):
 1. a1 + b = a2 + b \<or> (a1 + b, a2 + b) \<in> mult r
[PROOF STEP]
by auto


[STATEMENT]
lemma col_mat_of_cols[simp]:
  assumes j:"j < length vs" and n: "vs ! j \<in> carrier_vec n"
  shows "col (mat_of_cols n vs) j = vs ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (mat_of_cols n vs) j = vs ! j
[PROOF STEP]
unfolding mat_of_cols_def col_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec (dim_row (mat n (length vs) (\<lambda>(i, j). vs ! j $ i))) (\<lambda>i. mat n (length vs) (\<lambda>(i, j). vs ! j $ i) $$ (i, j)) = vs ! j
[PROOF STEP]
using j n
[PROOF STATE]
proof (prove)
using this:
j < length vs
vs ! j \<in> carrier_vec n

goal (1 subgoal):
 1. vec (dim_row (mat n (length vs) (\<lambda>(i, j). vs ! j $ i))) (\<lambda>i. mat n (length vs) (\<lambda>(i, j). vs ! j $ i) $$ (i, j)) = vs ! j
[PROOF STEP]
by auto


[STATEMENT]
lemma arcs_compl_un_eq_arcs:
  "r \<in> verts G \<Longrightarrow>
    {e2 \<in> arcs G. \<exists>e1\<in>arcs (dir_tree_r r). head G e2 = tail G e1 \<and> head G e1 = tail G e2}
      \<union> arcs (dir_tree_r r) = arcs G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r \<in> verts G \<Longrightarrow> {e2 \<in> arcs G. \<exists>e1\<in>arcs (dir_tree_r r). head G e2 = tail G e1 \<and> head G e1 = tail G e2} \<union> arcs (dir_tree_r r) = arcs G
[PROOF STEP]
using psp_tree.undir_arcs_compl_un_eq_arcs[OF psp_dir_tree_r undirected_tree_axioms]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?source \<in> verts G; Suc (card (verts G) - 1) = card (verts G)\<rbrakk> \<Longrightarrow> {e2 \<in> arcs G. \<exists>e1\<in>arcs (dir_tree_r ?source). head G e2 = tail G e1 \<and> head G e1 = tail G e2} \<union> arcs (dir_tree_r ?source) = arcs G

goal (1 subgoal):
 1. r \<in> verts G \<Longrightarrow> {e2 \<in> arcs G. \<exists>e1\<in>arcs (dir_tree_r r). head G e2 = tail G e1 \<and> head G e1 = tail G e2} \<union> arcs (dir_tree_r r) = arcs G
[PROOF STEP]
by blast


[STATEMENT]
lemma card1 :
  shows "(card{a, b} = Suc 0) = (a = b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (card {a, b} = Suc 0) = (a = b)
[PROOF STEP]
using singleton_insert_inj_eq'
[PROOF STATE]
proof (prove)
using this:
(insert ?a ?A = {?b}) = (?a = ?b \<and> ?A \<subseteq> {?b})

goal (1 subgoal):
 1. (card {a, b} = Suc 0) = (a = b)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma desargues_config_2D_rkRa_rkRb_rkRc :
  assumes "desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma>" and "rk {A, B, C, A', B', C', P, Q} \<ge> 4"
and "rk {P, Q, R} = 2" and "rk {Q, R} = 2" and "rk {Q, A', a} = 2" and "rk {Q, B', b} = 2" and
"rk {Q, C', c} = 2" and "rk {A', P} = 2" and "rk {B', P} = 2" and "rk {C', P} = 2"
  shows "rk {R, a} = 2" and "rk {R, b} = 2" and "rk {R, c} = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rk {R, a} = 2 &&& rk {R, b} = 2 &&& rk {R, c} = 2
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. rk {R, a} = 2
 2. rk {R, b} = 2
 3. rk {R, c} = 2
[PROOF STEP]
have f1:"rk {A, B, C, A', B', C', P} = 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rk {A, B, C, A', B', C', P} = 3
[PROOF STEP]
using coplanar_ABCA'B'C'P assms(1) desargues_config_2D_def[of A B C A' B' C' P \<alpha> \<beta> \<gamma>]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>rk {?A, ?A'} = 2; rk {?A, ?B, ?C, ?A', ?B', ?C'} = 3; rk {?A, ?A', ?P} = 2\<rbrakk> \<Longrightarrow> rk {?A, ?B, ?C, ?A', ?B', ?C', ?P} = 3
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma>
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma> \<equiv> rk {A, B, C} = 3 \<and> rk {A', B', C'} = 3 \<and> rk {A, A', P} = 2 \<and> rk {B, B', P} = 2 \<and> rk {C, C', P} = 2 \<and> rk {A, B, \<gamma>} = 2 \<and> rk {A', B', \<gamma>} = 2 \<and> rk {A, C, \<beta>} = 2 \<and> rk {A', C', \<beta>} = 2 \<and> rk {B, C, \<alpha>} = 2 \<and> rk {B', C', \<alpha>} = 2 \<and> rk {A, B, C, A', B', C'} = 3 \<and> rk {A, B, P} = 3 \<and> rk {A, C, P} = 3 \<and> rk {B, C, P} = 3 \<and> rk {A, A'} = 2 \<and> rk {B, B'} = 2 \<and> rk {C, C'} = 2

goal (1 subgoal):
 1. rk {A, B, C, A', B', C', P} = 3
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
rk {A, B, C, A', B', C', P} = 3

goal (3 subgoals):
 1. rk {R, a} = 2
 2. rk {R, b} = 2
 3. rk {R, c} = 2
[PROOF STEP]
have f2:"rk {A, B, A'} = 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rk {A, B, A'} = 3
[PROOF STEP]
using desargues_config_2D_non_collinear assms(1)
[PROOF STATE]
proof (prove)
using this:
desargues_config_2D ?A ?B ?C ?A' ?B' ?C' ?P ?\<alpha> ?\<beta> ?\<gamma> \<Longrightarrow> rk {?A, ?B, ?A'} = 3
desargues_config_2D ?A ?B ?C ?A' ?B' ?C' ?P ?\<alpha> ?\<beta> ?\<gamma> \<Longrightarrow> rk {?A, ?B, ?B'} = 3
desargues_config_2D ?A ?B ?C ?A' ?B' ?C' ?P ?\<alpha> ?\<beta> ?\<gamma> \<Longrightarrow> rk {?A, ?C, ?C'} = 3
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma>

goal (1 subgoal):
 1. rk {A, B, A'} = 3
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
rk {A, B, A'} = 3

goal (3 subgoals):
 1. rk {R, a} = 2
 2. rk {R, b} = 2
 3. rk {R, c} = 2
[PROOF STEP]
have f3:"rk {A, B, B'} = 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rk {A, B, B'} = 3
[PROOF STEP]
using desargues_config_2D_non_collinear assms(1)
[PROOF STATE]
proof (prove)
using this:
desargues_config_2D ?A ?B ?C ?A' ?B' ?C' ?P ?\<alpha> ?\<beta> ?\<gamma> \<Longrightarrow> rk {?A, ?B, ?A'} = 3
desargues_config_2D ?A ?B ?C ?A' ?B' ?C' ?P ?\<alpha> ?\<beta> ?\<gamma> \<Longrightarrow> rk {?A, ?B, ?B'} = 3
desargues_config_2D ?A ?B ?C ?A' ?B' ?C' ?P ?\<alpha> ?\<beta> ?\<gamma> \<Longrightarrow> rk {?A, ?C, ?C'} = 3
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma>

goal (1 subgoal):
 1. rk {A, B, B'} = 3
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
rk {A, B, B'} = 3

goal (3 subgoals):
 1. rk {R, a} = 2
 2. rk {R, b} = 2
 3. rk {R, c} = 2
[PROOF STEP]
have f4:"rk {A, C, C'} = 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rk {A, C, C'} = 3
[PROOF STEP]
using desargues_config_2D_non_collinear assms(1)
[PROOF STATE]
proof (prove)
using this:
desargues_config_2D ?A ?B ?C ?A' ?B' ?C' ?P ?\<alpha> ?\<beta> ?\<gamma> \<Longrightarrow> rk {?A, ?B, ?A'} = 3
desargues_config_2D ?A ?B ?C ?A' ?B' ?C' ?P ?\<alpha> ?\<beta> ?\<gamma> \<Longrightarrow> rk {?A, ?B, ?B'} = 3
desargues_config_2D ?A ?B ?C ?A' ?B' ?C' ?P ?\<alpha> ?\<beta> ?\<gamma> \<Longrightarrow> rk {?A, ?C, ?C'} = 3
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma>

goal (1 subgoal):
 1. rk {A, C, C'} = 3
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
rk {A, C, C'} = 3

goal (3 subgoals):
 1. rk {R, a} = 2
 2. rk {R, b} = 2
 3. rk {R, c} = 2
[PROOF STEP]
show "rk {R, a} = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rk {R, a} = 2
[PROOF STEP]
using f1 f2 rk_Ra[of Q A' a P R A B C B' C'] assms(1) desargues_config_2D_def[of A B C A' B' C' P \<alpha> \<beta> \<gamma>]
      assms(2) assms(3) assms(4) assms(5) assms(8)
[PROOF STATE]
proof (prove)
using this:
rk {A, B, C, A', B', C', P} = 3
rk {A, B, A'} = 3
\<lbrakk>rk {Q, A', a} = 2; rk {P, Q, R} = 2; rk {R, Q} = 2; rk {A, A', P} = 2; rk {A', P} = 2; rk {A, B, C, A', B', C', P} = 3; rk {A, B, A'} = 3; 4 \<le> rk {A, B, C, A', B', C', P, Q}\<rbrakk> \<Longrightarrow> rk {R, a} = 2
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma>
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma> \<equiv> rk {A, B, C} = 3 \<and> rk {A', B', C'} = 3 \<and> rk {A, A', P} = 2 \<and> rk {B, B', P} = 2 \<and> rk {C, C', P} = 2 \<and> rk {A, B, \<gamma>} = 2 \<and> rk {A', B', \<gamma>} = 2 \<and> rk {A, C, \<beta>} = 2 \<and> rk {A', C', \<beta>} = 2 \<and> rk {B, C, \<alpha>} = 2 \<and> rk {B', C', \<alpha>} = 2 \<and> rk {A, B, C, A', B', C'} = 3 \<and> rk {A, B, P} = 3 \<and> rk {A, C, P} = 3 \<and> rk {B, C, P} = 3 \<and> rk {A, A'} = 2 \<and> rk {B, B'} = 2 \<and> rk {C, C'} = 2
4 \<le> rk {A, B, C, A', B', C', P, Q}
rk {P, Q, R} = 2
rk {Q, R} = 2
rk {Q, A', a} = 2
rk {A', P} = 2

goal (1 subgoal):
 1. rk {R, a} = 2
[PROOF STEP]
by (metis insert_commute)
[PROOF STATE]
proof (state)
this:
rk {R, a} = 2

goal (2 subgoals):
 1. rk {R, b} = 2
 2. rk {R, c} = 2
[PROOF STEP]
show "rk {R, b} = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rk {R, b} = 2
[PROOF STEP]
using f1 f3 rk_Ra[of Q B' b P R B A C A' C'] assms(1) desargues_config_2D_def[of A B C A' B' C' P \<alpha> \<beta> \<gamma>]
      assms(2) assms(3) assms(4) assms(6) assms(9)
[PROOF STATE]
proof (prove)
using this:
rk {A, B, C, A', B', C', P} = 3
rk {A, B, B'} = 3
\<lbrakk>rk {Q, B', b} = 2; rk {P, Q, R} = 2; rk {R, Q} = 2; rk {B, B', P} = 2; rk {B', P} = 2; rk {B, A, C, B', A', C', P} = 3; rk {B, A, B'} = 3; 4 \<le> rk {B, A, C, B', A', C', P, Q}\<rbrakk> \<Longrightarrow> rk {R, b} = 2
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma>
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma> \<equiv> rk {A, B, C} = 3 \<and> rk {A', B', C'} = 3 \<and> rk {A, A', P} = 2 \<and> rk {B, B', P} = 2 \<and> rk {C, C', P} = 2 \<and> rk {A, B, \<gamma>} = 2 \<and> rk {A', B', \<gamma>} = 2 \<and> rk {A, C, \<beta>} = 2 \<and> rk {A', C', \<beta>} = 2 \<and> rk {B, C, \<alpha>} = 2 \<and> rk {B', C', \<alpha>} = 2 \<and> rk {A, B, C, A', B', C'} = 3 \<and> rk {A, B, P} = 3 \<and> rk {A, C, P} = 3 \<and> rk {B, C, P} = 3 \<and> rk {A, A'} = 2 \<and> rk {B, B'} = 2 \<and> rk {C, C'} = 2
4 \<le> rk {A, B, C, A', B', C', P, Q}
rk {P, Q, R} = 2
rk {Q, R} = 2
rk {Q, B', b} = 2
rk {B', P} = 2

goal (1 subgoal):
 1. rk {R, b} = 2
[PROOF STEP]
by (metis insert_commute)
[PROOF STATE]
proof (state)
this:
rk {R, b} = 2

goal (1 subgoal):
 1. rk {R, c} = 2
[PROOF STEP]
show "rk {R, c} = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rk {R, c} = 2
[PROOF STEP]
using f1 f4 rk_Ra[of Q C' c P R C A B A' B'] assms(1) desargues_config_2D_def[of A B C A' B' C' P \<alpha> \<beta> \<gamma>]
      assms(2) assms(3) assms(4) assms(7) assms(10)
[PROOF STATE]
proof (prove)
using this:
rk {A, B, C, A', B', C', P} = 3
rk {A, C, C'} = 3
\<lbrakk>rk {Q, C', c} = 2; rk {P, Q, R} = 2; rk {R, Q} = 2; rk {C, C', P} = 2; rk {C', P} = 2; rk {C, A, B, C', A', B', P} = 3; rk {C, A, C'} = 3; 4 \<le> rk {C, A, B, C', A', B', P, Q}\<rbrakk> \<Longrightarrow> rk {R, c} = 2
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma>
desargues_config_2D A B C A' B' C' P \<alpha> \<beta> \<gamma> \<equiv> rk {A, B, C} = 3 \<and> rk {A', B', C'} = 3 \<and> rk {A, A', P} = 2 \<and> rk {B, B', P} = 2 \<and> rk {C, C', P} = 2 \<and> rk {A, B, \<gamma>} = 2 \<and> rk {A', B', \<gamma>} = 2 \<and> rk {A, C, \<beta>} = 2 \<and> rk {A', C', \<beta>} = 2 \<and> rk {B, C, \<alpha>} = 2 \<and> rk {B', C', \<alpha>} = 2 \<and> rk {A, B, C, A', B', C'} = 3 \<and> rk {A, B, P} = 3 \<and> rk {A, C, P} = 3 \<and> rk {B, C, P} = 3 \<and> rk {A, A'} = 2 \<and> rk {B, B'} = 2 \<and> rk {C, C'} = 2
4 \<le> rk {A, B, C, A', B', C', P, Q}
rk {P, Q, R} = 2
rk {Q, R} = 2
rk {Q, C', c} = 2
rk {C', P} = 2

goal (1 subgoal):
 1. rk {R, c} = 2
[PROOF STEP]
by (metis insert_commute)
[PROOF STATE]
proof (state)
this:
rk {R, c} = 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma awp_Int_eq: "awp F (A\<inter>B) = awp F A \<inter> awp F B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. awp F (A \<inter> B) = awp F A \<inter> awp F B
[PROOF STEP]
by (simp add: awp_def wp_def, blast)


[STATEMENT]
lemma exists_x_in_M1: "\<exists>x. x \<in> M1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x. x \<in> M1
[PROOF STEP]
using prime_p [THEN prime_gt_Suc_0_nat] card_M1
[PROOF STATE]
proof (prove)
using this:
Suc 0 < p
card M1 = p ^ a

goal (1 subgoal):
 1. \<exists>x. x \<in> M1
[PROOF STEP]
by (metis Suc_lessD card_eq_0_iff empty_subsetI equalityI gr_implies_not0 nat_zero_less_power_iff subsetI)


[STATEMENT]
theorem UP_universal_property:
  assumes S: "s \<in> carrier S"
  shows "\<exists>!Phi. Phi \<in> ring_hom P S \<inter> extensional (carrier P) \<and>
    Phi (monom P \<one> 1) = s \<and>
    (\<forall>r \<in> carrier R. Phi (monom P r 0) = h r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>!Phi. Phi \<in> ring_hom P S \<inter> extensional (carrier P) \<and> Phi (monom P \<one> 1) = s \<and> (\<forall>r\<in>carrier R. Phi (monom P r 0) = h r)
[PROOF STEP]
using S eval_monom1
[PROOF STATE]
proof (prove)
using this:
s \<in> carrier S
?s \<in> carrier S \<Longrightarrow> eval R S h ?s (monom P \<one> 1) = ?s

goal (1 subgoal):
 1. \<exists>!Phi. Phi \<in> ring_hom P S \<inter> extensional (carrier P) \<and> Phi (monom P \<one> 1) = s \<and> (\<forall>r\<in>carrier R. Phi (monom P r 0) = h r)
[PROOF STEP]
apply (auto intro: eval_ring_hom eval_const eval_extensional)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>Phi y. \<lbrakk>Phi (monom P \<one> (Suc 0)) \<in> carrier S; \<And>s. s \<in> carrier S \<Longrightarrow> eval R S h s (monom P \<one> (Suc 0)) = s; Phi \<in> ring_hom P S; y \<in> ring_hom P S; Phi \<in> extensional (carrier P); y \<in> extensional (carrier P); \<forall>r\<in>carrier R. Phi (monom P r 0) = h r; s = Phi (monom P \<one> (Suc 0)); y (monom P \<one> (Suc 0)) = Phi (monom P \<one> (Suc 0)); \<forall>r\<in>carrier R. y (monom P r 0) = h r\<rbrakk> \<Longrightarrow> Phi = y
[PROOF STEP]
apply (rule extensionalityI)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>Phi y. \<lbrakk>Phi (monom P \<one> (Suc 0)) \<in> carrier S; \<And>s. s \<in> carrier S \<Longrightarrow> eval R S h s (monom P \<one> (Suc 0)) = s; Phi \<in> ring_hom P S; y \<in> ring_hom P S; Phi \<in> extensional (carrier P); y \<in> extensional (carrier P); \<forall>r\<in>carrier R. Phi (monom P r 0) = h r; s = Phi (monom P \<one> (Suc 0)); y (monom P \<one> (Suc 0)) = Phi (monom P \<one> (Suc 0)); \<forall>r\<in>carrier R. y (monom P r 0) = h r\<rbrakk> \<Longrightarrow> Phi \<in> extensional (?A39 Phi y)
 2. \<And>Phi y. \<lbrakk>Phi (monom P \<one> (Suc 0)) \<in> carrier S; \<And>s. s \<in> carrier S \<Longrightarrow> eval R S h s (monom P \<one> (Suc 0)) = s; Phi \<in> ring_hom P S; y \<in> ring_hom P S; Phi \<in> extensional (carrier P); y \<in> extensional (carrier P); \<forall>r\<in>carrier R. Phi (monom P r 0) = h r; s = Phi (monom P \<one> (Suc 0)); y (monom P \<one> (Suc 0)) = Phi (monom P \<one> (Suc 0)); \<forall>r\<in>carrier R. y (monom P r 0) = h r\<rbrakk> \<Longrightarrow> y \<in> extensional (?A39 Phi y)
 3. \<And>Phi y x. \<lbrakk>Phi (monom P \<one> (Suc 0)) \<in> carrier S; \<And>s. s \<in> carrier S \<Longrightarrow> eval R S h s (monom P \<one> (Suc 0)) = s; Phi \<in> ring_hom P S; y \<in> ring_hom P S; Phi \<in> extensional (carrier P); y \<in> extensional (carrier P); \<forall>r\<in>carrier R. Phi (monom P r 0) = h r; s = Phi (monom P \<one> (Suc 0)); y (monom P \<one> (Suc 0)) = Phi (monom P \<one> (Suc 0)); \<forall>r\<in>carrier R. y (monom P r 0) = h r; x \<in> ?A39 Phi y\<rbrakk> \<Longrightarrow> Phi x = y x
[PROOF STEP]
apply (auto intro: UP_hom_unique ring_homD)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma deg_pp_plus: "deg_pp (s + t) = deg_pp s + deg_pp (t::('a, 'b::comm_monoid_add) pp)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. deg_pp (s + t) = deg_pp s + deg_pp t
[PROOF STEP]
by (transfer, fact deg_pm_plus)