[STATEMENT]
lemma mod_poly_irreducible_altdef:
  "mod_poly_irreducible CARD('n :: nontriv) p \<longleftrightarrow>
    irreducible (of_int_poly p :: 'n mod_ring poly)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_poly_irreducible CARD('n) p = irreducible (of_int_poly p)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. mod_poly_irreducible CARD('n) p \<Longrightarrow> irreducible (of_int_poly p)
 2. irreducible (of_int_poly p) \<Longrightarrow> mod_poly_irreducible CARD('n) p
[PROOF STEP]
assume "irreducible (of_int_poly p :: 'n mod_ring poly)"
[PROOF STATE]
proof (state)
this:
irreducible (of_int_poly p)

goal (2 subgoals):
 1. mod_poly_irreducible CARD('n) p \<Longrightarrow> irreducible (of_int_poly p)
 2. irreducible (of_int_poly p) \<Longrightarrow> mod_poly_irreducible CARD('n) p
[PROOF STEP]
thus "mod_poly_irreducible CARD('n) p"
[PROOF STATE]
proof (prove)
using this:
irreducible (of_int_poly p)

goal (1 subgoal):
 1. mod_poly_irreducible CARD('n) p
[PROOF STEP]
by (auto simp: mod_poly_irreducible_def mod_poly_rel_altdef
    mod_poly_is_unit_altdef irreducible_def of_int_poly_hom.hom_mult)
[PROOF STATE]
proof (state)
this:
mod_poly_irreducible CARD('n) p

goal (1 subgoal):
 1. mod_poly_irreducible CARD('n) p \<Longrightarrow> irreducible (of_int_poly p)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mod_poly_irreducible CARD('n) p \<Longrightarrow> irreducible (of_int_poly p)
[PROOF STEP]
assume *: "mod_poly_irreducible CARD('n) p"
[PROOF STATE]
proof (state)
this:
mod_poly_irreducible CARD('n) p

goal (1 subgoal):
 1. mod_poly_irreducible CARD('n) p \<Longrightarrow> irreducible (of_int_poly p)
[PROOF STEP]
show "irreducible (of_int_poly p :: 'n mod_ring poly)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. irreducible (of_int_poly p)
[PROOF STEP]
unfolding irreducible_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_int_poly p \<noteq> 0 \<and> \<not> of_int_poly p dvd 1 \<and> (\<forall>a b. of_int_poly p = a * b \<longrightarrow> a dvd 1 \<or> b dvd 1)
[PROOF STEP]
proof (intro conjI impI allI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
fix a b
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
assume ab: "(of_int_poly p :: 'n mod_ring poly) = a * b"
[PROOF STATE]
proof (state)
this:
of_int_poly p = a * b

goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
have "of_int_poly (map_poly to_int_mod_ring a *
      map_poly to_int_mod_ring b) =
      of_int_poly (map_poly to_int_mod_ring a) *
      (of_int_poly (map_poly to_int_mod_ring b) :: 'n mod_ring poly)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_int_poly (to_int_poly a * to_int_poly b) = of_int_poly (to_int_poly a) * of_int_poly (to_int_poly b)
[PROOF STEP]
by (simp add: of_int_poly_hom.hom_mult)
[PROOF STATE]
proof (state)
this:
of_int_poly (to_int_poly a * to_int_poly b) = of_int_poly (to_int_poly a) * of_int_poly (to_int_poly b)

goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
of_int_poly (to_int_poly a * to_int_poly b) = of_int_poly (to_int_poly a) * of_int_poly (to_int_poly b)

goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
have "\<dots> = a * b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_int_poly (to_int_poly a) * of_int_poly (to_int_poly b) = a * b
[PROOF STEP]
by (simp add: of_int_poly_to_int_poly)
[PROOF STATE]
proof (state)
this:
of_int_poly (to_int_poly a) * of_int_poly (to_int_poly b) = a * b

goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
of_int_poly (to_int_poly a) * of_int_poly (to_int_poly b) = a * b

goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
have "\<dots> = of_int_poly p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * b = of_int_poly p
[PROOF STEP]
using ab
[PROOF STATE]
proof (prove)
using this:
of_int_poly p = a * b

goal (1 subgoal):
 1. a * b = of_int_poly p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a * b = of_int_poly p

goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
of_int_poly (to_int_poly a * to_int_poly b) = of_int_poly p
[PROOF STEP]
have "(of_int_poly p :: 'n mod_ring poly) =
      of_int_poly (to_int_poly a * to_int_poly b)"
[PROOF STATE]
proof (prove)
using this:
of_int_poly (to_int_poly a * to_int_poly b) = of_int_poly p

goal (1 subgoal):
 1. of_int_poly p = of_int_poly (to_int_poly a * to_int_poly b)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
of_int_poly p = of_int_poly (to_int_poly a * to_int_poly b)

goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
hence "of_int_poly (to_int_poly a) dvd (1 :: 'n mod_ring poly) \<or>
           of_int_poly (to_int_poly b) dvd (1 :: 'n mod_ring poly)"
[PROOF STATE]
proof (prove)
using this:
of_int_poly p = of_int_poly (to_int_poly a * to_int_poly b)

goal (1 subgoal):
 1. of_int_poly (to_int_poly a) dvd 1 \<or> of_int_poly (to_int_poly b) dvd 1
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
of_int_poly p = of_int_poly (to_int_poly a * to_int_poly b)
mod_poly_irreducible CARD('n) p

goal (1 subgoal):
 1. of_int_poly (to_int_poly a) dvd 1 \<or> of_int_poly (to_int_poly b) dvd 1
[PROOF STEP]
unfolding mod_poly_irreducible_def mod_poly_rel_altdef
        mod_poly_is_unit_altdef
[PROOF STATE]
proof (prove)
using this:
of_int_poly p = of_int_poly (to_int_poly a * to_int_poly b)
of_int_poly p \<noteq> of_int_poly 0 \<and> \<not> of_int_poly p dvd 1 \<and> (\<forall>a b. of_int_poly p = of_int_poly (a * b) \<longrightarrow> of_int_poly a dvd 1 \<or> of_int_poly b dvd 1)

goal (1 subgoal):
 1. of_int_poly (to_int_poly a) dvd 1 \<or> of_int_poly (to_int_poly b) dvd 1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
of_int_poly (to_int_poly a) dvd 1 \<or> of_int_poly (to_int_poly b) dvd 1

goal (3 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
 3. \<And>a b. of_int_poly p = a * b \<Longrightarrow> a dvd 1 \<or> b dvd 1
[PROOF STEP]
thus "(a dvd (1 :: 'n mod_ring poly)) \<or>
      (b dvd (1 :: 'n mod_ring poly))"
[PROOF STATE]
proof (prove)
using this:
of_int_poly (to_int_poly a) dvd 1 \<or> of_int_poly (to_int_poly b) dvd 1

goal (1 subgoal):
 1. a dvd 1 \<or> b dvd 1
[PROOF STEP]
by (simp add: of_int_poly_to_int_poly)
[PROOF STATE]
proof (state)
this:
a dvd 1 \<or> b dvd 1

goal (2 subgoals):
 1. of_int_poly p \<noteq> 0
 2. \<not> of_int_poly p dvd 1
[PROOF STEP]
qed (use * in \<open>auto simp: mod_poly_irreducible_def
    mod_poly_rel_altdef mod_poly_is_unit_altdef\<close>)
[PROOF STATE]
proof (state)
this:
irreducible (of_int_poly p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma row_echelon_form_zero_rows:
  assumes row_ech: "row_echelon_form A"
  assumes dim_asm: "dim_col A \<ge> dim_row A"
  shows "take_rows A [0..<length (pivot_positions A)] @\<^sub>r  0\<^sub>m (dim_row A - length (pivot_positions A))  (dim_col A) = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
have ex_pivot_fun: "\<exists> f. pivot_fun A f (dim_col A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A)
[PROOF STEP]
using row_ech
[PROOF STATE]
proof (prove)
using this:
row_echelon_form A

goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A)
[PROOF STEP]
unfolding row_echelon_form_def
[PROOF STATE]
proof (prove)
using this:
\<exists>f. pivot_fun A f (dim_col A)

goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>f. pivot_fun A f (dim_col A)

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
have len_help: "length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}
[PROOF STEP]
using ex_pivot_fun pivot_positions[where A = "A",where nr = "dim_row A", where nc = "dim_col A"]
[PROOF STATE]
proof (prove)
using this:
\<exists>f. pivot_fun A f (dim_col A)
\<lbrakk>A \<in> carrier_mat (dim_row A) (dim_col A); pivot_fun A ?f (dim_col A)\<rbrakk> \<Longrightarrow> set (pivot_positions A) = {(i, ?f i) |i. i < dim_row A \<and> ?f i \<noteq> dim_col A}
\<lbrakk>A \<in> carrier_mat (dim_row A) (dim_col A); pivot_fun A ?f (dim_col A)\<rbrakk> \<Longrightarrow> distinct (map fst (pivot_positions A))
\<lbrakk>A \<in> carrier_mat (dim_row A) (dim_col A); pivot_fun A ?f (dim_col A)\<rbrakk> \<Longrightarrow> distinct (map snd (pivot_positions A))
\<lbrakk>A \<in> carrier_mat (dim_row A) (dim_col A); pivot_fun A ?f (dim_col A)\<rbrakk> \<Longrightarrow> length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}

goal (1 subgoal):
 1. length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}
[PROOF STEP]
have len_help2: "length (pivot_positions A) \<le> dim_row A"
[PROOF STATE]
proof (prove)
using this:
length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}

goal (1 subgoal):
 1. length (pivot_positions A) \<le> dim_row A
[PROOF STEP]
by (metis (no_types, lifting) card_mono cardlt finite_Collect_less_nat le_trans mem_Collect_eq subsetI)
[PROOF STATE]
proof (state)
this:
length (pivot_positions A) \<le> dim_row A

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
have fileq: "filter (\<lambda>y. y < dim_row A) [0..< length (pivot_positions A)] = [0..<length (pivot_positions A)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter (\<lambda>y. y < dim_row A) [0..<length (pivot_positions A)] = [0..<length (pivot_positions A)]
[PROOF STEP]
apply (rule filter_True)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>set [0..<length (pivot_positions A)]. x < dim_row A
[PROOF STEP]
using len_help2
[PROOF STATE]
proof (prove)
using this:
length (pivot_positions A) \<le> dim_row A

goal (1 subgoal):
 1. \<forall>x\<in>set [0..<length (pivot_positions A)]. x < dim_row A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
filter (\<lambda>y. y < dim_row A) [0..<length (pivot_positions A)] = [0..<length (pivot_positions A)]

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
have "\<forall>n. card {i. i < n  \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
[PROOF STEP]
proof clarsimp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
[PROOF STEP]
have h: "\<forall>x. x \<in> {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<longrightarrow> x\<in>{..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. x \<in> {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<longrightarrow> x \<in> {..<n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>x. x \<in> {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<longrightarrow> x \<in> {..<n}

goal (1 subgoal):
 1. \<And>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x. x \<in> {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<longrightarrow> x \<in> {..<n}
[PROOF STEP]
have h1: "{i. i < n  \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<subseteq> {..<n}"
[PROOF STATE]
proof (prove)
using this:
\<forall>x. x \<in> {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<longrightarrow> x \<in> {..<n}

goal (1 subgoal):
 1. {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<subseteq> {..<n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<subseteq> {..<n}

goal (1 subgoal):
 1. \<And>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<subseteq> {..<n}
[PROOF STEP]
have h2: "(card {i. i < n  \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}::nat) \<le> (card {..<n}::nat)"
[PROOF STATE]
proof (prove)
using this:
{i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<subseteq> {..<n}

goal (1 subgoal):
 1. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> card {..<n}
[PROOF STEP]
using card_mono
[PROOF STATE]
proof (prove)
using this:
{i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<subseteq> {..<n}
\<lbrakk>finite ?B; ?A \<subseteq> ?B\<rbrakk> \<Longrightarrow> card ?A \<le> card ?B

goal (1 subgoal):
 1. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> card {..<n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> card {..<n}

goal (1 subgoal):
 1. \<And>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> card {..<n}
[PROOF STEP]
show "(card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}::nat) \<le> (n::nat)"
[PROOF STATE]
proof (prove)
using this:
card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> card {..<n}

goal (1 subgoal):
 1. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
[PROOF STEP]
using h2 card_lessThan[of n]
[PROOF STATE]
proof (prove)
using this:
card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> card {..<n}
card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> card {..<n}
card {..<n} = n

goal (1 subgoal):
 1. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
[PROOF STEP]
have pivot_len: "length (pivot_positions A) \<le> dim_row A "
[PROOF STATE]
proof (prove)
using this:
\<forall>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n

goal (1 subgoal):
 1. length (pivot_positions A) \<le> dim_row A
[PROOF STEP]
using len_help
[PROOF STATE]
proof (prove)
using this:
\<forall>n. card {i. i < n \<and> row A i \<noteq> 0\<^sub>v (dim_col A)} \<le> n
length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}

goal (1 subgoal):
 1. length (pivot_positions A) \<le> dim_row A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length (pivot_positions A) \<le> dim_row A

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
have alt_char: "mat_of_rows (dim_col A)
         (map ((!) (rows A)) (filter (\<lambda>y. y < dim_col A) [0..<length (pivot_positions A)])) =
      mat_of_rows (dim_col A) (map ((!) (rows A))  [0..<length (pivot_positions A)])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_col A) [0..<length (pivot_positions A)])) = mat_of_rows (dim_col A) (map ((!) (rows A)) [0..<length (pivot_positions A)])
[PROOF STEP]
using pivot_len dim_asm
[PROOF STATE]
proof (prove)
using this:
length (pivot_positions A) \<le> dim_row A
dim_row A \<le> dim_col A

goal (1 subgoal):
 1. mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_col A) [0..<length (pivot_positions A)])) = mat_of_rows (dim_col A) (map ((!) (rows A)) [0..<length (pivot_positions A)])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_col A) [0..<length (pivot_positions A)])) = mat_of_rows (dim_col A) (map ((!) (rows A)) [0..<length (pivot_positions A)])

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
have h1: "\<And>i j. i < dim_row A \<Longrightarrow>
           j < dim_col A \<Longrightarrow>
           i < dim_row (take_rows A [0..<length (pivot_positions A)]) \<Longrightarrow>
           take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
assume "i < dim_row A"
[PROOF STATE]
proof (state)
this:
i < dim_row A

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
assume j_lt: "j < dim_col A"
[PROOF STATE]
proof (state)
this:
j < dim_col A

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
assume i_lt: "i < dim_row (take_rows A [0..<length (pivot_positions A)])"
[PROOF STATE]
proof (state)
this:
i < dim_row (take_rows A [0..<length (pivot_positions A)])

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
have lt: "length (pivot_positions A) \<le> dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (pivot_positions A) \<le> dim_row A
[PROOF STEP]
using pivot_len
[PROOF STATE]
proof (prove)
using this:
length (pivot_positions A) \<le> dim_row A

goal (1 subgoal):
 1. length (pivot_positions A) \<le> dim_row A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (pivot_positions A) \<le> dim_row A

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
have h1: "take_rows A [0..<length (pivot_positions A)] $$ (i, j) = (row (take_rows A [0..<length (pivot_positions A)]) i)$j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] $$ (i, j) = row (take_rows A [0..<length (pivot_positions A)]) i $ j
[PROOF STEP]
by (simp add: i_lt j_lt)
[PROOF STATE]
proof (state)
this:
take_rows A [0..<length (pivot_positions A)] $$ (i, j) = row (take_rows A [0..<length (pivot_positions A)]) i $ j

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
take_rows A [0..<length (pivot_positions A)] $$ (i, j) = row (take_rows A [0..<length (pivot_positions A)]) i $ j
[PROOF STEP]
have h2: "(row (take_rows A [0..<length (pivot_positions A)]) i)$j = (row A i)$j"
[PROOF STATE]
proof (prove)
using this:
take_rows A [0..<length (pivot_positions A)] $$ (i, j) = row (take_rows A [0..<length (pivot_positions A)]) i $ j

goal (1 subgoal):
 1. row (take_rows A [0..<length (pivot_positions A)]) i $ j = row A i $ j
[PROOF STEP]
using lt alt_char i_lt
[PROOF STATE]
proof (prove)
using this:
take_rows A [0..<length (pivot_positions A)] $$ (i, j) = row (take_rows A [0..<length (pivot_positions A)]) i $ j
length (pivot_positions A) \<le> dim_row A
mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_col A) [0..<length (pivot_positions A)])) = mat_of_rows (dim_col A) (map ((!) (rows A)) [0..<length (pivot_positions A)])
i < dim_row (take_rows A [0..<length (pivot_positions A)])

goal (1 subgoal):
 1. row (take_rows A [0..<length (pivot_positions A)]) i $ j = row A i $ j
[PROOF STEP]
unfolding take_rows_def
[PROOF STATE]
proof (prove)
using this:
mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_row A) [0..<length (pivot_positions A)])) $$ (i, j) = row (mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_row A) [0..<length (pivot_positions A)]))) i $ j
length (pivot_positions A) \<le> dim_row A
mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_col A) [0..<length (pivot_positions A)])) = mat_of_rows (dim_col A) (map ((!) (rows A)) [0..<length (pivot_positions A)])
i < dim_row (mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_row A) [0..<length (pivot_positions A)])))

goal (1 subgoal):
 1. row (mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_row A) [0..<length (pivot_positions A)]))) i $ j = row A i $ j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row (take_rows A [0..<length (pivot_positions A)]) i $ j = row A i $ j

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
show "take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
using h1 h2
[PROOF STATE]
proof (prove)
using this:
take_rows A [0..<length (pivot_positions A)] $$ (i, j) = row (take_rows A [0..<length (pivot_positions A)]) i $ j
row (take_rows A [0..<length (pivot_positions A)]) i $ j = row A i $ j

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)
[PROOF STEP]
by (simp add: \<open>i < dim_row A\<close> j_lt)
[PROOF STATE]
proof (state)
this:
take_rows A [0..<length (pivot_positions A)] $$ (i, j) = A $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < dim_row A; ?j < dim_col A; ?i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (?i, ?j) = A $$ (?i, ?j)

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
let ?nc = "dim_col A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
let ?nr = "dim_row A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
have h2: "\<And>i j. i < dim_row A \<Longrightarrow>
           j < dim_col A \<Longrightarrow>
           \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)]) \<Longrightarrow>
           0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$
           (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) =
           A $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
assume lt_i: "i < dim_row A"
[PROOF STATE]
proof (state)
this:
i < dim_row A

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
assume lt_j: "j < dim_col A"
[PROOF STATE]
proof (state)
this:
j < dim_col A

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
assume not_lt: "\<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])"
[PROOF STATE]
proof (state)
this:
\<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
let ?ip = "i+1"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
have h0: "\<exists>f. pivot_fun A f (dim_col A) \<and> f i = ?nc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A
[PROOF STEP]
have half1: "\<exists>f. pivot_fun A f (dim_col A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
row_echelon_form A
dim_row A \<le> dim_col A

goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A)
[PROOF STEP]
unfolding row_echelon_form_def
[PROOF STATE]
proof (prove)
using this:
\<exists>f. pivot_fun A f (dim_col A)
dim_row A \<le> dim_col A

goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>f. pivot_fun A f (dim_col A)

goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A
[PROOF STEP]
have half2: "\<forall>f. pivot_fun A f (dim_col A) \<longrightarrow> f i = ?nc "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>f. pivot_fun A f (dim_col A) \<longrightarrow> f i = dim_col A
[PROOF STEP]
proof clarsimp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
fix f
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
assume is_piv: "pivot_fun A f (dim_col A)"
[PROOF STATE]
proof (state)
this:
pivot_fun A f (dim_col A)

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
have len_pp: "length (pivot_positions A) = card {i. i < ?nr \<and> row A i \<noteq> 0\<^sub>v ?nc}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}
[PROOF STEP]
using is_piv pivot_positions[of A ?nr ?nc f]
[PROOF STATE]
proof (prove)
using this:
pivot_fun A f (dim_col A)
\<lbrakk>A \<in> carrier_mat (dim_row A) (dim_col A); pivot_fun A f (dim_col A)\<rbrakk> \<Longrightarrow> set (pivot_positions A) = {(i, f i) |i. i < dim_row A \<and> f i \<noteq> dim_col A}
\<lbrakk>A \<in> carrier_mat (dim_row A) (dim_col A); pivot_fun A f (dim_col A)\<rbrakk> \<Longrightarrow> distinct (map fst (pivot_positions A))
\<lbrakk>A \<in> carrier_mat (dim_row A) (dim_col A); pivot_fun A f (dim_col A)\<rbrakk> \<Longrightarrow> distinct (map snd (pivot_positions A))
\<lbrakk>A \<in> carrier_mat (dim_row A) (dim_col A); pivot_fun A f (dim_col A)\<rbrakk> \<Longrightarrow> length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}

goal (1 subgoal):
 1. length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
have  "\<forall>i. (i < ?nr \<and> row A i \<noteq> 0\<^sub>v ?nc) \<longleftrightarrow>  (i < ?nr \<and> f i \<noteq> ?nc)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. (i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)) = (i < dim_row A \<and> f i \<noteq> dim_col A)
[PROOF STEP]
using is_piv pivot_fun_zero_row_iff[of A f ?nc ?nr]
[PROOF STATE]
proof (prove)
using this:
pivot_fun A f (dim_col A)
\<lbrakk>pivot_fun A f (dim_col A); A \<in> carrier_mat (dim_row A) (dim_col A); ?i < dim_row A\<rbrakk> \<Longrightarrow> (f ?i = dim_col A) = (row A ?i = 0\<^sub>v (dim_col A))

goal (1 subgoal):
 1. \<forall>i. (i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)) = (i < dim_row A \<and> f i \<noteq> dim_col A)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>i. (i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)) = (i < dim_row A \<and> f i \<noteq> dim_col A)

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>i. (i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)) = (i < dim_row A \<and> f i \<noteq> dim_col A)
[PROOF STEP]
have len_pp_var: "length (pivot_positions A) = card {i. i < ?nr \<and> f i \<noteq> ?nc}"
[PROOF STATE]
proof (prove)
using this:
\<forall>i. (i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)) = (i < dim_row A \<and> f i \<noteq> dim_col A)

goal (1 subgoal):
 1. length (pivot_positions A) = card {i. i < dim_row A \<and> f i \<noteq> dim_col A}
[PROOF STEP]
using len_pp
[PROOF STATE]
proof (prove)
using this:
\<forall>i. (i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)) = (i < dim_row A \<and> f i \<noteq> dim_col A)
length (pivot_positions A) = card {i. i < dim_row A \<and> row A i \<noteq> 0\<^sub>v (dim_col A)}

goal (1 subgoal):
 1. length (pivot_positions A) = card {i. i < dim_row A \<and> f i \<noteq> dim_col A}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (pivot_positions A) = card {i. i < dim_row A \<and> f i \<noteq> dim_col A}

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
have allj_hyp: "\<forall>j < ?nr. f j = ?nc \<longrightarrow> ((Suc j) < ?nr \<longrightarrow> f (Suc j) = ?nc)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>j<dim_row A. f j = dim_col A \<longrightarrow> Suc j < dim_row A \<longrightarrow> f (Suc j) = dim_col A
[PROOF STEP]
using is_piv
[PROOF STATE]
proof (prove)
using this:
pivot_fun A f (dim_col A)

goal (1 subgoal):
 1. \<forall>j<dim_row A. f j = dim_col A \<longrightarrow> Suc j < dim_row A \<longrightarrow> f (Suc j) = dim_col A
[PROOF STEP]
unfolding pivot_fun_def
[PROOF STATE]
proof (prove)
using this:
let nr = dim_row A in \<forall>i<nr. f i \<le> dim_col A \<and> (f i < dim_col A \<longrightarrow> A $$ (i, f i) = (1::'a) \<and> (\<forall>i'<nr. i' \<noteq> i \<longrightarrow> A $$ (i', f i) = (0::'a))) \<and> (\<forall>j<f i. A $$ (i, j) = (0::'a)) \<and> (Suc i < nr \<longrightarrow> f i < f (Suc i) \<or> f (Suc i) = dim_col A)

goal (1 subgoal):
 1. \<forall>j<dim_row A. f j = dim_col A \<longrightarrow> Suc j < dim_row A \<longrightarrow> f (Suc j) = dim_col A
[PROOF STEP]
using lt_i
[PROOF STATE]
proof (prove)
using this:
let nr = dim_row A in \<forall>i<nr. f i \<le> dim_col A \<and> (f i < dim_col A \<longrightarrow> A $$ (i, f i) = (1::'a) \<and> (\<forall>i'<nr. i' \<noteq> i \<longrightarrow> A $$ (i', f i) = (0::'a))) \<and> (\<forall>j<f i. A $$ (i, j) = (0::'a)) \<and> (Suc i < nr \<longrightarrow> f i < f (Suc i) \<or> f (Suc i) = dim_col A)
i < dim_row A

goal (1 subgoal):
 1. \<forall>j<dim_row A. f j = dim_col A \<longrightarrow> Suc j < dim_row A \<longrightarrow> f (Suc j) = dim_col A
[PROOF STEP]
by (metis le_antisym le_less)
[PROOF STATE]
proof (state)
this:
\<forall>j<dim_row A. f j = dim_col A \<longrightarrow> Suc j < dim_row A \<longrightarrow> f (Suc j) = dim_col A

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
have if_then_bad: "f i \<noteq> ?nc \<longrightarrow> (\<forall>j. j \<le> i \<longrightarrow> f j \<noteq> ?nc)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f i \<noteq> dim_col A \<longrightarrow> (\<forall>j\<le>i. f j \<noteq> dim_col A)
[PROOF STEP]
proof clarsimp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. \<lbrakk>f i \<noteq> dim_col A; j \<le> i; f j = dim_col A\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. \<lbrakk>f i \<noteq> dim_col A; j \<le> i; f j = dim_col A\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume not_i: "f i \<noteq> ?nc"
[PROOF STATE]
proof (state)
this:
f i \<noteq> dim_col A

goal (1 subgoal):
 1. \<And>j. \<lbrakk>f i \<noteq> dim_col A; j \<le> i; f j = dim_col A\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume j_leq: "j \<le> i"
[PROOF STATE]
proof (state)
this:
j \<le> i

goal (1 subgoal):
 1. \<And>j. \<lbrakk>f i \<noteq> dim_col A; j \<le> i; f j = dim_col A\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume bad_asm: "f j = ?nc"
[PROOF STATE]
proof (state)
this:
f j = dim_col A

goal (1 subgoal):
 1. \<And>j. \<lbrakk>f i \<noteq> dim_col A; j \<le> i; f j = dim_col A\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
have "\<And>k. k \<ge> j \<Longrightarrow>  k < ?nr \<Longrightarrow> f k = ?nc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
fix k :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
assume a1: "j \<le> k"
[PROOF STATE]
proof (state)
this:
j \<le> k

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
assume a2: "k < dim_row A"
[PROOF STATE]
proof (state)
this:
k < dim_row A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
have f3: "\<And>n. \<not> n < dim_row A \<or> f n \<noteq> f j \<or> \<not> Suc n < dim_row A \<or> f (Suc n) = f j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<not> n < dim_row A \<or> f n \<noteq> f j \<or> \<not> Suc n < dim_row A \<or> f (Suc n) = f j
[PROOF STEP]
using allj_hyp bad_asm
[PROOF STATE]
proof (prove)
using this:
\<forall>j<dim_row A. f j = dim_col A \<longrightarrow> Suc j < dim_row A \<longrightarrow> f (Suc j) = dim_col A
f j = dim_col A

goal (1 subgoal):
 1. \<And>n. \<not> n < dim_row A \<or> f n \<noteq> f j \<or> \<not> Suc n < dim_row A \<or> f (Suc n) = f j
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
\<not> ?n < dim_row A \<or> f ?n \<noteq> f j \<or> \<not> Suc ?n < dim_row A \<or> f (Suc ?n) = f j

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
obtain nn :: "nat \<Rightarrow> nat \<Rightarrow> (nat \<Rightarrow> bool) \<Rightarrow> nat" where
              f4: "\<And>n na p nb nc. (\<not> n \<le> na \<or> Suc n \<le> Suc na) \<and> (\<not> p nb \<or> \<not> nc \<le> nb \<or> \<not> p (nn nc nb p) \<or> p nc) \<and> (\<not> p nb \<or> \<not> nc \<le> nb \<or> p nc \<or> p (Suc (nn nc nb p)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>nn. (\<And>n na p nb nc. (\<not> n \<le> na \<or> Suc n \<le> Suc na) \<and> (\<not> p nb \<or> \<not> nc \<le> nb \<or> \<not> p (nn nc nb p) \<or> p nc) \<and> (\<not> p nb \<or> \<not> nc \<le> nb \<or> p nc \<or> p (Suc (nn nc nb p)))) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using inc_induct order_refl
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i \<le> ?j; ?P ?j; \<And>n. \<lbrakk>?i \<le> n; n < ?j; ?P (Suc n)\<rbrakk> \<Longrightarrow> ?P n\<rbrakk> \<Longrightarrow> ?P ?i
?x \<le> ?x

goal (1 subgoal):
 1. (\<And>nn. (\<And>n na p nb nc. (\<not> n \<le> na \<or> Suc n \<le> Suc na) \<and> (\<not> p nb \<or> \<not> nc \<le> nb \<or> \<not> p (nn nc nb p) \<or> p nc) \<and> (\<not> p nb \<or> \<not> nc \<le> nb \<or> p nc \<or> p (Suc (nn nc nb p)))) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by moura
[PROOF STATE]
proof (state)
this:
(\<not> ?n \<le> ?na \<or> Suc ?n \<le> Suc ?na) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> \<not> ?p (nn ?nc ?nb ?p) \<or> ?p ?nc) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> ?p ?nc \<or> ?p (Suc (nn ?nc ?nb ?p)))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<not> ?n \<le> ?na \<or> Suc ?n \<le> Suc ?na) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> \<not> ?p (nn ?nc ?nb ?p) \<or> ?p ?nc) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> ?p ?nc \<or> ?p (Suc (nn ?nc ?nb ?p)))
[PROOF STEP]
have f5: "\<And>p. \<not> p k \<or> p j \<or> p (Suc (nn j k p))"
[PROOF STATE]
proof (prove)
using this:
(\<not> ?n \<le> ?na \<or> Suc ?n \<le> Suc ?na) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> \<not> ?p (nn ?nc ?nb ?p) \<or> ?p ?nc) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> ?p ?nc \<or> ?p (Suc (nn ?nc ?nb ?p)))

goal (1 subgoal):
 1. \<And>p. \<not> p k \<or> p j \<or> p (Suc (nn j k p))
[PROOF STEP]
using a1
[PROOF STATE]
proof (prove)
using this:
(\<not> ?n \<le> ?na \<or> Suc ?n \<le> Suc ?na) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> \<not> ?p (nn ?nc ?nb ?p) \<or> ?p ?nc) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> ?p ?nc \<or> ?p (Suc (nn ?nc ?nb ?p)))
j \<le> k

goal (1 subgoal):
 1. \<And>p. \<not> p k \<or> p j \<or> p (Suc (nn j k p))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
\<not> ?p k \<or> ?p j \<or> ?p (Suc (nn j k ?p))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
have f6: "\<And>p. \<not> p k \<or> \<not> p (nn j k p) \<or> p j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>p. \<not> p k \<or> \<not> p (nn j k p) \<or> p j
[PROOF STEP]
using f4 a1
[PROOF STATE]
proof (prove)
using this:
(\<not> ?n \<le> ?na \<or> Suc ?n \<le> Suc ?na) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> \<not> ?p (nn ?nc ?nb ?p) \<or> ?p ?nc) \<and> (\<not> ?p ?nb \<or> \<not> ?nc \<le> ?nb \<or> ?p ?nc \<or> ?p (Suc (nn ?nc ?nb ?p)))
j \<le> k

goal (1 subgoal):
 1. \<And>p. \<not> p k \<or> \<not> p (nn j k p) \<or> p j
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
\<not> ?p k \<or> \<not> ?p (nn j k ?p) \<or> ?p j

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<not> ?p k \<or> \<not> ?p (nn j k ?p) \<or> ?p j

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
assume "nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A"
[PROOF STATE]
proof (state)
this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
assume "(nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A) \<and> (\<not> j < dim_row A \<or> f j = dim_col A)"
[PROOF STATE]
proof (state)
this:
(nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A) \<and> (\<not> j < dim_row A \<or> f j = dim_col A)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A) \<and> (\<not> j < dim_row A \<or> f j = dim_col A)
[PROOF STEP]
have "\<not> k < dim_row A \<or> f k = dim_col A"
[PROOF STATE]
proof (prove)
using this:
(nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A) \<and> (\<not> j < dim_row A \<or> f j = dim_col A)

goal (1 subgoal):
 1. \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
using f6
[PROOF STATE]
proof (prove)
using this:
(nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A) \<and> (\<not> j < dim_row A \<or> f j = dim_col A)
\<not> ?p k \<or> \<not> ?p (nn j k ?p) \<or> ?p j

goal (1 subgoal):
 1. \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
by (metis (mono_tags, lifting))
[PROOF STATE]
proof (state)
this:
\<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A) \<and> (\<not> j < dim_row A \<or> f j = dim_col A) \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A
(nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A) \<and> (\<not> j < dim_row A \<or> f j = dim_col A) \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
have "(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A"
[PROOF STATE]
proof (prove)
using this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A
(nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A) \<and> (\<not> j < dim_row A \<or> f j = dim_col A) \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. (\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
using bad_asm
[PROOF STATE]
proof (prove)
using this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A
(nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A) \<and> (\<not> j < dim_row A \<or> f j = dim_col A) \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A
f j = dim_col A

goal (1 subgoal):
 1. (\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A \<Longrightarrow> (\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A \<Longrightarrow> (\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A \<Longrightarrow> (\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
assume "(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A)"
[PROOF STATE]
proof (state)
this:
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A)
[PROOF STEP]
have "\<not> k < dim_row A \<or> f k = dim_col A"
[PROOF STATE]
proof (prove)
using this:
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A)

goal (1 subgoal):
 1. \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
using f5
[PROOF STATE]
proof (prove)
using this:
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A)
\<not> ?p k \<or> ?p j \<or> ?p (Suc (nn j k ?p))

goal (1 subgoal):
 1. \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A); \<And>p. \<not> p k \<or> p j \<or> p (Suc (nn j k p))\<rbrakk> \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
have "\<not> (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<and> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) \<noteq> dim_col A) \<and> \<not> (j < dim_row A \<and> f j \<noteq> dim_col A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<and> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) \<noteq> dim_col A) \<and> \<not> (j < dim_row A \<and> f j \<noteq> dim_col A)
[PROOF STEP]
using \<open>(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A)\<close>
[PROOF STATE]
proof (prove)
using this:
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A)

goal (1 subgoal):
 1. \<not> (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<and> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) \<noteq> dim_col A) \<and> \<not> (j < dim_row A \<and> f j \<noteq> dim_col A)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
\<not> (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<and> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) \<noteq> dim_col A) \<and> \<not> (j < dim_row A \<and> f j \<noteq> dim_col A)

goal (1 subgoal):
 1. \<lbrakk>(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A); \<And>p. \<not> p k \<or> p j \<or> p (Suc (nn j k p))\<rbrakk> \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<and> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) \<noteq> dim_col A) \<and> \<not> (j < dim_row A \<and> f j \<noteq> dim_col A)
[PROOF STEP]
have "\<not> (k < dim_row A \<and> f k \<noteq> dim_col A)"
[PROOF STATE]
proof (prove)
using this:
\<not> (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<and> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) \<noteq> dim_col A) \<and> \<not> (j < dim_row A \<and> f j \<noteq> dim_col A)

goal (1 subgoal):
 1. \<not> (k < dim_row A \<and> f k \<noteq> dim_col A)
[PROOF STEP]
by (metis (mono_tags, lifting) a2 bad_asm f5 le_less)
[PROOF STATE]
proof (state)
this:
\<not> (k < dim_row A \<and> f k \<noteq> dim_col A)

goal (1 subgoal):
 1. \<lbrakk>(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A); \<And>p. \<not> p k \<or> p j \<or> p (Suc (nn j k p))\<rbrakk> \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> (k < dim_row A \<and> f k \<noteq> dim_col A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> (k < dim_row A \<and> f k \<noteq> dim_col A)

goal (1 subgoal):
 1. \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
\<not> k < dim_row A \<or> f k = dim_col A

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. \<And>k. \<lbrakk>j \<le> k; k < dim_row A\<rbrakk> \<Longrightarrow> f k = dim_col A
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A \<Longrightarrow> (\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A
[PROOF STEP]
show "f k = dim_col A"
[PROOF STATE]
proof (prove)
using this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A \<Longrightarrow> (\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A

goal (1 subgoal):
 1. f k = dim_col A
[PROOF STEP]
using f3 a2
[PROOF STATE]
proof (prove)
using this:
nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A) < dim_row A \<and> f (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) \<noteq> dim_col A \<Longrightarrow> (\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<or> \<not> k < dim_row A \<or> f k = dim_col A
(\<not> j < dim_row A \<or> f j = dim_col A) \<and> (\<not> Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A)) < dim_row A \<or> f (Suc (nn j k (\<lambda>n. n < dim_row A \<and> f n \<noteq> dim_col A))) = dim_col A) \<Longrightarrow> \<not> k < dim_row A \<or> f k = dim_col A
\<not> ?n < dim_row A \<or> f ?n \<noteq> f j \<or> \<not> Suc ?n < dim_row A \<or> f (Suc ?n) = f j
k < dim_row A

goal (1 subgoal):
 1. f k = dim_col A
[PROOF STEP]
by (metis (lifting) Suc_lessD bad_asm)
[PROOF STATE]
proof (state)
this:
f k = dim_col A

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>j \<le> ?k; ?k < dim_row A\<rbrakk> \<Longrightarrow> f ?k = dim_col A

goal (1 subgoal):
 1. \<And>j. \<lbrakk>f i \<noteq> dim_col A; j \<le> i; f j = dim_col A\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>j \<le> ?k; ?k < dim_row A\<rbrakk> \<Longrightarrow> f ?k = dim_col A
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>j \<le> ?k; ?k < dim_row A\<rbrakk> \<Longrightarrow> f ?k = dim_col A

goal (1 subgoal):
 1. False
[PROOF STEP]
using lt_i not_i
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>j \<le> ?k; ?k < dim_row A\<rbrakk> \<Longrightarrow> f ?k = dim_col A
i < dim_row A
f i \<noteq> dim_col A

goal (1 subgoal):
 1. False
[PROOF STEP]
using j_leq
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>j \<le> ?k; ?k < dim_row A\<rbrakk> \<Longrightarrow> f ?k = dim_col A
i < dim_row A
f i \<noteq> dim_col A
j \<le> i

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
f i \<noteq> dim_col A \<longrightarrow> (\<forall>j\<le>i. f j \<noteq> dim_col A)

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
have "f i \<noteq> ?nc \<longrightarrow> ({0..<?ip} \<subseteq> {y. y < ?nr \<and> f y \<noteq> dim_col A})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f i \<noteq> dim_col A \<longrightarrow> {0..<i + 1} \<subseteq> {y. y < dim_row A \<and> f y \<noteq> dim_col A}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f i \<noteq> dim_col A \<longrightarrow> {0..<i + 1} \<subseteq> {y. y < dim_row A \<and> f y \<noteq> dim_col A}
[PROOF STEP]
have h1: "f i \<noteq> dim_col A \<longrightarrow> (\<forall>j\<le>i. j < ?nr \<and> f j \<noteq> dim_col A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f i \<noteq> dim_col A \<longrightarrow> (\<forall>j\<le>i. j < dim_row A \<and> f j \<noteq> dim_col A)
[PROOF STEP]
using if_then_bad lt_i
[PROOF STATE]
proof (prove)
using this:
f i \<noteq> dim_col A \<longrightarrow> (\<forall>j\<le>i. f j \<noteq> dim_col A)
i < dim_row A

goal (1 subgoal):
 1. f i \<noteq> dim_col A \<longrightarrow> (\<forall>j\<le>i. j < dim_row A \<and> f j \<noteq> dim_col A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f i \<noteq> dim_col A \<longrightarrow> (\<forall>j\<le>i. j < dim_row A \<and> f j \<noteq> dim_col A)

goal (1 subgoal):
 1. f i \<noteq> dim_col A \<longrightarrow> {0..<i + 1} \<subseteq> {y. y < dim_row A \<and> f y \<noteq> dim_col A}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f i \<noteq> dim_col A \<longrightarrow> (\<forall>j\<le>i. j < dim_row A \<and> f j \<noteq> dim_col A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f i \<noteq> dim_col A \<longrightarrow> (\<forall>j\<le>i. j < dim_row A \<and> f j \<noteq> dim_col A)

goal (1 subgoal):
 1. f i \<noteq> dim_col A \<longrightarrow> {0..<i + 1} \<subseteq> {y. y < dim_row A \<and> f y \<noteq> dim_col A}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f i \<noteq> dim_col A \<longrightarrow> {0..<i + 1} \<subseteq> {y. y < dim_row A \<and> f y \<noteq> dim_col A}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
f i \<noteq> dim_col A \<longrightarrow> {0..<i + 1} \<subseteq> {y. y < dim_row A \<and> f y \<noteq> dim_col A}

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f i \<noteq> dim_col A \<longrightarrow> {0..<i + 1} \<subseteq> {y. y < dim_row A \<and> f y \<noteq> dim_col A}
[PROOF STEP]
have gteq: "f i \<noteq> ?nc \<longrightarrow> (card {i. i < ?nr \<and> f i \<noteq> dim_col A} \<ge> (i+1))"
[PROOF STATE]
proof (prove)
using this:
f i \<noteq> dim_col A \<longrightarrow> {0..<i + 1} \<subseteq> {y. y < dim_row A \<and> f y \<noteq> dim_col A}

goal (1 subgoal):
 1. f i \<noteq> dim_col A \<longrightarrow> i + 1 \<le> card {i. i < dim_row A \<and> f i \<noteq> dim_col A}
[PROOF STEP]
using card_lessThan[of ?ip] card_mono[where B = "{i. i < ?nr \<and> f i \<noteq> dim_col A} ", where A = "{0..<?ip}"]
[PROOF STATE]
proof (prove)
using this:
f i \<noteq> dim_col A \<longrightarrow> {0..<i + 1} \<subseteq> {y. y < dim_row A \<and> f y \<noteq> dim_col A}
card {..<i + 1} = i + 1
\<lbrakk>finite {i. i < dim_row A \<and> f i \<noteq> dim_col A}; {0..<i + 1} \<subseteq> {i. i < dim_row A \<and> f i \<noteq> dim_col A}\<rbrakk> \<Longrightarrow> card {0..<i + 1} \<le> card {i. i < dim_row A \<and> f i \<noteq> dim_col A}

goal (1 subgoal):
 1. f i \<noteq> dim_col A \<longrightarrow> i + 1 \<le> card {i. i < dim_row A \<and> f i \<noteq> dim_col A}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f i \<noteq> dim_col A \<longrightarrow> i + 1 \<le> card {i. i < dim_row A \<and> f i \<noteq> dim_col A}

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f i \<noteq> dim_col A \<longrightarrow> i + 1 \<le> card {i. i < dim_row A \<and> f i \<noteq> dim_col A}
[PROOF STEP]
have clear: "dim_row (take_rows A [0..<length (pivot_positions A)]) = length (pivot_positions A)"
[PROOF STATE]
proof (prove)
using this:
f i \<noteq> dim_col A \<longrightarrow> i + 1 \<le> card {i. i < dim_row A \<and> f i \<noteq> dim_col A}

goal (1 subgoal):
 1. dim_row (take_rows A [0..<length (pivot_positions A)]) = length (pivot_positions A)
[PROOF STEP]
unfolding take_rows_def
[PROOF STATE]
proof (prove)
using this:
f i \<noteq> dim_col A \<longrightarrow> i + 1 \<le> card {i. i < dim_row A \<and> f i \<noteq> dim_col A}

goal (1 subgoal):
 1. dim_row (mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_row A) [0..<length (pivot_positions A)]))) = length (pivot_positions A)
[PROOF STEP]
using dim_asm fileq
[PROOF STATE]
proof (prove)
using this:
f i \<noteq> dim_col A \<longrightarrow> i + 1 \<le> card {i. i < dim_row A \<and> f i \<noteq> dim_col A}
dim_row A \<le> dim_col A
filter (\<lambda>y. y < dim_row A) [0..<length (pivot_positions A)] = [0..<length (pivot_positions A)]

goal (1 subgoal):
 1. dim_row (mat_of_rows (dim_col A) (map ((!) (rows A)) (filter (\<lambda>y. y < dim_row A) [0..<length (pivot_positions A)]))) = length (pivot_positions A)
[PROOF STEP]
by (auto)
[PROOF STATE]
proof (state)
this:
dim_row (take_rows A [0..<length (pivot_positions A)]) = length (pivot_positions A)

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
have "i + 1 > length (pivot_positions A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (pivot_positions A) < i + 1
[PROOF STEP]
using not_lt clear
[PROOF STATE]
proof (prove)
using this:
\<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])
dim_row (take_rows A [0..<length (pivot_positions A)]) = length (pivot_positions A)

goal (1 subgoal):
 1. length (pivot_positions A) < i + 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (pivot_positions A) < i + 1

goal (1 subgoal):
 1. \<And>f. pivot_fun A f (dim_col A) \<Longrightarrow> f i = dim_col A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length (pivot_positions A) < i + 1
[PROOF STEP]
show "f i = ?nc"
[PROOF STATE]
proof (prove)
using this:
length (pivot_positions A) < i + 1

goal (1 subgoal):
 1. f i = dim_col A
[PROOF STEP]
using gteq len_pp_var
[PROOF STATE]
proof (prove)
using this:
length (pivot_positions A) < i + 1
f i \<noteq> dim_col A \<longrightarrow> i + 1 \<le> card {i. i < dim_row A \<and> f i \<noteq> dim_col A}
length (pivot_positions A) = card {i. i < dim_row A \<and> f i \<noteq> dim_col A}

goal (1 subgoal):
 1. f i = dim_col A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f i = dim_col A

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>f. pivot_fun A f (dim_col A) \<longrightarrow> f i = dim_col A

goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A
[PROOF STEP]
using half1 half2
[PROOF STATE]
proof (prove)
using this:
\<exists>f. pivot_fun A f (dim_col A)
\<forall>f. pivot_fun A f (dim_col A) \<longrightarrow> f i = dim_col A

goal (1 subgoal):
 1. \<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A
[PROOF STEP]
have h1a: "row A i =  0\<^sub>v (dim_col A)"
[PROOF STATE]
proof (prove)
using this:
\<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A

goal (1 subgoal):
 1. row A i = 0\<^sub>v (dim_col A)
[PROOF STEP]
using pivot_fun_zero_row_iff[of A _ ?nc ?nr]
[PROOF STATE]
proof (prove)
using this:
\<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A
\<lbrakk>pivot_fun A ?f (dim_col A); A \<in> carrier_mat (dim_row A) (dim_col A); ?i < dim_row A\<rbrakk> \<Longrightarrow> (?f ?i = dim_col A) = (row A ?i = 0\<^sub>v (dim_col A))

goal (1 subgoal):
 1. row A i = 0\<^sub>v (dim_col A)
[PROOF STEP]
using lt_i
[PROOF STATE]
proof (prove)
using this:
\<exists>f. pivot_fun A f (dim_col A) \<and> f i = dim_col A
\<lbrakk>pivot_fun A ?f (dim_col A); A \<in> carrier_mat (dim_row A) (dim_col A); ?i < dim_row A\<rbrakk> \<Longrightarrow> (?f ?i = dim_col A) = (row A ?i = 0\<^sub>v (dim_col A))
i < dim_row A

goal (1 subgoal):
 1. row A i = 0\<^sub>v (dim_col A)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
row A i = 0\<^sub>v (dim_col A)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
row A i = 0\<^sub>v (dim_col A)
[PROOF STEP]
have h1: "A $$ (i, j) = 0"
[PROOF STATE]
proof (prove)
using this:
row A i = 0\<^sub>v (dim_col A)

goal (1 subgoal):
 1. A $$ (i, j) = (0::'a)
[PROOF STEP]
using index_row(1) lt_i lt_j
[PROOF STATE]
proof (prove)
using this:
row A i = 0\<^sub>v (dim_col A)
\<lbrakk>?i < dim_row ?A; ?j < dim_col ?A\<rbrakk> \<Longrightarrow> row ?A ?i $ ?j = ?A $$ (?i, ?j)
i < dim_row A
j < dim_col A

goal (1 subgoal):
 1. A $$ (i, j) = (0::'a)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
A $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
have h2a: "i - dim_row (take_rows A [0..<length (pivot_positions A)]) < dim_row A - length (pivot_positions A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i - dim_row (take_rows A [0..<length (pivot_positions A)]) < dim_row A - length (pivot_positions A)
[PROOF STEP]
using pivot_len lt_i not_lt
[PROOF STATE]
proof (prove)
using this:
length (pivot_positions A) \<le> dim_row A
i < dim_row A
\<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])

goal (1 subgoal):
 1. i - dim_row (take_rows A [0..<length (pivot_positions A)]) < dim_row A - length (pivot_positions A)
[PROOF STEP]
by (simp add: take_rows_def)
[PROOF STATE]
proof (state)
this:
i - dim_row (take_rows A [0..<length (pivot_positions A)]) < dim_row A - length (pivot_positions A)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i - dim_row (take_rows A [0..<length (pivot_positions A)]) < dim_row A - length (pivot_positions A)
[PROOF STEP]
have h2: "0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$
           (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = 0 "
[PROOF STATE]
proof (prove)
using this:
i - dim_row (take_rows A [0..<length (pivot_positions A)]) < dim_row A - length (pivot_positions A)

goal (1 subgoal):
 1. 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = (0::'b)
[PROOF STEP]
unfolding zero_mat_def
[PROOF STATE]
proof (prove)
using this:
i - dim_row (take_rows A [0..<length (pivot_positions A)]) < dim_row A - length (pivot_positions A)

goal (1 subgoal):
 1. mat (dim_row A - length (pivot_positions A)) (dim_col A) (\<lambda>ij. 0::'b) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = (0::'b)
[PROOF STEP]
using pivot_len lt_i lt_j
[PROOF STATE]
proof (prove)
using this:
i - dim_row (take_rows A [0..<length (pivot_positions A)]) < dim_row A - length (pivot_positions A)
length (pivot_positions A) \<le> dim_row A
i < dim_row A
j < dim_col A

goal (1 subgoal):
 1. mat (dim_row A - length (pivot_positions A)) (dim_col A) (\<lambda>ij. 0::'b) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = (0::'b)
[PROOF STEP]
using index_mat(1)
[PROOF STATE]
proof (prove)
using this:
i - dim_row (take_rows A [0..<length (pivot_positions A)]) < dim_row A - length (pivot_positions A)
length (pivot_positions A) \<le> dim_row A
i < dim_row A
j < dim_col A
\<lbrakk>?i < ?nr; ?j < ?nc\<rbrakk> \<Longrightarrow> mat ?nr ?nc ?f $$ (?i, ?j) = ?f (?i, ?j)

goal (1 subgoal):
 1. mat (dim_row A - length (pivot_positions A)) (dim_col A) (\<lambda>ij. 0::'b) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = (0::'b)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = (0::?'b1)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A; \<not> i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = (0::?'b1)
[PROOF STEP]
show "0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$
           (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) =
           A $$ (i, j)"
[PROOF STATE]
proof (prove)
using this:
0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = (0::?'b1)

goal (1 subgoal):
 1. 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
using h1 h2
[PROOF STATE]
proof (prove)
using this:
0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = (0::?'b1)
A $$ (i, j) = (0::'a)
0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = (0::?'b1)

goal (1 subgoal):
 1. 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (i - dim_row (take_rows A [0..<length (pivot_positions A)]), j) = A $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < dim_row A; ?j < dim_col A; \<not> ?i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (?i - dim_row (take_rows A [0..<length (pivot_positions A)]), ?j) = A $$ (?i, ?j)

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
have h3: "(dim_row (take_rows A [0..<length (pivot_positions A)])::nat) + ((dim_row A::nat) - (length (pivot_positions A)::nat)) =
    dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A)) = dim_row A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A)) = dim_row A
[PROOF STEP]
have h0: "dim_row (take_rows A [0..<length (pivot_positions A)]) = (length (pivot_positions A)::nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (take_rows A [0..<length (pivot_positions A)]) = length (pivot_positions A)
[PROOF STEP]
by (simp add: take_rows_def fileq)
[PROOF STATE]
proof (state)
this:
dim_row (take_rows A [0..<length (pivot_positions A)]) = length (pivot_positions A)

goal (1 subgoal):
 1. dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A)) = dim_row A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
dim_row (take_rows A [0..<length (pivot_positions A)]) = length (pivot_positions A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dim_row (take_rows A [0..<length (pivot_positions A)]) = length (pivot_positions A)

goal (1 subgoal):
 1. dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A)) = dim_row A
[PROOF STEP]
using add_diff_inverse_nat  pivot_len
[PROOF STATE]
proof (prove)
using this:
dim_row (take_rows A [0..<length (pivot_positions A)]) = length (pivot_positions A)
\<not> ?m < ?n \<Longrightarrow> ?n + (?m - ?n) = ?m
length (pivot_positions A) \<le> dim_row A

goal (1 subgoal):
 1. dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A)) = dim_row A
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A)) = dim_row A

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A)) = dim_row A

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
have h4: " \<And>i j. i < dim_row A \<Longrightarrow>
           j < dim_col A \<Longrightarrow>
           i < dim_row (take_rows A [0..<length (pivot_positions A)]) +
               (dim_row A - length (pivot_positions A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> i < dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A))
[PROOF STEP]
using pivot_len
[PROOF STATE]
proof (prove)
using this:
length (pivot_positions A) \<le> dim_row A

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> i < dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A))
[PROOF STEP]
by (simp add: h3)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < dim_row A; ?j < dim_col A\<rbrakk> \<Longrightarrow> ?i < dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A))

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?i < dim_row A; ?j < dim_col A\<rbrakk> \<Longrightarrow> ?i < dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i < dim_row A; ?j < dim_col A\<rbrakk> \<Longrightarrow> ?i < dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A))

goal (1 subgoal):
 1. take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A
[PROOF STEP]
apply (subst mat_eq_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> i < dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A))) \<Longrightarrow> dim_row (take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A)) = dim_row A \<and> dim_col (take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A)) = dim_col A \<and> (\<forall>i j. i < dim_row A \<longrightarrow> j < dim_col A \<longrightarrow> (take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A)) $$ (i, j) = A $$ (i, j))
[PROOF STEP]
using h1 h2 h3 h4
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i < dim_row A; ?j < dim_col A; ?i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> take_rows A [0..<length (pivot_positions A)] $$ (?i, ?j) = A $$ (?i, ?j)
\<lbrakk>?i < dim_row A; ?j < dim_col A; \<not> ?i < dim_row (take_rows A [0..<length (pivot_positions A)])\<rbrakk> \<Longrightarrow> 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) $$ (?i - dim_row (take_rows A [0..<length (pivot_positions A)]), ?j) = A $$ (?i, ?j)
dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A)) = dim_row A
\<lbrakk>?i < dim_row A; ?j < dim_col A\<rbrakk> \<Longrightarrow> ?i < dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A))

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> i < dim_row (take_rows A [0..<length (pivot_positions A)]) + (dim_row A - length (pivot_positions A))) \<Longrightarrow> dim_row (take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A)) = dim_row A \<and> dim_col (take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A)) = dim_col A \<and> (\<forall>i j. i < dim_row A \<longrightarrow> j < dim_col A \<longrightarrow> (take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A)) $$ (i, j) = A $$ (i, j))
[PROOF STEP]
by (auto simp add: append_rows_def)
[PROOF STATE]
proof (state)
this:
take_rows A [0..<length (pivot_positions A)] @\<^sub>r 0\<^sub>m (dim_row A - length (pivot_positions A)) (dim_col A) = A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma openin_subset_trans:
  "openin (top_of_set U) S \<Longrightarrow> S \<subseteq> T \<Longrightarrow> T \<subseteq> U \<Longrightarrow>
    openin (top_of_set T) S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>openin (top_of_set U) S; S \<subseteq> T; T \<subseteq> U\<rbrakk> \<Longrightarrow> openin (top_of_set T) S
[PROOF STEP]
by (auto simp: openin_open)


[STATEMENT]
lemma (in prob_space) k_wise_indep_vars_subset:
  assumes "k_wise_indep_vars k M' X I"
  assumes "J \<subseteq> I"
  assumes "finite J"
  assumes "card J \<le> k"
  shows "indep_vars M' X J"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. indep_vars M' X J
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
k_wise_indep_vars k M' X I
J \<subseteq> I
finite J
card J \<le> k

goal (1 subgoal):
 1. indep_vars M' X J
[PROOF STEP]
by (simp add:k_wise_indep_vars_def)


[STATEMENT]
lemma subadditiveD: "subadditive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x \<in> M \<Longrightarrow> y \<in> M \<Longrightarrow> f (x \<union> y) \<le> f x + f y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>subadditive M f; x \<inter> y = {}; x \<in> M; y \<in> M\<rbrakk> \<Longrightarrow> f (x \<union> y) \<le> f x + f y
[PROOF STEP]
by (auto simp add: subadditive_def)


[STATEMENT]
lemma dom_eq_and_eq_on_dom_imp_eq: "dom m = dom m' \<Longrightarrow> \<forall>x\<in>dom m . m x = m' x \<Longrightarrow> m = m'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>dom m = dom m'; \<forall>x\<in>dom m. m x = m' x\<rbrakk> \<Longrightarrow> m = m'
[PROOF STEP]
by (simp add: map_le_def map_le_same_dom_imp_same_map)


[STATEMENT]
lemma projector_square_eq:
  assumes "projector M"
  shows "M * M = M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M * M = M
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
projector M

goal (1 subgoal):
 1. M * M = M
[PROOF STEP]
unfolding projector_def
[PROOF STATE]
proof (prove)
using this:
hermitian M \<and> M * M = M

goal (1 subgoal):
 1. M * M = M
[PROOF STEP]
by simp


[STATEMENT]
lemma Lambert_W_times_ln_self':
  assumes "x \<ge> exp (-1)"
  shows   "Lambert_W (ln x  * x) = ln x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Lambert_W (ln x * x) = ln x
[PROOF STEP]
using Lambert_W_times_ln_self[OF assms]
[PROOF STATE]
proof (prove)
using this:
Lambert_W (x * ln x) = ln x

goal (1 subgoal):
 1. Lambert_W (ln x * x) = ln x
[PROOF STEP]
by (simp add: mult.commute)


[STATEMENT]
lemma is_arg_min_on_Min:
assumes "finite A" "is_arg_min_on f A a" shows "Min (f ` A) = f a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Min (f ` A) = f a
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Min (f ` A) = f a
[PROOF STEP]
from assms(2)
[PROOF STATE]
proof (chain)
picking this:
is_arg_min_on f A a
[PROOF STEP]
have "f ` A \<noteq> {}"
[PROOF STATE]
proof (prove)
using this:
is_arg_min_on f A a

goal (1 subgoal):
 1. f ` A \<noteq> {}
[PROOF STEP]
by (fastforce simp: is_arg_min_on_def)
[PROOF STATE]
proof (state)
this:
f ` A \<noteq> {}

goal (1 subgoal):
 1. Min (f ` A) = f a
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
f ` A \<noteq> {}

goal (1 subgoal):
 1. Min (f ` A) = f a
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f ` A \<noteq> {}
finite A
is_arg_min_on f A a

goal (1 subgoal):
 1. Min (f ` A) = f a
[PROOF STEP]
by (simp add: antisym is_arg_min_on_def)
[PROOF STATE]
proof (state)
this:
Min (f ` A) = f a

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ccw'_sortedP_mirror:
  "ccw'.sortedP x0 (map (mirror_point p0) xs) \<longleftrightarrow> ccw'.sortedP (mirror_point p0 x0) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ccw'.sortedP x0 (map (mirror_point p0) xs) = ccw'.sortedP (mirror_point p0 x0) xs
[PROOF STEP]
by (induct xs)
    (simp_all add: linorder_list0.sortedP.Nil linorder_list0.sortedP_Cons_iff ccw'_mirror_point0)


[STATEMENT]
lemma card_number_partitions_with_only_parts_1:
  "card {N. (\<forall>n. n\<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
 2. \<not> ?P \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
assume "n \<le> x"
[PROOF STATE]
proof (state)
this:
n \<le> x

goal (2 subgoals):
 1. ?P \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
 2. \<not> ?P \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
n \<le> x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n \<le> x

goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
using card_number_partitions_with_only_parts_1_eq_1
[PROOF STATE]
proof (prove)
using this:
n \<le> x
?n \<le> ?x \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition ?n N \<and> size N \<le> ?x} = 1

goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
unfolding iverson_def
[PROOF STATE]
proof (prove)
using this:
n \<le> x
?n \<le> ?x \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition ?n N \<and> size N \<le> ?x} = 1

goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = (if n \<le> x then 1 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)

goal (1 subgoal):
 1. \<not> n \<le> x \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> n \<le> x \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
assume "\<not> n \<le> x"
[PROOF STATE]
proof (state)
this:
\<not> n \<le> x

goal (1 subgoal):
 1. \<not> n \<le> x \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<not> n \<le> x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> n \<le> x

goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
using card_number_partitions_with_only_parts_1_eq_0
[PROOF STATE]
proof (prove)
using this:
\<not> n \<le> x
?x < ?n \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition ?n N \<and> size N \<le> ?x} = 0

goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)
[PROOF STEP]
unfolding iverson_def
[PROOF STATE]
proof (prove)
using this:
\<not> n \<le> x
?x < ?n \<Longrightarrow> card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition ?n N \<and> size N \<le> ?x} = 0

goal (1 subgoal):
 1. card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = (if n \<le> x then 1 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card {N. (\<forall>n. n \<in># N \<longrightarrow> n = 1) \<and> number_partition n N \<and> size N \<le> x} = iverson (n \<le> x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma absolutely_integrable_zero [simp]: "(\<lambda>x. 0) absolutely_integrable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. 0::'b) absolutely_integrable_on S
[PROOF STEP]
by (simp add: set_integrable_def)


[STATEMENT]
lemma collinear_3_expand:
   "collinear{a,b,c} \<longleftrightarrow> a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
have "collinear{a,b,c} = collinear{a,c,b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collinear {a, b, c} = collinear {a, c, b}
[PROOF STEP]
by (simp add: insert_commute)
[PROOF STATE]
proof (state)
this:
collinear {a, b, c} = collinear {a, c, b}

goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
collinear {a, b, c} = collinear {a, c, b}

goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
have "... = collinear {0, a - c, b - c}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collinear {a, c, b} = collinear {0::'a, a - c, b - c}
[PROOF STEP]
by (simp add: collinear_3)
[PROOF STATE]
proof (state)
this:
collinear {a, c, b} = collinear {0::'a, a - c, b - c}

goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
collinear {a, c, b} = collinear {0::'a, a - c, b - c}

goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
have "... \<longleftrightarrow> (a = c \<or> b = c \<or> (\<exists>ca. b - c = ca *\<^sub>R (a - c)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collinear {0::'a, a - c, b - c} = (a = c \<or> b = c \<or> (\<exists>ca. b - c = ca *\<^sub>R (a - c)))
[PROOF STEP]
by (simp add: collinear_lemma)
[PROOF STATE]
proof (state)
this:
collinear {0::'a, a - c, b - c} = (a = c \<or> b = c \<or> (\<exists>ca. b - c = ca *\<^sub>R (a - c)))

goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
collinear {0::'a, a - c, b - c} = (a = c \<or> b = c \<or> (\<exists>ca. b - c = ca *\<^sub>R (a - c)))

goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
have "... \<longleftrightarrow> a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a = c \<or> b = c \<or> (\<exists>ca. b - c = ca *\<^sub>R (a - c))) = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
by (cases "a = c \<or> b = c") (auto simp: algebra_simps)
[PROOF STATE]
proof (state)
this:
(a = c \<or> b = c \<or> (\<exists>ca. b - c = ca *\<^sub>R (a - c))) = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))

goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))

goal (1 subgoal):
 1. collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
collinear {a, b, c} = (a = c \<or> (\<exists>u. b = u *\<^sub>R a + (1 - u) *\<^sub>R c))

goal:
No subgoals!
[PROOF STEP]
qed