[STATEMENT]
lemma condition_3:
  fixes A::"'a::{field}^'columns::{mod_type}^'rows::{mod_type}" and k::nat
  defines ia:"ia\<equiv>(if \<forall>m. is_zero_row_upt_k m k A then 0 else to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)"
  defines B:"B\<equiv>(snd (Gauss_Jordan_column_k (ia,A) k))"
  assumes rref: "reduced_row_echelon_form_upt_k A k"
  and i_le: "i < i + 1"
  and not_zero_i_suc_k: "\<not> is_zero_row_upt_k i (Suc k) B"
  and not_zero_suc_i_suc_k: "\<not> is_zero_row_upt_k (i + 1) (Suc k) B"
  shows "(LEAST n. B $ i $ n \<noteq> 0) < (LEAST n. B $ (i + 1) $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. B $ i $ n \<noteq> (0::'a)) < (LEAST n. B $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
proof (unfold B Gauss_Jordan_column_k_def ia Let_def fst_conv snd_conv, auto, unfold from_nat_to_nat_greatest from_nat_0)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; \<forall>m\<ge>0::'rows. A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; (0::'rows) \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 4. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 5. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
assume all_zero: "\<forall>m. is_zero_row_upt_k m k A"
    and all_zero_k: "\<forall>m\<ge>0. A $ m $ from_nat k = 0"
[PROOF STATE]
proof (state)
this:
\<forall>m. is_zero_row_upt_k m k A
\<forall>m\<ge>0::'rows. A $ m $ mod_type_class.from_nat k = (0::'a)

goal (5 subgoals):
 1. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; \<forall>m\<ge>0::'rows. A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; (0::'rows) \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 4. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 5. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. A $ i $ n \<noteq> 0) < (LEAST n. A $ (i + 1) $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using condition_3_part_1[OF _ all_zero]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k ?i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<forall>m. A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ ?i $ n \<noteq> (0::'a)) < (LEAST n. A $ (?i + (1::'rows)) $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using all_zero_k least_mod_type not_zero_i_suc_k
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k ?i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<forall>m. A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ ?i $ n \<noteq> (0::'a)) < (LEAST n. A $ (?i + (1::'rows)) $ n \<noteq> (0::'a))
\<forall>m\<ge>0::'rows. A $ m $ mod_type_class.from_nat k = (0::'a)
(0::?'a) \<le> ?n
\<not> is_zero_row_upt_k i (Suc k) B

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding B ia
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k ?i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<forall>m. A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ ?i $ n \<noteq> (0::'a)) < (LEAST n. A $ (?i + (1::'rows)) $ n \<noteq> (0::'a))
\<forall>m\<ge>0::'rows. A $ m $ mod_type_class.from_nat k = (0::'a)
(0::?'a) \<le> ?n
\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
(LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))

goal (4 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; (0::'rows) \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 4. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; (0::'rows) \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 4. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; (0::'rows) \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 4. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
assume all_zero: "\<forall>m. is_zero_row_upt_k m k A"
    and Amk_notzero: "A $ m $ from_nat k \<noteq> 0"
[PROOF STATE]
proof (state)
this:
\<forall>m. is_zero_row_upt_k m k A
A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)

goal (4 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; (0::'rows) \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 4. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. Gauss_Jordan_in_ij A 0 (from_nat k) $ i $ n \<noteq> 0) < (LEAST n. Gauss_Jordan_in_ij A 0 (from_nat k) $ (i + 1) $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using condition_3_part_2[OF i_le _ _ all_zero Amk_notzero]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using not_zero_i_suc_k not_zero_suc_i_suc_k
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k i (Suc k) B
\<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) B

goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding B ia
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))
\<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))

goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A (0::'rows) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))

goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
assume not_zero_m: "\<not> is_zero_row_upt_k m k A"
    and zero_below_greatest: "\<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + 1. A $ m $ from_nat k = 0"
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k m k A
\<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)

goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 3. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. A $ i $ n \<noteq> 0) < (LEAST n. A $ (i + 1) $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using condition_3_part_3[OF rref i_le _ _ not_zero_m zero_below_greatest]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using not_zero_i_suc_k not_zero_suc_i_suc_k
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k i (Suc k) B
\<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) B

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding B ia
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))
\<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))

goal (2 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
assume not_zero_m: "\<not> is_zero_row_upt_k m k A"
    and greatest_eq_card: "Suc (to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A"
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k m k A
Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A

goal (2 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
 2. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. A $ i $ n \<noteq> 0) < (LEAST n. A $ (i + 1) $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using condition_3_part_4[OF rref i_le _ _ not_zero_m greatest_eq_card]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using not_zero_i_suc_k not_zero_suc_i_suc_k
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k i (Suc k) B
\<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) B

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding B ia
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))
\<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))

goal (1 subgoal):
 1. (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ (i + (1::'rows)) $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
fix m ma
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
assume not_zero_m: "\<not> is_zero_row_upt_k m k A"
    and greatest_not_card: "Suc (to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A"
    and greatest_less_ma: "(GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 \<le> ma"
    and A_ma_k_not_zero: "A $ ma $ from_nat k \<noteq> 0"
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k m k A
Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A
(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma
A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)

goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) (from_nat k) $ i $ n \<noteq> 0)
    < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) (from_nat k) $ (i + 1) $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using condition_3_part_5[OF rref i_le _ _ not_zero_m greatest_not_card greatest_less_ma A_ma_k_not_zero]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
using not_zero_i_suc_k not_zero_suc_i_suc_k
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k i (Suc k) B
\<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) B

goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding B ia
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)); \<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))\<rbrakk> \<Longrightarrow> (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))
\<not> is_zero_row_upt_k (i + (1::'rows)) (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))

goal (1 subgoal):
 1. (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ i $ n \<noteq> (0::'a)) < (LEAST n. Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k) $ (i + (1::'rows)) $ n \<noteq> (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "x = (1 :: real) \<Longrightarrow>
         ((\<lambda>n. abs (x powr n / (n * (1 + x powr (2 * n)))) powr (1 / n)) \<longlongrightarrow> 1 / x) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = 1 \<Longrightarrow> ((\<lambda>n. \<bar>x powr n / (n * (1 + x powr (2 * n)))\<bar> powr (1 / n)) \<longlongrightarrow> 1 / x) at_top
[PROOF STEP]
by (real_asymp simp add: exp_minus field_simps)


[STATEMENT]
lemma rsa_pss_verify: "\<lbrakk> prime p; prime q; p \<noteq> q; n = p*q; e*d mod ((pred p)*(pred q)) = 1; rsapss_sign m e n \<noteq> []; s = rsapss_sign m e n \<rbrakk> \<Longrightarrow> rsapss_verify m s d n = True"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = 1; rsapss_sign m e n \<noteq> []; s = rsapss_sign m e n\<rbrakk> \<Longrightarrow> rsapss_verify m s d n = True
[PROOF STEP]
apply (simp only: rsapss_sign_def rsapss_verify_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = 1; (if emsapss_encode m (length (nat_to_bv (p * q)) - 1) = [] then [] else rsapss_sign_help1 (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - 1))) e (p * q)) \<noteq> []; s = (if emsapss_encode m (length (nat_to_bv (p * q)) - 1) = [] then [] else rsapss_sign_help1 (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - 1))) e (p * q))\<rbrakk> \<Longrightarrow> (if length (if emsapss_encode m (length (nat_to_bv (p * q)) - 1) = [] then [] else rsapss_sign_help1 (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - 1))) e (p * q)) \<noteq> length (nat_to_bv (p * q)) then False else let em = nat_to_bv_length (rsa_crypt (bv_to_nat (if emsapss_encode m (length (nat_to_bv (p * q)) - 1) = [] then [] else rsapss_sign_help1 (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - 1))) e (p * q))) d (p * q)) (roundup (length (nat_to_bv (p * q)) - 1) 8 * 8) in emsapss_decode m em (length (nat_to_bv (p * q)) - 1)) = True
[PROOF STEP]
apply (simp only: rsapss_sign_help1_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = 1; (if emsapss_encode m (length (nat_to_bv (p * q)) - 1) = [] then [] else nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - 1))) e (p * q)) (length (nat_to_bv (p * q)))) \<noteq> []; s = (if emsapss_encode m (length (nat_to_bv (p * q)) - 1) = [] then [] else nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - 1))) e (p * q)) (length (nat_to_bv (p * q))))\<rbrakk> \<Longrightarrow> (if length (if emsapss_encode m (length (nat_to_bv (p * q)) - 1) = [] then [] else nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - 1))) e (p * q)) (length (nat_to_bv (p * q)))) \<noteq> length (nat_to_bv (p * q)) then False else let em = nat_to_bv_length (rsa_crypt (bv_to_nat (if emsapss_encode m (length (nat_to_bv (p * q)) - 1) = [] then [] else nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - 1))) e (p * q)) (length (nat_to_bv (p * q))))) d (p * q)) (roundup (length (nat_to_bv (p * q)) - 1) 8 * 8) in emsapss_decode m em (length (nat_to_bv (p * q)) - 1)) = True
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = Suc 0; nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))) \<noteq> []; s = nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []\<rbrakk> \<Longrightarrow> length (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q)))) = length (nat_to_bv (p * q))
 2. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = Suc 0; nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))) \<noteq> []; s = nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []; length (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q)))) = length (nat_to_bv (p * q))\<rbrakk> \<Longrightarrow> emsapss_decode m (nat_to_bv_length (rsa_crypt (bv_to_nat (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))))) d (p * q)) (roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8)) (length (nat_to_bv (p * q)) - Suc 0)
[PROOF STEP]
apply (simp add: length_nat_to_bv_length)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = Suc 0; nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))) \<noteq> []; s = nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []; length (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q)))) = length (nat_to_bv (p * q))\<rbrakk> \<Longrightarrow> emsapss_decode m (nat_to_bv_length (rsa_crypt (bv_to_nat (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))))) d (p * q)) (roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8)) (length (nat_to_bv (p * q)) - Suc 0)
[PROOF STEP]
apply (simp add: bv_to_nat_nat_to_bv_length)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = Suc 0; nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))) \<noteq> []; s = nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []; length (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q)))) = length (nat_to_bv (p * q))\<rbrakk> \<Longrightarrow> emsapss_decode m (nat_to_bv_length (rsa_crypt (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) d (p * q)) (roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8)) (length (nat_to_bv (p * q)) - Suc 0)
[PROOF STEP]
apply (insert length_emsapss_encode [of m "(length (nat_to_bv (p * q)) - Suc 0)"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = Suc 0; nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))) \<noteq> []; s = nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []; length (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q)))) = length (nat_to_bv (p * q)); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> [] \<Longrightarrow> length (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) = roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8\<rbrakk> \<Longrightarrow> emsapss_decode m (nat_to_bv_length (rsa_crypt (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) d (p * q)) (roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8)) (length (nat_to_bv (p * q)) - Suc 0)
[PROOF STEP]
apply (insert bv_to_nat_emsapss_smaller_pq [of p q m])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = Suc 0; nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))) \<noteq> []; s = nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []; length (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q)))) = length (nat_to_bv (p * q)); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> [] \<Longrightarrow> length (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) = roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8; \<lbrakk>prime p; prime q; p \<noteq> q; emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []\<rbrakk> \<Longrightarrow> bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) < p * q\<rbrakk> \<Longrightarrow> emsapss_decode m (nat_to_bv_length (rsa_crypt (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) d (p * q)) (roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8)) (length (nat_to_bv (p * q)) - Suc 0)
[PROOF STEP]
apply (simp add: cryptinverts)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = Suc 0; nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))) \<noteq> []; s = nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []; length (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q)))) = length (nat_to_bv (p * q)); length (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) = roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8; bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) < p * q\<rbrakk> \<Longrightarrow> emsapss_decode m (nat_to_bv_length (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) (roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8)) (length (nat_to_bv (p * q)) - Suc 0)
[PROOF STEP]
apply (insert length_emsapss_encode [of m "(length (nat_to_bv (p * q)) - Suc 0)"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = Suc 0; nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))) \<noteq> []; s = nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []; length (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q)))) = length (nat_to_bv (p * q)); length (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) = roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8; bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) < p * q; emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> [] \<Longrightarrow> length (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) = roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8\<rbrakk> \<Longrightarrow> emsapss_decode m (nat_to_bv_length (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) (roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8)) (length (nat_to_bv (p * q)) - Suc 0)
[PROOF STEP]
apply (insert nat_to_bv_length_bv_to_nat [of "emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)" "roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime p; prime q; p \<noteq> q; n = p * q; e * d mod (pred p * pred q) = Suc 0; nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))) \<noteq> []; s = nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q))); emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []; length (nat_to_bv_length (rsa_crypt (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) e (p * q)) (length (nat_to_bv (p * q)))) = length (nat_to_bv (p * q)); length (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) = roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8; bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) < p * q; emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> [] \<Longrightarrow> length (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) = roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8; \<lbrakk>length (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)) = roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8; emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0) \<noteq> []\<rbrakk> \<Longrightarrow> nat_to_bv_length (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) (roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8) = emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0)\<rbrakk> \<Longrightarrow> emsapss_decode m (nat_to_bv_length (bv_to_nat (emsapss_encode m (length (nat_to_bv (p * q)) - Suc 0))) (roundup (length (nat_to_bv (p * q)) - Suc 0) 8 * 8)) (length (nat_to_bv (p * q)) - Suc 0)
[PROOF STEP]
apply (simp add: verify)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma mset_size_le1_cases[case_names empty singleton,consumes 1]: "\<lbrakk> size M \<le> Suc 0; M={#} \<Longrightarrow> P; !!m. M={#m#} \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>size M \<le> Suc 0; M = {#} \<Longrightarrow> P; \<And>m. M = {#m#} \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P
[PROOF STEP]
by (cases M) auto


[STATEMENT]
lemma above_diagonal_in_residues:
  fixes H :: "(('a :: {bezout_ring_div, normalization_euclidean_semiring, unique_euclidean_ring}, 'b :: mod_type) vec, 'b) vec"
  assumes H: "Hermite associates residues H"
  and inv_H: "invertible H" and up_H: "upper_triangular H"
  and j_i: "j<i"
  shows "H $ j $ (LEAST n. H $ i $ n \<noteq> 0) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> 0))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H $ j $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. H $ j $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)))
[PROOF STEP]
have "H $ i $ i \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H $ i $ i \<noteq> (0::'a)
[PROOF STEP]
by (metis (full_types) inv_H invertible_iff_is_unit is_unit_diagonal not_is_unit_0 up_H)
[PROOF STATE]
proof (state)
this:
H $ i $ i \<noteq> (0::'a)

goal (1 subgoal):
 1. H $ j $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)))
[PROOF STEP]
hence "\<not> is_zero_row i H"
[PROOF STATE]
proof (prove)
using this:
H $ i $ i \<noteq> (0::'a)

goal (1 subgoal):
 1. \<not> is_zero_row i H
[PROOF STEP]
unfolding is_zero_row_def is_zero_row_upt_k_def ncols_def
[PROOF STATE]
proof (prove)
using this:
H $ i $ i \<noteq> (0::'a)

goal (1 subgoal):
 1. \<not> (\<forall>j. mod_type_class.to_nat j < CARD('b) \<longrightarrow> H $ i $ j = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row i H

goal (1 subgoal):
 1. H $ j $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row i H

goal (1 subgoal):
 1. H $ j $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)))
[PROOF STEP]
using H j_i
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row i H
Hermite associates residues H
j < i

goal (1 subgoal):
 1. H $ j $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)))
[PROOF STEP]
unfolding Hermite_def
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row i H
Complete_set_non_associates associates \<and> Complete_set_residues residues \<and> echelon_form H \<and> (\<forall>i. \<not> is_zero_row i H \<longrightarrow> H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> associates) \<and> (\<forall>i. \<not> is_zero_row i H \<longrightarrow> (\<forall>j<i. H $ j $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)))))
j < i

goal (1 subgoal):
 1. H $ j $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)))
[PROOF STEP]
unfolding diagonal_least_nonzero[OF H inv_H up_H]
[PROOF STATE]
proof (prove)
using this:
\<not> is_zero_row i H
Complete_set_non_associates associates \<and> Complete_set_residues residues \<and> echelon_form H \<and> (\<forall>i. \<not> is_zero_row i H \<longrightarrow> H $ i $ i \<in> associates) \<and> (\<forall>i. \<not> is_zero_row i H \<longrightarrow> (\<forall>j<i. H $ j $ i \<in> residues (H $ i $ i)))
j < i

goal (1 subgoal):
 1. H $ j $ i \<in> residues (H $ i $ i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
H $ j $ (LEAST n. H $ i $ n \<noteq> (0::'a)) \<in> residues (H $ i $ (LEAST n. H $ i $ n \<noteq> (0::'a)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma polynomial_of_mset_mult_poly_raw[simp]:
  \<open>polynomial_of_mset (mult_poly_raw xs ys) = polynomial_of_mset xs * polynomial_of_mset ys\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polynomial_of_mset (mult_poly_raw xs ys) = polynomial_of_mset xs * polynomial_of_mset ys
[PROOF STEP]
unfolding mult_poly_raw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polynomial_of_mset (\<Sum>y\<in>#xs. mult_poly_by_monom y ys) = polynomial_of_mset xs * polynomial_of_mset ys
[PROOF STEP]
by (induction xs arbitrary: ys)
   (auto simp: Const_mult algebra_simps)


[STATEMENT]
lemma wf_table_iff: "wf_table n A Q X \<longleftrightarrow> (\<forall>x. x \<in> X \<longleftrightarrow> (Q x \<and> wf_tuple n A x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf_table n A Q X = (\<forall>x. (x \<in> X) = (Q x \<and> wf_tuple n A x))
[PROOF STEP]
unfolding qtable_def table_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Ball X (wf_tuple n A) \<and> (\<forall>x. (x \<in> X \<and> True \<longrightarrow> Q x) \<and> (wf_tuple n A x \<and> True \<and> Q x \<longrightarrow> x \<in> X))) = (\<forall>x. (x \<in> X) = (Q x \<and> wf_tuple n A x))
[PROOF STEP]
by auto


[STATEMENT]
lemma fds_const_abs_converges [simp]: "fds_abs_converges (fds_const c) s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fds_abs_converges (fds_const c) s
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fds_abs_converges (fds_const c) s
[PROOF STEP]
have "summable (\<lambda>n. norm (fds_nth (fds_const c) n / nat_power n s)) \<longleftrightarrow>
          summable (\<lambda>n. if n = 1 then norm c else (0 :: real))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. norm (fds_nth (fds_const c) n / nat_power n s)) = summable (\<lambda>n. if n = 1 then norm c else 0)
[PROOF STEP]
by (intro summable_cong) simp
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. norm (fds_nth (fds_const c) n / nat_power n s)) = summable (\<lambda>n. if n = 1 then norm c else 0)

goal (1 subgoal):
 1. fds_abs_converges (fds_const c) s
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. norm (fds_nth (fds_const c) n / nat_power n s)) = summable (\<lambda>n. if n = 1 then norm c else 0)

goal (1 subgoal):
 1. fds_abs_converges (fds_const c) s
[PROOF STEP]
have \<dots>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. if n = 1 then norm c else 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. if n = 1 then norm c else 0)

goal (1 subgoal):
 1. fds_abs_converges (fds_const c) s
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
summable (\<lambda>n. norm (fds_nth (fds_const c) n / nat_power n s))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
summable (\<lambda>n. norm (fds_nth (fds_const c) n / nat_power n s))

goal (1 subgoal):
 1. fds_abs_converges (fds_const c) s
[PROOF STEP]
by (simp add: fds_abs_converges_def)
[PROOF STATE]
proof (state)
this:
fds_abs_converges (fds_const c) s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_edges: "e \<in> E \<Longrightarrow> finite e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. e \<in> E \<Longrightarrow> finite e
[PROOF STEP]
using card_ge_0_finite and edges2
[PROOF STATE]
proof (prove)
using this:
0 < card ?A \<Longrightarrow> finite ?A
?e \<in> E \<Longrightarrow> card ?e = 2

goal (1 subgoal):
 1. e \<in> E \<Longrightarrow> finite e
[PROOF STEP]
by force


[STATEMENT]
lemma image_projection_PiE:
  "(\<lambda>f. f i) ` (PiE I S) = (if PiE I S = {} then {} else if i \<in> I then S i else {undefined})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = (if Pi\<^sub>E I S = {} then {} else if i \<in> I then S i else {undefined})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = (if Pi\<^sub>E I S = {} then {} else if i \<in> I then S i else {undefined})
[PROOF STEP]
have "(\<lambda>f. f i) ` Pi\<^sub>E I S = S i" if "i \<in> I" "f \<in> PiE I S" for f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = S i
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
i \<in> I
f \<in> Pi\<^sub>E I S

goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = S i
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>i \<in> I; f \<in> Pi\<^sub>E I S; x \<in> S i\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>f. f i) ` Pi\<^sub>E I S
[PROOF STEP]
by (rule_tac x="(\<lambda>k. if k=i then x else f k)" in image_eqI) auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>i \<in> I; ?f \<in> Pi\<^sub>E I S\<rbrakk> \<Longrightarrow> (\<lambda>f. f i) ` Pi\<^sub>E I S = S i

goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = (if Pi\<^sub>E I S = {} then {} else if i \<in> I then S i else {undefined})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<lbrakk>i \<in> I; ?f \<in> Pi\<^sub>E I S\<rbrakk> \<Longrightarrow> (\<lambda>f. f i) ` Pi\<^sub>E I S = S i

goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = (if Pi\<^sub>E I S = {} then {} else if i \<in> I then S i else {undefined})
[PROOF STEP]
have "(\<lambda>f. f i) ` Pi\<^sub>E I S = {undefined}" if "f \<in> PiE I S" "i \<notin> I" for f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = {undefined}
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
f \<in> Pi\<^sub>E I S
i \<notin> I

goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = {undefined}
[PROOF STEP]
by (blast intro: PiE_arb [OF that, symmetric])
[PROOF STATE]
proof (state)
this:
\<lbrakk>?f \<in> Pi\<^sub>E I S; i \<notin> I\<rbrakk> \<Longrightarrow> (\<lambda>f. f i) ` Pi\<^sub>E I S = {undefined}

goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = (if Pi\<^sub>E I S = {} then {} else if i \<in> I then S i else {undefined})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>i \<in> I; ?f \<in> Pi\<^sub>E I S\<rbrakk> \<Longrightarrow> (\<lambda>f. f i) ` Pi\<^sub>E I S = S i
\<lbrakk>?f \<in> Pi\<^sub>E I S; i \<notin> I\<rbrakk> \<Longrightarrow> (\<lambda>f. f i) ` Pi\<^sub>E I S = {undefined}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>i \<in> I; ?f \<in> Pi\<^sub>E I S\<rbrakk> \<Longrightarrow> (\<lambda>f. f i) ` Pi\<^sub>E I S = S i
\<lbrakk>?f \<in> Pi\<^sub>E I S; i \<notin> I\<rbrakk> \<Longrightarrow> (\<lambda>f. f i) ` Pi\<^sub>E I S = {undefined}

goal (1 subgoal):
 1. (\<lambda>f. f i) ` Pi\<^sub>E I S = (if Pi\<^sub>E I S = {} then {} else if i \<in> I then S i else {undefined})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>f. f i) ` Pi\<^sub>E I S = (if Pi\<^sub>E I S = {} then {} else if i \<in> I then S i else {undefined})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma FG_advice_nested_prop_atoms_card:
  "card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms \<phi>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms \<phi>)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms \<phi>)
[PROOF STEP]
have "card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms\<^sub>\<mu> \<phi> Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms\<^sub>\<mu> \<phi> Y)
[PROOF STEP]
by (simp add: nested_prop_atoms\<^sub>\<mu>_finite FG_advice_nested_prop_atoms\<^sub>\<mu> card_mono)
[PROOF STATE]
proof (state)
this:
card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms\<^sub>\<mu> \<phi> Y)

goal (1 subgoal):
 1. card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms \<phi>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms\<^sub>\<mu> \<phi> Y)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms\<^sub>\<mu> \<phi> Y)

goal (1 subgoal):
 1. card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms \<phi>)
[PROOF STEP]
using nested_prop_atoms\<^sub>\<mu>_card le_trans
[PROOF STATE]
proof (prove)
using this:
card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms\<^sub>\<mu> \<phi> Y)
card (nested_prop_atoms\<^sub>\<mu> ?\<phi> ?X) \<le> card (nested_prop_atoms ?\<phi>)
\<lbrakk>?i \<le> ?j; ?j \<le> ?k\<rbrakk> \<Longrightarrow> ?i \<le> ?k

goal (1 subgoal):
 1. card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms \<phi>)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card (nested_prop_atoms (\<phi>[Y]\<^sub>\<mu>)) \<le> card (nested_prop_atoms \<phi>)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma loc_upb_lm_2_2: "(c_fst n) mod 7 = 4 \<longrightarrow> c_snd (c_snd n) < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_fst n mod 7 = 4 \<longrightarrow> c_snd (c_snd n) < n
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c_fst n mod 7 = 4 \<Longrightarrow> c_snd (c_snd n) < n
[PROOF STEP]
assume A1: "c_fst n mod 7 = 4"
[PROOF STATE]
proof (state)
this:
c_fst n mod 7 = 4

goal (1 subgoal):
 1. c_fst n mod 7 = 4 \<Longrightarrow> c_snd (c_snd n) < n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c_fst n mod 7 = 4
[PROOF STEP]
have S0: "c_fst n mod 7 > 1"
[PROOF STATE]
proof (prove)
using this:
c_fst n mod 7 = 4

goal (1 subgoal):
 1. 1 < c_fst n mod 7
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 < c_fst n mod 7

goal (1 subgoal):
 1. c_fst n mod 7 = 4 \<Longrightarrow> c_snd (c_snd n) < n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
1 < c_fst n mod 7
[PROOF STEP]
have S1: "c_snd n < n"
[PROOF STATE]
proof (prove)
using this:
1 < c_fst n mod 7

goal (1 subgoal):
 1. c_snd n < n
[PROOF STEP]
by (rule loc_upb_lm_2)
[PROOF STATE]
proof (state)
this:
c_snd n < n

goal (1 subgoal):
 1. c_fst n mod 7 = 4 \<Longrightarrow> c_snd (c_snd n) < n
[PROOF STEP]
have S2: "c_snd (c_snd n) \<le>  c_snd n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_snd (c_snd n) \<le> c_snd n
[PROOF STEP]
by (rule c_snd_le_arg)
[PROOF STATE]
proof (state)
this:
c_snd (c_snd n) \<le> c_snd n

goal (1 subgoal):
 1. c_fst n mod 7 = 4 \<Longrightarrow> c_snd (c_snd n) < n
[PROOF STEP]
from S1 S2
[PROOF STATE]
proof (chain)
picking this:
c_snd n < n
c_snd (c_snd n) \<le> c_snd n
[PROOF STEP]
show "c_snd (c_snd n) < n"
[PROOF STATE]
proof (prove)
using this:
c_snd n < n
c_snd (c_snd n) \<le> c_snd n

goal (1 subgoal):
 1. c_snd (c_snd n) < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c_snd (c_snd n) < n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finished_star:
  assumes "finished r x"
  shows "r\<^sup>*\<^sup>* x y \<Longrightarrow> x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r\<^sup>*\<^sup>* x y \<Longrightarrow> x = y
[PROOF STEP]
proof (induction y rule: rtranclp_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = x
 2. \<And>y z. \<lbrakk>r\<^sup>*\<^sup>* x y; r y z; x = y\<rbrakk> \<Longrightarrow> x = z
[PROOF STEP]
case base
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. x = x
 2. \<And>y z. \<lbrakk>r\<^sup>*\<^sup>* x y; r y z; x = y\<rbrakk> \<Longrightarrow> x = z
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x = x

goal (1 subgoal):
 1. \<And>y z. \<lbrakk>r\<^sup>*\<^sup>* x y; r y z; x = y\<rbrakk> \<Longrightarrow> x = z
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>y z. \<lbrakk>r\<^sup>*\<^sup>* x y; r y z; x = y\<rbrakk> \<Longrightarrow> x = z
[PROOF STEP]
case (step y z)
[PROOF STATE]
proof (state)
this:
r\<^sup>*\<^sup>* x y
r y z
x = y

goal (1 subgoal):
 1. \<And>y z. \<lbrakk>r\<^sup>*\<^sup>* x y; r y z; x = y\<rbrakk> \<Longrightarrow> x = z
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
r\<^sup>*\<^sup>* x y
r y z
x = y
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
r\<^sup>*\<^sup>* x y
r y z
x = y

goal (1 subgoal):
 1. x = z
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
r\<^sup>*\<^sup>* x y
r y z
x = y
finished r x

goal (1 subgoal):
 1. x = z
[PROOF STEP]
by (auto simp: finished_def)
[PROOF STATE]
proof (state)
this:
x = z

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma aposs_tna_poss:"\<lbrakk>n \<noteq> \<infinity>; 0 < n\<rbrakk> \<Longrightarrow> 0 < tna n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n \<noteq> \<infinity>; 0 < n\<rbrakk> \<Longrightarrow> 0 < tna n
[PROOF STEP]
apply (subst tna_0[THEN sym],
       subst aless_zless[THEN sym, of "tna 0" "tna n"],
       frule aless_imp_le[of "0" "n"],
       frule apos_neq_minf[of "n"],
       simp add:ant_tna ant_0)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma zero_lowner_le_positiveI:
  fixes A :: "complex mat"
  assumes dA: "A \<in> carrier_mat n n" and le: "positive A"
  shows "0\<^sub>m n n \<le>\<^sub>L A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0\<^sub>m n n \<le>\<^sub>L A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
positive A

goal (1 subgoal):
 1. 0\<^sub>m n n \<le>\<^sub>L A
[PROOF STEP]
unfolding lowner_le_def
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
positive A

goal (1 subgoal):
 1. dim_row (0\<^sub>m n n) = dim_row A \<and> dim_col (0\<^sub>m n n) = dim_col A \<and> positive (A - 0\<^sub>m n n)
[PROOF STEP]
by (subgoal_tac "A - 0\<^sub>m n n = A", auto)


[STATEMENT]
lemma bag_bound_V_empty: "\<lbrakk> V = {}; t \<in> V\<^bsub>T\<^esub> \<rbrakk> \<Longrightarrow> card (bag t) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>V = {}; t \<in> V\<^bsub>T\<^esub>\<rbrakk> \<Longrightarrow> card (bag t) = 0
[PROOF STEP]
using bag_bound_V
[PROOF STATE]
proof (prove)
using this:
?t \<in> V\<^bsub>T\<^esub> \<Longrightarrow> card (bag ?t) \<le> card V

goal (1 subgoal):
 1. \<lbrakk>V = {}; t \<in> V\<^bsub>T\<^esub>\<rbrakk> \<Longrightarrow> card (bag t) = 0
[PROOF STEP]
by auto


[STATEMENT]
lemma bitlen_ge_iff_power:
  "w \<le> bitlen x \<longleftrightarrow> w \<le> 0 \<or> 2 ^ (nat w - 1) \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (w \<le> bitlen x) = (w \<le> 0 \<or> 2 ^ (nat w - 1) \<le> x)
[PROOF STEP]
unfolding bitlen_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (w \<le> int (floorlog 2 (nat x))) = (w \<le> 0 \<or> 2 ^ (nat w - 1) \<le> x)
[PROOF STEP]
by (auto simp flip: nat_le_iff intro: floorlog_geI dest: floorlog_geD)


[STATEMENT]
lemma (in semicategory) op_smc_is_idem_arr[smc_op_simps]:
  "f : \<mapsto>\<^sub>i\<^sub>d\<^sub>e\<^bsub>op_smc \<CC>\<^esub> b \<longleftrightarrow> f : \<mapsto>\<^sub>i\<^sub>d\<^sub>e\<^bsub>\<CC>\<^esub> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f : \<mapsto>\<^sub>i\<^sub>d\<^sub>e\<^bsub>op_smc \<CC>\<^esub> b = f : \<mapsto>\<^sub>i\<^sub>d\<^sub>e\<^bsub>\<CC>\<^esub> b
[PROOF STEP]
using op_smc_Comp
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?f : ?b \<mapsto>\<^bsub>\<CC>\<^esub> ?c; ?g : ?a \<mapsto>\<^bsub>\<CC>\<^esub> ?b\<rbrakk> \<Longrightarrow> ?g \<circ>\<^sub>A\<^bsub>op_smc \<CC>\<^esub> ?f = ?f \<circ>\<^sub>A\<^bsub>\<CC>\<^esub> ?g

goal (1 subgoal):
 1. f : \<mapsto>\<^sub>i\<^sub>d\<^sub>e\<^bsub>op_smc \<CC>\<^esub> b = f : \<mapsto>\<^sub>i\<^sub>d\<^sub>e\<^bsub>\<CC>\<^esub> b
[PROOF STEP]
unfolding is_idem_arr_def smc_op_simps
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?f : ?b \<mapsto>\<^bsub>\<CC>\<^esub> ?c; ?g : ?a \<mapsto>\<^bsub>\<CC>\<^esub> ?b\<rbrakk> \<Longrightarrow> ?g \<circ>\<^sub>A\<^bsub>op_smc \<CC>\<^esub> ?f = ?f \<circ>\<^sub>A\<^bsub>\<CC>\<^esub> ?g

goal (1 subgoal):
 1. (f : b \<mapsto>\<^bsub>\<CC>\<^esub> b \<and> f \<circ>\<^sub>A\<^bsub>op_smc \<CC>\<^esub> f = f) = (f : b \<mapsto>\<^bsub>\<CC>\<^esub> b \<and> f \<circ>\<^sub>A\<^bsub>\<CC>\<^esub> f = f)
[PROOF STEP]
by auto


[STATEMENT]
lemma nth_least_le_Max:
    assumes "finite A" "A \<noteq> {}" "enat n < esize A"
    shows "nth_least A n \<le> Max A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_least A n \<le> Max A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. nth_least A n \<le> Max A
[PROOF STEP]
have "nth_least A n \<le> nth_least A (card A - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_least A n \<le> nth_least A (card A - 1)
[PROOF STEP]
proof (rule nth_least_mono)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. enat (card A - 1) < esize A
 2. n \<le> card A - 1
[PROOF STEP]
show "enat (card A - 1) < esize A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enat (card A - 1) < esize A
[PROOF STEP]
by (metis Suc_diff_1 Suc_ile_eq assms(1) assms(2)
        card_eq_0_iff esize_set.simps(1) not_gr0 order_refl)
[PROOF STATE]
proof (state)
this:
enat (card A - 1) < esize A

goal (1 subgoal):
 1. n \<le> card A - 1
[PROOF STEP]
show "n \<le> card A - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<le> card A - 1
[PROOF STEP]
by (metis Suc_diff_1 Suc_leI antisym_conv assms(1) assms(3)
        enat_ord_simps(2) esize_set.simps(1) le_less neq_iff not_gr0)
[PROOF STATE]
proof (state)
this:
n \<le> card A - 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
nth_least A n \<le> nth_least A (card A - 1)

goal (1 subgoal):
 1. nth_least A n \<le> Max A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nth_least A n \<le> nth_least A (card A - 1)

goal (1 subgoal):
 1. nth_least A n \<le> Max A
[PROOF STEP]
have "\<dots> = Max A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_least A (card A - 1) = Max A
[PROOF STEP]
using nth_least_Max assms(1, 2)
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite ?A; ?A \<noteq> {}\<rbrakk> \<Longrightarrow> nth_least ?A (card ?A - 1) = Max ?A
finite A
A \<noteq> {}

goal (1 subgoal):
 1. nth_least A (card A - 1) = Max A
[PROOF STEP]
by this
[PROOF STATE]
proof (state)
this:
nth_least A (card A - 1) = Max A

goal (1 subgoal):
 1. nth_least A n \<le> Max A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nth_least A n \<le> Max A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
nth_least A n \<le> Max A

goal (1 subgoal):
 1. nth_least A n \<le> Max A
[PROOF STEP]
by this
[PROOF STATE]
proof (state)
this:
nth_least A n \<le> Max A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma index_swap_distinct:
  "distinct xs \<Longrightarrow> Suc n < length xs \<Longrightarrow>
  index (swap n xs) x =
  (if x = xs!n then Suc n else if x = xs!Suc n then n else index xs x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distinct xs; Suc n < length xs\<rbrakk> \<Longrightarrow> index (swap n xs) x = (if x = xs ! n then Suc n else if x = xs ! Suc n then n else index xs x)
[PROOF STEP]
by(auto simp add: swap_def index_swap_if_distinct)


[STATEMENT]
lemma sqmatrix_mult_1_left [simp]:
  "1 * (A::('a::{semiring_0,monoid_mult},'m::len) sqmatrix) = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<cdot> A = A
[PROOF STEP]
by (cases A, simp add: one_sqmatrix_def)


[STATEMENT]
lemma twice_field_differentiable_at_mult [intro]:
  assumes "f twice_field_differentiable_at x"
      and "g twice_field_differentiable_at x"
    shows "(\<lambda>x. f x * g x) twice_field_differentiable_at x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
obtain S S'
   where Df_on_S:  "f field_differentiable_on S" and x_int_S: "x \<in> interior S"
     and Dg_on_S': "g field_differentiable_on S'" and x_int_S': " x \<in> interior S'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>S S'. \<lbrakk>f field_differentiable_on S; x \<in> interior S; g field_differentiable_on S'; x \<in> interior S'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms twice_field_differentiable_at_def
[PROOF STATE]
proof (prove)
using this:
f twice_field_differentiable_at x
g twice_field_differentiable_at x
?f twice_field_differentiable_at ?x \<equiv> \<exists>S. ?f field_differentiable_on S \<and> ?x \<in> interior S \<and> deriv ?f field_differentiable at ?x

goal (1 subgoal):
 1. (\<And>S S'. \<lbrakk>f field_differentiable_on S; x \<in> interior S; g field_differentiable_on S'; x \<in> interior S'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f field_differentiable_on S
x \<in> interior S
g field_differentiable_on S'
x \<in> interior S'

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
let ?T = "interior (S \<inter> S')"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
have x_int_T: "x \<in> interior ?T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> interior (interior (S \<inter> S'))
[PROOF STEP]
by (simp add: x_int_S x_int_S')
[PROOF STATE]
proof (state)
this:
x \<in> interior (interior (S \<inter> S'))

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
have Df_on_T: "f field_differentiable_on ?T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f field_differentiable_on interior (S \<inter> S')
[PROOF STEP]
by (meson Df_on_S field_differentiable_on_subset inf_sup_ord(1) interior_subset)
[PROOF STATE]
proof (state)
this:
f field_differentiable_on interior (S \<inter> S')

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
have  Dg_on_fT: "g field_differentiable_on ?T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g field_differentiable_on interior (S \<inter> S')
[PROOF STEP]
by (meson Dg_on_S' field_differentiable_on_subset interior_subset le_infE)
[PROOF STATE]
proof (state)
this:
g field_differentiable_on interior (S \<inter> S')

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
have "(\<lambda>x. f x * g x) field_differentiable_on ?T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x * g x) field_differentiable_on interior (S \<inter> S')
[PROOF STEP]
unfolding field_differentiable_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>interior (S \<inter> S'). (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> interior (S \<inter> S') \<Longrightarrow> (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> interior (S \<inter> S') \<Longrightarrow> (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
assume x_in_T: "x \<in> ?T"
[PROOF STATE]
proof (state)
this:
x \<in> interior (S \<inter> S')

goal (1 subgoal):
 1. \<And>x. x \<in> interior (S \<inter> S') \<Longrightarrow> (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
have "f field_differentiable at x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f field_differentiable at x
[PROOF STEP]
by (metis x_in_T Df_on_T at_within_open field_differentiable_on_def open_interior)
[PROOF STATE]
proof (state)
this:
f field_differentiable at x

goal (1 subgoal):
 1. \<And>x. x \<in> interior (S \<inter> S') \<Longrightarrow> (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f field_differentiable at x

goal (1 subgoal):
 1. \<And>x. x \<in> interior (S \<inter> S') \<Longrightarrow> (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
have "g field_differentiable at x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g field_differentiable at x
[PROOF STEP]
by (metis x_in_T Dg_on_fT at_within_open field_differentiable_on_def open_interior)
[PROOF STATE]
proof (state)
this:
g field_differentiable at x

goal (1 subgoal):
 1. \<And>x. x \<in> interior (S \<inter> S') \<Longrightarrow> (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
f field_differentiable at x
g field_differentiable at x
[PROOF STEP]
have "(\<lambda>x. f x * g x) field_differentiable at x"
[PROOF STATE]
proof (prove)
using this:
f field_differentiable at x
g field_differentiable at x

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
by (simp add: field_differentiable_mult)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x * g x) field_differentiable at x

goal (1 subgoal):
 1. \<And>x. x \<in> interior (S \<inter> S') \<Longrightarrow> (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
show "(\<lambda>x. f x * g x) field_differentiable at x within ?T"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. f x * g x) field_differentiable at x

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
using field_differentiable_at_within
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. f x * g x) field_differentiable at x
?f field_differentiable at ?x \<Longrightarrow> ?f field_differentiable at ?x within ?S

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x * g x) field_differentiable at x within interior (S \<inter> S')

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x * g x) field_differentiable_on interior (S \<inter> S')

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x * g x) field_differentiable_on interior (S \<inter> S')

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
have "deriv (\<lambda>x. f x * g x) field_differentiable at x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. deriv (\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. deriv (\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
have "deriv (\<lambda>x. f x * g x) x = f x * deriv g x + deriv f x * g x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. deriv (\<lambda>x. f x * g x) x = f x * deriv g x + deriv f x * g x
[PROOF STEP]
by (simp add: assms once_field_differentiable_at)
[PROOF STATE]
proof (state)
this:
deriv (\<lambda>x. f x * g x) x = f x * deriv g x + deriv f x * g x

goal (1 subgoal):
 1. deriv (\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
deriv (\<lambda>x. f x * g x) x = f x * deriv g x + deriv f x * g x

goal (1 subgoal):
 1. deriv (\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
have "(\<lambda>x. f x * deriv g x + deriv f x * g x) field_differentiable at x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x * deriv g x + deriv f x * g x) field_differentiable at x
[PROOF STEP]
by (rule field_differentiable_add, simp_all add: field_differentiable_mult assms once_field_differentiable_at deriv_field_differentiable_at)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x * deriv g x + deriv f x * g x) field_differentiable at x

goal (1 subgoal):
 1. deriv (\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
deriv (\<lambda>x. f x * g x) x = f x * deriv g x + deriv f x * g x
(\<lambda>x. f x * deriv g x + deriv f x * g x) field_differentiable at x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
deriv (\<lambda>x. f x * g x) x = f x * deriv g x + deriv f x * g x
(\<lambda>x. f x * deriv g x + deriv f x * g x) field_differentiable at x

goal (1 subgoal):
 1. deriv (\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
using assms DERIV_deriv_iff_field_differentiable
            DERIV_cong_ev[of x x "deriv (\<lambda>x. f x * g x)" "\<lambda>x. f x * deriv g x + deriv f x * g x"]
[PROOF STATE]
proof (prove)
using this:
deriv (\<lambda>x. f x * g x) x = f x * deriv g x + deriv f x * g x
(\<lambda>x. f x * deriv g x + deriv f x * g x) field_differentiable at x
f twice_field_differentiable_at x
g twice_field_differentiable_at x
(?f has_field_derivative deriv ?f ?x) (at ?x) = (?f field_differentiable at ?x)
\<lbrakk>x = x; \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x * g x) x = f x * deriv g x + deriv f x * g x; ?u = ?v\<rbrakk> \<Longrightarrow> (deriv (\<lambda>x. f x * g x) has_field_derivative ?u) (at x) = ((\<lambda>x. f x * deriv g x + deriv f x * g x) has_field_derivative ?v) (at x)

goal (1 subgoal):
 1. deriv (\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
by (simp add: eventually_deriv_mult field_differentiable_def)
[PROOF STATE]
proof (state)
this:
deriv (\<lambda>x. f x * g x) field_differentiable at x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
deriv (\<lambda>x. f x * g x) field_differentiable at x

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. f x * g x) field_differentiable_on interior (S \<inter> S')
deriv (\<lambda>x. f x * g x) field_differentiable at x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. f x * g x) field_differentiable_on interior (S \<inter> S')
deriv (\<lambda>x. f x * g x) field_differentiable at x

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
using twice_field_differentiable_at_def x_int_T
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. f x * g x) field_differentiable_on interior (S \<inter> S')
deriv (\<lambda>x. f x * g x) field_differentiable at x
?f twice_field_differentiable_at ?x \<equiv> \<exists>S. ?f field_differentiable_on S \<and> ?x \<in> interior S \<and> deriv ?f field_differentiable at ?x
x \<in> interior (interior (S \<inter> S'))

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) twice_field_differentiable_at x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x * g x) twice_field_differentiable_at x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_word_upto:
  fixes a b :: "('l :: len) word"
  assumes "a \<le> b"
  shows "sorted (word_upto a b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted (word_upto a b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sorted (word_upto a b)
[PROOF STEP]
define m and n where \<open>m = unat a\<close> and \<open>n = Suc (unat b)\<close>
[PROOF STATE]
proof (state)
this:
m = unat a
n = Suc (unat b)

goal (1 subgoal):
 1. sorted (word_upto a b)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
m = unat a
n = Suc (unat b)

goal (1 subgoal):
 1. sorted (word_upto a b)
[PROOF STEP]
have \<open>sorted_wrt (\<lambda>x y. (word_of_nat x :: 'l word) \<le> word_of_nat y) [m..<n]\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_wrt (\<lambda>x y. word_of_nat x \<le> word_of_nat y) [m..<n]
[PROOF STEP]
proof (rule sorted_wrt_mono_rel [of _ \<open>(\<le>)\<close>])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x y. \<lbrakk>x \<in> set [m..<n]; y \<in> set [m..<n]; x \<le> y\<rbrakk> \<Longrightarrow> word_of_nat x \<le> word_of_nat y
 2. sorted [m..<n]
[PROOF STEP]
show \<open>sorted [m..<n]\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted [m..<n]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sorted [m..<n]

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set [m..<n]; y \<in> set [m..<n]; x \<le> y\<rbrakk> \<Longrightarrow> word_of_nat x \<le> word_of_nat y
[PROOF STEP]
fix r s
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set [m..<n]; y \<in> set [m..<n]; x \<le> y\<rbrakk> \<Longrightarrow> word_of_nat x \<le> word_of_nat y
[PROOF STEP]
assume \<open>r \<in> set [m..<n]\<close> \<open>s \<in> set [m..<n]\<close> \<open>r \<le> s\<close>
[PROOF STATE]
proof (state)
this:
r \<in> set [m..<n]
s \<in> set [m..<n]
r \<le> s

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set [m..<n]; y \<in> set [m..<n]; x \<le> y\<rbrakk> \<Longrightarrow> word_of_nat x \<le> word_of_nat y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
r \<in> set [m..<n]
s \<in> set [m..<n]
r \<le> s
[PROOF STEP]
have \<open>m \<le> r\<close> \<open>s < n\<close>
[PROOF STATE]
proof (prove)
using this:
r \<in> set [m..<n]
s \<in> set [m..<n]
r \<le> s

goal (1 subgoal):
 1. m \<le> r &&& s < n
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
m \<le> r
s < n

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set [m..<n]; y \<in> set [m..<n]; x \<le> y\<rbrakk> \<Longrightarrow> word_of_nat x \<le> word_of_nat y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m \<le> r
s < n
[PROOF STEP]
have \<open>take_bit LENGTH('l) s = s\<close>
[PROOF STATE]
proof (prove)
using this:
m \<le> r
s < n

goal (1 subgoal):
 1. take_bit LENGTH('l) s = s
[PROOF STEP]
by (auto simp add: m_def n_def less_Suc_eq_le unsigned_of_nat dest: le_unat_uoi)
[PROOF STATE]
proof (state)
this:
take_bit LENGTH('l) s = s

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> set [m..<n]; y \<in> set [m..<n]; x \<le> y\<rbrakk> \<Longrightarrow> word_of_nat x \<le> word_of_nat y
[PROOF STEP]
with \<open>r \<le> s\<close>
[PROOF STATE]
proof (chain)
picking this:
r \<le> s
take_bit LENGTH('l) s = s
[PROOF STEP]
show \<open>(word_of_nat r :: 'l word) \<le> word_of_nat s\<close>
[PROOF STATE]
proof (prove)
using this:
r \<le> s
take_bit LENGTH('l) s = s

goal (1 subgoal):
 1. word_of_nat r \<le> word_of_nat s
[PROOF STEP]
apply (simp add: of_nat_word_less_eq_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>r \<le> s; take_bit LENGTH('l) s = s\<rbrakk> \<Longrightarrow> take_bit LENGTH('l) r \<le> s
[PROOF STEP]
using take_bit_nat_less_eq_self
[PROOF STATE]
proof (prove)
using this:
take_bit ?n ?m \<le> ?m

goal (1 subgoal):
 1. \<lbrakk>r \<le> s; take_bit LENGTH('l) s = s\<rbrakk> \<Longrightarrow> take_bit LENGTH('l) r \<le> s
[PROOF STEP]
apply (rule order_trans)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>r \<le> s; take_bit LENGTH('l) s = s\<rbrakk> \<Longrightarrow> r \<le> s
[PROOF STEP]
apply assumption
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
word_of_nat r \<le> word_of_nat s

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sorted_wrt (\<lambda>x y. word_of_nat x \<le> word_of_nat y) [m..<n]

goal (1 subgoal):
 1. sorted (word_upto a b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
sorted_wrt (\<lambda>x y. word_of_nat x \<le> word_of_nat y) [m..<n]
[PROOF STEP]
have \<open>sorted (map word_of_nat [m..<n] :: 'l word list)\<close>
[PROOF STATE]
proof (prove)
using this:
sorted_wrt (\<lambda>x y. word_of_nat x \<le> word_of_nat y) [m..<n]

goal (1 subgoal):
 1. sorted (map word_of_nat [m..<n])
[PROOF STEP]
by (simp add: sorted_map)
[PROOF STATE]
proof (state)
this:
sorted (map word_of_nat [m..<n])

goal (1 subgoal):
 1. sorted (word_upto a b)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
m = unat a
n = Suc (unat b)
sorted (map word_of_nat [m..<n])
[PROOF STEP]
have \<open>sorted (map of_nat [unat a..<Suc (unat b)] :: 'l word list)\<close>
[PROOF STATE]
proof (prove)
using this:
m = unat a
n = Suc (unat b)
sorted (map word_of_nat [m..<n])

goal (1 subgoal):
 1. sorted (map word_of_nat [unat a..<Suc (unat b)])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sorted (map word_of_nat [unat a..<Suc (unat b)])

goal (1 subgoal):
 1. sorted (word_upto a b)
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
a \<le> b
sorted (map word_of_nat [unat a..<Suc (unat b)])
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a \<le> b
sorted (map word_of_nat [unat a..<Suc (unat b)])

goal (1 subgoal):
 1. sorted (word_upto a b)
[PROOF STEP]
by (simp only: word_upto_alt)
[PROOF STATE]
proof (state)
this:
sorted (word_upto a b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ereal_uminus_eq_iff[simp]:
  fixes a b :: ereal
  shows "-a = -b \<longleftrightarrow> a = b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- a = - b) = (a = b)
[PROOF STEP]
by (cases rule: ereal2_cases[of a b]) simp_all


[STATEMENT]
lemma mset_merge_all:
  "mset (merge_all xss) = mset_mset xss"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (merge_all xss) = mset_mset xss
[PROOF STEP]
by(induction xss rule: merge_all.induct) (auto simp: mset_merge mset_merge_adj)