text:
[STATEMENT]
lemma card_bijections:
  assumes "finite A" "finite B"
  assumes "card A = card B"
  shows "card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)
[PROOF STEP]
have "card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = card {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = card {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B}
[PROOF STEP]
using \<open>finite A\<close> \<open>card A = card B\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
card A = card B

goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = card {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B}
[PROOF STEP]
by (metis bij_betw_implies_surj_on_and_card_eq)
[PROOF STATE]
proof (state)
this:
card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = card {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B}

goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = card {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B}

goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)
[PROOF STEP]
have "\<dots> = fact (card B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} = fact (card B)
[PROOF STEP]
using \<open>finite A\<close> \<open>finite B\<close> \<open>card A = card B\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
card A = card B

goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} = fact (card B)
[PROOF STEP]
by (simp add: card_extensional_funcset_surj_on)
[PROOF STATE]
proof (state)
this:
card {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} = fact (card B)

goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)

goal (1 subgoal):
 1. card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} = fact (card B)

goal:
No subgoals!
[PROOF STEP]
qed

lm_label:
1. YES
2. YES


text:
[STATEMENT]
lemma odd_square_mod_4:
  fixes x :: int
  assumes "odd x"
  shows "[x^2 = 1] (mod 4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
have "x^2 - 1 = (x - 1) * (x + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x\<^sup>2 - 1 = (x - 1) * (x + 1)
[PROOF STEP]
by (simp add: ring_distribs power2_eq_square)
[PROOF STATE]
proof (state)
this:
x\<^sup>2 - 1 = (x - 1) * (x + 1)

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x\<^sup>2 - 1 = (x - 1) * (x + 1)

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
from \<open>odd x\<close>
[PROOF STATE]
proof (chain)
picking this:
odd x
[PROOF STEP]
have "2 dvd x - 1" and "2 dvd x + 1"
[PROOF STATE]
proof (prove)
using this:
odd x

goal (1 subgoal):
 1. even (x - 1) &&& even (x + 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
even (x - 1)
even (x + 1)

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x\<^sup>2 - 1 = (x - 1) * (x + 1)
even (x - 1)
even (x + 1)
[PROOF STEP]
have "4 dvd x^2 - 1"
[PROOF STATE]
proof (prove)
using this:
x\<^sup>2 - 1 = (x - 1) * (x + 1)
even (x - 1)
even (x + 1)

goal (1 subgoal):
 1. 4 dvd x\<^sup>2 - 1
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
4 dvd x\<^sup>2 - 1

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
4 dvd x\<^sup>2 - 1

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
by (simp add: cong_iff_dvd_diff)
[PROOF STATE]
proof (state)
this:
[x\<^sup>2 = 1] (mod 4)

goal:
No subgoals!
[PROOF STEP]
qed


text:
[STATEMENT]
lemma tan_30: "tan (pi / 6) = 1 / sqrt 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan (pi / 6) = 1 / sqrt 3
[PROOF STEP]
unfolding tan_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (pi / 6) / cos (pi / 6) = 1 / sqrt 3
[PROOF STEP]
by (simp add: sin_30 cos_30)


text:
[STATEMENT]
theorem prob_eq:
  defines "x \<equiv> l / d"
  shows   "\<P>((x,\<phi>) in Buffon. needle l x \<phi> \<inter> {-d/2, d/2} \<noteq> {}) =
             (if l \<le> d then
                2 / pi * x
              else
                2 / pi * (x - sqrt (x\<^sup>2 - 1) + arccos (1 / x)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {(x, \<phi>). (x, \<phi>) \<in> space local.Buffon \<and> needle l x \<phi> \<inter> {- d / 2, d / 2} \<noteq> {}} = (if l \<le> d then 2 / pi * x else 2 / pi * (x - sqrt (x\<^sup>2 - 1) + arccos (1 / x)))
[PROOF STEP]
using prob_short prob_long
[PROOF STATE]
proof (prove)
using this:
l \<le> d \<Longrightarrow> prob {(x, \<phi>). (x, \<phi>) \<in> space local.Buffon \<and> needle l x \<phi> \<inter> {- d / 2, d / 2} \<noteq> {}} = 2 * l / (d * pi)
d \<le> l \<Longrightarrow> prob {(x, \<phi>). (x, \<phi>) \<in> space local.Buffon \<and> needle l x \<phi> \<inter> {- d / 2, d / 2} \<noteq> {}} = 2 / pi * (l / d - sqrt ((l / d)\<^sup>2 - 1) + arccos (d / l))

goal (1 subgoal):
 1. prob {(x, \<phi>). (x, \<phi>) \<in> space local.Buffon \<and> needle l x \<phi> \<inter> {- d / 2, d / 2} \<noteq> {}} = (if l \<le> d then 2 / pi * x else 2 / pi * (x - sqrt (x\<^sup>2 - 1) + arccos (1 / x)))
[PROOF STEP]
unfolding x_def
[PROOF STATE]
proof (prove)
using this:
l \<le> d \<Longrightarrow> prob {(x, \<phi>). (x, \<phi>) \<in> space local.Buffon \<and> needle l x \<phi> \<inter> {- d / 2, d / 2} \<noteq> {}} = 2 * l / (d * pi)
d \<le> l \<Longrightarrow> prob {(x, \<phi>). (x, \<phi>) \<in> space local.Buffon \<and> needle l x \<phi> \<inter> {- d / 2, d / 2} \<noteq> {}} = 2 / pi * (l / d - sqrt ((l / d)\<^sup>2 - 1) + arccos (d / l))

goal (1 subgoal):
 1. prob {(x, \<phi>). (x, \<phi>) \<in> space local.Buffon \<and> needle l x \<phi> \<inter> {- d / 2, d / 2} \<noteq> {}} = (if l \<le> d then 2 / pi * (l / d) else 2 / pi * (l / d - sqrt ((l / d)\<^sup>2 - 1) + arccos (1 / (l / d))))
[PROOF STEP]
by auto


text:
[STATEMENT]
theorem lucas_theorem:
  fixes n k d::nat
assumes "n < p ^ (Suc d)"
assumes "k < p ^ (Suc d)"
assumes "prime p"
shows "(n choose k) mod p = (\<Prod>i\<le>d. ((nth_digit_general n i p) choose (nth_digit_general k i p))) mod p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
n < p ^ Suc d
k < p ^ Suc d
prime p

goal (1 subgoal):
 1. (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
proof (induct d arbitrary: n k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n k. \<lbrakk>n < p ^ Suc 0; k < p ^ Suc 0; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>0. nth_digit_general n i p choose nth_digit_general k i p) mod p
 2. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
n < p ^ Suc 0
k < p ^ Suc 0
prime p

goal (2 subgoals):
 1. \<And>n k. \<lbrakk>n < p ^ Suc 0; k < p ^ Suc 0; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>0. nth_digit_general n i p choose nth_digit_general k i p) mod p
 2. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
n < p ^ Suc 0
k < p ^ Suc 0
prime p

goal (1 subgoal):
 1. (n choose k) mod p = (\<Prod>i\<le>0. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
using nth_digit_general_def assms
[PROOF STATE]
proof (prove)
using this:
n < p ^ Suc 0
k < p ^ Suc 0
prime p
nth_digit_general ?num ?i ?base = ?num div ?base ^ ?i mod ?base
n < p ^ Suc d
k < p ^ Suc d
prime p

goal (1 subgoal):
 1. (n choose k) mod p = (\<Prod>i\<le>0. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(n choose k) mod p = (\<Prod>i\<le>0. nth_digit_general n i p choose nth_digit_general k i p) mod p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
case (Suc d)
  \<comment> \<open>Representation Variables\<close>
[PROOF STATE]
proof (state)
this:
\<lbrakk>?n < p ^ Suc d; ?k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (?n choose ?k) mod p = (\<Prod>i\<le>d. nth_digit_general ?n i p choose nth_digit_general ?k i p) mod p
n < p ^ Suc (Suc d)
k < p ^ Suc (Suc d)
prime p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
let ?N = "n div p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
let ?K = "k div p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
let ?nr = "n mod p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
let ?kr = "k mod p"
  \<comment> \<open>Required assumption facts\<close>
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
have Mlessthan: "?N < p ^ (Suc d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n div p < p ^ Suc d
[PROOF STEP]
using less_mult_imp_div_less power_Suc2 assms(3) prime_ge_2_nat Suc.prems(1)
[PROOF STATE]
proof (prove)
using this:
?m < ?i * ?n \<Longrightarrow> ?m div ?n < ?i
?a ^ Suc ?n = ?a ^ ?n * ?a
prime p
prime ?p \<Longrightarrow> 2 \<le> ?p
n < p ^ Suc (Suc d)

goal (1 subgoal):
 1. n div p < p ^ Suc d
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
n div p < p ^ Suc d

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
have Nlessthan: "?K < p ^ (Suc d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k div p < p ^ Suc d
[PROOF STEP]
using less_mult_imp_div_less power_Suc2 prime_ge_2_nat Suc.prems(2) assms(3)
[PROOF STATE]
proof (prove)
using this:
?m < ?i * ?n \<Longrightarrow> ?m div ?n < ?i
?a ^ Suc ?n = ?a ^ ?n * ?a
prime ?p \<Longrightarrow> 2 \<le> ?p
k < p ^ Suc (Suc d)
prime p

goal (1 subgoal):
 1. k div p < p ^ Suc d
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
k div p < p ^ Suc d

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
have shift_bounds_fact: "(\<Prod>i=(Suc 0)..(Suc (d )). ((nth_digit_general n i p) choose (nth_digit_general k i p))) =
                            (\<Prod>i=0..(d).  (nth_digit_general n (Suc i) p) choose (nth_digit_general k (Suc i) p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i = Suc 0..Suc d. nth_digit_general n i p choose nth_digit_general k i p) = (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p)
[PROOF STEP]
using prod.shift_bounds_cl_Suc_ivl
[PROOF STATE]
proof (prove)
using this:
prod ?g {Suc ?m..Suc ?n} = (\<Prod>i = ?m..?n. ?g (Suc i))

goal (1 subgoal):
 1. (\<Prod>i = Suc 0..Suc d. nth_digit_general n i p choose nth_digit_general k i p) = (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p)
[PROOF STEP]
by blast \<comment> \<open>Product manipulation helper fact\<close>
[PROOF STATE]
proof (state)
this:
(\<Prod>i = Suc 0..Suc d. nth_digit_general n i p choose nth_digit_general k i p) = (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p)

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
have "(n choose k ) mod p = ((?N choose ?K) * (?nr choose ?kr)) mod p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n choose k) mod p = (n div p choose k div p) * (n mod p choose k mod p) mod p
[PROOF STEP]
using lucas_corollary assms(3)
[PROOF STATE]
proof (prove)
using this:
prime ?p \<Longrightarrow> (?n choose ?k) mod ?p = (?n div ?p choose ?k div ?p) * (?n mod ?p choose ?k mod ?p) mod ?p
prime p

goal (1 subgoal):
 1. (n choose k) mod p = (n div p choose k div p) * (n mod p choose k mod p) mod p
[PROOF STEP]
by blast \<comment> \<open>Application of corollary\<close>
[PROOF STATE]
proof (state)
this:
(n choose k) mod p = (n div p choose k div p) * (n mod p choose k mod p) mod p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(n choose k) mod p = (n div p choose k div p) * (n mod p choose k mod p) mod p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
have "...= ((\<Prod>i\<le>d. ((nth_digit_general ?N i p) choose (nth_digit_general ?K i p))) * (?nr choose ?kr)) mod p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n div p choose k div p) * (n mod p choose k mod p) mod p = (\<Prod>i\<le>d. nth_digit_general (n div p) i p choose nth_digit_general (k div p) i p) * (n mod p choose k mod p) mod p
[PROOF STEP]
using Mlessthan Nlessthan Suc.hyps mod_mult_cong assms(3)
[PROOF STATE]
proof (prove)
using this:
n div p < p ^ Suc d
k div p < p ^ Suc d
\<lbrakk>?n < p ^ Suc d; ?k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (?n choose ?k) mod p = (\<Prod>i\<le>d. nth_digit_general ?n i p choose nth_digit_general ?k i p) mod p
\<lbrakk>?a mod ?c = ?a' mod ?c; ?b mod ?c = ?b' mod ?c\<rbrakk> \<Longrightarrow> ?a * ?b mod ?c = ?a' * ?b' mod ?c
prime p

goal (1 subgoal):
 1. (n div p choose k div p) * (n mod p choose k mod p) mod p = (\<Prod>i\<le>d. nth_digit_general (n div p) i p choose nth_digit_general (k div p) i p) * (n mod p choose k mod p) mod p
[PROOF STEP]
by blast \<comment> \<open>Using Inductive Hypothesis\<close>
  \<comment> \<open>Product manipulation steps\<close>
[PROOF STATE]
proof (state)
this:
(n div p choose k div p) * (n mod p choose k mod p) mod p = (\<Prod>i\<le>d. nth_digit_general (n div p) i p choose nth_digit_general (k div p) i p) * (n mod p choose k mod p) mod p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(n div p choose k div p) * (n mod p choose k mod p) mod p = (\<Prod>i\<le>d. nth_digit_general (n div p) i p choose nth_digit_general (k div p) i p) * (n mod p choose k mod p) mod p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
have "... = ((\<Prod>i=0..(d). (nth_digit_general n (Suc i) p) choose (nth_digit_general k (Suc i) p)) * (?nr choose ?kr)) mod p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i\<le>d. nth_digit_general (n div p) i p choose nth_digit_general (k div p) i p) * (n mod p choose k mod p) mod p = (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p) * (n mod p choose k mod p) mod p
[PROOF STEP]
using  atMost_atLeast0 nth_digit_general_def div_mult2_eq
[PROOF STATE]
proof (prove)
using this:
{..?n} = {0..?n}
nth_digit_general ?num ?i ?base = ?num div ?base ^ ?i mod ?base
?m div (?n * ?q) = ?m div ?n div ?q

goal (1 subgoal):
 1. (\<Prod>i\<le>d. nth_digit_general (n div p) i p choose nth_digit_general (k div p) i p) * (n mod p choose k mod p) mod p = (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p) * (n mod p choose k mod p) mod p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<le>d. nth_digit_general (n div p) i p choose nth_digit_general (k div p) i p) * (n mod p choose k mod p) mod p = (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p) * (n mod p choose k mod p) mod p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<le>d. nth_digit_general (n div p) i p choose nth_digit_general (k div p) i p) * (n mod p choose k mod p) mod p = (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p) * (n mod p choose k mod p) mod p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
have "... = ((\<Prod>i=1..(d+1). (nth_digit_general n i p) choose (nth_digit_general k i p)) *
                            ((nth_digit_general n 0 p) choose (nth_digit_general k 0 p))) mod p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p) * (n mod p choose k mod p) mod p = (\<Prod>i = 1..d + 1. nth_digit_general n i p choose nth_digit_general k i p) * (nth_digit_general n 0 p choose nth_digit_general k 0 p) mod p
[PROOF STEP]
using nth_digit_general_def shift_bounds_fact
[PROOF STATE]
proof (prove)
using this:
nth_digit_general ?num ?i ?base = ?num div ?base ^ ?i mod ?base
(\<Prod>i = Suc 0..Suc d. nth_digit_general n i p choose nth_digit_general k i p) = (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p)

goal (1 subgoal):
 1. (\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p) * (n mod p choose k mod p) mod p = (\<Prod>i = 1..d + 1. nth_digit_general n i p choose nth_digit_general k i p) * (nth_digit_general n 0 p choose nth_digit_general k 0 p) mod p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Prod>i = 0..d. nth_digit_general n (Suc i) p choose nth_digit_general k (Suc i) p) * (n mod p choose k mod p) mod p = (\<Prod>i = 1..d + 1. nth_digit_general n i p choose nth_digit_general k i p) * (nth_digit_general n 0 p choose nth_digit_general k 0 p) mod p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(n choose k) mod p = (\<Prod>i = 1..d + 1. nth_digit_general n i p choose nth_digit_general k i p) * (nth_digit_general n 0 p choose nth_digit_general k 0 p) mod p
[PROOF STEP]
have "(n choose k ) mod p = ((\<Prod>i=0..(d+1). (nth_digit_general n i p) choose (nth_digit_general k i p))) mod p"
[PROOF STATE]
proof (prove)
using this:
(n choose k) mod p = (\<Prod>i = 1..d + 1. nth_digit_general n i p choose nth_digit_general k i p) * (nth_digit_general n 0 p choose nth_digit_general k 0 p) mod p

goal (1 subgoal):
 1. (n choose k) mod p = (\<Prod>i = 0..d + 1. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
using One_nat_def atMost_atLeast0 mult.commute prod.atLeast1_atMost_eq prod.atMost_shift
[PROOF STATE]
proof (prove)
using this:
(n choose k) mod p = (\<Prod>i = 1..d + 1. nth_digit_general n i p choose nth_digit_general k i p) * (nth_digit_general n 0 p choose nth_digit_general k 0 p) mod p
1 = Suc 0
{..?n} = {0..?n}
?a * ?b = ?b * ?a
prod ?g {Suc 0..?n} = (\<Prod>k<?n. ?g (Suc k))
prod ?g {..?n} = ?g 0 * (\<Prod>i<?n. ?g (Suc i))

goal (1 subgoal):
 1. (n choose k) mod p = (\<Prod>i = 0..d + 1. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
by (smt Suc_eq_plus1 shift_bounds_fact)
[PROOF STATE]
proof (state)
this:
(n choose k) mod p = (\<Prod>i = 0..d + 1. nth_digit_general n i p choose nth_digit_general k i p) mod p

goal (1 subgoal):
 1. \<And>d n k. \<lbrakk>\<And>n k. \<lbrakk>n < p ^ Suc d; k < p ^ Suc d; prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>d. nth_digit_general n i p choose nth_digit_general k i p) mod p; n < p ^ Suc (Suc d); k < p ^ Suc (Suc d); prime p\<rbrakk> \<Longrightarrow> (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
(n choose k) mod p = (\<Prod>i = 0..d + 1. nth_digit_general n i p choose nth_digit_general k i p) mod p

goal (1 subgoal):
 1. (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
using Suc_eq_plus1 atMost_atLeast0
[PROOF STATE]
proof (prove)
using this:
(n choose k) mod p = (\<Prod>i = 0..d + 1. nth_digit_general n i p choose nth_digit_general k i p) mod p
Suc ?n = ?n + 1
{..?n} = {0..?n}

goal (1 subgoal):
 1. (n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(n choose k) mod p = (\<Prod>i\<le>Suc d. nth_digit_general n i p choose nth_digit_general k i p) mod p

goal:
No subgoals!
[PROOF STEP]
qed


text:
[STATEMENT]
lemma convex_on_mean_ineq:
  fixes f::"real \<Rightarrow> real"
  assumes "convex_on A f" "x \<in> A" "y \<in> A"
  shows "f ((x+y)/2) \<le> (f x + f y) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ((x + y) / 2) \<le> (f x + f y) / 2
[PROOF STEP]
using convex_onD[OF assms(1), of "1/2" x y]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> 1 / 2; 1 / 2 \<le> 1; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> f ((1 - 1 / 2) *\<^sub>R x + (1 / 2) *\<^sub>R y) \<le> (1 - 1 / 2) * f x + 1 / 2 * f y

goal (1 subgoal):
 1. f ((x + y) / 2) \<le> (f x + f y) / 2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> 1 / 2; 1 / 2 \<le> 1; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> f ((1 - 1 / 2) *\<^sub>R x + (1 / 2) *\<^sub>R y) \<le> (1 - 1 / 2) * f x + 1 / 2 * f y
convex_on A f
x \<in> A
y \<in> A

goal (1 subgoal):
 1. f ((x + y) / 2) \<le> (f x + f y) / 2
[PROOF STEP]
by (auto simp add: divide_simps)


text:
[STATEMENT]
lemma card_bijections_domain_permutation_eq_1:
  assumes "finite A" "finite B"
  assumes "card A = card B"
  shows "card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B) = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B) = 1
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
finite A
finite B
card A = card B
[PROOF STEP]
have "{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B
    = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // domain_permutation A B"
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
card A = card B

goal (1 subgoal):
 1. {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // domain_permutation A B
[PROOF STEP]
by (metis (no_types, lifting) PiE_cong bij_betw_implies_surj_on_and_card_eq)
[PROOF STATE]
proof (state)
this:
{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // domain_permutation A B

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B) = 1
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // domain_permutation A B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // domain_permutation A B

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B) = 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // domain_permutation A B
finite A
finite B
card A = card B

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B) = 1
[PROOF STEP]
by (simp add: card_surjective_functions_domain_permutation)
[PROOF STATE]
proof (state)
this:
card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // domain_permutation A B) = 1

goal:
No subgoals!
[PROOF STEP]
qed


text:
[STATEMENT]
theorem ord_modulus_mult_coprime:
  fixes x :: nat
  assumes "coprime m n"
  shows   "ord (m * n) x = lcm (ord m x) (ord n x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord (m * n) x = lcm (ord m x) (ord n x)
[PROOF STEP]
proof (intro dvd_antisym)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ord (m * n) x dvd lcm (ord m x) (ord n x)
 2. lcm (ord m x) (ord n x) dvd ord (m * n) x
[PROOF STEP]
have "[x ^ lcm (ord m x) (ord n x) = 1] (mod (m * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ lcm (ord m x) (ord n x) = 1] (mod m * n)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
coprime m n

goal (1 subgoal):
 1. [x ^ lcm (ord m x) (ord n x) = 1] (mod m * n)
[PROOF STEP]
by (intro coprime_cong_mult_nat assms) (auto simp: ord_divides')
[PROOF STATE]
proof (state)
this:
[x ^ lcm (ord m x) (ord n x) = 1] (mod m * n)

goal (2 subgoals):
 1. ord (m * n) x dvd lcm (ord m x) (ord n x)
 2. lcm (ord m x) (ord n x) dvd ord (m * n) x
[PROOF STEP]
thus "ord (m * n) x dvd lcm (ord m x) (ord n x)"
[PROOF STATE]
proof (prove)
using this:
[x ^ lcm (ord m x) (ord n x) = 1] (mod m * n)

goal (1 subgoal):
 1. ord (m * n) x dvd lcm (ord m x) (ord n x)
[PROOF STEP]
by (simp add: ord_divides')
[PROOF STATE]
proof (state)
this:
ord (m * n) x dvd lcm (ord m x) (ord n x)

goal (1 subgoal):
 1. lcm (ord m x) (ord n x) dvd ord (m * n) x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lcm (ord m x) (ord n x) dvd ord (m * n) x
[PROOF STEP]
show "lcm (ord m x) (ord n x) dvd ord (m * n) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lcm (ord m x) (ord n x) dvd ord (m * n) x
[PROOF STEP]
proof (intro lcm_least)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ord m x dvd ord (m * n) x
 2. ord n x dvd ord (m * n) x
[PROOF STEP]
show "ord m x dvd ord (m * n) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord m x dvd ord (m * n) x
[PROOF STEP]
using cong_modulus_mult_nat[of "x ^ ord (m * n) x" 1 m n] assms
[PROOF STATE]
proof (prove)
using this:
[x ^ ord (m * n) x = 1] (mod m * n) \<Longrightarrow> [x ^ ord (m * n) x = 1] (mod m)
coprime m n

goal (1 subgoal):
 1. ord m x dvd ord (m * n) x
[PROOF STEP]
by (simp add: ord_divides')
[PROOF STATE]
proof (state)
this:
ord m x dvd ord (m * n) x

goal (1 subgoal):
 1. ord n x dvd ord (m * n) x
[PROOF STEP]
show "ord n x dvd ord (m * n) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord n x dvd ord (m * n) x
[PROOF STEP]
using cong_modulus_mult_nat[of "x ^ ord (m * n) x" 1 n m] assms
[PROOF STATE]
proof (prove)
using this:
[x ^ ord (m * n) x = 1] (mod n * m) \<Longrightarrow> [x ^ ord (m * n) x = 1] (mod n)
coprime m n

goal (1 subgoal):
 1. ord n x dvd ord (m * n) x
[PROOF STEP]
by (simp add: ord_divides' mult.commute)
[PROOF STATE]
proof (state)
this:
ord n x dvd ord (m * n) x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
lcm (ord m x) (ord n x) dvd ord (m * n) x

goal:
No subgoals!
[PROOF STEP]
qed


text:
[STATEMENT]
lemma l2norm_triangle:
  assumes "f square_integrable S" "g square_integrable S"
  shows "l2norm S (\<lambda>x. f x + g x) \<le> l2norm S f + l2norm S g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x + g x) \<le> l2norm S f + l2norm S g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x + g x) \<le> l2norm S f + l2norm S g
[PROOF STEP]
have "f \<in> lspace (lebesgue_on S) 2" "g \<in> lspace (lebesgue_on S) 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> lspace (lebesgue_on S) 2 &&& g \<in> lspace (lebesgue_on S) 2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f square_integrable S
g square_integrable S

goal (1 subgoal):
 1. f \<in> lspace (lebesgue_on S) 2 &&& g \<in> lspace (lebesgue_on S) 2
[PROOF STEP]
by (simp_all add: square_integrable_imp_lspace)
[PROOF STATE]
proof (state)
this:
f \<in> lspace (lebesgue_on S) 2
g \<in> lspace (lebesgue_on S) 2

goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x + g x) \<le> l2norm S f + l2norm S g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f \<in> lspace (lebesgue_on S) 2
g \<in> lspace (lebesgue_on S) 2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f \<in> lspace (lebesgue_on S) 2
g \<in> lspace (lebesgue_on S) 2

goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x + g x) \<le> l2norm S f + l2norm S g
[PROOF STEP]
using lnorm_triangle [of f 2 "lebesgue_on S"]
[PROOF STATE]
proof (prove)
using this:
f \<in> lspace (lebesgue_on S) 2
g \<in> lspace (lebesgue_on S) 2
\<lbrakk>f \<in> lspace (lebesgue_on S) (ennreal 2); ?g \<in> lspace (lebesgue_on S) (ennreal 2); 1 \<le> 2\<rbrakk> \<Longrightarrow> lnorm (lebesgue_on S) 2 (\<lambda>x. f x + ?g x) \<le> lnorm (lebesgue_on S) 2 f + lnorm (lebesgue_on S) 2 ?g

goal (1 subgoal):
 1. l2norm S (\<lambda>x. f x + g x) \<le> l2norm S f + l2norm S g
[PROOF STEP]
by (simp add: l2norm_lnorm)
[PROOF STATE]
proof (state)
this:
l2norm S (\<lambda>x. f x + g x) \<le> l2norm S f + l2norm S g

goal:
No subgoals!
[PROOF STEP]
qed


text:
[STATEMENT]
lemma dist_eq_on_real_2_vec:
  fixes a b :: "real ^ 2"
  shows "dist a b = sqrt ((a $ 1 - b $ 1) ^ 2 + (a $ 2 - b $ 2) ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist a b = sqrt ((a $ 1 - b $ 1)\<^sup>2 + (a $ 2 - b $ 2)\<^sup>2)
[PROOF STEP]
unfolding dist_norm norm_eq_on_real_2_vec
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (((a - b) $ 1)\<^sup>2 + ((a - b) $ 2)\<^sup>2) = sqrt ((a $ 1 - b $ 1)\<^sup>2 + (a $ 2 - b $ 2)\<^sup>2)
[PROOF STEP]
by simp


text:
[STATEMENT]
lemma dist_half_times2:
  fixes a :: "'a :: real_normed_vector"
  shows "dist ((1 / 2) *\<^sub>R (a + b)) x * 2 = dist (a+b) (2 *\<^sub>R x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist ((1 / 2) *\<^sub>R (a + b)) x * 2 = dist (a + b) (2 *\<^sub>R x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dist ((1 / 2) *\<^sub>R (a + b)) x * 2 = dist (a + b) (2 *\<^sub>R x)
[PROOF STEP]
have "norm ((1 / 2) *\<^sub>R (a + b) - x) * 2 = norm (2 *\<^sub>R ((1 / 2) *\<^sub>R (a + b) - x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm ((1 / 2) *\<^sub>R (a + b) - x) * 2 = norm (2 *\<^sub>R ((1 / 2) *\<^sub>R (a + b) - x))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
norm ((1 / 2) *\<^sub>R (a + b) - x) * 2 = norm (2 *\<^sub>R ((1 / 2) *\<^sub>R (a + b) - x))

goal (1 subgoal):
 1. dist ((1 / 2) *\<^sub>R (a + b)) x * 2 = dist (a + b) (2 *\<^sub>R x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm ((1 / 2) *\<^sub>R (a + b) - x) * 2 = norm (2 *\<^sub>R ((1 / 2) *\<^sub>R (a + b) - x))

goal (1 subgoal):
 1. dist ((1 / 2) *\<^sub>R (a + b)) x * 2 = dist (a + b) (2 *\<^sub>R x)
[PROOF STEP]
have "... = norm ((a + b) - 2 *\<^sub>R x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (2 *\<^sub>R ((1 / 2) *\<^sub>R (a + b) - x)) = norm (a + b - 2 *\<^sub>R x)
[PROOF STEP]
by (simp add: real_vector.scale_right_diff_distrib)
[PROOF STATE]
proof (state)
this:
norm (2 *\<^sub>R ((1 / 2) *\<^sub>R (a + b) - x)) = norm (a + b - 2 *\<^sub>R x)

goal (1 subgoal):
 1. dist ((1 / 2) *\<^sub>R (a + b)) x * 2 = dist (a + b) (2 *\<^sub>R x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm ((1 / 2) *\<^sub>R (a + b) - x) * 2 = norm (a + b - 2 *\<^sub>R x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm ((1 / 2) *\<^sub>R (a + b) - x) * 2 = norm (a + b - 2 *\<^sub>R x)

goal (1 subgoal):
 1. dist ((1 / 2) *\<^sub>R (a + b)) x * 2 = dist (a + b) (2 *\<^sub>R x)
[PROOF STEP]
by (simp only: dist_norm)
[PROOF STATE]
proof (state)
this:
dist ((1 / 2) *\<^sub>R (a + b)) x * 2 = dist (a + b) (2 *\<^sub>R x)

goal:
No subgoals!
[PROOF STEP]
qed