module Quadrilateral
import Base
public import Parallel
import Linear
import Ring
fun quadrilateral(A : Point, B : Point, C : Point, D : Point) {
same_side(C, D, line(A, B)) and same_side(D, A, line(B, C))
and same_side(A, B, line(C, D)) and same_side(B, C, line(D, A))
}
fun parallelogram(A : Point, B : Point, C : Point, D : Point) {
quadrilateral(A, B, C, D)
and parallel(line(A, B), line(C, D)) and parallel(line(B, C), line(D, A))
}
fun rectangle(A : Point, B : Point, C : Point, D : Point) {
quadrilateral(A, B, C, D)
and right_angle(D, A, B) and right_angle(A, B, C)
and right_angle(B, C, D) and right_angle(C, D, A)
}
fun rhombus(A : Point, B : Point, C : Point, D : Point) {
quadrilateral(A, B, C, D)
and seg_congruent(A, B, B, C) and seg_congruent(B, C, C, D)
and seg_congruent(C, D, D, A)
}
fun square(A : Point, B : Point, C : Point, D : Point) {
rectangle(A, B, C, D) and rhombus(A, B, C, D)
}
lemma cross_rotate: all A:Point, B:Point, C:Point. cross(B, C, A) = cross(A, B, C)
proof
arbitrary A:Point, B:Point, C:Point
expand cross
algebra
end
lemma sign_pos: all x:Real, y:Real, z:Real.
if real(+0) < x * y and real(+0) < x * z then real(+0) < y * z
proof
arbitrary x:Real, y:Real, z:Real
assume h
have nx: not (x = real(+0)) by { assume e replace e in conjunct 0 of h }
have xx: real(+0) < x * x by {
replace real_less_def
have nz: not (real(+0) = x * x) by {
assume e
apply nx to replace apply real_mult_zero_iff[x, x] to nx in symmetric e
}
(real_square_nonneg[x], nz)
}
have p: real(+0) < (x * y) * (x * z) by apply real_mult_pos to h
have e: (x * y) * (x * z) = (y * z) * (x * x) by algebra
have c: (real(+0) * (x * x) < (y * z) * (x * x)) = (real(+0) < y * z)
by apply real_pos_mult_less_iff[x * x, real(+0), y * z] to xx
replace symmetric c
replace e in p
end
lemma quad_sides_distinct: all A:Point, B:Point, C:Point, D:Point.
if quadrilateral(A, B, C, D)
then not (A = B) and not (B = C) and not (C = D) and not (D = A)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
expand quadrilateral
assume h
have ab: not (A = B) by {
assume e
have s: same_side(D, A, line(A, C)) by replace symmetric e in conjunct 1 of h
apply (conjunct 1 of apply line_same_side_off to s) to line_on_left[A, C]
}
have bc: not (B = C) by {
assume e
have s: same_side(A, B, line(B, D)) by replace symmetric e in conjunct 2 of h
apply (conjunct 1 of apply line_same_side_off to s) to line_on_left[B, D]
}
have cd: not (C = D) by {
assume e
have s: same_side(B, C, line(C, A)) by replace symmetric e in conjunct 3 of h
apply (conjunct 1 of apply line_same_side_off to s) to line_on_left[C, A]
}
have da: not (D = A) by {
assume e
have s: same_side(C, D, line(D, B)) by replace symmetric e in conjunct 0 of h
apply (conjunct 1 of apply line_same_side_off to s) to line_on_left[D, B]
}
(ab, bc, cd, da)
end
lemma quad_cross: all A:Point, B:Point, C:Point, D:Point.
if quadrilateral(A, B, C, D)
then real(+0) < cross(A, B, C) * cross(B, C, D)
and real(+0) < cross(A, B, C) * cross(C, D, A)
and real(+0) < cross(A, B, C) * cross(D, A, B)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume q
have ds: not (A = B) and not (B = C) and not (C = D) and not (D = A)
by apply quad_sides_distinct to q
have h: same_side(C, D, line(A, B)) and same_side(D, A, line(B, C))
and same_side(A, B, line(C, D)) and same_side(B, C, line(D, A))
by expand quadrilateral in q
have s14: real(+0) < cross(A, B, C) * cross(D, A, B) by {
replace symmetric cross_rotate[D, A, B]
replace apply line_same_side_cross[A, B, C, D] to conjunct 0 of ds in conjunct 0 of h
}
have s21: real(+0) < cross(B, C, D) * cross(A, B, C) by {
replace symmetric cross_rotate[A, B, C]
replace apply line_same_side_cross[B, C, D, A] to conjunct 1 of ds in conjunct 1 of h
}
have s32: real(+0) < cross(C, D, A) * cross(B, C, D) by {
replace symmetric cross_rotate[B, C, D]
replace apply line_same_side_cross[C, D, A, B] to conjunct 2 of ds in conjunct 2 of h
}
have s43: real(+0) < cross(D, A, B) * cross(C, D, A) by {
replace symmetric cross_rotate[C, D, A]
replace apply line_same_side_cross[D, A, B, C] to conjunct 3 of ds in conjunct 3 of h
}
have s12: real(+0) < cross(A, B, C) * cross(B, C, D) by algebra with s21
have s13: real(+0) < cross(A, B, C) * cross(C, D, A) by {
have s41: real(+0) < cross(D, A, B) * cross(A, B, C) by algebra with s14
apply sign_pos[cross(D, A, B), cross(A, B, C), cross(C, D, A)] to s41, s43
}
(s12, s13, s14)
end
theorem quad_rotate: all A:Point, B:Point, C:Point, D:Point.
quadrilateral(A, B, C, D) = quadrilateral(B, C, D, A)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
expand quadrilateral
have fwd: if same_side(C, D, line(A, B)) and same_side(D, A, line(B, C))
and same_side(A, B, line(C, D)) and same_side(B, C, line(D, A))
then same_side(D, A, line(B, C)) and same_side(A, B, line(C, D))
and same_side(B, C, line(D, A)) and same_side(C, D, line(A, B)) by {
assume h
((conjunct 1 of h), (conjunct 2 of h), (conjunct 3 of h), (conjunct 0 of h))
}
have bwd: if same_side(D, A, line(B, C)) and same_side(A, B, line(C, D))
and same_side(B, C, line(D, A)) and same_side(C, D, line(A, B))
then same_side(C, D, line(A, B)) and same_side(D, A, line(B, C))
and same_side(A, B, line(C, D)) and same_side(B, C, line(D, A)) by {
assume h
((conjunct 3 of h), (conjunct 0 of h), (conjunct 1 of h), (conjunct 2 of h))
}
apply iff_equal to fwd, bwd
end
theorem quad_triangles: all A:Point, B:Point, C:Point, D:Point.
if quadrilateral(A, B, C, D)
then triangle(A, B, C) and triangle(B, C, D) and triangle(C, D, A) and triangle(D, A, B)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume q
have s: real(+0) < cross(A, B, C) * cross(B, C, D)
and real(+0) < cross(A, B, C) * cross(C, D, A)
and real(+0) < cross(A, B, C) * cross(D, A, B) by apply quad_cross to q
expand triangle | collinear
have t1: not (cross(A, B, C) = real(+0)) by { assume z replace z in conjunct 0 of s }
have t2: not (cross(B, C, D) = real(+0)) by { assume z replace z in conjunct 0 of s }
have t3: not (cross(C, D, A) = real(+0)) by { assume z replace z in conjunct 1 of s }
have t4: not (cross(D, A, B) = real(+0)) by { assume z replace z in conjunct 2 of s }
(t1, t2, t3, t4)
end
theorem quad_distinct: all A:Point, B:Point, C:Point, D:Point.
if quadrilateral(A, B, C, D)
then not (A = B) and not (B = C) and not (C = D) and not (D = A)
and not (A = C) and not (B = D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume q
have ds: not (A = B) and not (B = C) and not (C = D) and not (D = A)
by apply quad_sides_distinct to q
have t: triangle(A, B, C) and triangle(B, C, D) and triangle(C, D, A) and triangle(D, A, B)
by apply quad_triangles to q
have ac: not (A = C) by conjunct 2 of apply triangle_distinct to conjunct 0 of t
have bd: not (B = D) by conjunct 2 of apply triangle_distinct to conjunct 1 of t
((conjunct 0 of ds), (conjunct 1 of ds), (conjunct 2 of ds), (conjunct 3 of ds), ac, bd)
end
theorem quad_diagonals: all A:Point, B:Point, C:Point, D:Point.
if quadrilateral(A, B, C, D)
then opposite_sides(B, D, line(A, C)) and opposite_sides(A, C, line(B, D))
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume q
have s: real(+0) < cross(A, B, C) * cross(B, C, D)
and real(+0) < cross(A, B, C) * cross(C, D, A)
and real(+0) < cross(A, B, C) * cross(D, A, B) by apply quad_cross to q
have ds: not (A = B) and not (B = C) and not (C = D) and not (D = A)
and not (A = C) and not (B = D) by apply quad_distinct to q
have o1: opposite_sides(B, D, line(A, C)) by {
have e1: cross(A, C, B) = - cross(A, B, C) by { expand cross algebra }
have e2: cross(A, C, D) = cross(C, D, A) by { expand cross algebra }
have i: (- cross(A, B, C)) * cross(C, D, A) = - (cross(A, B, C) * cross(C, D, A)) by algebra
replace apply line_opposite_sides_cross[A, C, B, D] to conjunct 4 of ds | e1 | e2 | i
algebra with conjunct 1 of s
}
have o2: opposite_sides(A, C, line(B, D)) by {
have s24: real(+0) < cross(B, C, D) * cross(D, A, B)
by apply sign_pos[cross(A, B, C), cross(B, C, D), cross(D, A, B)] to (conjunct 0 of s), (conjunct 2 of s)
have e1: cross(B, D, A) = cross(D, A, B) by { expand cross algebra }
have e2: cross(B, D, C) = - cross(B, C, D) by { expand cross algebra }
have i: cross(D, A, B) * (- cross(B, C, D)) = - (cross(B, C, D) * cross(D, A, B)) by algebra
replace apply line_opposite_sides_cross[B, D, A, C] to conjunct 5 of ds | e1 | e2 | i
algebra with s24
}
(o1, o2)
end
theorem quad_ccw: all A:Point, B:Point, C:Point, D:Point.
if real(+0) < cross(A, B, C) and real(+0) < cross(B, C, D)
and real(+0) < cross(C, D, A) and real(+0) < cross(D, A, B)
then quadrilateral(A, B, C, D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have t1: triangle(A, B, C) by { expand triangle | collinear assume z replace z in conjunct 0 of h }
have t3: triangle(C, D, A) by { expand triangle | collinear assume z replace z in conjunct 2 of h }
have d1: not (A = B) and not (B = C) and not (A = C) by apply triangle_distinct to t1
have d3: not (C = D) and not (D = A) and not (C = A) by apply triangle_distinct to t3
expand quadrilateral
replace apply line_same_side_cross[A, B, C, D] to conjunct 0 of d1
| apply line_same_side_cross[B, C, D, A] to conjunct 1 of d1
| apply line_same_side_cross[C, D, A, B] to conjunct 0 of d3
| apply line_same_side_cross[D, A, B, C] to conjunct 1 of d3
have r4: real(+0) < cross(A, B, D) by { replace cross_rotate[D, A, B] conjunct 3 of h }
have r1: real(+0) < cross(B, C, A) by { replace cross_rotate[A, B, C] conjunct 0 of h }
have r2: real(+0) < cross(C, D, B) by { replace cross_rotate[B, C, D] conjunct 1 of h }
have r3: real(+0) < cross(D, A, C) by { replace cross_rotate[C, D, A] conjunct 2 of h }
((apply real_mult_pos to (conjunct 0 of h), r4),
(apply real_mult_pos to (conjunct 1 of h), r1),
(apply real_mult_pos to (conjunct 2 of h), r2),
(apply real_mult_pos to (conjunct 3 of h), r3))
end
lemma parallelogram_vec: all A:Point, B:Point, C:Point, D:Point.
if parallelogram(A, B, C, D)
then xcoord(C) = xcoord(B) + xcoord(D) - xcoord(A)
and ycoord(C) = ycoord(B) + ycoord(D) - ycoord(A)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
expand parallelogram
assume h
have ds: not (A = B) and not (B = C) and not (C = D) and not (D = A)
and not (A = C) and not (B = D) by apply quad_distinct to conjunct 0 of h
have s1: seg_cross(A, B, C, D) = real(+0)
by replace apply line_parallel_seg_cross[A, B, C, D] to (conjunct 0 of ds), (conjunct 2 of ds)
in conjunct 1 of h
have s2: seg_cross(B, C, D, A) = real(+0)
by replace apply line_parallel_seg_cross[B, C, D, A] to (conjunct 1 of ds), (conjunct 3 of ds)
in conjunct 2 of h
have k: not (cross(A, B, D) = real(+0)) by {
have t: triangle(D, A, B) by conjunct 3 of apply quad_triangles to conjunct 0 of h
have e: cross(D, A, B) = cross(A, B, D) by symmetric cross_rotate[D, A, B]
replace symmetric e
expand triangle | collinear in t
}
have ix: cross(A, B, D) * (xcoord(C) - (xcoord(B) + xcoord(D) - xcoord(A)))
= seg_cross(A, B, C, D) * (xcoord(A) - xcoord(D))
+ seg_cross(B, C, D, A) * (xcoord(A) - xcoord(B))
by { expand cross | seg_cross algebra }
have iy: cross(A, B, D) * (ycoord(C) - (ycoord(B) + ycoord(D) - ycoord(A)))
= seg_cross(A, B, C, D) * (ycoord(A) - ycoord(D))
+ seg_cross(B, C, D, A) * (ycoord(A) - ycoord(B))
by { expand cross | seg_cross algebra }
have zx: cross(A, B, D) * (xcoord(C) - (xcoord(B) + xcoord(D) - xcoord(A))) = real(+0)
by { replace ix | s1 | s2. }
have zy: cross(A, B, D) * (ycoord(C) - (ycoord(B) + ycoord(D) - ycoord(A))) = real(+0)
by { replace iy | s1 | s2. }
have ex: xcoord(C) - (xcoord(B) + xcoord(D) - xcoord(A)) = real(+0)
by replace apply real_mult_zero_iff[cross(A, B, D),
xcoord(C) - (xcoord(B) + xcoord(D) - xcoord(A))] to k in zx
have ey: ycoord(C) - (ycoord(B) + ycoord(D) - ycoord(A)) = real(+0)
by replace apply real_mult_zero_iff[cross(A, B, D),
ycoord(C) - (ycoord(B) + ycoord(D) - ycoord(A))] to k in zy
((replace real_sub_eq_zero_iff in ex), (replace real_sub_eq_zero_iff in ey))
end
lemma parallelogram_of_vec: all A:Point, B:Point, C:Point, D:Point.
if quadrilateral(A, B, C, D)
and xcoord(C) = xcoord(B) + xcoord(D) - xcoord(A)
and ycoord(C) = ycoord(B) + ycoord(D) - ycoord(A)
then parallelogram(A, B, C, D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have cx: xcoord(C) = xcoord(B) + xcoord(D) - xcoord(A) by conjunct 1 of h
have cy: ycoord(C) = ycoord(B) + ycoord(D) - ycoord(A) by conjunct 2 of h
have ds: not (A = B) and not (B = C) and not (C = D) and not (D = A)
and not (A = C) and not (B = D) by apply quad_distinct to conjunct 0 of h
have p1: parallel(line(A, B), line(C, D)) by {
replace apply line_parallel_seg_cross[A, B, C, D] to (conjunct 0 of ds), (conjunct 2 of ds)
expand seg_cross
replace cx | cy
algebra
}
have p2: parallel(line(B, C), line(D, A)) by {
replace apply line_parallel_seg_cross[B, C, D, A] to (conjunct 1 of ds), (conjunct 3 of ds)
expand seg_cross
replace cx | cy
algebra
}
expand parallelogram
((conjunct 0 of h), p1, p2)
end
theorem parallelogram_rotate: all A:Point, B:Point, C:Point, D:Point.
if parallelogram(A, B, C, D) then parallelogram(B, C, D, A)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
expand parallelogram
assume h
have q: quadrilateral(B, C, D, A) by replace quad_rotate[A, B, C, D] in conjunct 0 of h
have p: parallel(line(C, D), line(A, B))
by apply line_parallel_symmetric to conjunct 1 of h
(q, (conjunct 2 of h), p)
end
theorem parallelogram_opposite_sides: all A:Point, B:Point, C:Point, D:Point.
if parallelogram(A, B, C, D) then seg_congruent(A, B, C, D) and seg_congruent(B, C, D, A)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have v: xcoord(C) = xcoord(B) + xcoord(D) - xcoord(A)
and ycoord(C) = ycoord(B) + ycoord(D) - ycoord(A) by apply parallelogram_vec to h
expand seg_congruent
have ab: dist2(A, B) = dist2(C, D) by {
expand dist2
replace conjunct 0 of v | conjunct 1 of v
algebra
}
have bc: dist2(B, C) = dist2(D, A) by {
expand dist2
replace conjunct 0 of v | conjunct 1 of v
algebra
}
(ab, bc)
end
theorem parallelogram_opposite_angles: all A:Point, B:Point, C:Point, D:Point.
if parallelogram(A, B, C, D)
then angle_congruent(D, A, B, B, C, D) and angle_congruent(A, B, C, C, D, A)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have v: xcoord(C) = xcoord(B) + xcoord(D) - xcoord(A)
and ycoord(C) = ycoord(B) + ycoord(D) - ycoord(A) by apply parallelogram_vec to h
expand angle_congruent
have a: m_angle(D, A, B) = m_angle(B, C, D) by {
have d: dot(A, D, B) = dot(C, B, D) by {
expand dot
replace conjunct 0 of v | conjunct 1 of v
algebra
}
have c: cross(A, D, B) = cross(C, B, D) by {
expand cross
replace conjunct 0 of v | conjunct 1 of v
algebra
}
apply angle_measure_dot_cross[D, A, B, B, C, D] to d, (replace c.)
}
have b: m_angle(A, B, C) = m_angle(C, D, A) by {
have d: dot(B, A, C) = dot(D, C, A) by {
expand dot
replace conjunct 0 of v | conjunct 1 of v
algebra
}
have c: cross(B, A, C) = cross(D, C, A) by {
expand cross
replace conjunct 0 of v | conjunct 1 of v
algebra
}
apply angle_measure_dot_cross[A, B, C, C, D, A] to d, (replace c.)
}
(a, b)
end
theorem parallelogram_consecutive_angles: all A:Point, B:Point, C:Point, D:Point.
if parallelogram(A, B, C, D) then supplementary(m_angle(D, A, B), m_angle(A, B, C))
proof
arbitrary A:Point, B:Point, C:Point, D:Point
expand parallelogram
assume h
have ab: not (A = B) by conjunct 0 of apply quad_distinct to conjunct 0 of h
have s: same_side(D, C, line(A, B)) by {
replace line_same_side_symmetric[D, C, line(A, B)]
conjunct 0 of expand quadrilateral in conjunct 0 of h
}
have p: parallel(line(A, D), line(B, C)) by {
replace line_symmetric[A, D]
apply line_parallel_symmetric to conjunct 2 of h
}
replace symmetric apply line_parallel_same_side[A, D, B, C] to ab, s
p
end
theorem parallelogram_diagonals: all A:Point, B:Point, C:Point, D:Point.
if parallelogram(A, B, C, D) then midpoint(A, C) = midpoint(B, D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have v: xcoord(C) = xcoord(B) + xcoord(D) - xcoord(A)
and ycoord(C) = ycoord(B) + ycoord(D) - ycoord(A) by apply parallelogram_vec to h
have ex: xcoord(midpoint(A, C)) = xcoord(midpoint(B, D)) by {
expand midpoint
replace conjunct 0 of v
algebra
}
have ey: ycoord(midpoint(A, C)) = ycoord(midpoint(B, D)) by {
expand midpoint
replace conjunct 1 of v
algebra
}
apply point_equal to ex, ey
end
lemma parallel_of_congruent: all A:Point, B:Point, C:Point, D:Point.
if not (A = C) and opposite_sides(B, D, line(A, C)) and tri_congruent(A, B, C, C, D, A)
then parallel(line(B, C), line(D, A))
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have ca: not (C = A) by { assume e apply (conjunct 0 of h) to symmetric e }
have opp: opposite_sides(B, D, line(C, A)) by replace line_symmetric[A, C] in conjunct 1 of h
replace line_symmetric[B, C] | line_symmetric[D, A]
replace apply line_parallel_alt_interior[C, B, A, D] to ca, opp
conjunct 5 of apply tri_cpctc to conjunct 2 of h
end
theorem parallelogram_of_opposite_sides: all A:Point, B:Point, C:Point, D:Point.
if quadrilateral(A, B, C, D) and seg_congruent(A, B, C, D) and seg_congruent(B, C, D, A)
then parallelogram(A, B, C, D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have ac: not (A = C) by conjunct 4 of apply quad_distinct to conjunct 0 of h
have opp: opposite_sides(B, D, line(A, C)) by conjunct 0 of apply quad_diagonals to conjunct 0 of h
have cong: tri_congruent(A, B, C, C, D, A)
by apply tri_sss[A, B, C, C, D, A]
to (conjunct 1 of h), (conjunct 2 of h), point_seg_congruent_reverse[C, A]
have p1: parallel(line(A, B), line(C, D)) by {
replace apply line_parallel_alt_interior[A, B, C, D] to ac, opp
expand angle_congruent
replace angle_measure_symmetric[B, A, C] | angle_measure_symmetric[D, C, A]
expand angle_congruent in conjunct 3 of apply tri_cpctc to cong
}
have p2: parallel(line(B, C), line(D, A)) by apply parallel_of_congruent to ac, opp, cong
expand parallelogram
((conjunct 0 of h), p1, p2)
end
theorem parallelogram_of_one_pair: all A:Point, B:Point, C:Point, D:Point.
if quadrilateral(A, B, C, D) and parallel(line(A, B), line(C, D)) and seg_congruent(A, B, C, D)
then parallelogram(A, B, C, D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have ac: not (A = C) by conjunct 4 of apply quad_distinct to conjunct 0 of h
have opp: opposite_sides(B, D, line(A, C)) by conjunct 0 of apply quad_diagonals to conjunct 0 of h
have alt: angle_congruent(C, A, B, A, C, D) by {
have a: angle_congruent(B, A, C, D, C, A)
by replace apply line_parallel_alt_interior[A, B, C, D] to ac, opp in conjunct 1 of h
expand angle_congruent
replace angle_measure_symmetric[C, A, B] | angle_measure_symmetric[A, C, D]
expand angle_congruent in a
}
have cong: tri_congruent(A, B, C, C, D, A)
by apply tri_sas[A, B, C, C, D, A]
to (conjunct 0 of apply quad_triangles to conjunct 0 of h), (conjunct 2 of h), alt,
point_seg_congruent_reverse[A, C]
have p2: parallel(line(B, C), line(D, A)) by apply parallel_of_congruent to ac, opp, cong
expand parallelogram
((conjunct 0 of h), (conjunct 1 of h), p2)
end
theorem parallelogram_of_diagonals: all A:Point, B:Point, C:Point, D:Point.
if quadrilateral(A, B, C, D) and midpoint(A, C) = midpoint(B, D)
then parallelogram(A, B, C, D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have mx: xcoord(midpoint(A, C)) = xcoord(midpoint(B, D)) by { replace conjunct 1 of h. }
have my: ycoord(midpoint(A, C)) = ycoord(midpoint(B, D)) by { replace conjunct 1 of h. }
have cx: xcoord(C) = xcoord(B) + xcoord(D) - xcoord(A) by {
have e: real(frac(+1, 2)) * (xcoord(A) + xcoord(C)) = real(frac(+1, 2)) * (xcoord(B) + xcoord(D))
by expand midpoint in mx
algebra with e
}
have cy: ycoord(C) = ycoord(B) + ycoord(D) - ycoord(A) by {
have e: real(frac(+1, 2)) * (ycoord(A) + ycoord(C)) = real(frac(+1, 2)) * (ycoord(B) + ycoord(D))
by expand midpoint in my
algebra with e
}
apply parallelogram_of_vec to (conjunct 0 of h), cx, cy
end
theorem rectangle_parallelogram: all A:Point, B:Point, C:Point, D:Point.
if rectangle(A, B, C, D) then parallelogram(A, B, C, D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
expand rectangle
assume h
have ds: not (A = B) and not (B = C) and not (C = D) and not (D = A)
and not (A = C) and not (B = D) by apply quad_distinct to conjunct 0 of h
have ab: not (A = B) by conjunct 0 of ds
have bc: not (B = C) by conjunct 1 of ds
have da: not (D = A) by conjunct 3 of ds
have ba: not (B = A) by { assume e apply ab to symmetric e }
have cb: not (C = B) by { assume e apply bc to symmetric e }
have dc: not (D = C) by { assume e apply (conjunct 2 of ds) to symmetric e }
have pa: perpendicular(line(D, A), line(A, B)) by {
replace symmetric line_symmetric[A, D]
replace symmetric apply angle_right_perpendicular[D, A, B] to da, ba
conjunct 1 of h
}
have pb: perpendicular(line(A, B), line(B, C)) by {
replace line_symmetric[A, B]
replace symmetric apply angle_right_perpendicular[A, B, C] to ab, cb
conjunct 2 of h
}
have pc: perpendicular(line(B, C), line(C, D)) by {
replace line_symmetric[B, C]
replace symmetric apply angle_right_perpendicular[B, C, D] to bc, dc
conjunct 3 of h
}
have p1: parallel(line(A, B), line(C, D))
by apply line_perpendicular_parallel[line(A, B), line(C, D), line(B, C)]
to pb, (apply line_perpendicular_symmetric to pc)
have p2: parallel(line(B, C), line(D, A))
by apply line_perpendicular_parallel[line(B, C), line(D, A), line(A, B)]
to (apply line_perpendicular_symmetric to pb), pa
expand parallelogram
((conjunct 0 of h), p1, p2)
end
theorem rectangle_diagonals: all A:Point, B:Point, C:Point, D:Point.
if rectangle(A, B, C, D) then seg_congruent(A, C, B, D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have v: xcoord(C) = xcoord(B) + xcoord(D) - xcoord(A)
and ycoord(C) = ycoord(B) + ycoord(D) - ycoord(A)
by apply parallelogram_vec to apply rectangle_parallelogram to h
have ds: not (A = B) and not (B = C) and not (C = D) and not (D = A)
and not (A = C) and not (B = D)
by apply quad_distinct to conjunct 0 of expand rectangle in h
have ba: not (B = A) by { assume e apply (conjunct 0 of ds) to symmetric e }
have r: dot(A, D, B) = real(+0)
by replace apply angle_right_dot[D, A, B] to (conjunct 3 of ds), ba
in conjunct 1 of expand rectangle in h
have e: dist2(A, C) = dist2(B, D) + real(+4) * dot(A, D, B) by {
expand dist2 | dot
replace conjunct 0 of v | conjunct 1 of v
algebra
}
expand seg_congruent
replace e | r.
end
theorem rhombus_parallelogram: all A:Point, B:Point, C:Point, D:Point.
if rhombus(A, B, C, D) then parallelogram(A, B, C, D)
proof
arbitrary A:Point, B:Point, C:Point, D:Point
expand rhombus
assume h
apply parallelogram_of_opposite_sides
to (conjunct 0 of h),
(apply point_seg_congruent_trans[A, B, B, C, C, D] to (conjunct 1 of h), (conjunct 2 of h)),
(apply point_seg_congruent_trans[B, C, C, D, D, A] to (conjunct 2 of h), (conjunct 3 of h))
end
theorem rhombus_diagonals: all A:Point, B:Point, C:Point, D:Point.
if rhombus(A, B, C, D) then perpendicular(line(A, C), line(B, D))
proof
arbitrary A:Point, B:Point, C:Point, D:Point
assume h
have v: xcoord(C) = xcoord(B) + xcoord(D) - xcoord(A)
and ycoord(C) = ycoord(B) + ycoord(D) - ycoord(A)
by apply parallelogram_vec to apply rhombus_parallelogram to h
have hr: quadrilateral(A, B, C, D) and seg_congruent(A, B, B, C) and seg_congruent(B, C, C, D)
and seg_congruent(C, D, D, A) by expand rhombus in h
have ds: not (A = B) and not (B = C) and not (C = D) and not (D = A)
and not (A = C) and not (B = D) by apply quad_distinct to conjunct 0 of hr
have ad: dist2(A, B) = dist2(D, A) by {
have s: seg_congruent(A, B, D, A)
by apply point_seg_congruent_trans[A, B, C, D, D, A]
to (apply point_seg_congruent_trans[A, B, B, C, C, D] to (conjunct 1 of hr), (conjunct 2 of hr)),
(conjunct 3 of hr)
expand seg_congruent in s
}
have e: seg_dot(A, C, B, D) = dist2(D, A) - dist2(A, B) by {
expand seg_dot | dist2
replace conjunct 0 of v | conjunct 1 of v
algebra
}
replace apply line_perpendicular_seg_dot[A, C, B, D] to (conjunct 4 of ds), (conjunct 5 of ds)
| e | ad.
end
theorem square_diagonals: all A:Point, B:Point, C:Point, D:Point.
if square(A, B, C, D)
then seg_congruent(A, C, B, D) and perpendicular(line(A, C), line(B, D))
proof
arbitrary A:Point, B:Point, C:Point, D:Point
expand square
assume h
((apply rectangle_diagonals to conjunct 0 of h), (apply rhombus_diagonals to conjunct 1 of h))
end