[STATEMENT]
lemma rsa_bijection:
  assumes coprime: "coprime e ((P-1)*(Q-1))"
    and prime_P: "prime (P::nat)"
    and prime_Q: "prime Q"
    and P_neq_Q: "P \<noteq> Q"
    and x_lt_pq: "x < P * Q"
    and y_lt_pd: "y < P * Q"
    and rsa_map_eq: "x ^ e mod (P * Q) = y ^ e mod (P * Q)"
  shows "x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
have flt_xP: "[x ^ P = x] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ P = x] (mod P)
[PROOF STEP]
using fermat_little prime_P
[PROOF STATE]
proof (prove)
using this:
prime ?P \<Longrightarrow> [?x ^ ?P = ?x] (mod ?P)
prime P

goal (1 subgoal):
 1. [x ^ P = x] (mod P)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[x ^ P = x] (mod P)

goal (1 subgoal):
 1. x = y
[PROOF STEP]
have flt_yP: "[y ^ P = y] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ P = y] (mod P)
[PROOF STEP]
using fermat_little prime_P
[PROOF STATE]
proof (prove)
using this:
prime ?P \<Longrightarrow> [?x ^ ?P = ?x] (mod ?P)
prime P

goal (1 subgoal):
 1. [y ^ P = y] (mod P)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[y ^ P = y] (mod P)

goal (1 subgoal):
 1. x = y
[PROOF STEP]
have flt_xQ: "[x ^ Q = x] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ Q = x] (mod Q)
[PROOF STEP]
using fermat_little prime_Q
[PROOF STATE]
proof (prove)
using this:
prime ?P \<Longrightarrow> [?x ^ ?P = ?x] (mod ?P)
prime Q

goal (1 subgoal):
 1. [x ^ Q = x] (mod Q)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[x ^ Q = x] (mod Q)

goal (1 subgoal):
 1. x = y
[PROOF STEP]
have flt_yQ: "[y ^ Q = y] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ Q = y] (mod Q)
[PROOF STEP]
using fermat_little prime_Q
[PROOF STATE]
proof (prove)
using this:
prime ?P \<Longrightarrow> [?x ^ ?P = ?x] (mod ?P)
prime Q

goal (1 subgoal):
 1. [y ^ Q = y] (mod Q)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[y ^ Q = y] (mod Q)

goal (1 subgoal):
 1. x = y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
proof(cases "y \<ge> x")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x \<le> y

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
hence ye_gt_xe: "y^e \<ge> x^e"
[PROOF STATE]
proof (prove)
using this:
x \<le> y

goal (1 subgoal):
 1. x ^ e \<le> y ^ e
[PROOF STEP]
by (simp add: power_mono)
[PROOF STATE]
proof (state)
this:
x ^ e \<le> y ^ e

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have x_y_exp_e: "[x^e = y^e] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ e = y ^ e] (mod P)
[PROOF STEP]
using cong_modulus_mult_nat  cong_altdef_nat True ye_gt_xe cong_sym cong_def assms
[PROOF STATE]
proof (prove)
using this:
[?x = ?y] (mod ?m * ?n) \<Longrightarrow> [?x = ?y] (mod ?m)
?b \<le> ?a \<Longrightarrow> [?a = ?b] (mod ?m) = (?m dvd ?a - ?b)
x \<le> y
x ^ e \<le> y ^ e
[?b = ?c] (mod ?a) \<Longrightarrow> [?c = ?b] (mod ?a)
[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)
coprime e ((P - 1) * (Q - 1))
prime P
prime Q
P \<noteq> Q
x < P * Q
y < P * Q
x ^ e mod (P * Q) = y ^ e mod (P * Q)

goal (1 subgoal):
 1. [x ^ e = y ^ e] (mod P)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[x ^ e = y ^ e] (mod P)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
obtain d where d:  "[e*d = 1] (mod (P-1)) \<and> d \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>d. [e * d = 1] (mod P - 1) \<and> d \<noteq> 0 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ex_inverse assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>coprime ?e ((?P - 1) * (?Q - 1)); prime ?P; prime ?Q; ?P \<noteq> ?Q\<rbrakk> \<Longrightarrow> \<exists>d. [?e * d = 1] (mod ?P - 1) \<and> d \<noteq> 0
coprime e ((P - 1) * (Q - 1))
prime P
prime Q
P \<noteq> Q
x < P * Q
y < P * Q
x ^ e mod (P * Q) = y ^ e mod (P * Q)

goal (1 subgoal):
 1. (\<And>d. [e * d = 1] (mod P - 1) \<and> d \<noteq> 0 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[e * d = 1] (mod P - 1) \<and> d \<noteq> 0

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[e * d = 1] (mod P - 1) \<and> d \<noteq> 0
[PROOF STEP]
obtain k where k: "e*d = 1 + k*(P-1)"
[PROOF STATE]
proof (prove)
using this:
[e * d = 1] (mod P - 1) \<and> d \<noteq> 0

goal (1 subgoal):
 1. (\<And>k. e * d = 1 + k * (P - 1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ex_k_mod assms
[PROOF STATE]
proof (prove)
using this:
[e * d = 1] (mod P - 1) \<and> d \<noteq> 0
\<lbrakk>coprime ?e ((?P - 1) * (?Q - 1)); ?P \<noteq> ?Q; prime ?P; prime ?Q; ?d \<noteq> 0; [?e * ?d = 1] (mod ?P - 1)\<rbrakk> \<Longrightarrow> \<exists>k. ?e * ?d = 1 + k * (?P - 1)
coprime e ((P - 1) * (Q - 1))
prime P
prime Q
P \<noteq> Q
x < P * Q
y < P * Q
x ^ e mod (P * Q) = y ^ e mod (P * Q)

goal (1 subgoal):
 1. (\<And>k. e * d = 1 + k * (P - 1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
e * d = 1 + k * (P - 1)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
hence xk_yk: "[x^(1 + k*(P-1)) = y^(1 + k*(P-1))] (mod P)"
[PROOF STATE]
proof (prove)
using this:
e * d = 1 + k * (P - 1)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)
[PROOF STEP]
by(metis k power_mult x_y_exp_e cong_pow)
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have xk_x: "[x^(1 + k*(P-1)) = x] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P)
[PROOF STEP]
proof(induct k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [x ^ (1 + 0 * (P - 1)) = x] (mod P)
 2. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. [x ^ (1 + 0 * (P - 1)) = x] (mod P)
 2. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + 0 * (P - 1)) = x] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + 0 * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
assume  asm: "[x ^ (1 + k * (P - 1)) = x] (mod P)"
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[x ^ (1 + k * (P - 1)) = x] (mod P)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
have exp_rewrite: "(k * (P - 1) + P) = (1 + (k + 1) * (P - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k * (P - 1) + P = 1 + (k + 1) * (P - 1)
[PROOF STEP]
by (smt add.assoc add.commute le_add_diff_inverse nat_le_linear not_add_less1 prime_P prime_gt_1_nat semiring_normalization_rules(3))
[PROOF STATE]
proof (state)
this:
k * (P - 1) + P = 1 + (k + 1) * (P - 1)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
have "[x * x ^ (k * (P - 1)) = x] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x * x ^ (k * (P - 1)) = x] (mod P)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x * x ^ (k * (P - 1)) = x] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x * x ^ (k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
hence "[x ^ (k * (P - 1)) * x ^ P = x] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[x * x ^ (k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (k * (P - 1)) * x ^ P = x] (mod P)
[PROOF STEP]
using flt_xP
[PROOF STATE]
proof (prove)
using this:
[x * x ^ (k * (P - 1)) = x] (mod P)
[x ^ P = x] (mod P)

goal (1 subgoal):
 1. [x ^ (k * (P - 1)) * x ^ P = x] (mod P)
[PROOF STEP]
by (metis cong_scalar_right cong_trans mult.commute)
[PROOF STATE]
proof (state)
this:
[x ^ (k * (P - 1)) * x ^ P = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
hence "[x ^ (k * (P - 1) + P) = x] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[x ^ (k * (P - 1)) * x ^ P = x] (mod P)

goal (1 subgoal):
 1. [x ^ (k * (P - 1) + P) = x] (mod P)
[PROOF STEP]
by (simp add: power_add)
[PROOF STATE]
proof (state)
this:
[x ^ (k * (P - 1) + P) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
hence "[x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[x ^ (k * (P - 1) + P) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)
[PROOF STEP]
using exp_rewrite
[PROOF STATE]
proof (prove)
using this:
[x ^ (k * (P - 1) + P) = x] (mod P)
k * (P - 1) + P = 1 + (k + 1) * (P - 1)

goal (1 subgoal):
 1. [x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
[x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + Suc k * (P - 1)) = x] (mod P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + Suc k * (P - 1)) = x] (mod P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have yk_y: "[y^(1 + k*(P-1)) = y] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P)
[PROOF STEP]
proof(induct k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [y ^ (1 + 0 * (P - 1)) = y] (mod P)
 2. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. [y ^ (1 + 0 * (P - 1)) = y] (mod P)
 2. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ (1 + 0 * (P - 1)) = y] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y ^ (1 + 0 * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
assume  asm: "[y ^ (1 + k * (P - 1)) = y] (mod P)"
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[y ^ (1 + k * (P - 1)) = y] (mod P)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
have exp_rewrite: "(k * (P - 1) + P) = (1 + (k + 1) * (P - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k * (P - 1) + P = 1 + (k + 1) * (P - 1)
[PROOF STEP]
by (smt add.assoc add.commute le_add_diff_inverse nat_le_linear not_add_less1 prime_P prime_gt_1_nat semiring_normalization_rules(3))
[PROOF STATE]
proof (state)
this:
k * (P - 1) + P = 1 + (k + 1) * (P - 1)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
have "[y * y ^ (k * (P - 1)) = y] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y * y ^ (k * (P - 1)) = y] (mod P)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y * y ^ (k * (P - 1)) = y] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y * y ^ (k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
hence "[y ^ (k * (P - 1)) * y ^ P = y] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[y * y ^ (k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (k * (P - 1)) * y ^ P = y] (mod P)
[PROOF STEP]
using flt_yP
[PROOF STATE]
proof (prove)
using this:
[y * y ^ (k * (P - 1)) = y] (mod P)
[y ^ P = y] (mod P)

goal (1 subgoal):
 1. [y ^ (k * (P - 1)) * y ^ P = y] (mod P)
[PROOF STEP]
by (metis cong_scalar_right cong_trans mult.commute)
[PROOF STATE]
proof (state)
this:
[y ^ (k * (P - 1)) * y ^ P = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
hence "[y ^ (k * (P - 1) + P) = y] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[y ^ (k * (P - 1)) * y ^ P = y] (mod P)

goal (1 subgoal):
 1. [y ^ (k * (P - 1) + P) = y] (mod P)
[PROOF STEP]
by (simp add: power_add)
[PROOF STATE]
proof (state)
this:
[y ^ (k * (P - 1) + P) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
hence "[y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[y ^ (k * (P - 1) + P) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)
[PROOF STEP]
using exp_rewrite
[PROOF STATE]
proof (prove)
using this:
[y ^ (k * (P - 1) + P) = y] (mod P)
k * (P - 1) + P = 1 + (k + 1) * (P - 1)

goal (1 subgoal):
 1. [y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
[y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y ^ (1 + Suc k * (P - 1)) = y] (mod P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[y ^ (1 + Suc k * (P - 1)) = y] (mod P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have "[x^e = y^e] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ e = y ^ e] (mod Q)
[PROOF STEP]
by (metis rsa_map_eq cong_modulus_mult_nat cong_def mult.commute)
[PROOF STATE]
proof (state)
this:
[x ^ e = y ^ e] (mod Q)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
obtain d' where d':  "[e*d' = 1] (mod (Q-1)) \<and> d' \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>d'. [e * d' = 1] (mod Q - 1) \<and> d' \<noteq> 0 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis mult.commute ex_inverse prime_P prime_Q P_neq_Q coprime)
[PROOF STATE]
proof (state)
this:
[e * d' = 1] (mod Q - 1) \<and> d' \<noteq> 0

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[e * d' = 1] (mod Q - 1) \<and> d' \<noteq> 0
[PROOF STEP]
obtain k' where k': "e*d' = 1 + k'*(Q-1)"
[PROOF STATE]
proof (prove)
using this:
[e * d' = 1] (mod Q - 1) \<and> d' \<noteq> 0

goal (1 subgoal):
 1. (\<And>k'. e * d' = 1 + k' * (Q - 1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by(metis ex_k_mod mult.commute prime_P prime_Q P_neq_Q coprime)
[PROOF STATE]
proof (state)
this:
e * d' = 1 + k' * (Q - 1)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
hence xk_yk': "[x^(1 + k'*(Q-1)) = y^(1 + k'*(Q-1))] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
e * d' = 1 + k' * (Q - 1)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)
[PROOF STEP]
by(metis k' power_mult \<open>[x ^ e = y ^ e] (mod Q)\<close> cong_pow)
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have xk_x': "[x^(1 + k'*(Q-1)) = x] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
proof(induct k')
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [x ^ (1 + 0 * (Q - 1)) = x] (mod Q)
 2. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. [x ^ (1 + 0 * (Q - 1)) = x] (mod Q)
 2. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + 0 * (Q - 1)) = x] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + 0 * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
case (Suc k')
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
assume  asm: "[x ^ (1 + k' * (Q - 1)) = x] (mod Q)"
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
have exp_rewrite: "(k' * (Q - 1) + Q) = (1 + (k' + 1) * (Q - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)
[PROOF STEP]
by (smt add.assoc add.commute le_add_diff_inverse nat_le_linear not_add_less1 prime_Q prime_gt_1_nat semiring_normalization_rules(3))
[PROOF STATE]
proof (state)
this:
k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
have "[x * x ^ (k' * (Q - 1)) = x] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x * x ^ (k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x * x ^ (k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x * x ^ (k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
hence "[x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[x * x ^ (k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)
[PROOF STEP]
using flt_xQ
[PROOF STATE]
proof (prove)
using this:
[x * x ^ (k' * (Q - 1)) = x] (mod Q)
[x ^ Q = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)
[PROOF STEP]
by (metis cong_scalar_right cong_trans mult.commute)
[PROOF STATE]
proof (state)
this:
[x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
hence "[x ^ (k' * (Q - 1) + Q) = x] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (k' * (Q - 1) + Q) = x] (mod Q)
[PROOF STEP]
by (simp add: power_add)
[PROOF STATE]
proof (state)
this:
[x ^ (k' * (Q - 1) + Q) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
hence "[x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[x ^ (k' * (Q - 1) + Q) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)
[PROOF STEP]
using exp_rewrite
[PROOF STATE]
proof (prove)
using this:
[x ^ (k' * (Q - 1) + Q) = x] (mod Q)
k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)

goal (1 subgoal):
 1. [x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
[x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have yk_y': "[y^(1 + k'*(Q-1)) = y] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
proof(induct k')
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [y ^ (1 + 0 * (Q - 1)) = y] (mod Q)
 2. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. [y ^ (1 + 0 * (Q - 1)) = y] (mod Q)
 2. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ (1 + 0 * (Q - 1)) = y] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y ^ (1 + 0 * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
case (Suc k')
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
assume  asm: "[y ^ (1 + k' * (Q - 1)) = y] (mod Q)"
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
have exp_rewrite: "(k' * (Q - 1) + Q) = (1 + (k' + 1) * (Q - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)
[PROOF STEP]
by (smt add.assoc add.commute le_add_diff_inverse nat_le_linear not_add_less1 prime_Q prime_gt_1_nat semiring_normalization_rules(3))
[PROOF STATE]
proof (state)
this:
k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
have "[y * y ^ (k' * (Q - 1)) = y] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y * y ^ (k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y * y ^ (k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y * y ^ (k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
hence "[y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[y * y ^ (k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)
[PROOF STEP]
using flt_yQ
[PROOF STATE]
proof (prove)
using this:
[y * y ^ (k' * (Q - 1)) = y] (mod Q)
[y ^ Q = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)
[PROOF STEP]
by (metis cong_scalar_right cong_trans mult.commute)
[PROOF STATE]
proof (state)
this:
[y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
hence "[y ^ (k' * (Q - 1) + Q) = y] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (k' * (Q - 1) + Q) = y] (mod Q)
[PROOF STEP]
by (simp add: power_add)
[PROOF STATE]
proof (state)
this:
[y ^ (k' * (Q - 1) + Q) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
hence "[y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[y ^ (k' * (Q - 1) + Q) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)
[PROOF STEP]
using exp_rewrite
[PROOF STATE]
proof (prove)
using this:
[y ^ (k' * (Q - 1) + Q) = y] (mod Q)
k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)

goal (1 subgoal):
 1. [y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
[y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have P_dvd_xy: "P dvd (y - x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P dvd y - x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. P dvd y - x
[PROOF STEP]
have "[x = y] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x = y] (mod P)
[PROOF STEP]
using xk_x yk_y xk_yk
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k * (P - 1)) = x] (mod P)
[y ^ (1 + k * (P - 1)) = y] (mod P)
[x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)

goal (1 subgoal):
 1. [x = y] (mod P)
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[x = y] (mod P)

goal (1 subgoal):
 1. P dvd y - x
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod P)

goal (1 subgoal):
 1. P dvd y - x
[PROOF STEP]
using cong_altdef_nat cong_sym True
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod P)
?b \<le> ?a \<Longrightarrow> [?a = ?b] (mod ?m) = (?m dvd ?a - ?b)
[?b = ?c] (mod ?a) \<Longrightarrow> [?c = ?b] (mod ?a)
x \<le> y

goal (1 subgoal):
 1. P dvd y - x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
P dvd y - x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
P dvd y - x

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have Q_dvd_xy: "Q dvd (y - x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Q dvd y - x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Q dvd y - x
[PROOF STEP]
have "[x = y] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x = y] (mod Q)
[PROOF STEP]
using xk_x' yk_y' xk_yk'
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)
[x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)

goal (1 subgoal):
 1. [x = y] (mod Q)
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[x = y] (mod Q)

goal (1 subgoal):
 1. Q dvd y - x
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod Q)

goal (1 subgoal):
 1. Q dvd y - x
[PROOF STEP]
using cong_altdef_nat cong_sym True
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod Q)
?b \<le> ?a \<Longrightarrow> [?a = ?b] (mod ?m) = (?m dvd ?a - ?b)
[?b = ?c] (mod ?a) \<Longrightarrow> [?c = ?b] (mod ?a)
x \<le> y

goal (1 subgoal):
 1. Q dvd y - x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Q dvd y - x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Q dvd y - x

goal (2 subgoals):
 1. x \<le> y \<Longrightarrow> x = y
 2. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
have "P*Q dvd (y - x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P * Q dvd y - x
[PROOF STEP]
using P_dvd_xy  Q_dvd_xy
[PROOF STATE]
proof (prove)
using this:
P dvd y - x
Q dvd y - x

goal (1 subgoal):
 1. P * Q dvd y - x
[PROOF STEP]
by (simp add: assms divides_mult primes_coprime)
[PROOF STATE]
proof (state)
this:
P * Q dvd y - x

goal (1 subgoal):
 1. x = y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
P * Q dvd y - x
[PROOF STEP]
have "[x = y] (mod P*Q)"
[PROOF STATE]
proof (prove)
using this:
P * Q dvd y - x

goal (1 subgoal):
 1. [x = y] (mod P * Q)
[PROOF STEP]
by (simp add: cong_altdef_nat cong_sym True)
[PROOF STATE]
proof (state)
this:
[x = y] (mod P * Q)

goal (1 subgoal):
 1. x = y
[PROOF STEP]
hence "x mod P*Q = y mod P*Q"
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod P * Q)

goal (1 subgoal):
 1. x mod P * Q = y mod P * Q
[PROOF STEP]
using  cong_def xk_x xk_yk yk_y
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod P * Q)
[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)
[x ^ (1 + k * (P - 1)) = x] (mod P)
[x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. x mod P * Q = y mod P * Q
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
x mod P * Q = y mod P * Q

goal (1 subgoal):
 1. x = y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x mod P * Q = y mod P * Q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x mod P * Q = y mod P * Q

goal (1 subgoal):
 1. x = y
[PROOF STEP]
using \<open>[x = y] (mod P * Q)\<close> cong_less_modulus_unique_nat x_lt_pq y_lt_pd
[PROOF STATE]
proof (prove)
using this:
x mod P * Q = y mod P * Q
[x = y] (mod P * Q)
\<lbrakk>[?x = ?y] (mod ?m); ?x < ?m; ?y < ?m\<rbrakk> \<Longrightarrow> ?x = ?y
x < P * Q
y < P * Q

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x = y

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> x \<le> y

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
hence ye_gt_xe: "x^e \<ge> y^e"
[PROOF STATE]
proof (prove)
using this:
\<not> x \<le> y

goal (1 subgoal):
 1. y ^ e \<le> x ^ e
[PROOF STEP]
by (simp add: power_mono)
[PROOF STATE]
proof (state)
this:
y ^ e \<le> x ^ e

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have pow_eq: "[x^e = y^e] (mod P*Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ e = y ^ e] (mod P * Q)
[PROOF STEP]
by (simp add: cong_def assms)
[PROOF STATE]
proof (state)
this:
[x ^ e = y ^ e] (mod P * Q)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[x ^ e = y ^ e] (mod P * Q)
[PROOF STEP]
have PQ_dvd_ye_xe: "(P*Q) dvd (x^e - y^e)"
[PROOF STATE]
proof (prove)
using this:
[x ^ e = y ^ e] (mod P * Q)

goal (1 subgoal):
 1. P * Q dvd x ^ e - y ^ e
[PROOF STEP]
using cong_altdef_nat False ye_gt_xe cong_sym
[PROOF STATE]
proof (prove)
using this:
[x ^ e = y ^ e] (mod P * Q)
?b \<le> ?a \<Longrightarrow> [?a = ?b] (mod ?m) = (?m dvd ?a - ?b)
\<not> x \<le> y
y ^ e \<le> x ^ e
[?b = ?c] (mod ?a) \<Longrightarrow> [?c = ?b] (mod ?a)

goal (1 subgoal):
 1. P * Q dvd x ^ e - y ^ e
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
P * Q dvd x ^ e - y ^ e

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
P * Q dvd x ^ e - y ^ e
[PROOF STEP]
have "[x^e = y^e] (mod P)"
[PROOF STATE]
proof (prove)
using this:
P * Q dvd x ^ e - y ^ e

goal (1 subgoal):
 1. [x ^ e = y ^ e] (mod P)
[PROOF STEP]
using cong_modulus_mult_nat pow_eq
[PROOF STATE]
proof (prove)
using this:
P * Q dvd x ^ e - y ^ e
[?x = ?y] (mod ?m * ?n) \<Longrightarrow> [?x = ?y] (mod ?m)
[x ^ e = y ^ e] (mod P * Q)

goal (1 subgoal):
 1. [x ^ e = y ^ e] (mod P)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[x ^ e = y ^ e] (mod P)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
obtain d where d:  "[e*d = 1] (mod (P-1)) \<and> d \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>d. [e * d = 1] (mod P - 1) \<and> d \<noteq> 0 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ex_inverse assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>coprime ?e ((?P - 1) * (?Q - 1)); prime ?P; prime ?Q; ?P \<noteq> ?Q\<rbrakk> \<Longrightarrow> \<exists>d. [?e * d = 1] (mod ?P - 1) \<and> d \<noteq> 0
coprime e ((P - 1) * (Q - 1))
prime P
prime Q
P \<noteq> Q
x < P * Q
y < P * Q
x ^ e mod (P * Q) = y ^ e mod (P * Q)

goal (1 subgoal):
 1. (\<And>d. [e * d = 1] (mod P - 1) \<and> d \<noteq> 0 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[e * d = 1] (mod P - 1) \<and> d \<noteq> 0

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[e * d = 1] (mod P - 1) \<and> d \<noteq> 0
[PROOF STEP]
obtain k where k: "e*d = 1 + k*(P-1)"
[PROOF STATE]
proof (prove)
using this:
[e * d = 1] (mod P - 1) \<and> d \<noteq> 0

goal (1 subgoal):
 1. (\<And>k. e * d = 1 + k * (P - 1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ex_k_mod assms
[PROOF STATE]
proof (prove)
using this:
[e * d = 1] (mod P - 1) \<and> d \<noteq> 0
\<lbrakk>coprime ?e ((?P - 1) * (?Q - 1)); ?P \<noteq> ?Q; prime ?P; prime ?Q; ?d \<noteq> 0; [?e * ?d = 1] (mod ?P - 1)\<rbrakk> \<Longrightarrow> \<exists>k. ?e * ?d = 1 + k * (?P - 1)
coprime e ((P - 1) * (Q - 1))
prime P
prime Q
P \<noteq> Q
x < P * Q
y < P * Q
x ^ e mod (P * Q) = y ^ e mod (P * Q)

goal (1 subgoal):
 1. (\<And>k. e * d = 1 + k * (P - 1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
e * d = 1 + k * (P - 1)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have xk_yk: "[x^(1 + k*(P-1)) = y^(1 + k*(P-1))] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)
[PROOF STEP]
have "[(x^e)^d = (y^e)^d] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [(x ^ e) ^ d = (y ^ e) ^ d] (mod P)
[PROOF STEP]
using \<open>[x ^ e = y ^ e] (mod P)\<close> cong_pow
[PROOF STATE]
proof (prove)
using this:
[x ^ e = y ^ e] (mod P)
[?b = ?c] (mod ?a) \<Longrightarrow> [?b ^ ?n = ?c ^ ?n] (mod ?a)

goal (1 subgoal):
 1. [(x ^ e) ^ d = (y ^ e) ^ d] (mod P)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[(x ^ e) ^ d = (y ^ e) ^ d] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[(x ^ e) ^ d = (y ^ e) ^ d] (mod P)
[PROOF STEP]
have "[x^(e*d) = y^(e*d)] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[(x ^ e) ^ d = (y ^ e) ^ d] (mod P)

goal (1 subgoal):
 1. [x ^ (e * d) = y ^ (e * d)] (mod P)
[PROOF STEP]
by (simp add: power_mult)
[PROOF STATE]
proof (state)
this:
[x ^ (e * d) = y ^ (e * d)] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x ^ (e * d) = y ^ (e * d)] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)
[PROOF STEP]
using k
[PROOF STATE]
proof (prove)
using this:
[x ^ (e * d) = y ^ (e * d)] (mod P)
e * d = 1 + k * (P - 1)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have xk_x: "[x^(1 + k*(P-1)) = x] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P)
[PROOF STEP]
proof(induct k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [x ^ (1 + 0 * (P - 1)) = x] (mod P)
 2. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. [x ^ (1 + 0 * (P - 1)) = x] (mod P)
 2. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + 0 * (P - 1)) = x] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + 0 * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
assume  asm: "[x ^ (1 + k * (P - 1)) = x] (mod P)"
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. \<And>k. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[x ^ (1 + k * (P - 1)) = x] (mod P)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
have exp_rewrite: "(k * (P - 1) + P) = (1 + (k + 1) * (P - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k * (P - 1) + P = 1 + (k + 1) * (P - 1)
[PROOF STEP]
by (smt add.assoc add.commute le_add_diff_inverse nat_le_linear not_add_less1 prime_P prime_gt_1_nat semiring_normalization_rules(3))
[PROOF STATE]
proof (state)
this:
k * (P - 1) + P = 1 + (k + 1) * (P - 1)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
have "[x * x ^ (k * (P - 1)) = x] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x * x ^ (k * (P - 1)) = x] (mod P)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x * x ^ (k * (P - 1)) = x] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x * x ^ (k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
hence "[x ^ (k * (P - 1)) * x ^ P = x] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[x * x ^ (k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (k * (P - 1)) * x ^ P = x] (mod P)
[PROOF STEP]
using flt_xP
[PROOF STATE]
proof (prove)
using this:
[x * x ^ (k * (P - 1)) = x] (mod P)
[x ^ P = x] (mod P)

goal (1 subgoal):
 1. [x ^ (k * (P - 1)) * x ^ P = x] (mod P)
[PROOF STEP]
by (metis cong_scalar_right cong_trans mult.commute)
[PROOF STATE]
proof (state)
this:
[x ^ (k * (P - 1)) * x ^ P = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
hence "[x ^ (k * (P - 1) + P) = x] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[x ^ (k * (P - 1)) * x ^ P = x] (mod P)

goal (1 subgoal):
 1. [x ^ (k * (P - 1) + P) = x] (mod P)
[PROOF STEP]
by (simp add: power_add)
[PROOF STATE]
proof (state)
this:
[x ^ (k * (P - 1) + P) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
hence "[x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[x ^ (k * (P - 1) + P) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)
[PROOF STEP]
using exp_rewrite
[PROOF STATE]
proof (prove)
using this:
[x ^ (k * (P - 1) + P) = x] (mod P)
k * (P - 1) + P = 1 + (k + 1) * (P - 1)

goal (1 subgoal):
 1. [x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
[x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + k * (P - 1)) = x] (mod P) \<Longrightarrow> [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + (k + 1) * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. [x ^ (1 + Suc k * (P - 1)) = x] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + Suc k * (P - 1)) = x] (mod P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + Suc k * (P - 1)) = x] (mod P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k * (P - 1)) = x] (mod P)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have yk_y: "[y^(1 + k*(P-1)) = y] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P)
[PROOF STEP]
proof(induct k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [y ^ (1 + 0 * (P - 1)) = y] (mod P)
 2. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. [y ^ (1 + 0 * (P - 1)) = y] (mod P)
 2. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ (1 + 0 * (P - 1)) = y] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y ^ (1 + 0 * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
assume  asm: "[y ^ (1 + k * (P - 1)) = y] (mod P)"
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. \<And>k. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[y ^ (1 + k * (P - 1)) = y] (mod P)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
have exp_rewrite: "(k * (P - 1) + P) = (1 + (k + 1) * (P - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k * (P - 1) + P = 1 + (k + 1) * (P - 1)
[PROOF STEP]
by (smt add.assoc add.commute le_add_diff_inverse nat_le_linear not_add_less1 prime_P prime_gt_1_nat semiring_normalization_rules(3))
[PROOF STATE]
proof (state)
this:
k * (P - 1) + P = 1 + (k + 1) * (P - 1)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
have "[y * y ^ (k * (P - 1)) = y] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y * y ^ (k * (P - 1)) = y] (mod P)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y * y ^ (k * (P - 1)) = y] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y * y ^ (k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
hence "[y ^ (k * (P - 1)) * y ^ P = y] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[y * y ^ (k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (k * (P - 1)) * y ^ P = y] (mod P)
[PROOF STEP]
using flt_yP
[PROOF STATE]
proof (prove)
using this:
[y * y ^ (k * (P - 1)) = y] (mod P)
[y ^ P = y] (mod P)

goal (1 subgoal):
 1. [y ^ (k * (P - 1)) * y ^ P = y] (mod P)
[PROOF STEP]
by (metis cong_scalar_right cong_trans mult.commute)
[PROOF STATE]
proof (state)
this:
[y ^ (k * (P - 1)) * y ^ P = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
hence "[y ^ (k * (P - 1) + P) = y] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[y ^ (k * (P - 1)) * y ^ P = y] (mod P)

goal (1 subgoal):
 1. [y ^ (k * (P - 1) + P) = y] (mod P)
[PROOF STEP]
by (simp add: power_add)
[PROOF STATE]
proof (state)
this:
[y ^ (k * (P - 1) + P) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
hence "[y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)"
[PROOF STATE]
proof (prove)
using this:
[y ^ (k * (P - 1) + P) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)
[PROOF STEP]
using exp_rewrite
[PROOF STATE]
proof (prove)
using this:
[y ^ (k * (P - 1) + P) = y] (mod P)
k * (P - 1) + P = 1 + (k + 1) * (P - 1)

goal (1 subgoal):
 1. [y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
[y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + k * (P - 1)) = y] (mod P) \<Longrightarrow> [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + (k + 1) * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. [y ^ (1 + Suc k * (P - 1)) = y] (mod P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y ^ (1 + Suc k * (P - 1)) = y] (mod P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[y ^ (1 + Suc k * (P - 1)) = y] (mod P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k * (P - 1)) = y] (mod P)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have P_dvd_xy: "P dvd (x - y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P dvd x - y
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. P dvd x - y
[PROOF STEP]
have "[x = y] (mod P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x = y] (mod P)
[PROOF STEP]
using xk_x yk_y xk_yk
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k * (P - 1)) = x] (mod P)
[y ^ (1 + k * (P - 1)) = y] (mod P)
[x ^ (1 + k * (P - 1)) = y ^ (1 + k * (P - 1))] (mod P)

goal (1 subgoal):
 1. [x = y] (mod P)
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[x = y] (mod P)

goal (1 subgoal):
 1. P dvd x - y
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod P)

goal (1 subgoal):
 1. P dvd x - y
[PROOF STEP]
using cong_altdef_nat cong_sym False
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod P)
?b \<le> ?a \<Longrightarrow> [?a = ?b] (mod ?m) = (?m dvd ?a - ?b)
[?b = ?c] (mod ?a) \<Longrightarrow> [?c = ?b] (mod ?a)
\<not> x \<le> y

goal (1 subgoal):
 1. P dvd x - y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
P dvd x - y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
P dvd x - y

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have "[x^e = y^e] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ e = y ^ e] (mod Q)
[PROOF STEP]
using cong_modulus_mult_nat pow_eq PQ_dvd_ye_xe cong_dvd_modulus_nat dvd_triv_right
[PROOF STATE]
proof (prove)
using this:
[?x = ?y] (mod ?m * ?n) \<Longrightarrow> [?x = ?y] (mod ?m)
[x ^ e = y ^ e] (mod P * Q)
P * Q dvd x ^ e - y ^ e
\<lbrakk>[?x = ?y] (mod ?m); ?n dvd ?m\<rbrakk> \<Longrightarrow> [?x = ?y] (mod ?n)
?a dvd ?b * ?a

goal (1 subgoal):
 1. [x ^ e = y ^ e] (mod Q)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[x ^ e = y ^ e] (mod Q)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
obtain d' where d':  "[e*d' = 1] (mod (Q-1)) \<and> d' \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>d'. [e * d' = 1] (mod Q - 1) \<and> d' \<noteq> 0 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis mult.commute ex_inverse prime_P prime_Q coprime P_neq_Q)
[PROOF STATE]
proof (state)
this:
[e * d' = 1] (mod Q - 1) \<and> d' \<noteq> 0

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[e * d' = 1] (mod Q - 1) \<and> d' \<noteq> 0
[PROOF STEP]
obtain k' where k': "e*d' = 1 + k'*(Q-1)"
[PROOF STATE]
proof (prove)
using this:
[e * d' = 1] (mod Q - 1) \<and> d' \<noteq> 0

goal (1 subgoal):
 1. (\<And>k'. e * d' = 1 + k' * (Q - 1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by(metis ex_k_mod mult.commute prime_P prime_Q coprime P_neq_Q)
[PROOF STATE]
proof (state)
this:
e * d' = 1 + k' * (Q - 1)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have xk_yk': "[x^(1 + k'*(Q-1)) = y^(1 + k'*(Q-1))] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)
[PROOF STEP]
have "[(x^e)^d' = (y^e)^d'] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [(x ^ e) ^ d' = (y ^ e) ^ d'] (mod Q)
[PROOF STEP]
using \<open>[x ^ e = y ^ e] (mod Q)\<close> cong_pow
[PROOF STATE]
proof (prove)
using this:
[x ^ e = y ^ e] (mod Q)
[?b = ?c] (mod ?a) \<Longrightarrow> [?b ^ ?n = ?c ^ ?n] (mod ?a)

goal (1 subgoal):
 1. [(x ^ e) ^ d' = (y ^ e) ^ d'] (mod Q)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[(x ^ e) ^ d' = (y ^ e) ^ d'] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[(x ^ e) ^ d' = (y ^ e) ^ d'] (mod Q)
[PROOF STEP]
have "[x^(e*d') = y^(e*d')] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[(x ^ e) ^ d' = (y ^ e) ^ d'] (mod Q)

goal (1 subgoal):
 1. [x ^ (e * d') = y ^ (e * d')] (mod Q)
[PROOF STEP]
by (simp add: power_mult)
[PROOF STATE]
proof (state)
this:
[x ^ (e * d') = y ^ (e * d')] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x ^ (e * d') = y ^ (e * d')] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)
[PROOF STEP]
using k'
[PROOF STATE]
proof (prove)
using this:
[x ^ (e * d') = y ^ (e * d')] (mod Q)
e * d' = 1 + k' * (Q - 1)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have xk_x': "[x^(1 + k'*(Q-1)) = x] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
proof(induct k')
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [x ^ (1 + 0 * (Q - 1)) = x] (mod Q)
 2. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. [x ^ (1 + 0 * (Q - 1)) = x] (mod Q)
 2. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x ^ (1 + 0 * (Q - 1)) = x] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + 0 * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
case (Suc k')
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
assume  asm: "[x ^ (1 + k' * (Q - 1)) = x] (mod Q)"
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
have exp_rewrite: "(k' * (Q - 1) + Q) = (1 + (k' + 1) * (Q - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)
[PROOF STEP]
by (smt add.assoc add.commute le_add_diff_inverse nat_le_linear not_add_less1 prime_Q prime_gt_1_nat semiring_normalization_rules(3))
[PROOF STATE]
proof (state)
this:
k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
have "[x * x ^ (k' * (Q - 1)) = x] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x * x ^ (k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x * x ^ (k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x * x ^ (k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
hence "[x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[x * x ^ (k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)
[PROOF STEP]
using flt_xQ
[PROOF STATE]
proof (prove)
using this:
[x * x ^ (k' * (Q - 1)) = x] (mod Q)
[x ^ Q = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)
[PROOF STEP]
by (metis cong_scalar_right cong_trans mult.commute)
[PROOF STATE]
proof (state)
this:
[x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
hence "[x ^ (k' * (Q - 1) + Q) = x] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[x ^ (k' * (Q - 1)) * x ^ Q = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (k' * (Q - 1) + Q) = x] (mod Q)
[PROOF STEP]
by (simp add: power_add)
[PROOF STATE]
proof (state)
this:
[x ^ (k' * (Q - 1) + Q) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
hence "[x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[x ^ (k' * (Q - 1) + Q) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)
[PROOF STEP]
using exp_rewrite
[PROOF STATE]
proof (prove)
using this:
[x ^ (k' * (Q - 1) + Q) = x] (mod Q)
k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)

goal (1 subgoal):
 1. [x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
[x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + k' * (Q - 1)) = x] (mod Q) \<Longrightarrow> [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + (k' + 1) * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. [x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + Suc k' * (Q - 1)) = x] (mod Q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have yk_y': "[y^(1 + k'*(Q-1)) = y] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
proof(induct k')
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [y ^ (1 + 0 * (Q - 1)) = y] (mod Q)
 2. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. [y ^ (1 + 0 * (Q - 1)) = y] (mod Q)
 2. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y ^ (1 + 0 * (Q - 1)) = y] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y ^ (1 + 0 * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
case (Suc k')
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
assume  asm: "[y ^ (1 + k' * (Q - 1)) = y] (mod Q)"
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. \<And>k'. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
have exp_rewrite: "(k' * (Q - 1) + Q) = (1 + (k' + 1) * (Q - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)
[PROOF STEP]
by (smt add.assoc add.commute le_add_diff_inverse nat_le_linear not_add_less1 prime_Q prime_gt_1_nat semiring_normalization_rules(3))
[PROOF STATE]
proof (state)
this:
k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
have "[y * y ^ (k' * (Q - 1)) = y] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y * y ^ (k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y * y ^ (k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y * y ^ (k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
hence "[y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[y * y ^ (k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)
[PROOF STEP]
using flt_yQ
[PROOF STATE]
proof (prove)
using this:
[y * y ^ (k' * (Q - 1)) = y] (mod Q)
[y ^ Q = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)
[PROOF STEP]
by (metis cong_scalar_right cong_trans mult.commute)
[PROOF STATE]
proof (state)
this:
[y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
hence "[y ^ (k' * (Q - 1) + Q) = y] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[y ^ (k' * (Q - 1)) * y ^ Q = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (k' * (Q - 1) + Q) = y] (mod Q)
[PROOF STEP]
by (simp add: power_add)
[PROOF STATE]
proof (state)
this:
[y ^ (k' * (Q - 1) + Q) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
hence "[y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)"
[PROOF STATE]
proof (prove)
using this:
[y ^ (k' * (Q - 1) + Q) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)
[PROOF STEP]
using exp_rewrite
[PROOF STATE]
proof (prove)
using this:
[y ^ (k' * (Q - 1) + Q) = y] (mod Q)
k' * (Q - 1) + Q = 1 + (k' + 1) * (Q - 1)

goal (1 subgoal):
 1. [y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
[y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + k' * (Q - 1)) = y] (mod Q) \<Longrightarrow> [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[y ^ (1 + (k' + 1) * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. [y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[y ^ (1 + Suc k' * (Q - 1)) = y] (mod Q)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
have Q_dvd_xy: "Q dvd (x - y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Q dvd x - y
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Q dvd x - y
[PROOF STEP]
have "[x = y] (mod Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x = y] (mod Q)
[PROOF STEP]
using xk_x' yk_y' xk_yk'
[PROOF STATE]
proof (prove)
using this:
[x ^ (1 + k' * (Q - 1)) = x] (mod Q)
[y ^ (1 + k' * (Q - 1)) = y] (mod Q)
[x ^ (1 + k' * (Q - 1)) = y ^ (1 + k' * (Q - 1))] (mod Q)

goal (1 subgoal):
 1. [x = y] (mod Q)
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[x = y] (mod Q)

goal (1 subgoal):
 1. Q dvd x - y
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod Q)

goal (1 subgoal):
 1. Q dvd x - y
[PROOF STEP]
using cong_altdef_nat cong_sym False
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod Q)
?b \<le> ?a \<Longrightarrow> [?a = ?b] (mod ?m) = (?m dvd ?a - ?b)
[?b = ?c] (mod ?a) \<Longrightarrow> [?c = ?b] (mod ?a)
\<not> x \<le> y

goal (1 subgoal):
 1. Q dvd x - y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Q dvd x - y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Q dvd x - y

goal (1 subgoal):
 1. \<not> x \<le> y \<Longrightarrow> x = y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
have "P*Q dvd (x - y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P * Q dvd x - y
[PROOF STEP]
using P_dvd_xy Q_dvd_xy
[PROOF STATE]
proof (prove)
using this:
P dvd x - y
Q dvd x - y

goal (1 subgoal):
 1. P * Q dvd x - y
[PROOF STEP]
by (simp add: assms divides_mult primes_coprime)
[PROOF STATE]
proof (state)
this:
P * Q dvd x - y

goal (1 subgoal):
 1. x = y
[PROOF STEP]
hence 1: "[x = y] (mod P*Q)"
[PROOF STATE]
proof (prove)
using this:
P * Q dvd x - y

goal (1 subgoal):
 1. [x = y] (mod P * Q)
[PROOF STEP]
using False cong_altdef_nat linear
[PROOF STATE]
proof (prove)
using this:
P * Q dvd x - y
\<not> x \<le> y
?b \<le> ?a \<Longrightarrow> [?a = ?b] (mod ?m) = (?m dvd ?a - ?b)
?x \<le> ?y \<or> ?y \<le> ?x

goal (1 subgoal):
 1. [x = y] (mod P * Q)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[x = y] (mod P * Q)

goal (1 subgoal):
 1. x = y
[PROOF STEP]
hence "x mod P*Q = y mod P*Q"
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod P * Q)

goal (1 subgoal):
 1. x mod P * Q = y mod P * Q
[PROOF STEP]
using cong_less_modulus_unique_nat x_lt_pq y_lt_pd
[PROOF STATE]
proof (prove)
using this:
[x = y] (mod P * Q)
\<lbrakk>[?x = ?y] (mod ?m); ?x < ?m; ?y < ?m\<rbrakk> \<Longrightarrow> ?x = ?y
x < P * Q
y < P * Q

goal (1 subgoal):
 1. x mod P * Q = y mod P * Q
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x mod P * Q = y mod P * Q

goal (1 subgoal):
 1. x = y
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
x mod P * Q = y mod P * Q

goal (1 subgoal):
 1. x = y
[PROOF STEP]
using 1 cong_less_modulus_unique_nat x_lt_pq y_lt_pd
[PROOF STATE]
proof (prove)
using this:
x mod P * Q = y mod P * Q
[x = y] (mod P * Q)
\<lbrakk>[?x = ?y] (mod ?m); ?x < ?m; ?y < ?m\<rbrakk> \<Longrightarrow> ?x = ?y
x < P * Q
y < P * Q

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x = y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x = y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dghm_cn_comp_ObjMap_vdomain[dg_cn_cs_simps]:
  assumes "\<GG> : \<BB> \<^sub>D\<^sub>G\<mapsto>\<mapsto>\<^bsub>\<alpha>\<^esub> \<CC>" and "\<FF> : \<AA> \<^sub>D\<^sub>G\<mapsto>\<mapsto>\<^bsub>\<alpha>\<^esub> \<BB>"
  shows "\<D>\<^sub>\<circ> ((\<GG> \<^sub>D\<^sub>G\<^sub>H\<^sub>M\<circ> \<FF>)\<lparr>ObjMap\<rparr>) = \<AA>\<lparr>Obj\<rparr>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<D>\<^sub>\<circ> ((\<GG> \<^sub>D\<^sub>G\<^sub>H\<^sub>M\<circ> \<FF>)\<lparr>ObjMap\<rparr>) = \<AA>\<lparr>Obj\<rparr>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<GG> : op_dg \<BB> \<mapsto>\<mapsto>\<^sub>D\<^sub>G\<^bsub>\<alpha>\<^esub> \<CC>
\<FF> : op_dg \<AA> \<mapsto>\<mapsto>\<^sub>D\<^sub>G\<^bsub>\<alpha>\<^esub> \<BB>

goal (1 subgoal):
 1. \<D>\<^sub>\<circ> ((\<GG> \<^sub>D\<^sub>G\<^sub>H\<^sub>M\<circ> \<FF>)\<lparr>ObjMap\<rparr>) = \<AA>\<lparr>Obj\<rparr>
[PROOF STEP]
by
    (
      cs_concl
        cs_simp: dghm_cn_comp_components dg_cs_simps dg_op_simps V_cs_simps
        cs_intro: is_dghm.dghm_ObjMap_vrange
    )


[STATEMENT]
lemma dvd_imp_mult_div_cancel_left[simp]:
  assumes "(a :: 'a :: semidom_divide) dvd b"
  shows "a * (b div a) = b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * (b div a) = b
[PROOF STEP]
proof(cases "b = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. b = (0::'a) \<Longrightarrow> a * (b div a) = b
 2. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
b = (0::'a)

goal (2 subgoals):
 1. b = (0::'a) \<Longrightarrow> a * (b div a) = b
 2. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
b = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
b = (0::'a)

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

goal (1 subgoal):
 1. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
b \<noteq> (0::'a)

goal (1 subgoal):
 1. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
with dvdE[OF assms]
[PROOF STATE]
proof (chain)
picking this:
(\<And>k. b = a * k \<Longrightarrow> ?P) \<Longrightarrow> ?P
b \<noteq> (0::'a)
[PROOF STEP]
obtain c where *: "b = a * c"
[PROOF STATE]
proof (prove)
using this:
(\<And>k. b = a * k \<Longrightarrow> ?P) \<Longrightarrow> ?P
b \<noteq> (0::'a)

goal (1 subgoal):
 1. (\<And>c. b = a * c \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b = a * c

goal (1 subgoal):
 1. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
b = a * c

goal (1 subgoal):
 1. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
with False
[PROOF STATE]
proof (chain)
picking this:
b \<noteq> (0::'a)
b = a * c
[PROOF STEP]
have "a \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
b \<noteq> (0::'a)
b = a * c

goal (1 subgoal):
 1. a \<noteq> (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a \<noteq> (0::'a)

goal (1 subgoal):
 1. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a \<noteq> (0::'a)
[PROOF STEP]
have "a * c div a = c"
[PROOF STATE]
proof (prove)
using this:
a \<noteq> (0::'a)

goal (1 subgoal):
 1. a * c div a = c
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a * c div a = c

goal (1 subgoal):
 1. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a * c div a = c

goal (1 subgoal):
 1. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
note *[symmetric]
[PROOF STATE]
proof (state)
this:
a * c = b

goal (1 subgoal):
 1. b \<noteq> (0::'a) \<Longrightarrow> a * (b div a) = b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a * (b div a) = b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a * (b div a) = b

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nba_g_E_rtrancl: "(g_E (nba_g A))\<^sup>* = {(p, q). q \<in> reachable A p}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (g_E (nba_g A))\<^sup>* = {(p, q). q \<in> reachable A p}
[PROOF STEP]
unfolding nba_g_def graph_rec.simps E_of_succ_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(u, v). v \<in> successors A u}\<^sup>* = {(p, q). q \<in> reachable A p}
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a b. (a, b) \<in> {(u, v). v \<in> successors A u}\<^sup>* \<Longrightarrow> b \<in> reachable A a
 2. \<And>a b. b \<in> reachable A a \<Longrightarrow> (a, b) \<in> {(u, v). v \<in> successors A u}\<^sup>*
[PROOF STEP]
show "(p, q) \<in> {(p, q). q \<in> successors A p}\<^sup>*" if "q \<in> reachable A p" for p q
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p, q) \<in> {(p, q). q \<in> successors A p}\<^sup>*
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
q \<in> reachable A p

goal (1 subgoal):
 1. (p, q) \<in> {(p, q). q \<in> successors A p}\<^sup>*
[PROOF STEP]
by (induct) (auto intro: rtrancl_into_rtrancl)
[PROOF STATE]
proof (state)
this:
?q \<in> reachable A ?p \<Longrightarrow> (?p, ?q) \<in> {(p, q). q \<in> successors A p}\<^sup>*

goal (1 subgoal):
 1. \<And>a b. (a, b) \<in> {(u, v). v \<in> successors A u}\<^sup>* \<Longrightarrow> b \<in> reachable A a
[PROOF STEP]
show "q \<in> reachable A p" if "(p, q) \<in> {(p, q). q \<in> successors A p}\<^sup>*" for p q
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q \<in> reachable A p
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
(p, q) \<in> {(p, q). q \<in> successors A p}\<^sup>*

goal (1 subgoal):
 1. q \<in> reachable A p
[PROOF STEP]
by induct auto
[PROOF STATE]
proof (state)
this:
(?p, ?q) \<in> {(p, q). q \<in> successors A p}\<^sup>* \<Longrightarrow> ?q \<in> reachable A ?p

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma root_primitive_part [simp]:
  fixes p :: "'a :: {semiring_gcd, semiring_no_zero_divisors} poly"
  shows  "poly (primitive_part p) x = 0 \<longleftrightarrow> poly p x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
proof(cases "p = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p = 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
 2. p \<noteq> 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
p = 0

goal (2 subgoals):
 1. p = 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
 2. p \<noteq> 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p = 0

goal (1 subgoal):
 1. (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
p \<noteq> 0

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
have "poly p x = content p * poly (primitive_part p) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly p x = content p * poly (primitive_part p) x
[PROOF STEP]
by (metis content_times_primitive_part poly_smult)
[PROOF STATE]
proof (state)
this:
poly p x = content p * poly (primitive_part p) x

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly p x = content p * poly (primitive_part p) x

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
have "\<dots> = 0 \<longleftrightarrow> poly (primitive_part p) x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (content p * poly (primitive_part p) x = (0::'a)) = (poly (primitive_part p) x = (0::'a))
[PROOF STEP]
by (simp add: False)
[PROOF STATE]
proof (state)
this:
(content p * poly (primitive_part p) x = (0::'a)) = (poly (primitive_part p) x = (0::'a))

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(poly p x = (0::'a)) = (poly (primitive_part p) x = (0::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(poly p x = (0::'a)) = (poly (primitive_part p) x = (0::'a))

goal (1 subgoal):
 1. (poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(poly (primitive_part p) x = (0::'a)) = (poly p x = (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vfinite_vunionD:
  assumes "vfinite (A \<union>\<^sub>\<circ> B)"
  shows "vfinite A" and "vfinite B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vfinite A &&& vfinite B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
vfinite (A \<union>\<^sub>\<circ> B)

goal (1 subgoal):
 1. vfinite A &&& vfinite B
[PROOF STEP]
by (auto simp: elts_sup_iff)


[STATEMENT]
lemma take_indices_lem:
  fixes p:: "real poly"
  fixes qs :: "real poly list"
  fixes arb_list :: "'a list list"
  fixes index_list :: "nat list"
  fixes n:: "nat"
  assumes lest: "n < length (take_indices arb_list index_list)"
  assumes well_def: "\<forall>q.(List.member index_list q \<longrightarrow> q < length arb_list)"
  shows "\<exists>k<length arb_list.
            (take_indices arb_list index_list) ! n =  arb_list ! k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k<length arb_list. take_indices arb_list index_list ! n = arb_list ! k
[PROOF STEP]
using lest well_def
[PROOF STATE]
proof (prove)
using this:
n < length (take_indices arb_list index_list)
\<forall>q. List.member index_list q \<longrightarrow> q < length arb_list

goal (1 subgoal):
 1. \<exists>k<length arb_list. take_indices arb_list index_list ! n = arb_list ! k
[PROOF STEP]
unfolding take_indices_def
[PROOF STATE]
proof (prove)
using this:
n < length (map ((!) arb_list) index_list)
\<forall>q. List.member index_list q \<longrightarrow> q < length arb_list

goal (1 subgoal):
 1. \<exists>k<length arb_list. map ((!) arb_list) index_list ! n = arb_list ! k
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < length index_list; \<forall>q. List.member index_list q \<longrightarrow> q < length arb_list\<rbrakk> \<Longrightarrow> \<exists>k<length arb_list. arb_list ! (index_list ! n) = arb_list ! k
[PROOF STEP]
by (metis in_set_member nth_mem)


[STATEMENT]
lemma vifunion_least:
  assumes "\<And>i. i \<in>\<^sub>\<circ> I \<Longrightarrow> f i \<subseteq>\<^sub>\<circ> C"
  shows "(\<Union>\<^sub>\<circ>i\<in>\<^sub>\<circ>I. f i) \<subseteq>\<^sub>\<circ> C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union>\<^sub>\<circ> (VLambda I f `\<^sub>\<circ> I) \<subseteq>\<^sub>\<circ> C
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?i \<in>\<^sub>\<circ> I \<Longrightarrow> f ?i \<subseteq>\<^sub>\<circ> C

goal (1 subgoal):
 1. \<Union>\<^sub>\<circ> (VLambda I f `\<^sub>\<circ> I) \<subseteq>\<^sub>\<circ> C
[PROOF STEP]
by auto


[STATEMENT]
lemma pred_list_conj [simp]: "list_all (\<lambda>x. P x \<and> Q x) = (\<lambda>x. list_all P x \<and> list_all Q x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. list_all (\<lambda>x. P x \<and> Q x) = (\<lambda>x. list_all P x \<and> list_all Q x)
[PROOF STEP]
by(auto simp add: list_all_def)


[STATEMENT]
lemma mpoly_coeff_1: "MPoly_Type.coeff 1 m = (if m = 0 then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. MPoly_Type.coeff 1 m = (if m = 0 then 1::'a else (0::'a))
[PROOF STEP]
by (simp add: MPoly_Type.coeff_def one_mpoly.rep_eq lookup_1)


[STATEMENT]
lemma cong_altdef_nat:
  "a \<ge> b \<Longrightarrow> [a = b] (mod m) \<longleftrightarrow> m dvd (a - b)"
  for a b :: nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<le> a \<Longrightarrow> [a = b] (mod m) = (m dvd a - b)
[PROOF STEP]
by (simp add: cong_0_iff [symmetric] cong_diff_iff_cong_0_nat)


[STATEMENT]
lemma pi_approx_75: "abs (pi - 3.1415926535897932384626 :: real) \<le> inverse (10^22)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
define a :: real
    where "a = 8295936325956147794769600190539918304 / 2626685325478320010006427764892578125"
[PROOF STATE]
proof (state)
this:
a = 8295936325956147794769600190539918304 / 2626685325478320010006427764892578125

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
define b :: real
    where "b = 8428294561696506782041394632 / 503593538783547230635598424135"
  \<comment> \<open>The introduction of this constant prevents the simplifier from applying solvers that
      we don't want. We want it to simply evaluate the terms to rational constants.}\<close>
[PROOF STATE]
proof (state)
this:
b = 8428294561696506782041394632 / 503593538783547230635598424135

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
define eq :: "real \<Rightarrow> real \<Rightarrow> bool" where "eq = (=)"

  \<comment> \<open>Splitting the computation into several steps has the advantage that simplification can
      be done in parallel\<close>
[PROOF STATE]
proof (state)
this:
eq = (=)

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
have "abs (pi - pi_approx 6) \<le> inverse (2^76)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>pi - pi_approx 6\<bar> \<le> inverse (2 ^ 76)
[PROOF STEP]
by (rule pi_approx') simp_all
[PROOF STATE]
proof (state)
this:
\<bar>pi - pi_approx 6\<bar> \<le> inverse (2 ^ 76)

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>pi - pi_approx 6\<bar> \<le> inverse (2 ^ 76)

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
have "pi_approx 6 = 16 * arctan_approx (3 * 6) (1 / 5) - 4 * arctan_approx 6 (1 / 239)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pi_approx 6 = 16 * arctan_approx (3 * 6) (1 / 5) - 4 * arctan_approx 6 (1 / 239)
[PROOF STEP]
unfolding pi_approx_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 16 * arctan_approx (3 * 6) (1 / 5) - 4 * arctan_approx 6 (1 / 239) = 16 * arctan_approx (3 * 6) (1 / 5) - 4 * arctan_approx 6 (1 / 239)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
pi_approx 6 = 16 * arctan_approx (3 * 6) (1 / 5) - 4 * arctan_approx 6 (1 / 239)

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pi_approx 6 = 16 * arctan_approx (3 * 6) (1 / 5) - 4 * arctan_approx 6 (1 / 239)

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
have [unfolded eq_def]: "eq (16 * arctan_approx (3 * 6) (1 / 5)) a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eq (16 * arctan_approx (3 * 6) (1 / 5)) a
[PROOF STEP]
by (simp add: arctan_approx_def' power2_eq_square,
        simp add: expand_arctan_approx, unfold a_def eq_def, rule refl)
[PROOF STATE]
proof (state)
this:
16 * arctan_approx (3 * 6) (1 / 5) = a

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
16 * arctan_approx (3 * 6) (1 / 5) = a

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
have [unfolded eq_def]: "eq (4 * arctan_approx 6 (1 / 239::real)) b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eq (4 * arctan_approx 6 (1 / 239)) b
[PROOF STEP]
by (simp add: arctan_approx_def' power2_eq_square,
        simp add: expand_arctan_approx, unfold b_def eq_def, rule refl)
[PROOF STATE]
proof (state)
this:
4 * arctan_approx 6 (1 / 239) = b

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
4 * arctan_approx 6 (1 / 239) = b

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
have [unfolded eq_def]:
    "eq (a - b) (171331331860120333586637094112743033554946184594977368554649608 /
                 54536456744112171868276045488779391002026386559009552001953125)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eq (a - b) (171331331860120333586637094112743033554946184594977368554649608 / 54536456744112171868276045488779391002026386559009552001953125)
[PROOF STEP]
by (unfold a_def b_def, simp, unfold eq_def, rule refl)
[PROOF STATE]
proof (state)
this:
a - b = 171331331860120333586637094112743033554946184594977368554649608 / 54536456744112171868276045488779391002026386559009552001953125

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<bar>pi - 171331331860120333586637094112743033554946184594977368554649608 / 54536456744112171868276045488779391002026386559009552001953125\<bar> \<le> inverse (2 ^ 76)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>pi - 171331331860120333586637094112743033554946184594977368554649608 / 54536456744112171868276045488779391002026386559009552001953125\<bar> \<le> inverse (2 ^ 76)

goal (1 subgoal):
 1. \<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)
[PROOF STEP]
by (rule approx_coarsen) simp
[PROOF STATE]
proof (state)
this:
\<bar>pi - 31415926535897932384626 / 10 ^ 22\<bar> \<le> inverse (10 ^ 22)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lang_INTERSECT:
  "lang n (INTERSECT xs) = (if xs = [] then lists (\<Sigma> n) else \<Inter>r \<in> set xs. lang n r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lang n (INTERSECT xs) = (if xs = [] then lists (\<Sigma> n) else \<Inter> (lang n ` set xs))
[PROOF STEP]
by (induct xs rule: list_singleton_induct) auto


[STATEMENT]
lemma fps_inverse_deriv':
  fixes a :: "'a::field fps"
  assumes a0: "a $ 0 \<noteq> 0"
  shows "fps_deriv (inverse a) = - fps_deriv a / a\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_deriv (inverse a) = - fps_deriv a / a\<^sup>2
[PROOF STEP]
using fps_inverse_deriv[OF a0] a0
[PROOF STATE]
proof (prove)
using this:
fps_deriv (inverse a) = - fps_deriv a * (inverse a)\<^sup>2
a $ 0 \<noteq> (0::'a)

goal (1 subgoal):
 1. fps_deriv (inverse a) = - fps_deriv a / a\<^sup>2
[PROOF STEP]
by (simp add: fps_divide_unit power2_eq_square fps_inverse_mult)


[STATEMENT]
lemma sum_of_2_squares_nat_altdef: "sum_of_2_squares_nat n \<longleftrightarrow> n \<in> range gauss_int_norm"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_of_2_squares_nat n = (n \<in> range gauss_int_norm)
[PROOF STEP]
proof (safe elim!: sum_of_2_squares_nat.cases)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a b. n = a\<^sup>2 + b\<^sup>2 \<Longrightarrow> a\<^sup>2 + b\<^sup>2 \<in> range gauss_int_norm
 2. \<And>x. \<lbrakk>x \<in> UNIV; n = gauss_int_norm x\<rbrakk> \<Longrightarrow> sum_of_2_squares_nat (gauss_int_norm x)
[PROOF STEP]
fix a b :: nat
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a b. n = a\<^sup>2 + b\<^sup>2 \<Longrightarrow> a\<^sup>2 + b\<^sup>2 \<in> range gauss_int_norm
 2. \<And>x. \<lbrakk>x \<in> UNIV; n = gauss_int_norm x\<rbrakk> \<Longrightarrow> sum_of_2_squares_nat (gauss_int_norm x)
[PROOF STEP]
have "a ^ 2 + b ^ 2 = gauss_int_norm (of_nat a + \<i>\<^sub>\<int> * of_nat b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a\<^sup>2 + b\<^sup>2 = gauss_int_norm (of_nat a + gauss_i * of_nat b)
[PROOF STEP]
by (auto simp: gauss_int_norm_def nat_add_distrib nat_power_eq)
[PROOF STATE]
proof (state)
this:
a\<^sup>2 + b\<^sup>2 = gauss_int_norm (of_nat a + gauss_i * of_nat b)

goal (2 subgoals):
 1. \<And>a b. n = a\<^sup>2 + b\<^sup>2 \<Longrightarrow> a\<^sup>2 + b\<^sup>2 \<in> range gauss_int_norm
 2. \<And>x. \<lbrakk>x \<in> UNIV; n = gauss_int_norm x\<rbrakk> \<Longrightarrow> sum_of_2_squares_nat (gauss_int_norm x)
[PROOF STEP]
thus "a ^ 2 + b ^ 2 \<in> range gauss_int_norm"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 + b\<^sup>2 = gauss_int_norm (of_nat a + gauss_i * of_nat b)

goal (1 subgoal):
 1. a\<^sup>2 + b\<^sup>2 \<in> range gauss_int_norm
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a\<^sup>2 + b\<^sup>2 \<in> range gauss_int_norm

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<in> UNIV; n = gauss_int_norm x\<rbrakk> \<Longrightarrow> sum_of_2_squares_nat (gauss_int_norm x)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<in> UNIV; n = gauss_int_norm x\<rbrakk> \<Longrightarrow> sum_of_2_squares_nat (gauss_int_norm x)
[PROOF STEP]
fix z :: gauss_int
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<in> UNIV; n = gauss_int_norm x\<rbrakk> \<Longrightarrow> sum_of_2_squares_nat (gauss_int_norm x)
[PROOF STEP]
have "gauss_int_norm z = nat \<bar>ReZ z\<bar> ^ 2 + nat \<bar>ImZ z\<bar> ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_int_norm z = (nat \<bar>ReZ z\<bar>)\<^sup>2 + (nat \<bar>ImZ z\<bar>)\<^sup>2
[PROOF STEP]
by (auto simp: gauss_int_norm_def nat_add_distrib simp flip: nat_power_eq)
[PROOF STATE]
proof (state)
this:
gauss_int_norm z = (nat \<bar>ReZ z\<bar>)\<^sup>2 + (nat \<bar>ImZ z\<bar>)\<^sup>2

goal (1 subgoal):
 1. \<And>x. \<lbrakk>x \<in> UNIV; n = gauss_int_norm x\<rbrakk> \<Longrightarrow> sum_of_2_squares_nat (gauss_int_norm x)
[PROOF STEP]
thus "sum_of_2_squares_nat (gauss_int_norm z)"
[PROOF STATE]
proof (prove)
using this:
gauss_int_norm z = (nat \<bar>ReZ z\<bar>)\<^sup>2 + (nat \<bar>ImZ z\<bar>)\<^sup>2

goal (1 subgoal):
 1. sum_of_2_squares_nat (gauss_int_norm z)
[PROOF STEP]
by (auto intro: sum_of_2_squares_nat.intros)
[PROOF STATE]
proof (state)
this:
sum_of_2_squares_nat (gauss_int_norm z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "{P} R {> Q} = (\<forall>s t. s \<in> P \<longrightarrow> (s, t) \<in> R \<longrightarrow> t \<in> Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {P} R {> Q} = (\<forall>s t. s \<in> P \<longrightarrow> (s, t) \<in> R \<longrightarrow> t \<in> Q)
[PROOF STEP]
by (auto simp add: PO_hoare_defs)


[STATEMENT]
lemma norm_bound_CBasis_le: "b \<in> CBasis \<Longrightarrow> norm x \<le> e \<Longrightarrow> cmod (inner x b) \<le> e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>b \<in> CBasis; norm x \<le> e\<rbrakk> \<Longrightarrow> cmod (complex_of_real (x \<bullet> b)) \<le> e
[PROOF STEP]
by (metis inner_commute mult.left_neutral norm_CBasis norm_of_real order_trans real_inner_class.Cauchy_Schwarz_ineq2)


[STATEMENT]
lemma add_left_strict_mono: "strict_mono (\<lambda>x. n + (x::'a::ordered_cancel_ab_semigroup_add))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_mono ((+) n)
[PROOF STEP]
by (unfold strict_mono_def, clarify, rule add_strict_left_mono)


[STATEMENT]
lemma borel_measurable_vimage_borel:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  shows "f \<in> borel_measurable (lebesgue_on S) \<longleftrightarrow>
         (\<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S))"
        (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<in> borel_measurable (lebesgue_on S)) = (\<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f \<in> borel_measurable (lebesgue_on S) \<Longrightarrow> \<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S)
 2. \<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S) \<Longrightarrow> f \<in> borel_measurable (lebesgue_on S)
[PROOF STEP]
assume f: ?lhs
[PROOF STATE]
proof (state)
this:
f \<in> borel_measurable (lebesgue_on S)

goal (2 subgoals):
 1. f \<in> borel_measurable (lebesgue_on S) \<Longrightarrow> \<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S)
 2. \<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S) \<Longrightarrow> f \<in> borel_measurable (lebesgue_on S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f \<in> borel_measurable (lebesgue_on S)
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (lebesgue_on S)

goal (1 subgoal):
 1. \<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S)
[PROOF STEP]
using measurable_sets [OF f]
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (lebesgue_on S)
?S \<in> sets borel \<Longrightarrow> f -` ?S \<inter> space (lebesgue_on S) \<in> sets (lebesgue_on S)

goal (1 subgoal):
 1. \<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S)
[PROOF STEP]
by (simp add: Collect_conj_eq inf_sup_aci(1) space_restrict_space vimage_def)
[PROOF STATE]
proof (state)
this:
\<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S)

goal (1 subgoal):
 1. \<forall>T. T \<in> sets borel \<longrightarrow> {x \<in> S. f x \<in> T} \<in> sets (lebesgue_on S) \<Longrightarrow> f \<in> borel_measurable (lebesgue_on S)
[PROOF STEP]
qed (simp add: borel_measurable_vimage_open_interval)


[STATEMENT]
lemma higher_deriv_linear [simp]:
    "(deriv ^^ n) (\<lambda>w. c*w) = (\<lambda>z. if n = 0 then c*z else if n = 1 then c else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (deriv ^^ n) ((*) c) = (\<lambda>z. if n = 0 then c * z else if n = 1 then c else (0::'a))
[PROOF STEP]
by (induction n) auto


[STATEMENT]
lemma left_commute: "f a (f b c) = f b (f a c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f a (f b c) = f b (f a c)
[PROOF STEP]
apply (simp add: left_assoc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (f a b) c = f (f b a) c
[PROOF STEP]
apply (simp add: commute)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma distinct_if_sorted: "sorted xs \<Longrightarrow> distinct xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sorted_Less.sorted xs \<Longrightarrow> distinct xs
[PROOF STEP]
by (induction xs rule: induct_list012) auto


[STATEMENT]
lemma pow_res_one_imp_nth_pow:
  assumes "n > 0"
  assumes "a \<in> pow_res n \<one>"
  shows "\<exists>y \<in> nonzero Q\<^sub>p. a = y[^]n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>y\<in>nonzero Q\<^sub>p. a = y [^] n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n
a \<in> pow_res n \<one>

goal (1 subgoal):
 1. \<exists>y\<in>nonzero Q\<^sub>p. a = y [^] n
[PROOF STEP]
unfolding pow_res_def
[PROOF STATE]
proof (prove)
using this:
0 < n
a \<in> {a \<in> carrier Q\<^sub>p. \<exists>y\<in>nonzero Q\<^sub>p. a = \<one> \<otimes> y [^] n}

goal (1 subgoal):
 1. \<exists>y\<in>nonzero Q\<^sub>p. a = y [^] n
[PROOF STEP]
using Qp.l_one Qp.nat_pow_closed Qp.nonzero_closed
[PROOF STATE]
proof (prove)
using this:
0 < n
a \<in> {a \<in> carrier Q\<^sub>p. \<exists>y\<in>nonzero Q\<^sub>p. a = \<one> \<otimes> y [^] n}
?x \<in> carrier Q\<^sub>p \<Longrightarrow> \<one> \<otimes> ?x = ?x
?x \<in> carrier Q\<^sub>p \<Longrightarrow> ?x [^] ?n \<in> carrier Q\<^sub>p
?a \<in> nonzero Q\<^sub>p \<Longrightarrow> ?a \<in> carrier Q\<^sub>p

goal (1 subgoal):
 1. \<exists>y\<in>nonzero Q\<^sub>p. a = y [^] n
[PROOF STEP]
by blast