module Arc
import Base
public import InscribedAngle
import Triangle
import Linear
import Ring
fun arc_measure(A : Point, B : Point, P : Point, c : Circle) {
if opposite_sides(P, center(c), line(A, B)) then deg(+360) - m_angle(A, center(c), B)
else m_angle(A, center(c), B)
}
theorem inscribed_angle_theorem_arc: all c:Circle, A:Point, B:Point, P:Point.
if chord(A, B, c) and on_circle(P, c) and not (P = A) and not (P = B)
then m_angle(A, P, B) = frac(+1, 2) * arc_measure(A, B, P, c)
proof
arbitrary c:Circle, A:Point, B:Point, P:Point
assume h
have ch: not (A = B) and on_circle(A, c) and on_circle(B, c) by expand chord in conjunct 0 of h
expand arc_measure
switch opposite_sides(P, center(c), line(A, B)) {
case true assume op {
have m: m_angle(A, P, B) = deg(+180) - frac(+1, 2) * m_angle(A, center(c), B)
by apply inscribed_angle_theorem_opposite[c, A, B, P] to conjunct 0 of h, conjunct 1 of h, op
algebra with m
}
case false assume nop {
have side: same_side(P, center(c), line(A, B)) or on_line(center(c), line(A, B)) by {
switch on_line(center(c), line(A, B)) {
case true assume on { . }
case false assume off {
have pa: not (A = P) by { assume e apply (conjunct 2 of h) to symmetric e }
have pb: not (B = P) by { assume e apply (conjunct 3 of h) to symmetric e }
have np: not on_line(P, line(A, B)) by {
replace apply line_on_collinear[A, B, P] to conjunct 0 of ch
apply circle_not_collinear[A, B, P, c]
to conjunct 1 of ch, conjunct 2 of ch, conjunct 1 of h, conjunct 0 of ch, pb, pa
}
have sep: (same_side(P, center(c), line(A, B)) or opposite_sides(P, center(c), line(A, B)))
and not (same_side(P, center(c), line(A, B))
and opposite_sides(P, center(c), line(A, B)))
by apply plane_separation_postulate[P, center(c), line(A, B)] to np, off
cases conjunct 0 of sep
case ss { ss }
case os { conclude false by apply nop to os }
}
}
}
apply inscribed_angle_theorem[c, A, B, P] to conjunct 0 of h, conjunct 1 of h,
conjunct 2 of h, conjunct 3 of h, side
}
}
end
lemma tangent_chord_scalar: all U:Real, W:Real, d:Real, c:Real, a:Real, x:Real, w:Real,
z:Real, R:Real, p:Real, q:Real.
if a = real(+0) and U * w = d * a + c * x and U * z = d * x - c * a
and U * W = d * d + c * c and U * R = a * a + x * x
and W = real(+2) * w and p = R - w and q = z
and real(+0) < U and real(+0) < W
then real(+0) < x * c and real(+0) < real(+2) * (U * (c * c))
and (x * c) * (d * d - c * c) = (real(+2) * (U * (c * c))) * p
and (x * c) * (real(+2) * (d * c)) = (real(+2) * (U * (c * c))) * q
and d * (x * c) = U * (q * c)
proof
arbitrary U:Real, W:Real, d:Real, c:Real, a:Real, x:Real, w:Real, z:Real, R:Real,
p:Real, q:Real
assume h
have da: d * a = real(+0) by { replace conjunct 0 of h. }
have ca: c * a = real(+0) by { replace conjunct 0 of h. }
have aa: a * a = real(+0) by { replace conjunct 0 of h. }
have z3: U * w - c * x = real(+0) by algebra with conjunct 1 of h | da
have z4: d * x - U * z = real(+0) by algebra with conjunct 2 of h | ca
have z2: U * R - x * x = real(+0) by algebra with conjunct 4 of h | aa
have uw: U * W = real(+2) * (U * w) by { replace conjunct 5 of h algebra }
have z1: d * d + c * c - real(+2) * (c * x) = real(+0) by algebra with conjunct 3 of h | uw | z3
have s: real(+0) < x * c by {
have uwp: real(+0) < U * W by apply real_mult_pos to conjunct 8 of h, conjunct 9 of h
algebra with uwp | uw | z3
}
have cc: real(+0) < c * c by {
replace real_less_def
have nz: not (real(+0) = c * c) by {
assume e
have c0: c = real(+0) by {
cases apply real_mult_to_zero[c, c] to symmetric e
case cz { cz }
case cz { cz }
}
have xc: x * c = real(+0) by { replace c0. }
conclude false by algebra with s | xc
}
(real_square_nonneg[c], nz)
}
have t: real(+0) < real(+2) * (U * (c * c)) by {
have ucp: real(+0) < U * (c * c) by apply real_mult_pos to conjunct 8 of h, cc
algebra with ucp
}
have g3: (x * c) * (d * d - c * c) = (real(+2) * (U * (c * c))) * p by {
have i: (x * c) * (d * d - c * c) - (real(+2) * (U * (c * c))) * (R - w)
= (x * c) * (d * d + c * c - real(+2) * (c * x))
- real(+2) * (c * c) * ((U * R - x * x) - (U * w - c * x)) by algebra
have e: (x * c) * (d * d - c * c) - (real(+2) * (U * (c * c))) * (R - w) = real(+0)
by { replace i | z1 | z2 | z3. }
replace conjunct 6 of h
algebra with e
}
have g4: (x * c) * (real(+2) * (d * c)) = (real(+2) * (U * (c * c))) * q by {
have i: (x * c) * (real(+2) * (d * c)) - (real(+2) * (U * (c * c))) * z
= real(+2) * (c * c) * (d * x - U * z) by algebra
have e: (x * c) * (real(+2) * (d * c)) - (real(+2) * (U * (c * c))) * z = real(+0)
by { replace i | z4. }
replace conjunct 7 of h
algebra with e
}
have g5: d * (x * c) = U * (q * c) by {
have i: d * (x * c) - U * (z * c) = c * (d * x - U * z) by algebra
have e: d * (x * c) - U * (z * c) = real(+0) by { replace i | z4. }
replace conjunct 7 of h
algebra with e
}
(s, t, g3, g4, g5)
end
lemma sign_of: all d:Real, s:Real, U:Real, k:Real.
if real(+0) < s and real(+0) < U and d * s = U * k
then (if real(+0) ≤ k then real(+0) ≤ d) and (if k ≤ real(+0) then d ≤ real(+0))
proof
arbitrary d:Real, s:Real, U:Real, k:Real
assume h
have i: s * (- d) = - (d * s) by algebra
have j: U * (- k) = - (U * k) by algebra
have kpos: if real(+0) ≤ k then real(+0) ≤ d by {
assume kp
cases real_dichotomy[real(+0), d]
case nn { nn }
case neg {
have a: real(+0) < s * (- d)
by apply real_mult_pos to conjunct 0 of h, (conclude real(+0) < - d by algebra with neg)
have b: real(+0) ≤ U * k
by apply real_mult_nonneg to (apply real_less_implies_less_equal to conjunct 1 of h), kp
conclude false by algebra with a | b | i | conjunct 2 of h
}
}
have npos: if k ≤ real(+0) then d ≤ real(+0) by {
assume kn
cases real_dichotomy[d, real(+0)]
case le { le }
case gt {
have a: real(+0) < s * d by apply real_mult_pos to conjunct 0 of h, gt
have b: real(+0) ≤ U * (- k)
by apply real_mult_nonneg to (apply real_less_implies_less_equal to conjunct 1 of h),
(conclude real(+0) ≤ - k by algebra with kn)
have sd: s * d = d * s by algebra
conclude false by algebra with a | b | j | sd | conjunct 2 of h
}
}
(kpos, npos)
end
lemma tangent_chord: all L:Line, c:Circle, A:Point, B:Point, T:Point.
if tangent_at(L, c, A) and on_circle(B, c) and not (B = A) and on_line(T, L) and not (T = A)
then (if real(+0) ≤ cross(A, B, center(c)) * cross(A, T, B)
then m_angle(T, A, B) + m_angle(T, A, B) = m_angle(A, center(c), B))
and (if cross(A, B, center(c)) * cross(A, T, B) ≤ real(+0)
then m_angle(T, A, B) + m_angle(T, A, B) + m_angle(A, center(c), B) = deg(+360))
proof
arbitrary L:Line, c:Circle, A:Point, B:Point, T:Point
assume h
have ac: on_circle(A, c) by conjunct 1 of expand tangent_at in conjunct 0 of h
have a0: dot(A, T, center(c)) = real(+0) by {
have td: dot(A, center(c), T) = real(+0)
by apply circle_tangent_dot[L, c, A, T] to conjunct 0 of h, conjunct 3 of h
have sw: dot(A, T, center(c)) = dot(A, center(c), T) by { expand dot algebra }
replace sw
td
}
have w2: dist2(A, B) = real(+2) * dot(A, B, center(c))
by algebra with point_dist2_dot[A, B, center(c)] | apply circle_dist2_radius to conjunct 1 of h
| apply circle_dist2_radius to ac | point_dist2_symmetric[B, center(c)]
| point_dist2_symmetric[A, center(c)]
have hp: dot(center(c), A, B) = dist2(A, center(c)) - dot(A, B, center(c))
by { expand dot | dist2 algebra }
have hq: cross(center(c), A, B) = cross(A, B, center(c)) by { expand cross algebra }
have bb: dot(A, B, B) = dist2(A, B) by { expand dot | dist2 algebra }
have oo: dot(A, center(c), center(c)) = dist2(A, center(c)) by { expand dot | dist2 algebra }
have tp: real(+0) < dist2(A, T)
by apply point_dist2_pos to (conclude not (A = T) by { assume e apply (conjunct 4 of h) to symmetric e })
have bp: real(+0) < dist2(A, B)
by apply point_dist2_pos to (conclude not (A = B) by { assume e apply (conjunct 2 of h) to symmetric e })
have sc: real(+0) < cross(A, T, center(c)) * cross(A, T, B)
and real(+0) < real(+2) * (dist2(A, T) * (cross(A, T, B) * cross(A, T, B)))
and (cross(A, T, center(c)) * cross(A, T, B))
* (dot(A, T, B) * dot(A, T, B) - cross(A, T, B) * cross(A, T, B))
= (real(+2) * (dist2(A, T) * (cross(A, T, B) * cross(A, T, B)))) * dot(center(c), A, B)
and (cross(A, T, center(c)) * cross(A, T, B)) * (real(+2) * (dot(A, T, B) * cross(A, T, B)))
= (real(+2) * (dist2(A, T) * (cross(A, T, B) * cross(A, T, B)))) * cross(center(c), A, B)
and dot(A, T, B) * (cross(A, T, center(c)) * cross(A, T, B))
= dist2(A, T) * (cross(center(c), A, B) * cross(A, T, B))
by apply tangent_chord_scalar[dist2(A, T), dist2(A, B), dot(A, T, B), cross(A, T, B),
dot(A, T, center(c)), cross(A, T, center(c)), dot(A, B, center(c)),
cross(A, B, center(c)), dist2(A, center(c)),
dot(center(c), A, B), cross(center(c), A, B)]
to a0, point_dot_frame[A, T, B, center(c)], point_cross_frame[A, T, B, center(c)],
(replace bb in point_dot_frame[A, T, B, B]),
(replace oo in point_dot_frame[A, T, center(c), center(c)]),
w2, hp, hq, tp, bp
have nc: not collinear(T, A, B) by {
have e: cross(T, A, B) = - cross(A, T, B) by { expand cross algebra }
expand collinear
assume z
have c0: cross(A, T, B) = real(+0) by algebra with e | z
have z2: cross(A, T, center(c)) * cross(A, T, B) = real(+0) by { replace c0. }
conclude false by algebra with z2 | conjunct 0 of sc
}
have dbl: (if real(+0) ≤ dot(A, T, B)
then m_angle(T, A, B) + m_angle(T, A, B) = m_angle(A, center(c), B))
and (if dot(A, T, B) ≤ real(+0)
then m_angle(T, A, B) + m_angle(T, A, B) + m_angle(A, center(c), B) = deg(+360))
by apply angle_measure_double[T, A, B, A, center(c), B,
cross(A, T, center(c)) * cross(A, T, B),
real(+2) * (dist2(A, T) * (cross(A, T, B) * cross(A, T, B)))]
to nc, conjunct 0 of sc, conjunct 1 of sc, conjunct 2 of sc, conjunct 3 of sc
have sg: (if real(+0) ≤ cross(center(c), A, B) * cross(A, T, B) then real(+0) ≤ dot(A, T, B))
and (if cross(center(c), A, B) * cross(A, T, B) ≤ real(+0) then dot(A, T, B) ≤ real(+0))
by apply sign_of to conjunct 0 of sc, tp, conjunct 4 of sc
replace symmetric hq
((assume s apply (conjunct 0 of dbl) to apply (conjunct 0 of sg) to s),
(assume s apply (conjunct 1 of dbl) to apply (conjunct 1 of sg) to s))
end
theorem tangent_chord_angle_theorem: all L:Line, c:Circle, A:Point, B:Point, T:Point.
if tangent_at(L, c, A) and on_circle(B, c) and not (B = A) and on_line(T, L) and not (T = A)
and (opposite_sides(T, center(c), line(A, B)) or on_line(center(c), line(A, B)))
then m_angle(T, A, B) = frac(+1, 2) * m_angle(A, center(c), B)
proof
arbitrary L:Line, c:Circle, A:Point, B:Point, T:Point
assume h
have ab: not (A = B) by { assume e apply (conjunct 2 of h) to symmetric e }
have cyc: cross(A, B, T) = - cross(A, T, B) by { expand cross algebra }
have sign: real(+0) ≤ cross(A, B, center(c)) * cross(A, T, B) by {
cases conjunct 5 of h
case os {
have n: cross(A, B, T) * cross(A, B, center(c)) < real(+0)
by replace apply line_opposite_sides_cross[A, B, T, center(c)] to ab in os
have i: cross(A, B, T) * cross(A, B, center(c)) = - (cross(A, B, center(c)) * cross(A, T, B))
by { replace cyc algebra }
algebra with n | i
}
case on {
have z: cross(A, B, center(c)) = real(+0)
by expand collinear in replace apply line_on_collinear[A, B, center(c)] to ab in on
replace z.
}
}
have d: m_angle(T, A, B) + m_angle(T, A, B) = m_angle(A, center(c), B)
by apply (conjunct 0 of apply tangent_chord[L, c, A, B, T]
to conjunct 0 of h, conjunct 1 of h, conjunct 2 of h, conjunct 3 of h, conjunct 4 of h)
to sign
algebra with d
end
theorem tangent_chord_angle_theorem_same_side: all L:Line, c:Circle, A:Point, B:Point, T:Point.
if tangent_at(L, c, A) and on_circle(B, c) and not (B = A) and on_line(T, L)
and same_side(T, center(c), line(A, B))
then m_angle(T, A, B) = deg(+180) - frac(+1, 2) * m_angle(A, center(c), B)
proof
arbitrary L:Line, c:Circle, A:Point, B:Point, T:Point
assume h
have ab: not (A = B) by { assume e apply (conjunct 2 of h) to symmetric e }
have ta: not (T = A) by {
assume e
apply (conjunct 0 of apply line_same_side_off to conjunct 4 of h)
to (conclude on_line(T, line(A, B)) by { replace e line_on_left[A, B] })
}
have cyc: cross(A, B, T) = - cross(A, T, B) by { expand cross algebra }
have sign: cross(A, B, center(c)) * cross(A, T, B) ≤ real(+0) by {
have sp: real(+0) < cross(A, B, T) * cross(A, B, center(c))
by replace apply line_same_side_cross[A, B, T, center(c)] to ab in conjunct 4 of h
have i: cross(A, B, T) * cross(A, B, center(c)) = - (cross(A, B, center(c)) * cross(A, T, B))
by { replace cyc algebra }
algebra with sp | i
}
have d: m_angle(T, A, B) + m_angle(T, A, B) + m_angle(A, center(c), B) = deg(+360)
by apply (conjunct 1 of apply tangent_chord[L, c, A, B, T]
to conjunct 0 of h, conjunct 1 of h, conjunct 2 of h, conjunct 3 of h, ta)
to sign
algebra with d
end
theorem angles_inside_the_circle_theorem:
all c:Circle, A:Point, B:Point, C:Point, D:Point, E:Point.
if on_circle(A, c) and on_circle(B, c) and on_circle(C, c) and on_circle(D, c)
and between(A, E, B) and between(C, E, D) and not collinear(A, E, C)
then m_angle(A, E, C) = frac(+1, 2) * (arc_measure(A, C, B, c) + arc_measure(B, D, C, c))
proof
arbitrary c:Circle, A:Point, B:Point, C:Point, D:Point, E:Point
assume h
have d1: not (A = E) and not (E = B) and not (A = B) by apply between_distinct to conjunct 4 of h
have d2: not (C = E) and not (E = D) and not (C = D) by apply between_distinct to conjunct 5 of h
have nae: not collinear(A, E, C) by conjunct 6 of h
have eba: collinear(E, B, A) by {
replace symmetric point_collinear_rotate[A, E, B]
apply between_collinear to conjunct 4 of h
}
have on_ae: all X:Point. if collinear(E, B, X) then collinear(A, E, X) by {
arbitrary X:Point
assume ebx
replace point_collinear_rotate[A, E, X] | point_collinear_swap[E, X, A]
apply point_collinear_trans[E, B, A, X] to conjunct 1 of d1, eba, ebx
}
have t: triangle(C, B, E) by {
expand triangle
assume z
apply nae to (apply on_ae[C]
to (replace point_collinear_rotate[C, B, E] | point_collinear_rotate[B, E, C]
| point_collinear_swap[E, C, B] in z))
}
have ac: not (A = C) by {
assume e
apply nae to (conclude collinear(A, E, C) by { replace symmetric e expand collinear | cross. })
}
have bc: not (B = C) by {
assume e
apply nae to (conclude collinear(A, E, C) by { replace symmetric e apply between_collinear to conjunct 4 of h })
}
have bd: not (B = D) by {
assume e
have ceb: collinear(C, E, B) by { replace e apply between_collinear to conjunct 5 of h }
apply nae to apply on_ae[C] to (replace point_collinear_rotate[C, E, B] in ceb)
}
have ca: not (C = A) by { assume e apply ac to symmetric e }
have cb: not (C = B) by { assume e apply bc to symmetric e }
have ba: not (B = A) by { assume e apply (conjunct 2 of d1) to symmetric e }
have bea: between(B, E, A) by { replace symmetric between_symmetric[A, E, B] conjunct 4 of h }
have ext: m_angle(C, E, A) = m_angle(E, C, B) + m_angle(C, B, E)
by apply exterior_angle_theorem[C, B, E, A] to t, bea
have r1: m_angle(E, C, B) = m_angle(D, C, B)
by apply angle_measure_ray[D, C, B, E]
to (conclude not (D = C) by { assume e apply (conjunct 2 of d2) to symmetric e }),
(conclude not (E = C) by { assume e apply (conjunct 0 of d2) to symmetric e }),
(conclude on_ray(E, C, D) by { expand on_ray | on_segment conjunct 5 of h })
have r2: m_angle(E, B, C) = m_angle(A, B, C)
by apply angle_measure_ray[A, B, C, E]
to (conjunct 2 of d1), (conjunct 1 of d1),
(conclude on_ray(E, B, A) by { expand on_ray | on_segment bea })
have ma: m_angle(A, B, C) = frac(+1, 2) * arc_measure(A, C, B, c)
by apply inscribed_angle_theorem_arc[c, A, C, B]
to (conclude chord(A, C, c) by { expand chord (ac, conjunct 0 of h, conjunct 2 of h) }),
conjunct 1 of h, ba, bc
have mc: m_angle(B, C, D) = frac(+1, 2) * arc_measure(B, D, C, c)
by apply inscribed_angle_theorem_arc[c, B, D, C]
to (conclude chord(B, D, c) by { expand chord (bd, conjunct 1 of h, conjunct 3 of h) }),
conjunct 2 of h, cb, conjunct 2 of d2
algebra with ext | r1 | r2 | ma | mc | angle_measure_symmetric[A, E, C]
| angle_measure_symmetric[C, B, E] | angle_measure_symmetric[D, C, B]
end