[STATEMENT]
lemma assumes sg: "subgraph H G"
  shows connected_VV: "{(x, y) |x y. nodes_connected H x y} \<subseteq> V\<times>V"
    and connected_refl: "refl_on V {(x, y) |x y. nodes_connected H x y}"
    and connected_trans: "trans {(x, y) |x y. nodes_connected H x y}"
    and connected_sym: "sym {(x, y) |x y. nodes_connected H x y}"
    and connected_equiv: "equiv V {(x, y) |x y. nodes_connected H x y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({(x, y) |x y. nodes_connected H x y} \<subseteq> V \<times> V &&& refl_on V {(x, y) |x y. nodes_connected H x y}) &&& trans {(x, y) |x y. nodes_connected H x y} &&& sym {(x, y) |x y. nodes_connected H x y} &&& equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. {(x, y) |x y. nodes_connected H x y} \<subseteq> V \<times> V
 2. refl_on V {(x, y) |x y. nodes_connected H x y}
 3. trans {(x, y) |x y. nodes_connected H x y}
 4. sym {(x, y) |x y. nodes_connected H x y}
 5. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
have *: "\<And>R S. Domain R \<subseteq> S \<Longrightarrow> Range R \<subseteq> S \<Longrightarrow> R \<subseteq> S\<times>S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>R S. \<lbrakk>Domain R \<subseteq> S; Range R \<subseteq> S\<rbrakk> \<Longrightarrow> R \<subseteq> S \<times> S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>Domain ?R \<subseteq> ?S; Range ?R \<subseteq> ?S\<rbrakk> \<Longrightarrow> ?R \<subseteq> ?S \<times> ?S

goal (5 subgoals):
 1. {(x, y) |x y. nodes_connected H x y} \<subseteq> V \<times> V
 2. refl_on V {(x, y) |x y. nodes_connected H x y}
 3. trans {(x, y) |x y. nodes_connected H x y}
 4. sym {(x, y) |x y. nodes_connected H x y}
 5. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
from sg
[PROOF STATE]
proof (chain)
picking this:
subgraph H G
[PROOF STEP]
have [simp]: "nodes H = V"
[PROOF STATE]
proof (prove)
using this:
subgraph H G

goal (1 subgoal):
 1. nodes H = V
[PROOF STEP]
by (auto simp: subgraph_def)
[PROOF STATE]
proof (state)
this:
nodes H = V

goal (5 subgoals):
 1. {(x, y) |x y. nodes_connected H x y} \<subseteq> V \<times> V
 2. refl_on V {(x, y) |x y. nodes_connected H x y}
 3. trans {(x, y) |x y. nodes_connected H x y}
 4. sym {(x, y) |x y. nodes_connected H x y}
 5. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
from sg valid_subgraph
[PROOF STATE]
proof (chain)
picking this:
subgraph H G
subgraph ?H G \<Longrightarrow> valid_graph ?H
[PROOF STEP]
have v: "valid_graph H"
[PROOF STATE]
proof (prove)
using this:
subgraph H G
subgraph ?H G \<Longrightarrow> valid_graph ?H

goal (1 subgoal):
 1. valid_graph H
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
valid_graph H

goal (5 subgoals):
 1. {(x, y) |x y. nodes_connected H x y} \<subseteq> V \<times> V
 2. refl_on V {(x, y) |x y. nodes_connected H x y}
 3. trans {(x, y) |x y. nodes_connected H x y}
 4. sym {(x, y) |x y. nodes_connected H x y}
 5. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
from valid_graph.Domain_nodes_connected[OF this] valid_graph.Range_nodes_connected[OF this]
[PROOF STATE]
proof (chain)
picking this:
Domain {(x, y) |x y. nodes_connected H x y} = nodes H
Range {(x, y) |x y. nodes_connected H x y} = nodes H
[PROOF STEP]
show i: "{(x, y) |x y. nodes_connected H x y} \<subseteq> V\<times>V"
[PROOF STATE]
proof (prove)
using this:
Domain {(x, y) |x y. nodes_connected H x y} = nodes H
Range {(x, y) |x y. nodes_connected H x y} = nodes H

goal (1 subgoal):
 1. {(x, y) |x y. nodes_connected H x y} \<subseteq> V \<times> V
[PROOF STEP]
apply(intro *)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>Domain {(x, y) |x y. nodes_connected H x y} = nodes H; Range {(x, y) |x y. nodes_connected H x y} = nodes H\<rbrakk> \<Longrightarrow> Domain {(x, y) |x y. nodes_connected H x y} \<subseteq> V
 2. \<lbrakk>Domain {(x, y) |x y. nodes_connected H x y} = nodes H; Range {(x, y) |x y. nodes_connected H x y} = nodes H\<rbrakk> \<Longrightarrow> Range {(x, y) |x y. nodes_connected H x y} \<subseteq> V
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{(x, y) |x y. nodes_connected H x y} \<subseteq> V \<times> V

goal (4 subgoals):
 1. refl_on V {(x, y) |x y. nodes_connected H x y}
 2. trans {(x, y) |x y. nodes_connected H x y}
 3. sym {(x, y) |x y. nodes_connected H x y}
 4. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
have ii: "\<And>x. x \<in> V \<Longrightarrow> (x, x) \<in> {(x, y) |x y. nodes_connected H x y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> V \<Longrightarrow> (x, x) \<in> {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
using valid_graph.nodes_connected_refl[OF v]
[PROOF STATE]
proof (prove)
using this:
?a \<in> nodes H \<Longrightarrow> nodes_connected H ?a ?a

goal (1 subgoal):
 1. \<And>x. x \<in> V \<Longrightarrow> (x, x) \<in> {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?x1 \<in> V \<Longrightarrow> (?x1, ?x1) \<in> {(x, y) |x y. nodes_connected H x y}

goal (4 subgoals):
 1. refl_on V {(x, y) |x y. nodes_connected H x y}
 2. trans {(x, y) |x y. nodes_connected H x y}
 3. sym {(x, y) |x y. nodes_connected H x y}
 4. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
show "refl_on V {(x, y) |x y. nodes_connected H x y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. refl_on V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
apply(rule refl_onI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. {(x, y) |x y. nodes_connected H x y} \<subseteq> V \<times> V
 2. \<And>x. x \<in> V \<Longrightarrow> (x, x) \<in> {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
by fact+
[PROOF STATE]
proof (state)
this:
refl_on V {(x, y) |x y. nodes_connected H x y}

goal (3 subgoals):
 1. trans {(x, y) |x y. nodes_connected H x y}
 2. sym {(x, y) |x y. nodes_connected H x y}
 3. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
from valid_graph.is_path_undir_append[OF v]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>is_path_undir H ?v ?p1.0 ?u; is_path_undir H ?u ?p2.0 ?w\<rbrakk> \<Longrightarrow> is_path_undir H ?v (?p1.0 @ ?p2.0) ?w
[PROOF STEP]
show "trans {(x, y) |x y. nodes_connected H x y}"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_path_undir H ?v ?p1.0 ?u; is_path_undir H ?u ?p2.0 ?w\<rbrakk> \<Longrightarrow> is_path_undir H ?v (?p1.0 @ ?p2.0) ?w

goal (1 subgoal):
 1. trans {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
unfolding trans_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_path_undir H ?v ?p1.0 ?u; is_path_undir H ?u ?p2.0 ?w\<rbrakk> \<Longrightarrow> is_path_undir H ?v (?p1.0 @ ?p2.0) ?w

goal (1 subgoal):
 1. \<forall>x y z. (x, y) \<in> {(x, y) |x y. nodes_connected H x y} \<longrightarrow> (y, z) \<in> {(x, y) |x y. nodes_connected H x y} \<longrightarrow> (x, z) \<in> {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
trans {(x, y) |x y. nodes_connected H x y}

goal (2 subgoals):
 1. sym {(x, y) |x y. nodes_connected H x y}
 2. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
from valid_graph.nodes_connected_sym[OF v]
[PROOF STATE]
proof (chain)
picking this:
nodes_connected H ?a ?b = nodes_connected H ?b ?a
[PROOF STEP]
show "sym {(x, y) |x y. nodes_connected H x y}"
[PROOF STATE]
proof (prove)
using this:
nodes_connected H ?a ?b = nodes_connected H ?b ?a

goal (1 subgoal):
 1. sym {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
unfolding sym_def
[PROOF STATE]
proof (prove)
using this:
nodes_connected H ?a ?b = nodes_connected H ?b ?a

goal (1 subgoal):
 1. \<forall>x y. (x, y) \<in> {(x, y) |x y. nodes_connected H x y} \<longrightarrow> (y, x) \<in> {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
sym {(x, y) |x y. nodes_connected H x y}

goal (1 subgoal):
 1. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
show "equiv V {(x, y) |x y. nodes_connected H x y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. equiv V {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
apply (rule equivI)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. refl_on V {(x, y) |x y. nodes_connected H x y}
 2. sym {(x, y) |x y. nodes_connected H x y}
 3. trans {(x, y) |x y. nodes_connected H x y}
[PROOF STEP]
by fact+
[PROOF STATE]
proof (state)
this:
equiv V {(x, y) |x y. nodes_connected H x y}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma independence_max_alt: "V \<noteq> {} \<Longrightarrow> \<alpha> = Max ((\<lambda> vs . enat (card vs)) ` independent_sets)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. V \<noteq> {} \<Longrightarrow> \<alpha> = (MAX vs\<in>independent_sets. enat (card vs))
[PROOF STEP]
unfolding independence_number_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. V \<noteq> {} \<Longrightarrow> (SUP vs\<in>independent_sets. enat (card vs)) = (MAX vs\<in>independent_sets. enat (card vs))
[PROOF STEP]
using Sup_enat_def zero_less_independence
[PROOF STATE]
proof (prove)
using this:
Sup ?A = (if ?A = {} then 0 else if finite ?A then Max ?A else \<infinity>)
V \<noteq> {} \<Longrightarrow> 0 < \<alpha>

goal (1 subgoal):
 1. V \<noteq> {} \<Longrightarrow> (SUP vs\<in>independent_sets. enat (card vs)) = (MAX vs\<in>independent_sets. enat (card vs))
[PROOF STEP]
by (metis i0_less independence_fin independence_number_def)


[STATEMENT]
theorem Quadratic_Reciprocity:
  assumes "prime p" "2 < p" "prime q" "2 < q" "p \<noteq> q"
  shows "Legendre p q * Legendre q p = (-1::int) ^ ((p - 1) div 2 * ((q - 1) div 2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Legendre (int p) (int q) * Legendre (int q) (int p) = (- 1) ^ ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
using QR.Quadratic_Reciprocity QR_def assms
[PROOF STATE]
proof (prove)
using this:
QR ?p ?q \<Longrightarrow> Legendre (int ?p) (int ?q) * Legendre (int ?q) (int ?p) = (- 1) ^ ((?p - 1) div 2 * ((?q - 1) div 2))
QR ?p ?q \<equiv> (prime ?p \<and> 2 < ?p) \<and> prime ?q \<and> 2 < ?q \<and> ?p \<noteq> ?q
prime p
2 < p
prime q
2 < q
p \<noteq> q

goal (1 subgoal):
 1. Legendre (int p) (int q) * Legendre (int q) (int p) = (- 1) ^ ((p - 1) div 2 * ((q - 1) div 2))
[PROOF STEP]
by blast


[STATEMENT]
lemma scalar_mult_zero[simp]: "scalar_mult y 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. scalar_mult y 0 = 0
[PROOF STEP]
by (simp add: scalar_mult_def)


[STATEMENT]
theorem UNIV_stream: \<open>surj f \<Longrightarrow> sset (fair_stream f) = UNIV\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. surj f \<Longrightarrow> sset (fair_stream f) = UNIV
[PROOF STEP]
unfolding fair_stream_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. surj f \<Longrightarrow> sset (smap f fair_nats) = UNIV
[PROOF STEP]
using all_ex_fair_nats
[PROOF STATE]
proof (prove)
using this:
\<exists>n\<ge>?m. fair_nats !! n = ?x

goal (1 subgoal):
 1. surj f \<Longrightarrow> sset (smap f fair_nats) = UNIV
[PROOF STEP]
by (metis sset_range stream.set_map surjI)


[STATEMENT]
lemma rightUniqueInjectiveOnFirstImplication:
  assumes "runiq P"
  shows "inj_on fst P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on fst P
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>P. \<forall>y\<in>P. fst x = fst y \<longrightarrow> x = y
[PROOF STEP]
using assms runiq_def trivial_def trivial_imp_no_distinct
        the_elem_eq surjective_pairing subsetI Image_singleton_iff
[PROOF STATE]
proof (prove)
using this:
runiq P
runiq ?R = (\<forall>X. trivial X \<longrightarrow> trivial (?R `` X))
trivial ?x = (?x \<subseteq> {the_elem ?x})
\<lbrakk>trivial ?X; ?x \<in> ?X; ?y \<in> ?X\<rbrakk> \<Longrightarrow> ?x = ?y
the_elem {?x} = ?x
?t = (fst ?t, snd ?t)
(\<And>x. x \<in> ?A \<Longrightarrow> x \<in> ?B) \<Longrightarrow> ?A \<subseteq> ?B
(?b \<in> ?r `` {?a}) = ((?a, ?b) \<in> ?r)

goal (1 subgoal):
 1. \<forall>x\<in>P. \<forall>y\<in>P. fst x = fst y \<longrightarrow> x = y
[PROOF STEP]
by (metis(no_types))


[STATEMENT]
lemma segment_to_closest_point:
  fixes S :: "'a :: euclidean_space set"
  shows "\<lbrakk>closed S; S \<noteq> {}\<rbrakk> \<Longrightarrow> open_segment a (closest_point S a) \<inter> S = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closed S; S \<noteq> {}\<rbrakk> \<Longrightarrow> open_segment a (closest_point S a) \<inter> S = {}
[PROOF STEP]
unfolding disjoint_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closed S; S \<noteq> {}\<rbrakk> \<Longrightarrow> \<forall>x. x \<in> open_segment a (closest_point S a) \<longrightarrow> x \<notin> S
[PROOF STEP]
by (metis closest_point_le dist_commute dist_in_open_segment not_le)


[STATEMENT]
lemma infimum_unique: "(infimum A = {x}) = (x \<in> infimum A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (infimum A = {x}) = (x \<in> infimum A)
[PROOF STEP]
apply safe
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. infimum A = {x} \<Longrightarrow> x \<in> infimum A
 2. \<And>xa. \<lbrakk>x \<in> infimum A; xa \<in> infimum A; xa \<notin> {}\<rbrakk> \<Longrightarrow> xa = x
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xa. \<lbrakk>x \<in> infimum A; xa \<in> infimum A; xa \<notin> {}\<rbrakk> \<Longrightarrow> xa = x
[PROOF STEP]
apply (rule order.antisym)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>xa. \<lbrakk>x \<in> infimum A; xa \<in> infimum A; xa \<notin> {}\<rbrakk> \<Longrightarrow> xa \<le> x
 2. \<And>xa. \<lbrakk>x \<in> infimum A; xa \<in> infimum A; xa \<notin> {}\<rbrakk> \<Longrightarrow> x \<le> xa
[PROOF STEP]
by (simp_all add: infimum_def)


[STATEMENT]
lemma scalsquare_vv_zero:
  shows "(vec_cnj v) *\<^sub>v\<^sub>v v = 0 \<longleftrightarrow> v = vec_zero"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec_cnj v *\<^sub>v\<^sub>v v = 0) = (v = vec_zero)
[PROOF STEP]
apply (cases v)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b. v = (a, b) \<Longrightarrow> (vec_cnj v *\<^sub>v\<^sub>v v = 0) = (v = vec_zero)
[PROOF STEP]
apply (auto simp add: vec_cnj_def field_simps complex_mult_cnj_cmod power2_eq_square)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a b. \<lbrakk>v = (a, b); cor (cmod a) * cor (cmod a) + cor (cmod b) * cor (cmod b) = 0\<rbrakk> \<Longrightarrow> a = 0
 2. \<And>a b. \<lbrakk>v = (a, b); cor (cmod a) * cor (cmod a) + cor (cmod b) * cor (cmod b) = 0\<rbrakk> \<Longrightarrow> b = 0
[PROOF STEP]
apply (metis (no_types) norm_eq_zero of_real_0 of_real_add of_real_eq_iff of_real_mult sum_squares_eq_zero_iff)+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma poly_rel_dupe_monic_i: assumes mon: "monic D"
  and rel: "poly_rel d D" "poly_rel h H" "poly_rel s S" "poly_rel t T" "poly_rel u U"
shows "rel_prod poly_rel poly_rel (dupe_monic_i ops d h s t u) (dupe_monic D H S T U)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_prod poly_rel poly_rel (dupe_monic_i ops d h s t u) (dupe_monic D H S T U)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rel_prod poly_rel poly_rel (dupe_monic_i ops d h s t u) (dupe_monic D H S T U)
[PROOF STEP]
note defs = dupe_monic_i_def dupe_monic_def
[PROOF STATE]
proof (state)
this:
dupe_monic_i ?ops ?D ?H ?S ?T ?U = (case pdivmod_monic_i ?ops (times_poly_i ?ops ?T ?U) ?D of (Q, R) \<Rightarrow> (plus_poly_i ?ops (times_poly_i ?ops ?S ?U) (times_poly_i ?ops ?H Q), R))
dupe_monic ?D ?H ?S ?T ?U = (case pdivmod_monic (?T * ?U) ?D of (q, r) \<Rightarrow> (?S * ?U + ?H * q, r))

goal (1 subgoal):
 1. rel_prod poly_rel poly_rel (dupe_monic_i ops d h s t u) (dupe_monic D H S T U)
[PROOF STEP]
note [transfer_rule] = rel
[PROOF STATE]
proof (state)
this:
poly_rel d D
poly_rel h H
poly_rel s S
poly_rel t T
poly_rel u U

goal (1 subgoal):
 1. rel_prod poly_rel poly_rel (dupe_monic_i ops d h s t u) (dupe_monic D H S T U)
[PROOF STEP]
have [transfer_rule]: "rel_prod poly_rel poly_rel
    (pdivmod_monic_i ops (times_poly_i ops t u) d)
    (pdivmod_monic (T * U) D)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_prod poly_rel poly_rel (pdivmod_monic_i ops (times_poly_i ops t u) d) (pdivmod_monic (T * U) D)
[PROOF STEP]
by (rule poly_rel_pdivmod_monic[OF mon], transfer_prover+)
[PROOF STATE]
proof (state)
this:
rel_prod poly_rel poly_rel (pdivmod_monic_i ops (times_poly_i ops t u) d) (pdivmod_monic (T * U) D)

goal (1 subgoal):
 1. rel_prod poly_rel poly_rel (dupe_monic_i ops d h s t u) (dupe_monic D H S T U)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_prod poly_rel poly_rel (dupe_monic_i ops d h s t u) (dupe_monic D H S T U)
[PROOF STEP]
unfolding defs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_prod poly_rel poly_rel (case pdivmod_monic_i ops (times_poly_i ops t u) d of (Q, x) \<Rightarrow> (plus_poly_i ops (times_poly_i ops s u) (times_poly_i ops h Q), x)) (case pdivmod_monic (T * U) D of (q, x) \<Rightarrow> (S * U + H * q, x))
[PROOF STEP]
by transfer_prover
[PROOF STATE]
proof (state)
this:
rel_prod poly_rel poly_rel (dupe_monic_i ops d h s t u) (dupe_monic D H S T U)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cross_ratio_in_terms_of_cosh_dist:
  assumes "are_endpoints_in_S p q a b"
  and "B\<^sub>\<real> (cart2_pt a) (cart2_pt b) (cart2_pt p)"
  shows "cross_ratio p q a b
  = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1"
  (is "?pqab = 2 * ?ab\<^sup>2 + 2 * ?ab * sqrt (?ab\<^sup>2 - 1) - 1")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
from \<open>are_endpoints_in_S p q a b\<close>
[PROOF STATE]
proof (chain)
picking this:
are_endpoints_in_S p q a b
[PROOF STEP]
have "?ab = (sqrt ?pqab + 1 / sqrt ?pqab) / 2"
[PROOF STATE]
proof (prove)
using this:
are_endpoints_in_S p q a b

goal (1 subgoal):
 1. cosh_dist a b = (sqrt (cross_ratio p q a b) + 1 / sqrt (cross_ratio p q a b)) / 2
[PROOF STEP]
by (rule cosh_dist_general)
[PROOF STATE]
proof (state)
this:
cosh_dist a b = (sqrt (cross_ratio p q a b) + 1 / sqrt (cross_ratio p q a b)) / 2

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
hence "sqrt ?pqab - 2 * ?ab + 1 / sqrt ?pqab = 0"
[PROOF STATE]
proof (prove)
using this:
cosh_dist a b = (sqrt (cross_ratio p q a b) + 1 / sqrt (cross_ratio p q a b)) / 2

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) - 2 * cosh_dist a b + 1 / sqrt (cross_ratio p q a b) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) - 2 * cosh_dist a b + 1 / sqrt (cross_ratio p q a b) = 0

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
hence "sqrt ?pqab * (sqrt ?pqab - 2 * ?ab + 1 / sqrt ?pqab) = 0"
[PROOF STATE]
proof (prove)
using this:
sqrt (cross_ratio p q a b) - 2 * cosh_dist a b + 1 / sqrt (cross_ratio p q a b) = 0

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) * (sqrt (cross_ratio p q a b) - 2 * cosh_dist a b + 1 / sqrt (cross_ratio p q a b)) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) * (sqrt (cross_ratio p q a b) - 2 * cosh_dist a b + 1 / sqrt (cross_ratio p q a b)) = 0

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) * (sqrt (cross_ratio p q a b) - 2 * cosh_dist a b + 1 / sqrt (cross_ratio p q a b)) = 0

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
are_endpoints_in_S p q a b
B\<^sub>\<real> cart2_pt a cart2_pt b cart2_pt p
[PROOF STEP]
have "?pqab \<ge> 1"
[PROOF STATE]
proof (prove)
using this:
are_endpoints_in_S p q a b
B\<^sub>\<real> cart2_pt a cart2_pt b cart2_pt p

goal (1 subgoal):
 1. 1 \<le> cross_ratio p q a b
[PROOF STEP]
by (rule are_endpoints_in_S_ordered_cross_ratio)
[PROOF STATE]
proof (state)
this:
1 \<le> cross_ratio p q a b

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
sqrt (cross_ratio p q a b) * (sqrt (cross_ratio p q a b) - 2 * cosh_dist a b + 1 / sqrt (cross_ratio p q a b)) = 0
1 \<le> cross_ratio p q a b
[PROOF STEP]
have "?pqab - 2 * ?ab * (sqrt ?pqab) + 1 = 0"
[PROOF STATE]
proof (prove)
using this:
sqrt (cross_ratio p q a b) * (sqrt (cross_ratio p q a b) - 2 * cosh_dist a b + 1 / sqrt (cross_ratio p q a b)) = 0
1 \<le> cross_ratio p q a b

goal (1 subgoal):
 1. cross_ratio p q a b - 2 * cosh_dist a b * sqrt (cross_ratio p q a b) + 1 = 0
[PROOF STEP]
by (simp add: algebra_simps real_sqrt_mult [symmetric])
[PROOF STATE]
proof (state)
this:
cross_ratio p q a b - 2 * cosh_dist a b * sqrt (cross_ratio p q a b) + 1 = 0

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
with \<open>?pqab \<ge> 1\<close> and discriminant_iff [of 1 "sqrt ?pqab" "- 2 * ?ab" 1]
[PROOF STATE]
proof (chain)
picking this:
1 \<le> cross_ratio p q a b
1 \<noteq> 0 \<Longrightarrow> (1 * (sqrt (cross_ratio p q a b))\<^sup>2 + - 2 * cosh_dist a b * sqrt (cross_ratio p q a b) + 1 = 0) = (0 \<le> discrim 1 (- 2 * cosh_dist a b) 1 \<and> (sqrt (cross_ratio p q a b) = (- (- 2 * cosh_dist a b) + sqrt (discrim 1 (- 2 * cosh_dist a b) 1)) / (2 * 1) \<or> sqrt (cross_ratio p q a b) = (- (- 2 * cosh_dist a b) - sqrt (discrim 1 (- 2 * cosh_dist a b) 1)) / (2 * 1)))
cross_ratio p q a b - 2 * cosh_dist a b * sqrt (cross_ratio p q a b) + 1 = 0
[PROOF STEP]
have "sqrt ?pqab = (2 * ?ab + sqrt (4 * ?ab\<^sup>2 - 4)) / 2
    \<or> sqrt ?pqab = (2 * ?ab - sqrt (4 * ?ab\<^sup>2 - 4)) / 2"
[PROOF STATE]
proof (prove)
using this:
1 \<le> cross_ratio p q a b
1 \<noteq> 0 \<Longrightarrow> (1 * (sqrt (cross_ratio p q a b))\<^sup>2 + - 2 * cosh_dist a b * sqrt (cross_ratio p q a b) + 1 = 0) = (0 \<le> discrim 1 (- 2 * cosh_dist a b) 1 \<and> (sqrt (cross_ratio p q a b) = (- (- 2 * cosh_dist a b) + sqrt (discrim 1 (- 2 * cosh_dist a b) 1)) / (2 * 1) \<or> sqrt (cross_ratio p q a b) = (- (- 2 * cosh_dist a b) - sqrt (discrim 1 (- 2 * cosh_dist a b) 1)) / (2 * 1)))
cross_ratio p q a b - 2 * cosh_dist a b * sqrt (cross_ratio p q a b) + 1 = 0

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) = (2 * cosh_dist a b + sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2 \<or> sqrt (cross_ratio p q a b) = (2 * cosh_dist a b - sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2
[PROOF STEP]
unfolding discrim_def
[PROOF STATE]
proof (prove)
using this:
1 \<le> cross_ratio p q a b
1 \<noteq> 0 \<Longrightarrow> (1 * (sqrt (cross_ratio p q a b))\<^sup>2 + - 2 * cosh_dist a b * sqrt (cross_ratio p q a b) + 1 = 0) = (0 \<le> (- 2 * cosh_dist a b)\<^sup>2 - 4 * 1 * 1 \<and> (sqrt (cross_ratio p q a b) = (- (- 2 * cosh_dist a b) + sqrt ((- 2 * cosh_dist a b)\<^sup>2 - 4 * 1 * 1)) / (2 * 1) \<or> sqrt (cross_ratio p q a b) = (- (- 2 * cosh_dist a b) - sqrt ((- 2 * cosh_dist a b)\<^sup>2 - 4 * 1 * 1)) / (2 * 1)))
cross_ratio p q a b - 2 * cosh_dist a b * sqrt (cross_ratio p q a b) + 1 = 0

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) = (2 * cosh_dist a b + sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2 \<or> sqrt (cross_ratio p q a b) = (2 * cosh_dist a b - sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2
[PROOF STEP]
by (simp add: real_sqrt_mult [symmetric] power2_eq_square)
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) = (2 * cosh_dist a b + sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2 \<or> sqrt (cross_ratio p q a b) = (2 * cosh_dist a b - sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) = (2 * cosh_dist a b + sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2 \<or> sqrt (cross_ratio p q a b) = (2 * cosh_dist a b - sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
have "sqrt (4 * ?ab\<^sup>2 - 4) = sqrt (4 * (?ab\<^sup>2 - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (4 * (cosh_dist a b)\<^sup>2 - 4) = sqrt (4 * ((cosh_dist a b)\<^sup>2 - 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (4 * (cosh_dist a b)\<^sup>2 - 4) = sqrt (4 * ((cosh_dist a b)\<^sup>2 - 1))

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
hence "sqrt (4 * ?ab\<^sup>2 - 4) = 2 * sqrt (?ab\<^sup>2 - 1)"
[PROOF STATE]
proof (prove)
using this:
sqrt (4 * (cosh_dist a b)\<^sup>2 - 4) = sqrt (4 * ((cosh_dist a b)\<^sup>2 - 1))

goal (1 subgoal):
 1. sqrt (4 * (cosh_dist a b)\<^sup>2 - 4) = 2 * sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
by (unfold real_sqrt_mult) simp
[PROOF STATE]
proof (state)
this:
sqrt (4 * (cosh_dist a b)\<^sup>2 - 4) = 2 * sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
sqrt (cross_ratio p q a b) = (2 * cosh_dist a b + sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2 \<or> sqrt (cross_ratio p q a b) = (2 * cosh_dist a b - sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2
sqrt (4 * (cosh_dist a b)\<^sup>2 - 4) = 2 * sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
have "sqrt ?pqab = 2 * (?ab + sqrt (?ab\<^sup>2 - 1)) / 2
    \<or> sqrt ?pqab = 2 * (?ab - sqrt (?ab\<^sup>2 - 1)) / 2"
[PROOF STATE]
proof (prove)
using this:
sqrt (cross_ratio p q a b) = (2 * cosh_dist a b + sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2 \<or> sqrt (cross_ratio p q a b) = (2 * cosh_dist a b - sqrt (4 * (cosh_dist a b)\<^sup>2 - 4)) / 2
sqrt (4 * (cosh_dist a b)\<^sup>2 - 4) = 2 * sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) = 2 * (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) / 2 \<or> sqrt (cross_ratio p q a b) = 2 * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)) / 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) = 2 * (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) / 2 \<or> sqrt (cross_ratio p q a b) = 2 * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)) / 2

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
hence "sqrt ?pqab = ?ab + sqrt (?ab\<^sup>2 - 1)
    \<or> sqrt ?pqab = ?ab - sqrt (?ab\<^sup>2 - 1)"
[PROOF STATE]
proof (prove)
using this:
sqrt (cross_ratio p q a b) = 2 * (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) / 2 \<or> sqrt (cross_ratio p q a b) = 2 * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)) / 2

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<or> sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
by (simp only: nonzero_mult_div_cancel_left [of 2])
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<or> sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
from \<open>are_endpoints_in_S p q a b\<close>
[PROOF STATE]
proof (chain)
picking this:
are_endpoints_in_S p q a b
[PROOF STEP]
have "a \<in> hyp2" and "b \<in> hyp2"
[PROOF STATE]
proof (prove)
using this:
are_endpoints_in_S p q a b

goal (1 subgoal):
 1. a \<in> hyp2 &&& b \<in> hyp2
[PROOF STEP]
by (unfold are_endpoints_in_S_def) simp_all
[PROOF STATE]
proof (state)
this:
a \<in> hyp2
b \<in> hyp2

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
hence "?ab \<ge> 1"
[PROOF STATE]
proof (prove)
using this:
a \<in> hyp2
b \<in> hyp2

goal (1 subgoal):
 1. 1 \<le> cosh_dist a b
[PROOF STEP]
by (rule cosh_dist_at_least_1)
[PROOF STATE]
proof (state)
this:
1 \<le> cosh_dist a b

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
hence "?ab\<^sup>2 \<ge> 1"
[PROOF STATE]
proof (prove)
using this:
1 \<le> cosh_dist a b

goal (1 subgoal):
 1. 1 \<le> (cosh_dist a b)\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 \<le> (cosh_dist a b)\<^sup>2

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
hence "sqrt (?ab\<^sup>2 - 1) \<ge> 0"
[PROOF STATE]
proof (prove)
using this:
1 \<le> (cosh_dist a b)\<^sup>2

goal (1 subgoal):
 1. 0 \<le> sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
hence "sqrt (?ab\<^sup>2 - 1) * sqrt (?ab\<^sup>2 - 1) = ?ab\<^sup>2 - 1"
[PROOF STATE]
proof (prove)
using this:
0 \<le> sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. sqrt ((cosh_dist a b)\<^sup>2 - 1) * sqrt ((cosh_dist a b)\<^sup>2 - 1) = (cosh_dist a b)\<^sup>2 - 1
[PROOF STEP]
by (simp add: real_sqrt_mult [symmetric])
[PROOF STATE]
proof (state)
this:
sqrt ((cosh_dist a b)\<^sup>2 - 1) * sqrt ((cosh_dist a b)\<^sup>2 - 1) = (cosh_dist a b)\<^sup>2 - 1

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
hence "(?ab + sqrt (?ab\<^sup>2 - 1)) * (?ab - sqrt (?ab\<^sup>2 - 1)) = 1"
[PROOF STATE]
proof (prove)
using this:
sqrt ((cosh_dist a b)\<^sup>2 - 1) * sqrt ((cosh_dist a b)\<^sup>2 - 1) = (cosh_dist a b)\<^sup>2 - 1

goal (1 subgoal):
 1. (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)) = 1
[PROOF STEP]
by (simp add: algebra_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
(cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)) = 1

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
have "?ab - sqrt (?ab\<^sup>2 - 1) \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1 \<Longrightarrow> False
[PROOF STEP]
assume "\<not> (?ab - sqrt (?ab\<^sup>2 - 1) \<le> 1)"
[PROOF STATE]
proof (state)
this:
\<not> cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1

goal (1 subgoal):
 1. \<not> cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1 \<Longrightarrow> False
[PROOF STEP]
hence "1 < ?ab - sqrt (?ab\<^sup>2 - 1)"
[PROOF STATE]
proof (prove)
using this:
\<not> cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1

goal (1 subgoal):
 1. 1 < cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 < cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. \<not> cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 < cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. \<not> cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1 \<Longrightarrow> False
[PROOF STEP]
from \<open>sqrt (?ab\<^sup>2 - 1) \<ge> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
0 \<le> sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
have "\<dots> \<le> ?ab + sqrt (?ab\<^sup>2 - 1)"
[PROOF STATE]
proof (prove)
using this:
0 \<le> sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. \<not> cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1 \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
1 < cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
have "1 < ?ab + sqrt (?ab\<^sup>2 - 1)"
[PROOF STATE]
proof (prove)
using this:
1 < cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. 1 < cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 < cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. \<not> cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1 \<Longrightarrow> False
[PROOF STEP]
with \<open>1 < ?ab - sqrt (?ab\<^sup>2 - 1)\<close>
      and mult_strict_mono' [of
      1 "?ab + sqrt (?ab\<^sup>2 - 1)" 1 "?ab - sqrt (?ab\<^sup>2 - 1)"]
[PROOF STATE]
proof (chain)
picking this:
1 < cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
\<lbrakk>1 < cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1); 1 < cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1); 0 \<le> 1; 0 \<le> 1\<rbrakk> \<Longrightarrow> 1 * 1 < (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1))
1 < cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
have "1 < (?ab + sqrt (?ab\<^sup>2 - 1)) * (?ab - sqrt (?ab\<^sup>2 - 1))"
[PROOF STATE]
proof (prove)
using this:
1 < cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
\<lbrakk>1 < cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1); 1 < cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1); 0 \<le> 1; 0 \<le> 1\<rbrakk> \<Longrightarrow> 1 * 1 < (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1))
1 < cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. 1 < (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 < (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1))

goal (1 subgoal):
 1. \<not> cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1 \<Longrightarrow> False
[PROOF STEP]
with \<open>(?ab + sqrt (?ab\<^sup>2 - 1)) * (?ab - sqrt (?ab\<^sup>2 - 1)) = 1\<close>
[PROOF STATE]
proof (chain)
picking this:
(cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)) = 1
1 < (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1))
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
(cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)) = 1
1 < (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1))

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
have "sqrt ?pqab = ?ab + sqrt (?ab\<^sup>2 - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<Longrightarrow> False
[PROOF STEP]
assume "sqrt ?pqab \<noteq> ?ab + sqrt (?ab\<^sup>2 - 1)"
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<Longrightarrow> False
[PROOF STEP]
with \<open>sqrt ?pqab = ?ab + sqrt (?ab\<^sup>2 - 1)
      \<or> sqrt ?pqab = ?ab - sqrt (?ab\<^sup>2 - 1)\<close>
[PROOF STATE]
proof (chain)
picking this:
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<or> sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
have "sqrt ?pqab = ?ab - sqrt (?ab\<^sup>2 - 1)"
[PROOF STATE]
proof (prove)
using this:
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<or> sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<Longrightarrow> False
[PROOF STEP]
with \<open>?ab - sqrt (?ab\<^sup>2 - 1) \<le> 1\<close>
[PROOF STATE]
proof (chain)
picking this:
cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1
sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
have "sqrt ?pqab \<le> 1"
[PROOF STATE]
proof (prove)
using this:
cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1) \<le> 1
sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)

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

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<Longrightarrow> False
[PROOF STEP]
with \<open>?pqab \<ge> 1\<close>
[PROOF STATE]
proof (chain)
picking this:
1 \<le> cross_ratio p q a b
sqrt (cross_ratio p q a b) \<le> 1
[PROOF STEP]
have "sqrt ?pqab = 1"
[PROOF STATE]
proof (prove)
using this:
1 \<le> cross_ratio p q a b
sqrt (cross_ratio p q a b) \<le> 1

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

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<Longrightarrow> False
[PROOF STEP]
with \<open>sqrt ?pqab = ?ab - sqrt (?ab\<^sup>2 - 1)\<close>
      and \<open>(?ab + sqrt (?ab\<^sup>2 - 1)) * (?ab - sqrt (?ab\<^sup>2 - 1)) = 1\<close>
[PROOF STATE]
proof (chain)
picking this:
sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
(cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)) = 1
sqrt (cross_ratio p q a b) = 1
[PROOF STEP]
have "?ab + sqrt (?ab\<^sup>2 - 1) = 1"
[PROOF STATE]
proof (prove)
using this:
sqrt (cross_ratio p q a b) = cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)
(cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)) * (cosh_dist a b - sqrt ((cosh_dist a b)\<^sup>2 - 1)) = 1
sqrt (cross_ratio p q a b) = 1

goal (1 subgoal):
 1. cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) = 1

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<Longrightarrow> False
[PROOF STEP]
with \<open>sqrt ?pqab = 1\<close>
[PROOF STATE]
proof (chain)
picking this:
sqrt (cross_ratio p q a b) = 1
cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) = 1
[PROOF STEP]
have "sqrt ?pqab = ?ab + sqrt (?ab\<^sup>2 - 1)"
[PROOF STATE]
proof (prove)
using this:
sqrt (cross_ratio p q a b) = 1
cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) = 1

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1) \<Longrightarrow> False
[PROOF STEP]
with \<open>sqrt ?pqab \<noteq> ?ab + sqrt (?ab\<^sup>2 - 1)\<close>
[PROOF STATE]
proof (chain)
picking this:
sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
sqrt (cross_ratio p q a b) \<noteq> cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
from \<open>?pqab \<ge> 1\<close>
[PROOF STATE]
proof (chain)
picking this:
1 \<le> cross_ratio p q a b
[PROOF STEP]
have "?pqab = (sqrt ?pqab)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
1 \<le> cross_ratio p q a b

goal (1 subgoal):
 1. cross_ratio p q a b = (sqrt (cross_ratio p q a b))\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cross_ratio p q a b = (sqrt (cross_ratio p q a b))\<^sup>2

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
cross_ratio p q a b = (sqrt (cross_ratio p q a b))\<^sup>2
[PROOF STEP]
have "?pqab = (?ab + sqrt (?ab\<^sup>2 - 1))\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
sqrt (cross_ratio p q a b) = cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1)
cross_ratio p q a b = (sqrt (cross_ratio p q a b))\<^sup>2

goal (1 subgoal):
 1. cross_ratio p q a b = (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1))\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cross_ratio p q a b = (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1))\<^sup>2

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
with \<open>sqrt (?ab\<^sup>2 - 1) * sqrt (?ab\<^sup>2 - 1) = ?ab\<^sup>2 - 1\<close>
[PROOF STATE]
proof (chain)
picking this:
sqrt ((cosh_dist a b)\<^sup>2 - 1) * sqrt ((cosh_dist a b)\<^sup>2 - 1) = (cosh_dist a b)\<^sup>2 - 1
cross_ratio p q a b = (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1))\<^sup>2
[PROOF STEP]
show "?pqab = 2 * ?ab\<^sup>2 + 2 * ?ab * sqrt (?ab\<^sup>2 - 1) - 1"
[PROOF STATE]
proof (prove)
using this:
sqrt ((cosh_dist a b)\<^sup>2 - 1) * sqrt ((cosh_dist a b)\<^sup>2 - 1) = (cosh_dist a b)\<^sup>2 - 1
cross_ratio p q a b = (cosh_dist a b + sqrt ((cosh_dist a b)\<^sup>2 - 1))\<^sup>2

goal (1 subgoal):
 1. cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1
[PROOF STEP]
by (simp add: power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
cross_ratio p q a b = 2 * (cosh_dist a b)\<^sup>2 + 2 * cosh_dist a b * sqrt ((cosh_dist a b)\<^sup>2 - 1) - 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_ordering_inj_on: "\<lbrakk>finite X; ordering f ord X\<rbrakk> \<Longrightarrow> inj_on f {0..card X - 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite X; TernaryOrdering.ordering f ord X\<rbrakk> \<Longrightarrow> inj_on f {0..card X - 1}
[PROOF STEP]
by (metis finite_ordering_img Suc_diff_1 atLeastAtMost_iff card_atLeastAtMost card_eq_0_iff
        diff_0_eq_0 diff_zero eq_card_imp_inj_on gr0I inj_onI le_0_eq)


[STATEMENT]
lemma word_rsplit_upt:
  "\<lbrakk> size x = LENGTH('a :: len) * n; n \<noteq> 0 \<rbrakk>
    \<Longrightarrow> word_rsplit x = map (\<lambda>i. ucast (x >> (i * LENGTH('a))) :: 'a word) (rev [0 ..< n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>size x = LENGTH('a) * n; n \<noteq> 0\<rbrakk> \<Longrightarrow> word_rsplit x = map (\<lambda>i. ucast (x >> i * LENGTH('a))) (rev [0..<n])
[PROOF STEP]
apply (subgoal_tac "length (word_rsplit x :: 'a word list) = n")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>size x = LENGTH('a) * n; n \<noteq> 0; length (word_rsplit x) = n\<rbrakk> \<Longrightarrow> word_rsplit x = map (\<lambda>i. ucast (x >> i * LENGTH('a))) (rev [0..<n])
 2. \<lbrakk>size x = LENGTH('a) * n; n \<noteq> 0\<rbrakk> \<Longrightarrow> length (word_rsplit x) = n
[PROOF STEP]
apply (rule nth_equalityI, simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>i. \<lbrakk>size x = LENGTH('a) * n; n \<noteq> 0; length (word_rsplit x) = n; i < length (word_rsplit x)\<rbrakk> \<Longrightarrow> word_rsplit x ! i = map (\<lambda>i. ucast (x >> i * LENGTH('a))) (rev [0..<n]) ! i
 2. \<lbrakk>size x = LENGTH('a) * n; n \<noteq> 0\<rbrakk> \<Longrightarrow> length (word_rsplit x) = n
[PROOF STEP]
apply (intro allI word_eqI impI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>i na. \<lbrakk>size x = LENGTH('a) * n; n \<noteq> 0; length (word_rsplit x) = n; i < length (word_rsplit x); na < size (word_rsplit x ! i)\<rbrakk> \<Longrightarrow> bit (word_rsplit x ! i) na = bit (map (\<lambda>i. ucast (x >> i * LENGTH('a))) (rev [0..<n]) ! i) na
 2. \<lbrakk>size x = LENGTH('a) * n; n \<noteq> 0\<rbrakk> \<Longrightarrow> length (word_rsplit x) = n
[PROOF STEP]
apply (simp add: test_bit_rsplit_alt word_size)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>i na. \<lbrakk>LENGTH('b) = LENGTH('a) * n; length (word_rsplit x) = n; i < n; na < LENGTH('a)\<rbrakk> \<Longrightarrow> bit x ((n - Suc i) * LENGTH('a) + na) = bit (ucast (x >> rev [0..<n] ! i * LENGTH('a))) na
 2. \<lbrakk>size x = LENGTH('a) * n; n \<noteq> 0\<rbrakk> \<Longrightarrow> length (word_rsplit x) = n
[PROOF STEP]
apply (simp add: nth_ucast bit_simps rev_nth field_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>size x = LENGTH('a) * n; n \<noteq> 0\<rbrakk> \<Longrightarrow> length (word_rsplit x) = n
[PROOF STEP]
apply (simp add: length_word_rsplit_exp_size word_size)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>LENGTH('b) = LENGTH('a) * n; 0 < n\<rbrakk> \<Longrightarrow> (LENGTH('a) * n + LENGTH('a) - Suc 0) div LENGTH('a) = n
[PROOF STEP]
apply (subst diff_add_assoc)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>LENGTH('b) = LENGTH('a) * n; 0 < n\<rbrakk> \<Longrightarrow> Suc 0 \<le> LENGTH('a)
 2. \<lbrakk>LENGTH('b) = LENGTH('a) * n; 0 < n\<rbrakk> \<Longrightarrow> (LENGTH('a) * n + (LENGTH('a) - Suc 0)) div LENGTH('a) = n
[PROOF STEP]
apply (simp flip: less_eq_Suc_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>LENGTH('b) = LENGTH('a) * n; 0 < n\<rbrakk> \<Longrightarrow> (LENGTH('a) * n + (LENGTH('a) - Suc 0)) div LENGTH('a) = n
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma indicator_sum_eq:
  fixes m::real and f :: "'a \<Rightarrow> real"
  assumes "\<bar>m\<bar> \<le> 2 ^ (2*n)" "m/2^n \<le> f x" "f x < (m+1)/2^n" "m \<in> \<int>"
  shows   "(\<Sum>k::real | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2*n).
            k/2^n * indicator {y. k/2^n \<le> f y \<and> f y < (k+1)/2^n} x)  = m/2^n"
          (is "sum ?f ?S = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n
[PROOF STEP]
have "sum ?f ?S = sum (\<lambda>k. k/2^n * indicator {y. k/2^n \<le> f y \<and> f y < (k+1)/2^n} x) {m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = (\<Sum>k\<in>{m}. k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x)
[PROOF STEP]
proof (rule comm_monoid_add_class.sum.mono_neutral_right)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. finite {k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)}
 2. {m} \<subseteq> {k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)}
 3. \<forall>i\<in>{k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)} - {m}. i / 2 ^ n * indicat_real {y. i / 2 ^ n \<le> f y \<and> f y < (i + 1) / 2 ^ n} x = 0
[PROOF STEP]
show "finite ?S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)}
[PROOF STEP]
by (rule finite_abs_int_segment)
[PROOF STATE]
proof (state)
this:
finite {k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)}

goal (2 subgoals):
 1. {m} \<subseteq> {k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)}
 2. \<forall>i\<in>{k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)} - {m}. i / 2 ^ n * indicat_real {y. i / 2 ^ n \<le> f y \<and> f y < (i + 1) / 2 ^ n} x = 0
[PROOF STEP]
show "{m} \<subseteq> {k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2*n)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {m} \<subseteq> {k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<bar>m\<bar> \<le> 2 ^ (2 * n)
m / 2 ^ n \<le> f x
f x < (m + 1) / 2 ^ n
m \<in> \<int>

goal (1 subgoal):
 1. {m} \<subseteq> {k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{m} \<subseteq> {k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)}

goal (1 subgoal):
 1. \<forall>i\<in>{k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)} - {m}. i / 2 ^ n * indicat_real {y. i / 2 ^ n \<le> f y \<and> f y < (i + 1) / 2 ^ n} x = 0
[PROOF STEP]
show "\<forall>i\<in>{k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2*n)} - {m}. ?f i = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i\<in>{k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)} - {m}. i / 2 ^ n * indicat_real {y. i / 2 ^ n \<le> f y \<and> f y < (i + 1) / 2 ^ n} x = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<bar>m\<bar> \<le> 2 ^ (2 * n)
m / 2 ^ n \<le> f x
f x < (m + 1) / 2 ^ n
m \<in> \<int>

goal (1 subgoal):
 1. \<forall>i\<in>{k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)} - {m}. i / 2 ^ n * indicat_real {y. i / 2 ^ n \<le> f y \<and> f y < (i + 1) / 2 ^ n} x = 0
[PROOF STEP]
by (auto simp: indicator_def Ints_def abs_le_iff field_split_simps)
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>{k \<in> \<int>. \<bar>k\<bar> \<le> 2 ^ (2 * n)} - {m}. i / 2 ^ n * indicat_real {y. i / 2 ^ n \<le> f y \<and> f y < (i + 1) / 2 ^ n} x = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = (\<Sum>k\<in>{m}. k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x)

goal (1 subgoal):
 1. (\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = (\<Sum>k\<in>{m}. k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x)

goal (1 subgoal):
 1. (\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n
[PROOF STEP]
have "\<dots> = m/2^n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<in>{m}. k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<bar>m\<bar> \<le> 2 ^ (2 * n)
m / 2 ^ n \<le> f x
f x < (m + 1) / 2 ^ n
m \<in> \<int>

goal (1 subgoal):
 1. (\<Sum>k\<in>{m}. k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n
[PROOF STEP]
by (auto simp: indicator_def not_less)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>{m}. k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n

goal (1 subgoal):
 1. (\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n

goal (1 subgoal):
 1. (\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>k | k \<in> \<int> \<and> \<bar>k\<bar> \<le> 2 ^ (2 * n). k / 2 ^ n * indicat_real {y. k / 2 ^ n \<le> f y \<and> f y < (k + 1) / 2 ^ n} x) = m / 2 ^ n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "(10000::nat) div 9 = 1111"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 10000 div 9 = 1111
[PROOF STEP]
by simp


[STATEMENT]
lemma continuous_diff [continuous_intros]:
  fixes f g :: "'a::t2_space \<Rightarrow> 'b::topological_group_add"
  shows "continuous F f \<Longrightarrow> continuous F g \<Longrightarrow> continuous F (\<lambda>x. f x - g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>continuous F f; continuous F g\<rbrakk> \<Longrightarrow> continuous F (\<lambda>x. f x - g x)
[PROOF STEP]
unfolding continuous_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(f \<longlongrightarrow> f (Lim F (\<lambda>x. x))) F; (g \<longlongrightarrow> g (Lim F (\<lambda>x. x))) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x - g x) \<longlongrightarrow> f (Lim F (\<lambda>x. x)) - g (Lim F (\<lambda>x. x))) F
[PROOF STEP]
by (rule tendsto_diff)


[STATEMENT]
lemma Fvars_instInpP2[simp]:
assumes "\<phi> \<in> fmla" and \<tau>: "\<tau> \<in> ptrm n" and "Fvars \<phi> \<subseteq> {inp}"
shows "Fvars (instInpP \<phi> n \<tau>) = Fvars \<phi> - {inp} \<union> Variable ` {(Suc 0)..n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Fvars (instInpP \<phi> n \<tau>) = Fvars \<phi> - {inp} \<union> Variable ` {Suc 0..n}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<phi> \<in> fmla
\<tau> \<in> ptrm n
Fvars \<phi> \<subseteq> {inp}

goal (1 subgoal):
 1. Fvars (instInpP \<phi> n \<tau>) = Fvars \<phi> - {inp} \<union> Variable ` {Suc 0..n}
[PROOF STEP]
by (subst Fvars_instInpP) auto


[STATEMENT]
lemma carter_wegman_hash_familyI:
  assumes "field F"
  assumes "finite (carrier F)"
  assumes "0 < k"
  shows "carter_wegman_hash_family F k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. carter_wegman_hash_family F k
[PROOF STEP]
using assms field.is_ring[OF assms(1)] poly_hash_familyI
[PROOF STATE]
proof (prove)
using this:
field F
finite (carrier F)
0 < k
ring F
\<lbrakk>ring ?R; finite (carrier ?R); 0 < ?k\<rbrakk> \<Longrightarrow> poly_hash_family ?R ?k

goal (1 subgoal):
 1. carter_wegman_hash_family F k
[PROOF STEP]
by (simp add:carter_wegman_hash_family_def carter_wegman_hash_family_axioms_def)


[STATEMENT]
lemma poly_MVT: "a < b \<Longrightarrow> \<exists>x. a < x \<and> x < b \<and> poly p b - poly p a = (b - a) * poly (pderiv p) x"
  for a b :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a < b \<Longrightarrow> \<exists>x>a. x < b \<and> poly p b - poly p a = (b - a) * poly (pderiv p) x
[PROOF STEP]
by (simp add: MVT2)


[STATEMENT]
lemma vifunion_vintersection_index_right[simp]: "(\<Union>\<^sub>\<circ>C\<in>\<^sub>\<circ>B. A \<inter>\<^sub>\<circ> C) = A \<inter>\<^sub>\<circ> \<Union>\<^sub>\<circ>B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union>\<^sub>\<circ> (VLambda B ((\<inter>\<^sub>\<circ>) A) `\<^sub>\<circ> B) = A \<inter>\<^sub>\<circ> \<Union>\<^sub>\<circ> B
[PROOF STEP]
by (force simp: vimage_VLambda_vrange_rep)


[STATEMENT]
lemma Bounded_mat_elements_mat: "A \<in> Bounded_mat b \<longleftrightarrow> (\<forall> x \<in> elements_mat A. abs x \<le> b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A \<in> Bounded_mat b) = (\<forall>x\<in>elements_mat A. \<bar>x\<bar> \<le> b)
[PROOF STEP]
unfolding Bounded_mat_def elements_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A \<in> {A. \<forall>i<dim_row A. \<forall>j<dim_col A. \<bar>A $$ (i, j)\<bar> \<le> b}) = (\<forall>x\<in>set (concat (map (\<lambda>i. map (\<lambda>j. A $$ (i, j)) [0..<dim_col A]) [0..<dim_row A])). \<bar>x\<bar> \<le> b)
[PROOF STEP]
by auto


[STATEMENT]
theorem teRiele_Rule_Amicable:
  fixes a u p r c q :: nat
  assumes "a \<ge> 1" and "u \<ge> 1"
      and "prime p" and "prime r" and "prime c" and "prime q" and "r \<noteq> c"
      and "\<not>(p dvd a)" and "(a*u) Amic (a*p)" and "gcd a (r*c)=1"
      and "q = r+c+u" and "gcd (a*u) q =1" and "r*c = p*(r +c+ u) + p+u"
  shows "(a*u*q) Amic (a*r*c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
have "p+1 >0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < p + 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u

goal (1 subgoal):
 1. 0 < p + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < p + 1

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
have Z1: " r*c = p*q+p+u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r * c = p * q + p + u
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u

goal (1 subgoal):
 1. r * c = p * q + p + u
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r * c = p * q + p + u

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
have Z2: "(r+1)*(c+1) = (q+1)*(p+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (r + 1) * (c + 1) = (q + 1) * (p + 1)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (r + 1) * (c + 1) = (q + 1) * (p + 1)
[PROOF STEP]
have y: "(q+1)*(p+1) = q*p + q+ p+1 "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (q + 1) * (p + 1) = q * p + q + p + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(q + 1) * (p + 1) = q * p + q + p + 1

goal (1 subgoal):
 1. (r + 1) * (c + 1) = (q + 1) * (p + 1)
[PROOF STEP]
have yy: "(r+1)*(c+1) = r*c + r+ c+1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (r + 1) * (c + 1) = r * c + r + c + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(r + 1) * (c + 1) = r * c + r + c + 1

goal (1 subgoal):
 1. (r + 1) * (c + 1) = (q + 1) * (p + 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (r + 1) * (c + 1) = (q + 1) * (p + 1)
[PROOF STEP]
using assms y Z1 yy
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
(q + 1) * (p + 1) = q * p + q + p + 1
r * c = p * q + p + u
(r + 1) * (c + 1) = r * c + r + c + 1

goal (1 subgoal):
 1. (r + 1) * (c + 1) = (q + 1) * (p + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(r + 1) * (c + 1) = (q + 1) * (p + 1)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(r + 1) * (c + 1) = (q + 1) * (p + 1)

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
have "Esigma(a) = (a*(u+p)/(p+1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (Esigma a) = real (a * (u + p)) / real (p + 1)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real (Esigma a) = real (a * (u + p)) / real (p + 1)
[PROOF STEP]
have d: "Esigma (a*p) = (Esigma a)*(Esigma p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * p) = Esigma a * Esigma p
[PROOF STEP]
using assms gcd_Esigma_mult \<open>prime p\<close> \<open>\<not> (p dvd a)\<close>
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
gcd ?m ?n = 1 \<Longrightarrow> Esigma (?m * ?n) = Esigma ?m * Esigma ?n
prime p
\<not> p dvd a

goal (1 subgoal):
 1. Esigma (a * p) = Esigma a * Esigma p
[PROOF STEP]
by (metis gcd_unique_nat prime_nat_iff)
[PROOF STATE]
proof (state)
this:
Esigma (a * p) = Esigma a * Esigma p

goal (1 subgoal):
 1. real (Esigma a) = real (a * (u + p)) / real (p + 1)
[PROOF STEP]
have dd : "Esigma (a*p) =(Esigma a)*(p+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * p) = Esigma a * (p + 1)
[PROOF STEP]
using d assms  prime_sum_div
[PROOF STATE]
proof (prove)
using this:
Esigma (a * p) = Esigma a * Esigma p
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
prime ?n \<Longrightarrow> Esigma ?n = ?n + 1

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

goal (1 subgoal):
 1. real (Esigma a) = real (a * (u + p)) / real (p + 1)
[PROOF STEP]
have ddd: "Esigma (a*p) = a*(u+p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * p) = a * (u + p)
[PROOF STEP]
using assms Amicable_pair_def
        Amicable_pair_equiv_def
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
?m Amic ?n \<equiv> ?m = aliquot_sum ?n \<and> ?n = aliquot_sum ?m
\<lbrakk>?m Amic ?n; 1 \<le> ?m; 1 \<le> ?n\<rbrakk> \<Longrightarrow> Esigma ?m = Esigma ?n \<and> Esigma ?m = ?m + ?n

goal (1 subgoal):
 1. Esigma (a * p) = a * (u + p)
[PROOF STEP]
by (smt One_nat_def add_mult_distrib2 one_le_mult_iff prime_ge_1_nat)
[PROOF STATE]
proof (state)
this:
Esigma (a * p) = a * (u + p)

goal (1 subgoal):
 1. real (Esigma a) = real (a * (u + p)) / real (p + 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (Esigma a) = real (a * (u + p)) / real (p + 1)
[PROOF STEP]
using d dd ddd Esigmanotzero assms(3) dvd_triv_right
        nonzero_mult_div_cancel_right prime_nat_iff prime_sum_div real_of_nat_div
[PROOF STATE]
proof (prove)
using this:
Esigma (a * p) = Esigma a * Esigma p
Esigma (a * p) = Esigma a * (p + 1)
Esigma (a * p) = a * (u + p)
1 \<le> ?n \<Longrightarrow> 1 \<le> Esigma ?n
prime p
?a dvd ?b * ?a
?b \<noteq> (0::?'a) \<Longrightarrow> ?a * ?b div ?b = ?a
prime ?n = (1 < ?n \<and> (\<forall>m. m dvd ?n \<longrightarrow> m = 1 \<or> m = ?n))
prime ?n \<Longrightarrow> Esigma ?n = ?n + 1
?d dvd ?n \<Longrightarrow> real (?n div ?d) = real ?n / real ?d

goal (1 subgoal):
 1. real (Esigma a) = real (a * (u + p)) / real (p + 1)
[PROOF STEP]
by (metis \<open>0 < p + 1\<close> neq0_conv)
[PROOF STATE]
proof (state)
this:
real (Esigma a) = real (a * (u + p)) / real (p + 1)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
real (Esigma a) = real (a * (u + p)) / real (p + 1)

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
have "Esigma(r) = (r+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma r = r + 1
[PROOF STEP]
using assms prime_sum_div
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
prime ?n \<Longrightarrow> Esigma ?n = ?n + 1

goal (1 subgoal):
 1. Esigma r = r + 1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Esigma r = r + 1

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
have "Esigma(c) = (c+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma c = c + 1
[PROOF STEP]
using assms prime_sum_div
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
prime ?n \<Longrightarrow> Esigma ?n = ?n + 1

goal (1 subgoal):
 1. Esigma c = c + 1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Esigma c = c + 1

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
have "Esigma (a*r*c) = (Esigma a)*(Esigma r)*(Esigma c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * r * c) = Esigma a * Esigma r * Esigma c
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Esigma (a * r * c) = Esigma a * Esigma r * Esigma c
[PROOF STEP]
have h: "Esigma (a*r*c) = (Esigma a)*(Esigma (r*c))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * r * c) = Esigma a * Esigma (r * c)
[PROOF STEP]
using assms gcd_Esigma_mult
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
gcd ?m ?n = 1 \<Longrightarrow> Esigma (?m * ?n) = Esigma ?m * Esigma ?n

goal (1 subgoal):
 1. Esigma (a * r * c) = Esigma a * Esigma (r * c)
[PROOF STEP]
by (metis mult.assoc mult.commute)
[PROOF STATE]
proof (state)
this:
Esigma (a * r * c) = Esigma a * Esigma (r * c)

goal (1 subgoal):
 1. Esigma (a * r * c) = Esigma a * Esigma r * Esigma c
[PROOF STEP]
have hh: " Esigma (r*c) = (Esigma r)*(Esigma c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (r * c) = Esigma r * Esigma c
[PROOF STEP]
using assms prime_Esigma_mult
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
\<lbrakk>prime ?m; prime ?n; ?m \<noteq> ?n\<rbrakk> \<Longrightarrow> Esigma (?m * ?n) = Esigma ?n * Esigma ?m

goal (1 subgoal):
 1. Esigma (r * c) = Esigma r * Esigma c
[PROOF STEP]
by (metis semiring_normalization_rules(7))
[PROOF STATE]
proof (state)
this:
Esigma (r * c) = Esigma r * Esigma c

goal (1 subgoal):
 1. Esigma (a * r * c) = Esigma a * Esigma r * Esigma c
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * r * c) = Esigma a * Esigma r * Esigma c
[PROOF STEP]
using h hh
[PROOF STATE]
proof (prove)
using this:
Esigma (a * r * c) = Esigma a * Esigma (r * c)
Esigma (r * c) = Esigma r * Esigma c

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Esigma (a * r * c) = Esigma a * Esigma r * Esigma c

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
have A: "Esigma (a*u*q) = Esigma (a*r*c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * r * c)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * r * c)
[PROOF STEP]
have wk: "Esigma (a*u*q) = Esigma (a*u)*(q+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * u) * (q + 1)
[PROOF STEP]
using assms gcd_Esigma_mult
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
gcd ?m ?n = 1 \<Longrightarrow> Esigma (?m * ?n) = Esigma ?m * Esigma ?n

goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * u) * (q + 1)
[PROOF STEP]
by (simp add: prime_sum_div)
[PROOF STATE]
proof (state)
this:
Esigma (a * u * q) = Esigma (a * u) * (q + 1)

goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * r * c)
[PROOF STEP]
have wk1: "Esigma (a*u) = a*(u+p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * u) = a * (u + p)
[PROOF STEP]
using assms Amicable_pair_equiv_def
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
\<lbrakk>?m Amic ?n; 1 \<le> ?m; 1 \<le> ?n\<rbrakk> \<Longrightarrow> Esigma ?m = Esigma ?n \<and> Esigma ?m = ?m + ?n

goal (1 subgoal):
 1. Esigma (a * u) = a * (u + p)
[PROOF STEP]
by (smt One_nat_def add_mult_distrib2 one_le_mult_iff prime_ge_1_nat)
[PROOF STATE]
proof (state)
this:
Esigma (a * u) = a * (u + p)

goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * r * c)
[PROOF STEP]
have w3: "Esigma (a*u*q) = a*(u+p)*(q+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * u * q) = a * (u + p) * (q + 1)
[PROOF STEP]
using wk wk1
[PROOF STATE]
proof (prove)
using this:
Esigma (a * u * q) = Esigma (a * u) * (q + 1)
Esigma (a * u) = a * (u + p)

goal (1 subgoal):
 1. Esigma (a * u * q) = a * (u + p) * (q + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Esigma (a * u * q) = a * (u + p) * (q + 1)

goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * r * c)
[PROOF STEP]
have w4: "Esigma (a*r*c) =(Esigma a)*(r+1) * (c+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * r * c) = Esigma a * (r + 1) * (c + 1)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u

goal (1 subgoal):
 1. Esigma (a * r * c) = Esigma a * (r + 1) * (c + 1)
[PROOF STEP]
by (simp add: \<open>Esigma (a*r*c) = Esigma a * Esigma r * Esigma c\<close> \<open>Esigma c = c + 1\<close>
           \<open>Esigma r = r+1\<close>)
[PROOF STATE]
proof (state)
this:
Esigma (a * r * c) = Esigma a * (r + 1) * (c + 1)

goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * r * c)
[PROOF STEP]
have we: "a*(u+p)*(q+1) = (Esigma a)*(r+1)*(c+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * (u + p) * (q + 1) = Esigma a * (r + 1) * (c + 1)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a * (u + p) * (q + 1) = Esigma a * (r + 1) * (c + 1)
[PROOF STEP]
have we1: "(Esigma a)*(r+1)*(c+1) = (a*(u+p)/(p+1))*(r+1)*(c+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (Esigma a * (r + 1) * (c + 1)) = real (a * (u + p)) / real (p + 1) * real (r + 1) * real (c + 1)
[PROOF STEP]
by (metis \<open>real (Esigma a) = real (a*(u+p))/real(p+1)\<close> of_nat_mult)
[PROOF STATE]
proof (state)
this:
real (Esigma a * (r + 1) * (c + 1)) = real (a * (u + p)) / real (p + 1) * real (r + 1) * real (c + 1)

goal (1 subgoal):
 1. a * (u + p) * (q + 1) = Esigma a * (r + 1) * (c + 1)
[PROOF STEP]
have we12: " (Esigma a)*(r+1)*(c+1) = (a*(u+p)/(p+1))*(q+1)*(p+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (Esigma a * (r + 1) * (c + 1)) = real (a * (u + p)) / real (p + 1) * real (q + 1) * real (p + 1)
[PROOF STEP]
using we1 Z2
[PROOF STATE]
proof (prove)
using this:
real (Esigma a * (r + 1) * (c + 1)) = real (a * (u + p)) / real (p + 1) * real (r + 1) * real (c + 1)
(r + 1) * (c + 1) = (q + 1) * (p + 1)

goal (1 subgoal):
 1. real (Esigma a * (r + 1) * (c + 1)) = real (a * (u + p)) / real (p + 1) * real (q + 1) * real (p + 1)
[PROOF STEP]
by (metis of_nat_mult semiring_normalization_rules(18))
[PROOF STATE]
proof (state)
this:
real (Esigma a * (r + 1) * (c + 1)) = real (a * (u + p)) / real (p + 1) * real (q + 1) * real (p + 1)

goal (1 subgoal):
 1. a * (u + p) * (q + 1) = Esigma a * (r + 1) * (c + 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * (u + p) * (q + 1) = Esigma a * (r + 1) * (c + 1)
[PROOF STEP]
using we12 assms
[PROOF STATE]
proof (prove)
using this:
real (Esigma a * (r + 1) * (c + 1)) = real (a * (u + p)) / real (p + 1) * real (q + 1) * real (p + 1)
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u

goal (1 subgoal):
 1. a * (u + p) * (q + 1) = Esigma a * (r + 1) * (c + 1)
[PROOF STEP]
by (smt  nonzero_mult_div_cancel_right of_nat_1  of_nat_add of_nat_eq_iff of_nat_le_iff
            of_nat_mult prime_ge_1_nat times_divide_eq_left)
[PROOF STATE]
proof (state)
this:
a * (u + p) * (q + 1) = Esigma a * (r + 1) * (c + 1)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a * (u + p) * (q + 1) = Esigma a * (r + 1) * (c + 1)

goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * r * c)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * r * c)
[PROOF STEP]
using we w3 w4
[PROOF STATE]
proof (prove)
using this:
a * (u + p) * (q + 1) = Esigma a * (r + 1) * (c + 1)
Esigma (a * u * q) = a * (u + p) * (q + 1)
Esigma (a * r * c) = Esigma a * (r + 1) * (c + 1)

goal (1 subgoal):
 1. Esigma (a * u * q) = Esigma (a * r * c)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Esigma (a * u * q) = Esigma (a * r * c)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Esigma (a * u * q) = Esigma (a * r * c)

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
have B : "Esigma (a*r*c) = (a*u*q)+(a*r*c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a1: "(u+p)*(q+1) = (u*q+p*q+p+u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u + p) * (q + 1) = u * q + p * q + p + u
[PROOF STEP]
using assms add_mult_distrib
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
(?m + ?n) * ?k = ?m * ?k + ?n * ?k

goal (1 subgoal):
 1. (u + p) * (q + 1) = u * q + p * q + p + u
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(u + p) * (q + 1) = u * q + p * q + p + u

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a2: "(u+p)*(q+1)*(p+1) = (u*q+p*q+p+u)*(p+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u + p) * (q + 1) * (p + 1) = (u * q + p * q + p + u) * (p + 1)
[PROOF STEP]
using a1 assms
[PROOF STATE]
proof (prove)
using this:
(u + p) * (q + 1) = u * q + p * q + p + u
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u

goal (1 subgoal):
 1. (u + p) * (q + 1) * (p + 1) = (u * q + p * q + p + u) * (p + 1)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
(u + p) * (q + 1) * (p + 1) = (u * q + p * q + p + u) * (p + 1)

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a3: "(u+p)*(r+1)*(c+1) = (u*q+p*q+p+u)*(p+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u + p) * (r + 1) * (c + 1) = (u * q + p * q + p + u) * (p + 1)
[PROOF STEP]
using assms a2 Z2
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
(u + p) * (q + 1) * (p + 1) = (u * q + p * q + p + u) * (p + 1)
(r + 1) * (c + 1) = (q + 1) * (p + 1)

goal (1 subgoal):
 1. (u + p) * (r + 1) * (c + 1) = (u * q + p * q + p + u) * (p + 1)
[PROOF STEP]
by (metis semiring_normalization_rules(18))
[PROOF STATE]
proof (state)
this:
(u + p) * (r + 1) * (c + 1) = (u * q + p * q + p + u) * (p + 1)

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a4: "a*(u+p)* (r+1)*(c+1) = a*(u*q+ p*q+p+u)*(p+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * (u + p) * (r + 1) * (c + 1) = a * (u * q + p * q + p + u) * (p + 1)
[PROOF STEP]
using assms a3
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
(u + p) * (r + 1) * (c + 1) = (u * q + p * q + p + u) * (p + 1)

goal (1 subgoal):
 1. a * (u + p) * (r + 1) * (c + 1) = a * (u * q + p * q + p + u) * (p + 1)
[PROOF STEP]
by (metis semiring_normalization_rules(18))
[PROOF STATE]
proof (state)
this:
a * (u + p) * (r + 1) * (c + 1) = a * (u * q + p * q + p + u) * (p + 1)

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a5: "a*(u+p)*(r+1)*(c+1) = a*(u*q+r*c)*(p+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * (u + p) * (r + 1) * (c + 1) = a * (u * q + r * c) * (p + 1)
[PROOF STEP]
using assms a4 Z1
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
a * (u + p) * (r + 1) * (c + 1) = a * (u * q + p * q + p + u) * (p + 1)
r * c = p * q + p + u

goal (1 subgoal):
 1. a * (u + p) * (r + 1) * (c + 1) = a * (u * q + r * c) * (p + 1)
[PROOF STEP]
by (simp add: semiring_normalization_rules(21))
[PROOF STATE]
proof (state)
this:
a * (u + p) * (r + 1) * (c + 1) = a * (u * q + r * c) * (p + 1)

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a6: "(a*(u+p)*(r+1)*(c+1))/(p+1) =(a*(u*q+ r*c)* (p+1))/(p+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (a * (u + p) * (r + 1) * (c + 1)) / real (p + 1) = real (a * (u * q + r * c) * (p + 1)) / real (p + 1)
[PROOF STEP]
using assms a5
        semiring_normalization_rules(21) \<open>p+1 >0\<close>
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
a * (u + p) * (r + 1) * (c + 1) = a * (u * q + r * c) * (p + 1)
?a + ?b + ?c = ?a + (?b + ?c)
0 < p + 1

goal (1 subgoal):
 1. real (a * (u + p) * (r + 1) * (c + 1)) / real (p + 1) = real (a * (u * q + r * c) * (p + 1)) / real (p + 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real (a * (u + p) * (r + 1) * (c + 1)) / real (p + 1) = real (a * (u * q + r * c) * (p + 1)) / real (p + 1)

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a7: "(a*(u+p)*(r+1)*(c+1))/(p+1) =(a*(u*q+ r*c))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (a * (u + p) * (r + 1) * (c + 1)) / real (p + 1) = real (a * (u * q + r * c))
[PROOF STEP]
using assms a6 \<open>p+1 >0\<close>
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
real (a * (u + p) * (r + 1) * (c + 1)) / real (p + 1) = real (a * (u * q + r * c) * (p + 1)) / real (p + 1)
0 < p + 1

goal (1 subgoal):
 1. real (a * (u + p) * (r + 1) * (c + 1)) / real (p + 1) = real (a * (u * q + r * c))
[PROOF STEP]
by (metis neq0_conv nonzero_mult_div_cancel_right of_nat_eq_0_iff of_nat_mult)
[PROOF STATE]
proof (state)
this:
real (a * (u + p) * (r + 1) * (c + 1)) / real (p + 1) = real (a * (u * q + r * c))

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a8:"(a*(u+p)/(p+1))*(r+1)*(c+1) = a*(u*q+r*c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (a * (u + p)) / real (p + 1) * real (r + 1) * real (c + 1) = real (a * (u * q + r * c))
[PROOF STEP]
using assms a7  \<open>p+1 >0\<close>
[PROOF STATE]
proof (prove)
using this:
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
real (a * (u + p) * (r + 1) * (c + 1)) / real (p + 1) = real (a * (u * q + r * c))
0 < p + 1

goal (1 subgoal):
 1. real (a * (u + p)) / real (p + 1) * real (r + 1) * real (c + 1) = real (a * (u * q + r * c))
[PROOF STEP]
by (metis of_nat_mult times_divide_eq_left)
[PROOF STATE]
proof (state)
this:
real (a * (u + p)) / real (p + 1) * real (r + 1) * real (c + 1) = real (a * (u * q + r * c))

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a9: "(Esigma a)* Esigma(r)* Esigma(c) = a*(u*q+ r*c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma a * Esigma r * Esigma c = a * (u * q + r * c)
[PROOF STEP]
using a8 assms
        \<open> Esigma(r) = (r+1)\<close> \<open> Esigma(c) = (c+1)\<close>
[PROOF STATE]
proof (prove)
using this:
real (a * (u + p)) / real (p + 1) * real (r + 1) * real (c + 1) = real (a * (u * q + r * c))
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
Esigma r = r + 1
Esigma c = c + 1

goal (1 subgoal):
 1. Esigma a * Esigma r * Esigma c = a * (u * q + r * c)
[PROOF STEP]
by (metis \<open>real (Esigma a) = real (a*(u + p))/real(p + 1)\<close> of_nat_eq_iff of_nat_mult)
[PROOF STATE]
proof (state)
this:
Esigma a * Esigma r * Esigma c = a * (u * q + r * c)

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
have a10: " Esigma(a*r*c) = a*(u*q+ r*c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * r * c) = a * (u * q + r * c)
[PROOF STEP]
using a9 assms
        \<open>Esigma (a*r*c) = (Esigma a)*(Esigma r)*(Esigma c)\<close>
[PROOF STATE]
proof (prove)
using this:
Esigma a * Esigma r * Esigma c = a * (u * q + r * c)
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
Esigma (a * r * c) = Esigma a * Esigma r * Esigma c

goal (1 subgoal):
 1. Esigma (a * r * c) = a * (u * q + r * c)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Esigma (a * r * c) = a * (u * q + r * c)

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
using a10 assms
[PROOF STATE]
proof (prove)
using this:
Esigma (a * r * c) = a * (u * q + r * c)
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u

goal (1 subgoal):
 1. Esigma (a * r * c) = a * u * q + a * r * c
[PROOF STEP]
by (simp add: add_mult_distrib2 mult.assoc)
[PROOF STATE]
proof (state)
this:
Esigma (a * r * c) = a * u * q + a * r * c

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Esigma (a * r * c) = a * u * q + a * r * c

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
using A B  Amicable_pair_equiv_def_conv assms One_nat_def  one_le_mult_iff
[PROOF STATE]
proof (prove)
using this:
Esigma (a * u * q) = Esigma (a * r * c)
Esigma (a * r * c) = a * u * q + a * r * c
\<lbrakk>1 \<le> ?m; 1 \<le> ?n; Esigma ?m = Esigma ?n \<and> Esigma ?m = ?m + ?n\<rbrakk> \<Longrightarrow> ?m Amic ?n
1 \<le> a
1 \<le> u
prime p
prime r
prime c
prime q
r \<noteq> c
\<not> p dvd a
(a * u) Amic (a * p)
gcd a (r * c) = 1
q = r + c + u
gcd (a * u) q = 1
r * c = p * (r + c + u) + p + u
1 = Suc 0
(Suc 0 \<le> ?m * ?n) = (Suc 0 \<le> ?m \<and> Suc 0 \<le> ?n)

goal (1 subgoal):
 1. (a * u * q) Amic (a * r * c)
[PROOF STEP]
by (smt prime_ge_1_nat)
[PROOF STATE]
proof (state)
this:
(a * u * q) Amic (a * r * c)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hypreal_of_real_less_Infinitesimal_le_zero:
  "hypreal_of_real x < e \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> hypreal_of_real x \<le> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>hypreal_of_real x < e; e \<in> Infinitesimal\<rbrakk> \<Longrightarrow> hypreal_of_real x \<le> 0
[PROOF STEP]
by (metis Infinitesimal_interval eq_iff le_less_linear star_of_Infinitesimal_iff_0 star_of_eq_0)


[STATEMENT]
lemma of_nat32_0:
  "\<lbrakk>of_nat n = (0::word32); n < 2 ^ word_bits\<rbrakk> \<Longrightarrow> n = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>word_of_nat n = 0; n < 2 ^ word_bits\<rbrakk> \<Longrightarrow> n = 0
[PROOF STEP]
by (erule of_nat_0, simp add: word_bits_def)


[STATEMENT]
lemma Lcm_upto_real_conv_\<psi>:
  includes prime_counting_notation
  shows "real (Lcm {1..nat \<lfloor>x\<rfloor>}) = exp (\<psi> x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (Lcm {1..nat \<lfloor>x\<rfloor>}) = exp (\<psi> x)
[PROOF STEP]
by (subst Lcm_atLeast1AtMost_conv_\<psi>) (simp add: primes_psi_def sum_upto_altdef)


[STATEMENT]
lemma sorted_wrt_linorder_index_le_iff:
  assumes "linorder_on A R" "set xs \<subseteq> A" "sorted_wrt R xs"
          "x \<in> set xs" "y \<in> set xs"
  shows   "index xs x \<le> index xs y \<longleftrightarrow> (x,y) \<in> R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (index xs x \<le> index xs y) = ((x, y) \<in> R)
[PROOF STEP]
using sorted_wrt_linorder_index_le_imp[OF assms] sorted_wrt_linorder_imp_index_le[OF assms]
[PROOF STATE]
proof (prove)
using this:
index xs x \<le> index xs y \<Longrightarrow> (x, y) \<in> R
(x, y) \<in> R \<Longrightarrow> index xs x \<le> index xs y

goal (1 subgoal):
 1. (index xs x \<le> index xs y) = ((x, y) \<in> R)
[PROOF STEP]
by blast


[STATEMENT]
lemma Osum_Partial_order:
"\<lbrakk>Field r Int Field r' = {}; Partial_order r; Partial_order r'\<rbrakk> \<Longrightarrow>
 Partial_order (r Osum r')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Field r \<inter> Field r' = {}; Partial_order r; Partial_order r'\<rbrakk> \<Longrightarrow> Partial_order (r \<union>o r')
[PROOF STEP]
unfolding partial_order_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Field r \<inter> Field r' = {}; Preorder r \<and> antisym r; Preorder r' \<and> antisym r'\<rbrakk> \<Longrightarrow> Preorder (r \<union>o r') \<and> antisym (r \<union>o r')
[PROOF STEP]
using Osum_Preorder Osum_antisym
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>Field ?r \<inter> Field ?r' = {}; Preorder ?r; Preorder ?r'\<rbrakk> \<Longrightarrow> Preorder (?r \<union>o ?r')
\<lbrakk>Field ?r \<inter> Field ?r' = {}; antisym ?r; antisym ?r'\<rbrakk> \<Longrightarrow> antisym (?r \<union>o ?r')

goal (1 subgoal):
 1. \<lbrakk>Field r \<inter> Field r' = {}; Preorder r \<and> antisym r; Preorder r' \<and> antisym r'\<rbrakk> \<Longrightarrow> Preorder (r \<union>o r') \<and> antisym (r \<union>o r')
[PROOF STEP]
by blast