[STATEMENT]
theorem euler_criterion: assumes "prime p" "2 < p"
  shows "[(Legendre a p) = a ^ ((p - 1) div 2)] (mod p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
proof (cases "[a = 0] (mod p)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [a = 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
 2. [a \<noteq> 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
[a = 0] (mod int p)

goal (2 subgoals):
 1. [a = 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
 2. [a \<noteq> 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[a = 0] (mod int p)
[PROOF STEP]
have "[a ^ ((p - 1) div 2) = 0 ^ ((p - 1) div 2)] (mod p)"
[PROOF STATE]
proof (prove)
using this:
[a = 0] (mod int p)

goal (1 subgoal):
 1. [a ^ ((p - 1) div 2) = 0 ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
using cong_pow
[PROOF STATE]
proof (prove)
using this:
[a = 0] (mod int p)
[?b = ?c] (mod ?a) \<Longrightarrow> [?b ^ ?n = ?c ^ ?n] (mod ?a)

goal (1 subgoal):
 1. [a ^ ((p - 1) div 2) = 0 ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[a ^ ((p - 1) div 2) = 0 ^ ((p - 1) div 2)] (mod int p)

goal (2 subgoals):
 1. [a = 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
 2. [a \<noteq> 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
[a ^ ((p - 1) div 2) = 0 ^ ((p - 1) div 2)] (mod int p)

goal (2 subgoals):
 1. [a = 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
 2. [a \<noteq> 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
have "(0::int) ^ ((p - 1) div 2) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 ^ ((p - 1) div 2) = 0
[PROOF STEP]
using zero_power [of "(p - 1) div 2"] assms(2)
[PROOF STATE]
proof (prove)
using this:
0 < (p - 1) div 2 \<Longrightarrow> (0::?'a) ^ ((p - 1) div 2) = (0::?'a)
2 < p

goal (1 subgoal):
 1. 0 ^ ((p - 1) div 2) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 ^ ((p - 1) div 2) = 0

goal (2 subgoals):
 1. [a = 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
 2. [a \<noteq> 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
[a ^ ((p - 1) div 2) = 0 ^ ((p - 1) div 2)] (mod int p)
0 ^ ((p - 1) div 2) = 0
[PROOF STEP]
have "[a ^ ((p - 1) div 2) = 0] (mod p)"
[PROOF STATE]
proof (prove)
using this:
[a ^ ((p - 1) div 2) = 0 ^ ((p - 1) div 2)] (mod int p)
0 ^ ((p - 1) div 2) = 0

goal (1 subgoal):
 1. [a ^ ((p - 1) div 2) = 0] (mod int p)
[PROOF STEP]
using True assms(1) prime_dvd_power_int_iff
[PROOF STATE]
proof (prove)
using this:
[a ^ ((p - 1) div 2) = 0 ^ ((p - 1) div 2)] (mod int p)
0 ^ ((p - 1) div 2) = 0
[a = 0] (mod int p)
prime p
\<lbrakk>prime ?p; 0 < ?n\<rbrakk> \<Longrightarrow> (?p dvd ?x ^ ?n) = (?p dvd ?x)

goal (1 subgoal):
 1. [a ^ ((p - 1) div 2) = 0] (mod int p)
[PROOF STEP]
by (simp add: cong_iff_dvd_diff)
[PROOF STATE]
proof (state)
this:
[a ^ ((p - 1) div 2) = 0] (mod int p)

goal (2 subgoals):
 1. [a = 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
 2. [a \<noteq> 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[a ^ ((p - 1) div 2) = 0] (mod int p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[a ^ ((p - 1) div 2) = 0] (mod int p)

goal (1 subgoal):
 1. [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
unfolding Legendre_def
[PROOF STATE]
proof (prove)
using this:
[a ^ ((p - 1) div 2) = 0] (mod int p)

goal (1 subgoal):
 1. [if [a = 0] (mod int p) then 0 else if QuadRes (int p) a then 1 else - 1 = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
using True cong_sym
[PROOF STATE]
proof (prove)
using this:
[a ^ ((p - 1) div 2) = 0] (mod int p)
[a = 0] (mod int p)
[?b = ?c] (mod ?a) \<Longrightarrow> [?c = ?b] (mod ?a)

goal (1 subgoal):
 1. [if [a = 0] (mod int p) then 0 else if QuadRes (int p) a then 1 else - 1 = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
[Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)

goal (1 subgoal):
 1. [a \<noteq> 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [a \<noteq> 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
[a \<noteq> 0] (mod int p)

goal (1 subgoal):
 1. [a \<noteq> 0] (mod int p) \<Longrightarrow> [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[a \<noteq> 0] (mod int p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[a \<noteq> 0] (mod int p)

goal (1 subgoal):
 1. [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
using euler_criterion_aux assms
[PROOF STATE]
proof (prove)
using this:
[a \<noteq> 0] (mod int p)
\<lbrakk>prime ?p; 2 < ?p; [?a \<noteq> 0] (mod int ?p)\<rbrakk> \<Longrightarrow> [Legendre ?a (int ?p) = ?a ^ ((?p - 1) div 2)] (mod int ?p)
prime p
2 < p

goal (1 subgoal):
 1. [Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
[Legendre a (int p) = a ^ ((p - 1) div 2)] (mod int p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma csqrt_2_sq [simp]:
  "complex_of_real (sqrt 2) * complex_of_real (sqrt 2) = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (sqrt 2) * complex_of_real (sqrt 2) = 2
[PROOF STEP]
by (smt of_real_add of_real_hom.hom_one of_real_power one_add_one power2_eq_square real_sqrt_pow2)


[STATEMENT]
lemma bind_nonempty'':
  assumes "f \<in> measurable M (subprob_algebra N)" "space M \<noteq> {}"
  shows "bind M f = join (distr M (subprob_algebra N) f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M \<bind> f = join (distr M (subprob_algebra N) f)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> M \<rightarrow>\<^sub>M subprob_algebra N
space M \<noteq> {}

goal (1 subgoal):
 1. M \<bind> f = join (distr M (subprob_algebra N) f)
[PROOF STEP]
by (auto intro: bind_nonempty')


[STATEMENT]
lemma subset_rel_interior:
  fixes S T :: "'n::euclidean_space set"
  assumes "S \<subseteq> T"
    and "affine hull S = affine hull T"
  shows "rel_interior S \<subseteq> rel_interior T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_interior S \<subseteq> rel_interior T
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
S \<subseteq> T
affine hull S = affine hull T

goal (1 subgoal):
 1. rel_interior S \<subseteq> rel_interior T
[PROOF STEP]
by (auto simp: rel_interior_def)


[STATEMENT]
lemma r:
  assumes e1: "e1 = (y + (q - b)) mod q"
    and s1: "s1 = (x*((y + (q - b)) mod q) + (q - r)) mod q"
    and b: "b < q"
    and x: "x < q"
    and y: "y < q"
    and r: "r < q"
  shows "r = (x*e1 + (q - s1)) mod q"
    (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
have "s1 = (x*((y + (q - b))) + (q - r)) mod q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s1 = (x * (y + (q - b)) + (q - r)) mod q
[PROOF STEP]
using s1 b
[PROOF STATE]
proof (prove)
using this:
s1 = (x * ((y + (q - b)) mod q) + (q - r)) mod q
b < q

goal (1 subgoal):
 1. s1 = (x * (y + (q - b)) + (q - r)) mod q
[PROOF STEP]
by (metis mod_add_left_eq mod_mult_right_eq)
[PROOF STATE]
proof (state)
this:
s1 = (x * (y + (q - b)) + (q - r)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
s1 = (x * (y + (q - b)) + (q - r)) mod q
[PROOF STEP]
have s1_dist: "s1 = (x*y + x*(q - b) + (q - r)) mod q"
[PROOF STATE]
proof (prove)
using this:
s1 = (x * (y + (q - b)) + (q - r)) mod q

goal (1 subgoal):
 1. s1 = (x * y + x * (q - b) + (q - r)) mod q
[PROOF STEP]
by(metis distrib_left)
[PROOF STATE]
proof (state)
this:
s1 = (x * y + x * (q - b) + (q - r)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
s1 = (x * y + x * (q - b) + (q - r)) mod q
[PROOF STEP]
have "?rhs = (x*((y + (q - b)) mod q) + (q - (x*y + x*(q - b) + (q - r)) mod q)) mod q"
[PROOF STATE]
proof (prove)
using this:
s1 = (x * y + x * (q - b) + (q - r)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * ((y + (q - b)) mod q) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
using e1
[PROOF STATE]
proof (prove)
using this:
s1 = (x * y + x * (q - b) + (q - r)) mod q
e1 = (y + (q - b)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * ((y + (q - b)) mod q) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * ((y + (q - b)) mod q) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * ((y + (q - b)) mod q) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
have "?rhs = (x*((y + (q - b))) + (q - (x*y + x*(q - b) + (q - r)) mod q)) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * ((y + (q - b)) mod q) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * (y + (q - b)) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
by (metis mod_add_left_eq mod_mult_right_eq)
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * (y + (q - b)) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * (y + (q - b)) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
have "?rhs = (x*y + x*(q - b) + (q - (x*y + x*(q - b) + (q - r)) mod q)) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * (y + (q - b)) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * (q - b) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
by(metis distrib_left)
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * (q - b) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * y + x * (q - b) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
have a: "?rhs = (x*y + x*q - x*b + (q - (x*y + x*(q - b) + (q - r)) mod q)) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * y + x * (q - b) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
using distrib_left b diff_mult_distrib2
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * y + x * (q - b) + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
?a * (?b + ?c) = ?a * ?b + ?a * ?c
b < q
?k * (?m - ?n) = ?k * ?m - ?k * ?n

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
have b: "?rhs = (x*y + x*q - x*b + (q*q + q*q + q  - (x*y + x*(q - b) + (q - r)) mod q)) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
have "(x*y + x*q - x*b + (q - (x*y + x*(q - b) + (q - r)) mod q)) mod q = (x*y + x*q - x*b + (q*q + q*q + q - (x*y + x*(q - b) + (q - r)) mod q)) mod q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
have f1: "\<forall>n na nb nc nd. (n::nat) mod na \<noteq> nb mod na \<or> nc mod na \<noteq> nd mod na \<or> (n + nc) mod na = (nb + nd) mod na"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n na nb nc nd. n mod na \<noteq> nb mod na \<or> nc mod na \<noteq> nd mod na \<or> (n + nc) mod na = (nb + nd) mod na
[PROOF STEP]
by (meson mod_add_cong)
[PROOF STATE]
proof (state)
this:
\<forall>n na nb nc nd. n mod na \<noteq> nb mod na \<or> nc mod na \<noteq> nd mod na \<or> (n + nc) mod na = (nb + nd) mod na

goal (1 subgoal):
 1. (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>n na nb nc nd. n mod na \<noteq> nb mod na \<or> nc mod na \<noteq> nd mod na \<or> (n + nc) mod na = (nb + nd) mod na
[PROOF STEP]
have "(q - (x * y + x*(q - b) + (q - r)) mod q) mod q = (q * q + q * q + q - (x * y + x*(q - b) + (q - r)) mod q) mod q"
[PROOF STATE]
proof (prove)
using this:
\<forall>n na nb nc nd. n mod na \<noteq> nb mod na \<or> nc mod na \<noteq> nd mod na \<or> (n + nc) mod na = (nb + nd) mod na

goal (1 subgoal):
 1. (q - (x * y + x * (q - b) + (q - r)) mod q) mod q = (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q) mod q
[PROOF STEP]
by (metis Nat.diff_add_assoc mod_le_divisor q_gt_0 mod_mult_self4)
[PROOF STATE]
proof (state)
this:
(q - (x * y + x * (q - b) + (q - r)) mod q) mod q = (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q) mod q

goal (1 subgoal):
 1. (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(q - (x * y + x * (q - b) + (q - r)) mod q) mod q = (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q) mod q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(q - (x * y + x * (q - b) + (q - r)) mod q) mod q = (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q) mod q

goal (1 subgoal):
 1. (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
using f1
[PROOF STATE]
proof (prove)
using this:
(q - (x * y + x * (q - b) + (q - r)) mod q) mod q = (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q) mod q
\<forall>n na nb nc nd. n mod na \<noteq> nb mod na \<or> nc mod na \<noteq> nd mod na \<or> (n + nc) mod na = (nb + nd) mod na

goal (1 subgoal):
 1. (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
(x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q
[PROOF STEP]
have "?rhs = (x*y + x*q - x*b + (q*q + q*q + q  - (x*y + x*(q - b) + (q - r)))) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
have "(x*y + x*q - x*b + (q*q + q*q + q - (x*y + x*(q - b) + (q - r)) mod q)) mod q =
         (x*y + x*q - x*b + (q*q + q*q + q - (x*y + x*(q - b)+ (q - r)))) mod q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
proof(cases "x = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
 2. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x = 0

goal (2 subgoals):
 1. x = 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
 2. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x = 0

goal (1 subgoal):
 1. (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
by (metis (no_types, lifting) assms(2) assms(4) True Nat.add_diff_assoc add.left_neutral
            cong_def diff_le_self minus_mod mult_is_0 not_gr_zero zero_eq_add_iff_both_eq_0 zero_less_diff)
[PROOF STATE]
proof (state)
this:
(x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q

goal (1 subgoal):
 1. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x \<noteq> 0

goal (1 subgoal):
 1. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
have qb: "q - b \<le> q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q - b \<le> q
[PROOF STEP]
using b
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. q - b \<le> q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
q - b \<le> q

goal (1 subgoal):
 1. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
q - b \<le> q
[PROOF STEP]
have qb':"x*(q - b) < q*q"
[PROOF STATE]
proof (prove)
using this:
q - b \<le> q

goal (1 subgoal):
 1. x * (q - b) < q * q
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
q - b \<le> q
x < q

goal (1 subgoal):
 1. x * (q - b) < q * q
[PROOF STEP]
by (metis mult_less_le_imp_less nat_0_less_mult_iff nat_less_le neq0_conv)
[PROOF STATE]
proof (state)
this:
x * (q - b) < q * q

goal (1 subgoal):
 1. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
have a: "x*y + x*(q - b) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x * y + x * (q - b)
[PROOF STEP]
using False assms
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0
e1 = (y + (q - b)) mod q
s1 = (x * ((y + (q - b)) mod q) + (q - r)) mod q
b < q
x < q
y < q
r < q

goal (1 subgoal):
 1. 0 < x * y + x * (q - b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < x * y + x * (q - b)

goal (1 subgoal):
 1. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
have 1: "q*q > x*y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * y < q * q
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0

goal (1 subgoal):
 1. x * y < q * q
[PROOF STEP]
by (simp add: mult_strict_mono q_gt_0 x y)
[PROOF STATE]
proof (state)
this:
x * y < q * q

goal (1 subgoal):
 1. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
have 2: "q*q > x*q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * q < q * q
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0

goal (1 subgoal):
 1. x * q < q * q
[PROOF STEP]
by (simp add: mult_strict_mono q_gt_0 x y)
[PROOF STATE]
proof (state)
this:
x * q < q * q

goal (1 subgoal):
 1. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
have b: "(q*q + q*q + q - (x*y + x*(q - b) + (q - r))) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < q * q + q * q + q - (x * y + x * (q - b) + (q - r))
[PROOF STEP]
using 1 qb'
[PROOF STATE]
proof (prove)
using this:
x * y < q * q
x * (q - b) < q * q

goal (1 subgoal):
 1. 0 < q * q + q * q + q - (x * y + x * (q - b) + (q - r))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < q * q + q * q + q - (x * y + x * (q - b) + (q - r))

goal (1 subgoal):
 1. x \<noteq> 0 \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < q * q + q * q + q - (x * y + x * (q - b) + (q - r))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < q * q + q * q + q - (x * y + x * (q - b) + (q - r))

goal (1 subgoal):
 1. (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
using a b mod_minus[of "x*y + x*q" "x*b" "q*q + q*q + q" "x*y + x*(q - b) + (q - r)"]
[PROOF STATE]
proof (prove)
using this:
0 < q * q + q * q + q - (x * y + x * (q - b) + (q - r))
0 < x * y + x * (q - b)
0 < q * q + q * q + q - (x * y + x * (q - b) + (q - r))
\<lbrakk>0 < x * y + x * q - x * b; 0 < q * q + q * q + q - (x * y + x * (q - b) + (q - r))\<rbrakk> \<Longrightarrow> (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q

goal (1 subgoal):
 1. (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
by (smt add.left_neutral cong_def gr0I minus_mod zero_less_diff)
[PROOF STATE]
proof (state)
this:
(x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
using b
[PROOF STATE]
proof (prove)
using this:
(x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q
[PROOF STEP]
have d: "?rhs = (x*y + x*q - x*b + (q*q + q*q + q - x*y - x*(q - b) - (q - r))) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)))) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q
[PROOF STEP]
have e: "?rhs = (x*y + x*q - x*b + q*q + q*q + q - x*y - x*(q - b) - (q - r)) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
proof(cases "x = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x = 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
 2. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x = 0

goal (2 subgoals):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x = 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
 2. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x = 0

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
using True d
[PROOF STATE]
proof (prove)
using this:
x = 0
x = 0
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x \<noteq> 0

goal (1 subgoal):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have qb: "q - b \<le> q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q - b \<le> q
[PROOF STEP]
using b
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - (x * y + x * (q - b) + (q - r)) mod q)) mod q

goal (1 subgoal):
 1. q - b \<le> q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
q - b \<le> q

goal (1 subgoal):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
q - b \<le> q
[PROOF STEP]
have qb':"x*(q - b) < q*q"
[PROOF STATE]
proof (prove)
using this:
q - b \<le> q

goal (1 subgoal):
 1. x * (q - b) < q * q
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
q - b \<le> q
x < q

goal (1 subgoal):
 1. x * (q - b) < q * q
[PROOF STEP]
by (metis mult_less_le_imp_less nat_0_less_mult_iff nat_less_le neq0_conv)
[PROOF STATE]
proof (state)
this:
x * (q - b) < q * q

goal (1 subgoal):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have a: "x*y + x*(q - b) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x * y + x * (q - b)
[PROOF STEP]
using False assms
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0
e1 = (y + (q - b)) mod q
s1 = (x * ((y + (q - b)) mod q) + (q - r)) mod q
b < q
x < q
y < q
r < q

goal (1 subgoal):
 1. 0 < x * y + x * (q - b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < x * y + x * (q - b)

goal (1 subgoal):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have 1: "q*q > x*y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * y < q * q
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0

goal (1 subgoal):
 1. x * y < q * q
[PROOF STEP]
by (simp add: mult_strict_mono q_gt_0 x y)
[PROOF STATE]
proof (state)
this:
x * y < q * q

goal (1 subgoal):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have 2: "q*q > x*q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * q < q * q
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0

goal (1 subgoal):
 1. x * q < q * q
[PROOF STEP]
by (simp add: mult_strict_mono q_gt_0 x y)
[PROOF STATE]
proof (state)
this:
x * q < q * q

goal (1 subgoal):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have b: "q*q + q*q + q  - x*y - x*(q - b) - (q - r) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < q * q + q * q + q - x * y - x * (q - b) - (q - r)
[PROOF STEP]
using 1 qb'
[PROOF STATE]
proof (prove)
using this:
x * y < q * q
x * (q - b) < q * q

goal (1 subgoal):
 1. 0 < q * q + q * q + q - x * y - x * (q - b) - (q - r)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < q * q + q * q + q - x * y - x * (q - b) - (q - r)

goal (1 subgoal):
 1. \<lbrakk>(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q; x \<noteq> 0\<rbrakk> \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < q * q + q * q + q - x * y - x * (q - b) - (q - r)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < q * q + q * q + q - x * y - x * (q - b) - (q - r)

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
using b d
[PROOF STATE]
proof (prove)
using this:
0 < q * q + q * q + q - x * y - x * (q - b) - (q - r)
0 < q * q + q * q + q - x * y - x * (q - b) - (q - r)
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + (q * q + q * q + q - x * y - x * (q - b) - (q - r))) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
by (smt Nat.add_diff_assoc add.assoc diff_diff_left less_imp_le_nat zero_less_diff)
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have "?rhs = (x*q - x*b + q*q + q*q + q - x*(q - b) - (q - r)) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have "(x*y + x*q - x*b + q*q + q*q + q - x*y - x*(q - b) - (q - r)) mod q = (x*q - x*b + q*q + q*q + q - x*(q - b) - (q - r)) mod q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have 1: "q + n - b = q - b + n" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q + n - b = q - b + n
[PROOF STEP]
by (simp add: assms(3) less_imp_le)
[PROOF STATE]
proof (state)
this:
q + ?n - b = q - b + ?n

goal (1 subgoal):
 1. (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have 2: "(c::nat) * b + (c * a + n) = c * (b + a) + n"
        for n a b c
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c * b + (c * a + n) = c * (b + a) + n
[PROOF STEP]
by (simp add: distrib_left)
[PROOF STATE]
proof (state)
this:
?c * ?b + (?c * ?a + ?n) = ?c * (?b + ?a) + ?n

goal (1 subgoal):
 1. (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have "(c::nat) + (b + a) - (n + a) = c + b - n" for n a b c
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c + (b + a) - (n + a) = c + b - n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?c + (?b + ?a) - (?n + ?a) = ?c + ?b - ?n

goal (1 subgoal):
 1. (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?c + (?b + ?a) - (?n + ?a) = ?c + ?b - ?n
[PROOF STEP]
have "(q + (q * q + (q * q + x * (q + y - b))) - (q - r + x * (y + (q - b)))) mod q = (q + (q * q + (q * q + x * (q - b))) - (q - r + x * (q - b))) mod q"
[PROOF STATE]
proof (prove)
using this:
?c + (?b + ?a) - (?n + ?a) = ?c + ?b - ?n

goal (1 subgoal):
 1. (q + (q * q + (q * q + x * (q + y - b))) - (q - r + x * (y + (q - b)))) mod q = (q + (q * q + (q * q + x * (q - b))) - (q - r + x * (q - b))) mod q
[PROOF STEP]
by (metis (no_types) add.commute 1 2)
[PROOF STATE]
proof (state)
this:
(q + (q * q + (q * q + x * (q + y - b))) - (q - r + x * (y + (q - b)))) mod q = (q + (q * q + (q * q + x * (q - b))) - (q - r + x * (q - b))) mod q

goal (1 subgoal):
 1. (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(q + (q * q + (q * q + x * (q + y - b))) - (q - r + x * (y + (q - b)))) mod q = (q + (q * q + (q * q + x * (q - b))) - (q - r + x * (q - b))) mod q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(q + (q * q + (q * q + x * (q + y - b))) - (q - r + x * (y + (q - b)))) mod q = (q + (q * q + (q * q + x * (q - b))) - (q - r + x * (q - b))) mod q

goal (1 subgoal):
 1. (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
by (simp add: add.commute diff_mult_distrib2 distrib_left)
[PROOF STATE]
proof (state)
this:
(x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q \<Longrightarrow> (x * e1 + (q - s1)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
using e
[PROOF STATE]
proof (prove)
using this:
(x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
(x * e1 + (q - s1)) mod q = (x * y + x * q - x * b + q * q + q * q + q - x * y - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have "?rhs = (x*(q - b) + q*q + q*q + q - x*(q - b) - (q - r)) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * q - x * b + q * q + q * q + q - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (x * (q - b) + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
by(metis diff_mult_distrib2)
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (x * (q - b) + q * q + q * q + q - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (x * (q - b) + q * q + q * q + q - x * (q - b) - (q - r)) mod q
[PROOF STEP]
have "?rhs = (q*q + q*q + q - (q - r)) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * (q - b) + q * q + q * q + q - x * (q - b) - (q - r)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (q * q + q * q + q - (q - r)) mod q
[PROOF STEP]
using assms(6)
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (x * (q - b) + q * q + q * q + q - x * (q - b) - (q - r)) mod q
r < q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (q * q + q * q + q - (q - r)) mod q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + q - (q - r)) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + q - (q - r)) mod q
[PROOF STEP]
have "?rhs = (q*q + q*q + q - q + r) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + q - (q - r)) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (q * q + q * q + q - q + r) mod q
[PROOF STEP]
using assms(6)
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + q - (q - r)) mod q
r < q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (q * q + q * q + q - q + r) mod q
[PROOF STEP]
by(simp add: Nat.diff_add_assoc2 less_imp_le)
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + q - q + r) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + q - q + r) mod q
[PROOF STEP]
have "?rhs = (q*q + q*q  + r) mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + q - q + r) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = (q * q + q * q + r) mod q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + r) mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + r) mod q
[PROOF STEP]
have "?rhs = r mod q"
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = (q * q + q * q + r) mod q

goal (1 subgoal):
 1. (x * e1 + (q - s1)) mod q = r mod q
[PROOF STEP]
by (metis add.commute distrib_right mod_mult_self1)
[PROOF STATE]
proof (state)
this:
(x * e1 + (q - s1)) mod q = r mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x * e1 + (q - s1)) mod q = r mod q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = r mod q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
using assms(6)
[PROOF STATE]
proof (prove)
using this:
(x * e1 + (q - s1)) mod q = r mod q
r < q

goal (1 subgoal):
 1. r = (x * e1 + (q - s1)) mod q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
r = (x * e1 + (q - s1)) mod q

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sigma_algebra_disjoint_iff:
  "sigma_algebra \<Omega> M \<longleftrightarrow> algebra \<Omega> M \<and>
    (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sigma_algebra \<Omega> M = (algebra \<Omega> M \<and> (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> \<Union> (range A) \<in> M))
[PROOF STEP]
proof (auto simp add: sigma_algebra_iff)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>A. \<lbrakk>algebra \<Omega> M; \<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> \<Union> (range A) \<in> M; range A \<subseteq> M\<rbrakk> \<Longrightarrow> \<Union> (range A) \<in> M
[PROOF STEP]
fix A :: "nat \<Rightarrow> 'a set"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>A. \<lbrakk>algebra \<Omega> M; \<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> \<Union> (range A) \<in> M; range A \<subseteq> M\<rbrakk> \<Longrightarrow> \<Union> (range A) \<in> M
[PROOF STEP]
assume M: "algebra \<Omega> M"
     and A: "range A \<subseteq> M"
     and UnA: "\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> M"
[PROOF STATE]
proof (state)
this:
algebra \<Omega> M
range A \<subseteq> M
\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> \<Union> (range A) \<in> M

goal (1 subgoal):
 1. \<And>A. \<lbrakk>algebra \<Omega> M; \<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> \<Union> (range A) \<in> M; range A \<subseteq> M\<rbrakk> \<Longrightarrow> \<Union> (range A) \<in> M
[PROOF STEP]
hence "range (disjointed A) \<subseteq> M \<longrightarrow>
         disjoint_family (disjointed A) \<longrightarrow>
         (\<Union>i. disjointed A i) \<in> M"
[PROOF STATE]
proof (prove)
using this:
algebra \<Omega> M
range A \<subseteq> M
\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> \<Union> (range A) \<in> M

goal (1 subgoal):
 1. range (disjointed A) \<subseteq> M \<longrightarrow> disjoint_family (disjointed A) \<longrightarrow> \<Union> (range (disjointed A)) \<in> M
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
range (disjointed A) \<subseteq> M \<longrightarrow> disjoint_family (disjointed A) \<longrightarrow> \<Union> (range (disjointed A)) \<in> M

goal (1 subgoal):
 1. \<And>A. \<lbrakk>algebra \<Omega> M; \<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> \<Union> (range A) \<in> M; range A \<subseteq> M\<rbrakk> \<Longrightarrow> \<Union> (range A) \<in> M
[PROOF STEP]
hence "(\<Union>i. disjointed A i) \<in> M"
[PROOF STATE]
proof (prove)
using this:
range (disjointed A) \<subseteq> M \<longrightarrow> disjoint_family (disjointed A) \<longrightarrow> \<Union> (range (disjointed A)) \<in> M

goal (1 subgoal):
 1. \<Union> (range (disjointed A)) \<in> M
[PROOF STEP]
by (simp add: algebra.range_disjointed_sets'[of \<Omega>] M A disjoint_family_disjointed)
[PROOF STATE]
proof (state)
this:
\<Union> (range (disjointed A)) \<in> M

goal (1 subgoal):
 1. \<And>A. \<lbrakk>algebra \<Omega> M; \<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> \<Union> (range A) \<in> M; range A \<subseteq> M\<rbrakk> \<Longrightarrow> \<Union> (range A) \<in> M
[PROOF STEP]
thus "(\<Union>i::nat. A i) \<in> M"
[PROOF STATE]
proof (prove)
using this:
\<Union> (range (disjointed A)) \<in> M

goal (1 subgoal):
 1. \<Union> (range A) \<in> M
[PROOF STEP]
by (simp add: UN_disjointed_eq)
[PROOF STATE]
proof (state)
this:
\<Union> (range A) \<in> M

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma frechet_derivative_eq_vector_derivative_1:
  assumes "f differentiable at t"
  shows "frechet_derivative f (at t) 1 = vector_derivative f (at t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. frechet_derivative f (at t) 1 = vector_derivative f (at t)
[PROOF STEP]
apply (subst frechet_derivative_eq_vector_derivative)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. f differentiable at t
 2. 1 *\<^sub>R vector_derivative f (at t) = vector_derivative f (at t)
[PROOF STEP]
apply (rule assms)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 *\<^sub>R vector_derivative f (at t) = vector_derivative f (at t)
[PROOF STEP]
by auto


[STATEMENT]
lemma arctan_zero_zero [simp]: "arctan 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arctan 0 = 0
[PROOF STEP]
by (rule arctan_unique) simp_all


[STATEMENT]
lemma nat_fun_sum_eq_conv:
  fixes f :: "'a \<Rightarrow> nat"
  shows "(\<lambda>a. f a + g a) = (\<lambda>a. 0) \<longleftrightarrow> f = (\<lambda>a .0) \<and> g = (\<lambda>a. 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>a. f a + g a) = (\<lambda>a. 0)) = (f = (\<lambda>a. 0) \<and> g = (\<lambda>a. 0))
[PROOF STEP]
by(auto simp add: fun_eq_iff)


[STATEMENT]
lemma differentiable_chain_within:
  "f differentiable (at x within S) \<Longrightarrow>
    g differentiable (at(f x) within (f ` S)) \<Longrightarrow> (g \<circ> f) differentiable (at x within S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f differentiable at x within S; g differentiable at (f x) within f ` S\<rbrakk> \<Longrightarrow> g \<circ> f differentiable at x within S
[PROOF STEP]
unfolding differentiable_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>D. (f has_derivative D) (at x within S); \<exists>D. (g has_derivative D) (at (f x) within f ` S)\<rbrakk> \<Longrightarrow> \<exists>D. (g \<circ> f has_derivative D) (at x within S)
[PROOF STEP]
by (meson diff_chain_within)


[STATEMENT]
lemma ccspan_superset:
  \<open>A \<subseteq> space_as_set (ccspan A)\<close>
  for A :: \<open>'a::complex_normed_vector set\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<subseteq> space_as_set (ccspan A)
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A. A \<subseteq> closure (cspan A)
[PROOF STEP]
by (meson closure_subset complex_vector.span_superset subset_trans)


[STATEMENT]
lemma nonzero_norm_inverse: "a \<noteq> 0 \<Longrightarrow> norm (inverse a) = inverse (norm a)"
  for a :: "'a::real_normed_div_algebra"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<noteq> (0::'a) \<Longrightarrow> norm (inverse a) = inverse (norm a)
[PROOF STEP]
by (metis inverse_unique norm_mult norm_one right_inverse)


[STATEMENT]
lemma pcompose_assoc: "pcompose p (pcompose q r) = pcompose (pcompose p q) r"
  for p q r :: "'a::comm_semiring_0 poly"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<circ>\<^sub>p (q \<circ>\<^sub>p r) = p \<circ>\<^sub>p q \<circ>\<^sub>p r
[PROOF STEP]
by (induct p arbitrary: q) (simp_all add: pcompose_pCons pcompose_add pcompose_mult)


[STATEMENT]
lemma compact_closure [simp]:
  fixes S :: "'a::heine_borel set"
  shows "compact(closure S) \<longleftrightarrow> bounded S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact (closure S) = bounded S
[PROOF STEP]
by (meson bounded_closure bounded_subset closed_closure closure_subset compact_eq_bounded_closed)


[STATEMENT]
lemma Legacy_col_is_Matrix_col:
  assumes a1:"j < length A" and a2:"length (A ! j) = mult.row_length A"
  shows "col A j = list_of_vec (Matrix.col (mat_of_cols_list (mult.row_length A) A) j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix_Legacy.col A j = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)
[PROOF STEP]
proof (rule nth_equalityI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (Matrix_Legacy.col A j) = length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j))
 2. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
have "length (list_of_vec (Matrix.col (mat_of_cols_list (mult.row_length A) A) j)) =
dim_vec (Matrix.col (mat_of_cols_list (mult.row_length A) A) j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)) = dim_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)
[PROOF STEP]
using length_list_of_vec
[PROOF STATE]
proof (prove)
using this:
length (list_of_vec ?v) = dim_vec ?v

goal (1 subgoal):
 1. length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)) = dim_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)) = dim_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)

goal (2 subgoals):
 1. length (Matrix_Legacy.col A j) = length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j))
 2. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)) = dim_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)

goal (2 subgoals):
 1. length (Matrix_Legacy.col A j) = length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j))
 2. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
have "\<dots> = dim_row (mat_of_cols_list (mult.row_length A) A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) = dim_row (Tensor.mat_of_cols_list (mult.row_length A) A)
[PROOF STEP]
using Matrix.col_def
[PROOF STATE]
proof (prove)
using this:
Matrix.col ?A ?j = Matrix.vec (dim_row ?A) (\<lambda>i. ?A $$ (i, ?j))

goal (1 subgoal):
 1. dim_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) = dim_row (Tensor.mat_of_cols_list (mult.row_length A) A)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) = dim_row (Tensor.mat_of_cols_list (mult.row_length A) A)

goal (2 subgoals):
 1. length (Matrix_Legacy.col A j) = length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j))
 2. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dim_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) = dim_row (Tensor.mat_of_cols_list (mult.row_length A) A)

goal (2 subgoals):
 1. length (Matrix_Legacy.col A j) = length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j))
 2. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
have f1:"\<dots> = mult.row_length A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (Tensor.mat_of_cols_list (mult.row_length A) A) = mult.row_length A
[PROOF STEP]
by (simp add: mat_of_cols_list_def)
[PROOF STATE]
proof (state)
this:
dim_row (Tensor.mat_of_cols_list (mult.row_length A) A) = mult.row_length A

goal (2 subgoals):
 1. length (Matrix_Legacy.col A j) = length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j))
 2. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)) = mult.row_length A
[PROOF STEP]
show f2:"length (col A j) = length (list_of_vec (Matrix.col (mat_of_cols_list (mult.row_length A) A) j))"
[PROOF STATE]
proof (prove)
using this:
length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)) = mult.row_length A

goal (1 subgoal):
 1. length (Matrix_Legacy.col A j) = length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j))
[PROOF STEP]
using a2
[PROOF STATE]
proof (prove)
using this:
length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j)) = mult.row_length A
length (A ! j) = mult.row_length A

goal (1 subgoal):
 1. length (Matrix_Legacy.col A j) = length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j))
[PROOF STEP]
by (simp add: col_def)
[PROOF STATE]
proof (state)
this:
length (Matrix_Legacy.col A j) = length (list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j))

goal (1 subgoal):
 1. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
fix i:: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
assume "i<length (col A j)"
[PROOF STATE]
proof (state)
this:
i < length (Matrix_Legacy.col A j)

goal (1 subgoal):
 1. \<And>i. i < length (Matrix_Legacy.col A j) \<Longrightarrow> Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < length (Matrix_Legacy.col A j)
[PROOF STEP]
show "(col A j) ! i = (list_of_vec (Matrix.col (mat_of_cols_list (mult.row_length A) A) j)) ! i"
[PROOF STATE]
proof (prove)
using this:
i < length (Matrix_Legacy.col A j)

goal (1 subgoal):
 1. Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i
[PROOF STEP]
by (metis col_def a1 a2 col_mat_of_cols_list list_vec)
[PROOF STATE]
proof (state)
this:
Matrix_Legacy.col A j ! i = list_of_vec (Matrix.col (Tensor.mat_of_cols_list (mult.row_length A) A) j) ! i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma standard_borel_sets[simp]:
  assumes "sets M = sets Y"
  shows "standard_borel Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. standard_borel Y
[PROOF STEP]
unfolding standard_borel_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f\<in>borel_measurable Y. \<exists>g\<in>real_borel \<rightarrow>\<^sub>M Y. \<forall>x\<in>space Y. (g \<circ> f) x = x
[PROOF STEP]
using measurable_cong_sets[OF assms refl,of real_borel] measurable_cong_sets[OF refl assms,of real_borel] sets_eq_imp_space_eq[OF assms] exist_fg
[PROOF STATE]
proof (prove)
using this:
borel_measurable M = borel_measurable Y
real_borel \<rightarrow>\<^sub>M M = real_borel \<rightarrow>\<^sub>M Y
space M = space Y
\<exists>f\<in>borel_measurable M. \<exists>g\<in>real_borel \<rightarrow>\<^sub>M M. \<forall>x\<in>space M. (g \<circ> f) x = x

goal (1 subgoal):
 1. \<exists>f\<in>borel_measurable Y. \<exists>g\<in>real_borel \<rightarrow>\<^sub>M Y. \<forall>x\<in>space Y. (g \<circ> f) x = x
[PROOF STEP]
by simp


[STATEMENT]
lemma divmod_int_code[code]: "divmod_int m n = map_prod int_of_integer int_of_integer
  (divmod_integer (integer_of_int m) (integer_of_int n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. divmod_int m n = map_prod int_of_integer int_of_integer (divmod_integer (integer_of_int m) (integer_of_int n))
[PROOF STEP]
unfolding divmod_int_def divmod_integer_def map_prod_def split prod.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m div n = int_of_integer (integer_of_int m div integer_of_int n) \<and> m mod n = int_of_integer (integer_of_int m mod integer_of_int n)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. m div n = int_of_integer (integer_of_int m div integer_of_int n)
 2. m mod n = int_of_integer (integer_of_int m mod integer_of_int n)
[PROOF STEP]
show "m div n = int_of_integer
     (integer_of_int m div integer_of_int n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m div n = int_of_integer (integer_of_int m div integer_of_int n)
[PROOF STEP]
by (transfer, simp)
[PROOF STATE]
proof (state)
this:
m div n = int_of_integer (integer_of_int m div integer_of_int n)

goal (1 subgoal):
 1. m mod n = int_of_integer (integer_of_int m mod integer_of_int n)
[PROOF STEP]
show "m mod n = int_of_integer
     (integer_of_int m mod integer_of_int n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m mod n = int_of_integer (integer_of_int m mod integer_of_int n)
[PROOF STEP]
by (transfer, simp)
[PROOF STATE]
proof (state)
this:
m mod n = int_of_integer (integer_of_int m mod integer_of_int n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Max_Collect_less_nat: "Max {i::nat. i < k} = (if k = 0 then Max {} else k - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max {i. i < k} = (if k = 0 then Max {} else k - 1)
[PROOF STEP]
by (auto intro!: Max_eqI)


[STATEMENT]
lemma inverse_prod_list: "inverse (prod_list xs) = prod_list (map inverse (xs :: 'a :: field list))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse (prod_list xs) = prod_list (map inverse xs)
[PROOF STEP]
by (induct xs, auto)


[STATEMENT]
lemma (in finite_field) card_irred_1:
  "card {f. monic_irreducible_poly R f \<and> degree f = 1} = order R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {f. m_i_p R f \<and> Polynomials.degree f = 1} = order R
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {f. m_i_p R f \<and> Polynomials.degree f = 1} = order R
[PROOF STEP]
have "int (1 * card {f. monic_irreducible_poly R f \<and> degree f = 1})
    = int (order R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (1 * card {f. m_i_p R f \<and> Polynomials.degree f = 1}) = int (order R)
[PROOF STEP]
by (subst card_irred, auto)
[PROOF STATE]
proof (state)
this:
int (1 * card {f. m_i_p R f \<and> Polynomials.degree f = 1}) = int (order R)

goal (1 subgoal):
 1. card {f. m_i_p R f \<and> Polynomials.degree f = 1} = order R
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
int (1 * card {f. m_i_p R f \<and> Polynomials.degree f = 1}) = int (order R)

goal (1 subgoal):
 1. card {f. m_i_p R f \<and> Polynomials.degree f = 1} = order R
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {f. m_i_p R f \<and> Polynomials.degree f = 1} = order R

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ChiRel_int_disjoint:
  "S \<noteq> T \<Longrightarrow> (ChiRel A `` {S}) \<inter> (ChiRel A `` {T}) = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<noteq> T \<Longrightarrow> ChiRel A `` {S} \<inter> ChiRel A `` {T} = {}
[PROOF STEP]
apply (unfold ChiRel_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<noteq> T \<Longrightarrow> {(S, S'). S \<in> HAStates A \<and> S' \<in> HAStates A \<and> S' \<in> Chi A S} `` {S} \<inter> {(S, S'). S \<in> HAStates A \<and> S' \<in> HAStates A \<and> S' \<in> Chi A S} `` {T} = {}
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>S \<noteq> T; S \<in> HAStates A; T \<in> HAStates A; x \<in> Chi A S; x \<in> HAStates A; x \<in> Chi A T\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (simp only: Chi_range_disjoint)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Diff_eq_empty_iff_mset: "A - B = {#} \<longleftrightarrow> A \<subseteq># B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A - B = {#}) = (A \<subseteq># B)
[PROOF STEP]
by (auto simp: multiset_eq_iff subseteq_mset_def)


[STATEMENT]
theorem p17: "(p \<and> (q \<longrightarrow> r) \<longrightarrow> s) \<longleftrightarrow> (\<not>p \<or> q \<or> s) \<and> (\<not>p \<or> \<not>r \<or> s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p \<and> (q \<longrightarrow> r) \<longrightarrow> s) = ((\<not> p \<or> q \<or> s) \<and> (\<not> p \<or> \<not> r \<or> s))
[PROOF STEP]
by auto2


[STATEMENT]
lemma rbtreeify_f_rec_aux_lemma:
  "\<lbrakk>k - n div 2 = Suc k'; n \<le> k; n mod 2 = Suc 0\<rbrakk>
  \<Longrightarrow> k' - n div 2 = k - n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>k - n div 2 = Suc k'; n \<le> k; n mod 2 = Suc 0\<rbrakk> \<Longrightarrow> k' - n div 2 = k - n
[PROOF STEP]
apply(rule add_right_imp_eq[where a = "n - n div 2"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>k - n div 2 = Suc k'; n \<le> k; n mod 2 = Suc 0\<rbrakk> \<Longrightarrow> k' - n div 2 + (n - n div 2) = k - n + (n - n div 2)
[PROOF STEP]
apply(subst add_diff_assoc2, arith)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>k - n div 2 = Suc k'; n \<le> k; n mod 2 = Suc 0\<rbrakk> \<Longrightarrow> k' + (n - n div 2) - n div 2 = k - n + (n - n div 2)
[PROOF STEP]
apply(simp add: div2_plus_div2)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma op_norm_scaleR: "\<parallel>c *\<^sub>R A\<parallel>\<^sub>o\<^sub>p = \<bar>c\<bar> * (\<parallel>A\<parallel>\<^sub>o\<^sub>p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>c *\<^sub>R A\<parallel>\<^sub>o\<^sub>p = \<bar>c\<bar> * (\<parallel>A\<parallel>\<^sub>o\<^sub>p)
[PROOF STEP]
unfolding onorm_scaleR[OF blin_matrix_vector_mult, symmetric] scaleR_vector_assoc
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>c *\<^sub>R A\<parallel>\<^sub>o\<^sub>p = \<parallel>c *\<^sub>R A\<parallel>\<^sub>o\<^sub>p
[PROOF STEP]
..


[STATEMENT]
lemma powr_at_top:
  assumes "(p::real) > 0"
  shows   "filterlim (\<lambda>x. x powr p) at_top at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM x at_top. x powr p :> at_top
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. LIM x at_top. x powr p :> at_top
[PROOF STEP]
have "LIM x at_top. exp (p * ln x) :> at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM x at_top. exp (p * ln x) :> at_top
[PROOF STEP]
by (rule filterlim_compose[OF exp_at_top filterlim_tendsto_pos_mult_at_top[OF tendsto_const]])
       (simp_all add: ln_at_top assms)
[PROOF STATE]
proof (state)
this:
LIM x at_top. exp (p * ln x) :> at_top

goal (1 subgoal):
 1. LIM x at_top. x powr p :> at_top
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
LIM x at_top. exp (p * ln x) :> at_top

goal (1 subgoal):
 1. LIM x at_top. x powr p :> at_top
[PROOF STEP]
by (subst filterlim_cong[OF refl refl powr_eventually_exp_ln])
[PROOF STATE]
proof (state)
this:
LIM x at_top. x powr p :> at_top

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma interpret_floatarith_divide:
  "interpret_floatarith (Mult a (Inverse b)) vs =
    (interpret_floatarith a vs) / (interpret_floatarith b vs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interpret_floatarith (Mult a (Inverse b)) vs = interpret_floatarith a vs / interpret_floatarith b vs
[PROOF STEP]
unfolding divide_inverse interpret_floatarith.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interpret_floatarith a vs * inverse (interpret_floatarith b vs) = interpret_floatarith a vs * inverse (interpret_floatarith b vs)
[PROOF STEP]
..


[STATEMENT]
lemma Sigma_mset_Union: "Sigma_mset (\<Sum>\<^sub>#X) B = (\<Sum>\<^sub># (image_mset (\<lambda>A. Sigma_mset A B) X))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_mset (\<Sum>\<^sub># X) B = (\<Sum>A\<in>#X. Sigma_mset A B)
[PROOF STEP]
by (auto simp: multiset_eq_iff count_sum_mset count_image_mset_Pair sum_mset_if_eq_constant
    Sigma_mset_def iterate_op_plus min_def not_in_iff sum_mset_distrib_left)


[STATEMENT]
lemma convex_INT: "(\<And>i. i \<in> A \<Longrightarrow> convex (B i)) \<Longrightarrow> convex (\<Inter>i\<in>A. B i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. i \<in> A \<Longrightarrow> convex (B i)) \<Longrightarrow> convex (\<Inter> (B ` A))
[PROOF STEP]
unfolding convex_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. i \<in> A \<Longrightarrow> \<forall>x\<in>B i. \<forall>y\<in>B i. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> B i) \<Longrightarrow> \<forall>x\<in>\<Inter> (B ` A). \<forall>y\<in>\<Inter> (B ` A). \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> \<Inter> (B ` A)
[PROOF STEP]
by auto


[STATEMENT]
lemma nat_not_le_less:"(\<not> (n::nat) \<le> m) = (m < n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<not> n \<le> m) = (m < n)
[PROOF STEP]
by (simp add: not_le)


[STATEMENT]
lemma bigo_const_mult3: "c \<noteq> 0 \<Longrightarrow> f \<in> O(\<lambda>x. c * f x)"
  for c :: "'a::linordered_field"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<noteq> (0::'a) \<Longrightarrow> f \<in> O(\<lambda>x. c * f x)
[PROOF STEP]
apply (simp add: bigo_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<noteq> (0::'a) \<Longrightarrow> \<exists>ca. \<forall>x. \<bar>f x\<bar> \<le> ca * \<bar>c * f x\<bar>
[PROOF STEP]
apply (rule_tac x = "\<bar>inverse c\<bar>" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<noteq> (0::'a) \<Longrightarrow> \<forall>x. \<bar>f x\<bar> \<le> \<bar>inverse c\<bar> * \<bar>c * f x\<bar>
[PROOF STEP]
apply (simp add: abs_mult mult.assoc [symmetric])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma sums_confine_le:
  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
  shows "confine f N sums l \<longleftrightarrow> ((\<lambda>n. \<Sum>i \<in> {..n} \<inter> N. f i) \<longlonglongrightarrow> l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. confine f N sums l = (\<lambda>n. sum f ({..n} \<inter> N)) \<longlonglongrightarrow> l
[PROOF STEP]
by (simp add: sums_def_le atLeast0AtMost confine_def sum.inter_restrict)


[STATEMENT]
lemma eSuc_ile_mono [simp]: "eSuc n \<le> eSuc m \<longleftrightarrow> n \<le> m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (eSuc n \<le> eSuc m) = (n \<le> m)
[PROOF STEP]
by (simp add: eSuc_def less_eq_enat_def split: enat.splits)


[STATEMENT]
lemma closed_Collect_all: "(\<And>i. closed {x. P i x}) \<Longrightarrow> closed {x. \<forall>i. P i x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. closed {x. P i x}) \<Longrightarrow> closed {x. \<forall>i. P i x}
[PROOF STEP]
using closed_INT[of UNIV "\<lambda>i. {x. P i x}"]
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>UNIV. closed {xa. P x xa} \<Longrightarrow> closed (\<Inter>x. {xa. P x xa})

goal (1 subgoal):
 1. (\<And>i. closed {x. P i x}) \<Longrightarrow> closed {x. \<forall>i. P i x}
[PROOF STEP]
by (simp add: Collect_all_eq)


[STATEMENT]
lemma size_heap_of_A:
  "size (heap_of_A xs) = length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size (heap_of_A xs) = length xs
[PROOF STEP]
using arg_cong[OF mset_tree_heap_of_A, of size xs]
[PROOF STATE]
proof (prove)
using this:
size (mset_tree (heap_of_A xs)) = size (mset xs)

goal (1 subgoal):
 1. size (heap_of_A xs) = length xs
[PROOF STEP]
by simp


[STATEMENT]
lemma sorted_wrt_map:
  "sorted_wrt R (map f xs) = sorted_wrt (\<lambda>x y. R (f x) (f y)) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_wrt R (map f xs) = sorted_wrt (\<lambda>x y. R (f x) (f y)) xs
[PROOF STEP]
by (induction xs) simp_all


[STATEMENT]
lemma invfun_l:"\<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B; a \<in> A\<rbrakk>
                      \<Longrightarrow> (invfun A B f) (f a) = a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> A \<rightarrow> B; inj_on f A; surj_to f A B; a \<in> A\<rbrakk> \<Longrightarrow> (f\<inverse>\<^bsub>B,A\<^esub>) (f a) = a
[PROOF STEP]
apply (simp add:invfun_def Pi_def restrict_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x. x \<in> A \<longrightarrow> f x \<in> B; inj_on f A; surj_to f A B; a \<in> A\<rbrakk> \<Longrightarrow> (SOME x. x \<in> A \<and> f x = f a) = a
[PROOF STEP]
apply (rule someI2_ex)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<forall>x. x \<in> A \<longrightarrow> f x \<in> B; inj_on f A; surj_to f A B; a \<in> A\<rbrakk> \<Longrightarrow> \<exists>aa. aa \<in> A \<and> f aa = f a
 2. \<And>x. \<lbrakk>\<forall>x. x \<in> A \<longrightarrow> f x \<in> B; inj_on f A; surj_to f A B; a \<in> A; x \<in> A \<and> f x = f a\<rbrakk> \<Longrightarrow> x = a
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<forall>x. x \<in> A \<longrightarrow> f x \<in> B; inj_on f A; surj_to f A B; a \<in> A; x \<in> A; f x = f a\<rbrakk> \<Longrightarrow> x = a
[PROOF STEP]
apply (simp add:inj_on_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma homeomorphic_locally:
  fixes S:: "'a::metric_space set" and T:: "'b::metric_space set"
  assumes hom: "S homeomorphic T"
          and iff: "\<And>X Y. X homeomorphic Y \<Longrightarrow> (P X \<longleftrightarrow> Q Y)"
    shows "locally P S \<longleftrightarrow> locally Q T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. locally P S = locally Q T
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. locally P S = locally Q T
[PROOF STEP]
obtain f g where hom: "homeomorphism S T f g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f g. homeomorphism S T f g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
S homeomorphic T
?X homeomorphic ?Y \<Longrightarrow> P ?X = Q ?Y

goal (1 subgoal):
 1. (\<And>f g. homeomorphism S T f g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (force simp: homeomorphic_def)
[PROOF STATE]
proof (state)
this:
homeomorphism S T f g

goal (1 subgoal):
 1. locally P S = locally Q T
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
homeomorphism S T f g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
homeomorphism S T f g

goal (1 subgoal):
 1. locally P S = locally Q T
[PROOF STEP]
using homeomorphic_def local.iff
[PROOF STATE]
proof (prove)
using this:
homeomorphism S T f g
?s homeomorphic ?t \<equiv> \<exists>f g. homeomorphism ?s ?t f g
?X homeomorphic ?Y \<Longrightarrow> P ?X = Q ?Y

goal (1 subgoal):
 1. locally P S = locally Q T
[PROOF STEP]
by (blast intro!: homeomorphism_locally)
[PROOF STATE]
proof (state)
this:
locally P S = locally Q T

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Min_mono:
  assumes "finite A"
  assumes "A \<noteq> {}"
  assumes "\<And> a. a \<in> A \<Longrightarrow>  f a \<le> a"
  shows "Min (f`A) \<le> Min A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Min (f ` A) \<le> Min A
[PROOF STEP]
by (meson Min_in Min_le_iff assms(1) assms(2) assms(3) finite_imageI image_eqI image_is_empty)


[STATEMENT]
lemma vec_eq[simp]: "(vec m = vec n) \<longleftrightarrow> (m = n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec m = vec n) = (m = n)
[PROOF STEP]
by (simp add: vec_eq_iff)


[STATEMENT]
lemma integral_by_parts':
  fixes f g F G::"real \<Rightarrow> real"
  assumes "a \<le> b"
  assumes "!!x. a \<le>x \<Longrightarrow> x\<le>b \<Longrightarrow> isCont f x"
  assumes "!!x. a \<le>x \<Longrightarrow> x\<le>b \<Longrightarrow> isCont g x"
  assumes "!!x. DERIV F x :> f x"
  assumes "!!x. DERIV G x :> g x"
  shows "(\<integral>x. indicator {a .. b} x *\<^sub>R (F x * g x) \<partial>lborel)
            =  F b * G b - F a * G a - \<integral>x. indicator {a .. b} x *\<^sub>R (f x * G x) \<partial>lborel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LBINT x. indicat_real {a..b} x *\<^sub>R (F x * g x) = F b * G b - F a * G a - (LBINT x. indicat_real {a..b} x *\<^sub>R (f x * G x))
[PROOF STEP]
using integral_by_parts[OF assms]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> a \<le> x; \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> x \<le> b; \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> a \<le> x; \<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> x \<le> b\<rbrakk> \<Longrightarrow> LBINT x. F x * g x * indicat_real {a..b} x = F b * G b - F a * G a - (LBINT x. f x * G x * indicat_real {a..b} x)

goal (1 subgoal):
 1. LBINT x. indicat_real {a..b} x *\<^sub>R (F x * g x) = F b * G b - F a * G a - (LBINT x. indicat_real {a..b} x *\<^sub>R (f x * G x))
[PROOF STEP]
by (simp add: ac_simps)


[STATEMENT]
lemma max_eventually_eq:
  "eventually (\<lambda>x. f x = (g x :: real)) at_top \<Longrightarrow> eventually (\<lambda>x. max (f x) (g x) = f x) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. f x = g x \<Longrightarrow> \<forall>\<^sub>F x in at_top. max (f x) (g x) = f x
[PROOF STEP]
by (erule eventually_mono) simp


[STATEMENT]
lemma Inf_Sup_var: "\<Squnion>(\<Inter>x \<in> X. \<down>x) = \<Sqinter>X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Squnion> \<Inter> (\<down> ` X) = \<Sqinter> X
[PROOF STEP]
unfolding downset_prop
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Squnion> (\<Inter>x\<in>X. {y. y \<le> x}) = \<Sqinter> X
[PROOF STEP]
by (simp add: Collect_ball_eq Inf_eq_Sup)


[STATEMENT]
lemma integral_indicator:
  assumes "(S \<inter> T) \<in> lmeasurable"
  shows "integral T (indicator S) = measure lebesgue (S \<inter> T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
have "integral UNIV (indicator (S \<inter> T)) = integral UNIV (\<lambda>a. if a \<in> S \<inter> T then 1::real else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral UNIV (indicat_real (S \<inter> T)) = integral UNIV (\<lambda>a. if a \<in> S \<inter> T then 1 else 0)
[PROOF STEP]
by (simp add: indicator_def [abs_def] of_bool_def)
[PROOF STATE]
proof (state)
this:
integral UNIV (indicat_real (S \<inter> T)) = integral UNIV (\<lambda>a. if a \<in> S \<inter> T then 1 else 0)

goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
integral UNIV (indicat_real (S \<inter> T)) = integral UNIV (\<lambda>a. if a \<in> S \<inter> T then 1 else 0)

goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
have "(indicator (S \<inter> T) has_integral measure lebesgue (S \<inter> T)) UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (indicat_real (S \<inter> T) has_integral Sigma_Algebra.measure lebesgue (S \<inter> T)) UNIV
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
S \<inter> T \<in> lmeasurable

goal (1 subgoal):
 1. (indicat_real (S \<inter> T) has_integral Sigma_Algebra.measure lebesgue (S \<inter> T)) UNIV
[PROOF STEP]
by (simp add: lmeasurable_iff_has_integral)
[PROOF STATE]
proof (state)
this:
(indicat_real (S \<inter> T) has_integral Sigma_Algebra.measure lebesgue (S \<inter> T)) UNIV

goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
integral UNIV (indicat_real (S \<inter> T)) = integral UNIV (\<lambda>a. if a \<in> S \<inter> T then 1 else 0)
(indicat_real (S \<inter> T) has_integral Sigma_Algebra.measure lebesgue (S \<inter> T)) UNIV
[PROOF STEP]
have "integral UNIV (\<lambda>x. if x \<in> S \<inter> T then 1 else 0) = measure lebesgue (S \<inter> T)"
[PROOF STATE]
proof (prove)
using this:
integral UNIV (indicat_real (S \<inter> T)) = integral UNIV (\<lambda>a. if a \<in> S \<inter> T then 1 else 0)
(indicat_real (S \<inter> T) has_integral Sigma_Algebra.measure lebesgue (S \<inter> T)) UNIV

goal (1 subgoal):
 1. integral UNIV (\<lambda>x. if x \<in> S \<inter> T then 1 else 0) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
by (metis (no_types) integral_unique)
[PROOF STATE]
proof (state)
this:
integral UNIV (\<lambda>x. if x \<in> S \<inter> T then 1 else 0) = Sigma_Algebra.measure lebesgue (S \<inter> T)

goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
integral UNIV (\<lambda>x. if x \<in> S \<inter> T then 1 else 0) = Sigma_Algebra.measure lebesgue (S \<inter> T)

goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
have "integral T (\<lambda>a. if a \<in> S then 1::real else 0) = integral (S \<inter> T \<inter> UNIV) (\<lambda>a. 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral T (\<lambda>a. if a \<in> S then 1 else 0) = integral (S \<inter> T \<inter> UNIV) (\<lambda>a. 1)
[PROOF STEP]
by (simp add: Henstock_Kurzweil_Integration.integral_restrict_Int)
[PROOF STATE]
proof (state)
this:
integral T (\<lambda>a. if a \<in> S then 1 else 0) = integral (S \<inter> T \<inter> UNIV) (\<lambda>a. 1)

goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
integral T (\<lambda>a. if a \<in> S then 1 else 0) = integral (S \<inter> T \<inter> UNIV) (\<lambda>a. 1)

goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
have "integral T (indicat_real S) = integral T (\<lambda>a. if a \<in> S then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral T (indicat_real S) = integral T (\<lambda>a. if a \<in> S then 1 else 0)
[PROOF STEP]
by (simp add: indicator_def [abs_def] of_bool_def)
[PROOF STATE]
proof (state)
this:
integral T (indicat_real S) = integral T (\<lambda>a. if a \<in> S then 1 else 0)

goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
integral UNIV (\<lambda>x. if x \<in> S \<inter> T then 1 else 0) = Sigma_Algebra.measure lebesgue (S \<inter> T)
integral T (\<lambda>a. if a \<in> S then 1 else 0) = integral (S \<inter> T \<inter> UNIV) (\<lambda>a. 1)
integral T (indicat_real S) = integral T (\<lambda>a. if a \<in> S then 1 else 0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
integral UNIV (\<lambda>x. if x \<in> S \<inter> T then 1 else 0) = Sigma_Algebra.measure lebesgue (S \<inter> T)
integral T (\<lambda>a. if a \<in> S then 1 else 0) = integral (S \<inter> T \<inter> UNIV) (\<lambda>a. 1)
integral T (indicat_real S) = integral T (\<lambda>a. if a \<in> S then 1 else 0)

goal (1 subgoal):
 1. integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)
[PROOF STEP]
by (simp add: assms lmeasure_integral)
[PROOF STATE]
proof (state)
this:
integral T (indicat_real S) = Sigma_Algebra.measure lebesgue (S \<inter> T)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homeomorphic_contractible_eq:
  fixes S :: "'a::real_normed_vector set" and T :: "'b::real_normed_vector set"
  shows "S homeomorphic T \<Longrightarrow> (contractible S \<longleftrightarrow> contractible T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S homeomorphic T \<Longrightarrow> contractible S = contractible T
[PROOF STEP]
by (simp add: homeomorphic_imp_homotopy_eqv homotopy_eqv_contractibility)


[STATEMENT]
lemma gcd_poly_decompose:
  fixes p q :: "'a :: {factorial_ring_gcd,semiring_gcd_mult_normalize} poly"
  shows "gcd p q =
           smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd p q = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
proof (rule sym, rule gcdI)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd p
 2. smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd q
 3. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 4. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
have "[:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q) dvd
          [:content p:] * primitive_part p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q) dvd [:content p:] * primitive_part p
[PROOF STEP]
by (intro mult_dvd_mono) simp_all
[PROOF STATE]
proof (state)
this:
[:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q) dvd [:content p:] * primitive_part p

goal (4 subgoals):
 1. smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd p
 2. smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd q
 3. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 4. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
thus "smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd p"
[PROOF STATE]
proof (prove)
using this:
[:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q) dvd [:content p:] * primitive_part p

goal (1 subgoal):
 1. smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd p

goal (3 subgoals):
 1. smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd q
 2. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 3. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd q
 2. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 3. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
have "[:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q) dvd
          [:content q:] * primitive_part q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q) dvd [:content q:] * primitive_part q
[PROOF STEP]
by (intro mult_dvd_mono) simp_all
[PROOF STATE]
proof (state)
this:
[:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q) dvd [:content q:] * primitive_part q

goal (3 subgoals):
 1. smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd q
 2. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 3. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
thus "smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd q"
[PROOF STATE]
proof (prove)
using this:
[:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q) dvd [:content q:] * primitive_part q

goal (1 subgoal):
 1. smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q)) dvd q

goal (2 subgoals):
 1. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 2. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 2. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
fix d
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 2. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
assume "d dvd p" "d dvd q"
[PROOF STATE]
proof (state)
this:
d dvd p
d dvd q

goal (2 subgoals):
 1. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 2. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
hence "[:content d:] * primitive_part d dvd
           [:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q)"
[PROOF STATE]
proof (prove)
using this:
d dvd p
d dvd q

goal (1 subgoal):
 1. [:content d:] * primitive_part d dvd [:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q)
[PROOF STEP]
by (intro mult_dvd_mono) auto
[PROOF STATE]
proof (state)
this:
[:content d:] * primitive_part d dvd [:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q)

goal (2 subgoals):
 1. \<And>d. \<lbrakk>d dvd p; d dvd q\<rbrakk> \<Longrightarrow> d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
 2. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
thus "d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))"
[PROOF STATE]
proof (prove)
using this:
[:content d:] * primitive_part d dvd [:gcd (content p) (content q):] * gcd (primitive_part p) (primitive_part q)

goal (1 subgoal):
 1. d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
d dvd smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))

goal (1 subgoal):
 1. normalize (smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))) = smult (gcd (content p) (content q)) (gcd (primitive_part p) (primitive_part q))
[PROOF STEP]
qed (auto simp: normalize_smult)


[STATEMENT]
lemma [code abstract]:
  "integer_of_natural (m - n) = max 0 (integer_of_natural m - integer_of_natural n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integer_of_natural (m - n) = max 0 (integer_of_natural m - integer_of_natural n)
[PROOF STEP]
by transfer simp


[STATEMENT]
lemma nat_of_bool_mod_eq: "nat_of_bool (n mod 2 = 1) = n mod 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_bool (n mod 2 = 1) = n mod 2
[PROOF STEP]
by (cases "n mod 2 = 1") simp_all


[STATEMENT]
theorem metre_definition:
  "1 *\<^sub>Q metre \<cong>\<^sub>Q (\<^bold>c \<^bold>/ (299792458 *\<^sub>Q \<one>))\<^bold>\<cdot>second"
  "1 *\<^sub>Q metre \<cong>\<^sub>Q (9192631770 / 299792458) *\<^sub>Q (\<^bold>c \<^bold>/ \<Delta>v\<^sub>C\<^sub>s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1::'a) *\<^sub>Q metre \<cong>\<^sub>Q \<^bold>c \<^bold>\<cdot> ((299792458::'a) *\<^sub>Q \<one>)\<^sup>-\<^sup>\<one> \<^bold>\<cdot> second &&& (1::'b) *\<^sub>Q metre \<cong>\<^sub>Q (9192631770::'b) / (299792458::'b) *\<^sub>Q \<^bold>c \<^bold>\<cdot> ((9192631770::'b) *\<^sub>Q second\<^sup>-\<^sup>\<one>)\<^sup>-\<^sup>\<one>
[PROOF STEP]
by si_calc+