Demos¶
Nine standalone runnable scripts in demos/ showcase every layer of geometor.pappus—spanning
both the projective Pappus–Steiner–Pascal canon and Books III, IV, V, and VIII of the Synagoge—with
formatted Rich terminal tables and 100% exact SymPy coordinates.
1. demos/pappus_hexagon.py — Synagoge VII.138 & VII.139¶
Constructs both the oblique intersecting-carrier hexagon (Prop. 139) and the parallel-carrier
hexagon (Prop. 138), verifies the universal 8-variable polynomial proof, and computes the exact
signed areas of the three homologous square / circle / diamond triangles.
uv run --no-sync python demos/pappus_hexagon.py
"""Demonstration 1: Pappus's Hexagon Theorem (Synagoge VII.138 & VII.139) and Type Triangles.
Constructs both the general intersecting-carrier case (Prop. 139) and the parallel
carrier case (Prop. 138), verifies the universal symbolic polynomial proof over
eight free indeterminates, and revives the homologous ``square`` / ``circle`` /
``diamond`` triangles from GEOMETOR's ``pappus-3.py`` exploration.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC_DIR = Path(__file__).resolve().parents[1] / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
from rich.console import Console # noqa: E402
from rich.table import Table # noqa: E402
from geometor.pappus import ( # noqa: E402
construct_pappus_hexagon,
line_spread,
quadrance,
verify_pappus_symbolic,
)
def run_demo() -> None:
"""Execute the Pappus Hexagon demonstration and print exact symbolic tables."""
console = Console()
# 1. General projective case (Synagoge Book VII, Prop. 139)
general = construct_pappus_hexagon(
preset="hexagon",
perm=(0, 1, 2),
include_hexagon=True,
include_type_triangles=True,
)
table_gen = Table(title="Synagoge VII.139 — General Intersecting Carriers")
table_gen.add_column("Element", style="cyan bold")
table_gen.add_column("Exact Symbolic Expression", style="green")
table_gen.add_row("Line a", f"{general.line_a.equation()} = 0")
table_gen.add_row("Line b", f"{general.line_b.equation()} = 0")
table_gen.add_row("Carrier Spread s(a, b)", str(line_spread(general.line_a, general.line_b)))
if general.apex is not None:
table_gen.add_row("Carrier Apex O = a ∩ b", f"({general.apex.x}, {general.apex.y})")
for m_id, m_pt in general.meets.items():
if m_pt is not None:
table_gen.add_row(f"Meet {m_id}", f"({m_pt.x}, {m_pt.y})")
table_gen.add_row("Pappus Line", f"{general.pappus_line.equation()} = 0")
table_gen.add_row("Collinear?", str(general.is_collinear))
console.print(table_gen)
# 2. Parallel carrier case (Synagoge Book VII, Prop. 138)
parallel = construct_pappus_hexagon(preset="parallel", perm=(0, 1, 2))
table_par = Table(title="Synagoge VII.138 — Parallel Carriers (s(a, b) = 0)")
table_par.add_column("Element", style="cyan bold")
table_par.add_column("Exact Symbolic Expression", style="green")
table_par.add_row("Carrier Spread s(a, b)", str(line_spread(parallel.line_a, parallel.line_b)))
for m_id, m_pt in parallel.meets.items():
if m_pt is not None:
table_par.add_row(f"Meet {m_id}", f"({m_pt.x}, {m_pt.y})")
m01, m12, m20 = parallel.meets["M01"], parallel.meets["M12"], parallel.meets["M20"]
if m01 is not None and m12 is not None and m20 is not None:
table_par.add_row("Quadrance Q(M01, M20)", str(quadrance(m01, m20)))
table_par.add_row("Quadrance Q(M20, M12)", str(quadrance(m20, m12)))
table_par.add_row("Pappus Line", f"{parallel.pappus_line.equation()} = 0")
table_par.add_row("Collinear?", str(parallel.is_collinear))
console.print(table_par)
# 3. Homologous Type Triangles (reviving pappus-3.py)
tri_table = Table(title="Homologous Type Triangles (Square, Circle, Diamond)")
tri_table.add_column("Type", style="magenta bold")
tri_table.add_column("Vertices", style="white")
tri_table.add_column("Exact Area", style="yellow")
for t_name, poly in general.type_triangles.items():
v_ids = ", ".join(general.model[v].ID for v in poly.vertices)
tri_table.add_row(t_name, f"({v_ids})", str(abs(poly.area)))
console.print(tri_table)
# 4. Universal algebraic proof over Q(a0, a1, a2, b0, b1, b2, m, c)
det_expr = verify_pappus_symbolic()
console.print(
f"[bold green]Universal symbolic collinearity determinant:[/bold green] {det_expr} (identically zero)"
)
if __name__ == "__main__":
run_demo()
2. demos/pappus_six_permutations.py — Six $S_3$ Lines & Steiner Star Points¶
Constructs all $3! = 6$ permutations on both preset="steiner" and the 2023 preset="parallel"
configuration, printing every cross-join meet, Pappus line equation, and exact Star concurrency
point $(S_+, S_-)$.
uv run --no-sync python demos/pappus_six_permutations.py
r"""Demonstration 2: The Six Permutations (S_3) & Steiner's Two Star Concurrency Points.
Revives and completes GEOMETOR's 2023 ``pappus.py`` exploration: permuting
$(B_0, B_1, B_2)$ across all $3! = 6$ elements of $S_3$ yields six Pappus lines
that split by permutation parity into two concurrent triples:
- The 3 **even** Pappus lines ($A_3$) concur at the even star point $S_+$.
- The 3 **odd** Pappus lines ($S_3 \setminus A_3$) concur at the odd star point $S_-$.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC_DIR = Path(__file__).resolve().parents[1] / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
from rich.console import Console # noqa: E402
from rich.table import Table # noqa: E402
from geometor.pappus import ( # noqa: E402
PERMUTATIONS_S3,
construct_pappus_configuration,
permutation_parity,
)
def run_demo() -> None:
"""Construct and compare both the 2023 parallel configuration and the compact Steiner configuration."""
console = Console()
for preset_key in ("parallel", "steiner"):
cfg = construct_pappus_configuration(preset=preset_key, scan_harmonics=True)
table = Table(title=f"Six-Permutation Pappus–Steiner Configuration ({preset_key})")
table.add_column("#", justify="right", style="dim")
table.add_column("Perm σ", style="cyan bold")
table.add_column("Parity", style="magenta")
table.add_column("Three Cross-Join Meets", style="white")
table.add_column("Pappus Line Equation (= 0)", style="green")
for idx, perm in enumerate(PERMUTATIONS_S3):
parity = permutation_parity(perm)
meets = cfg.meets_by_perm[perm]
meet_str = ", ".join(
f"{cfg.model[m].ID}=({m.x},{m.y})" if m is not None else "∞"
for m in meets
)
eq_str = str(cfg.pappus_lines[perm].equation())
table.add_row(str(idx), str(perm), parity, meet_str, eq_str)
console.print(table)
star_table = Table(title=f"Steiner Concurrency Summary ({preset_key})")
star_table.add_column("Invariant", style="bold yellow")
star_table.add_column("Exact Symbolic Result", style="cyan")
star_table.add_row("Total Cross-Join Meets", str(len(cfg.all_meets)))
if cfg.steiner_even is not None:
star_table.add_row("Even Star Point S+ (S1)", f"({cfg.steiner_even.x}, {cfg.steiner_even.y})")
if cfg.steiner_odd is not None:
star_table.add_row("Odd Star Point S- (S2)", f"({cfg.steiner_odd.x}, {cfg.steiner_odd.y})")
if cfg.steiner_line is not None:
star_table.add_row("Steiner Line [S+ S-]", f"{cfg.steiner_line.equation()} = 0")
star_table.add_row("Collinear Harmonic Tetrads", str(len(cfg.harmonic_ranges)))
console.print(star_table)
if __name__ == "__main__":
run_demo()
3. demos/harmonic_conjugate.py — Complete Quadrilateral & Harmonic Tetrads¶
Verifies Book VII Prop. 129 central perspectivity invariance, demonstrates straightedge fourth
harmonic construction across two distinct auxiliary apex/relay choices (confirming invariance of
$D = (-4, 0)$), and catalogs emergent harmonic tetrads on preset="harmonic".
uv run --no-sync python demos/harmonic_conjugate.py
"""Demonstration 3: Straightedge Fourth Harmonic Conjugate & Projective Invariance.
Constructs the fourth harmonic conjugate $D$ of $C$ with respect to $(A, B)$
using only straightedge incidences via a complete quadrilateral, verifies
$(A, B; C, D) = -1$, and proves that $D$ is completely independent of the
auxiliary apex $P$ and relay point $Q$.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC_DIR = Path(__file__).resolve().parents[1] / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
import sympy as sp # noqa: E402
from rich.console import Console # noqa: E402
from rich.table import Table # noqa: E402
from geometor.pappus import ( # noqa: E402
construct_harmonic_fourth,
construct_pappus_configuration,
cross_ratio,
harmonic_conjugate_point,
is_harmonic_range,
)
def run_demo() -> None:
"""Run the complete quadrilateral harmonic conjugate construction and invariance check."""
console = Console()
res_1 = construct_harmonic_fourth(
pt_a=(0, 0),
pt_b=(4, 0),
pt_c=(sp.Rational(4, 3), 0),
apex=(2, 3),
relay=(sp.Rational(5, 3), sp.Rational(3, 2)),
)
res_2 = construct_harmonic_fourth(
pt_a=(0, 0),
pt_b=(4, 0),
pt_c=(sp.Rational(4, 3), 0),
apex=(-1, 5),
relay=(sp.Rational(2, 5), 2),
)
algebraic_d = harmonic_conjugate_point(res_1.pt_a, res_1.pt_b, res_1.pt_c)
cr_val = cross_ratio(res_1.pt_a, res_1.pt_b, res_1.pt_c, res_1.pt_d)
q_table = Table(title="Complete Quadrilateral Fourth Harmonic Construction")
q_table.add_column("Quantity", style="cyan bold")
q_table.add_column("Exact Value", style="green")
q_table.add_row("Base Points A, B", f"({res_1.pt_a.x}, {res_1.pt_a.y}), ({res_1.pt_b.x}, {res_1.pt_b.y})")
q_table.add_row("Interior Point C", f"({res_1.pt_c.x}, {res_1.pt_c.y})")
q_table.add_row("Constructed D (Trial 1: P=(2,3))", f"({res_1.pt_d.x}, {res_1.pt_d.y})")
q_table.add_row("Constructed D' (Trial 2: P=(-1,5))", f"({res_2.pt_d.x}, {res_2.pt_d.y})")
q_table.add_row("Algebraic Formula D", f"({algebraic_d.x}, {algebraic_d.y})")
q_table.add_row("D == D' == Algebraic?", str(res_1.pt_d.equals(res_2.pt_d) and res_1.pt_d.equals(algebraic_d)))
q_table.add_row("Cross-Ratio (A, B; C, D)", str(cr_val))
q_table.add_row("is_harmonic_range(A, B, C, D)", str(is_harmonic_range(res_1.pt_a, res_1.pt_b, res_1.pt_c, res_1.pt_d)))
console.print(q_table)
# Emergent harmonic tetrads inside the Pappus configuration
cfg = construct_pappus_configuration(preset="harmonic", discover_all_intersections=True)
h_table = Table(title=f"Sample Emergent Harmonic Ranges in Pappus Configuration ({len(cfg.harmonic_ranges)} total)")
h_table.add_column("#", justify="right", style="dim")
h_table.add_column("Carrier Line", style="cyan")
h_table.add_column("Ordered Points (P1 < P2 < P3 < P4)", style="white")
h_table.add_column("(P1, P3; P2, P4)", style="green")
for idx, hr in enumerate(cfg.harmonic_ranges[:10], start=1):
h_table.add_row(str(idx), hr.line_id, f"({', '.join(hr.point_ids)})", str(hr.value))
console.print(h_table)
if __name__ == "__main__":
run_demo()
4. demos/golden_pappus.py — Golden Projectivity in $\mathbb{Q}(\phi)$¶
Computes the canonical golden cross-ratio $(0, 1; \phi, \phi + 1) = \phi$, its six-value
anharmonic power orbit, the harmonic-golden identity $(0, \phi; 1, \phi^3) = -1$, and runs
geometor.divine to uncover the emergent golden section / A1 M12 B2 /.
uv run --no-sync python demos/golden_pappus.py
r"""Demonstration 4: Golden Projectivity, Cross-Ratio Orbits & Book VII Prop. 129.
Connects Pappus's invariance of the cross-ratio under central perspectivity
(*Synagoge* Book VII, Prop. 129) to GEOMETOR's central theme of the Golden Ratio
$\phi = (1 + \sqrt{5})/2$:
1. Verifies the canonical golden chain cross-ratio $(0, 1; \phi, \phi + 1) = \phi$
and computes its six-value anharmonic $S_4 / V_4$ orbit in $\mathbb{Q}(\phi)$.
2. Proves the harmonic-golden identity $(0, \phi; 1, \phi^3) = -1$ where $\phi^3 = 2\phi + 1$.
3. Projects a golden range onto an oblique line via central perspectivity and
verifies exact preservation of $\phi$ in the cross-ratio even when Euclidean
ratios change.
4. Constructs the Golden Pappus Hexagon over $\mathbb{Q}(\phi)$ and scans it with
:mod:`geometor.divine`.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC_DIR = Path(__file__).resolve().parents[1] / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
import sympy as sp # noqa: E402
import sympy.geometry as spg # noqa: E402
from geometor.model import Model # noqa: E402
from rich.console import Console # noqa: E402
from rich.table import Table # noqa: E402
from geometor.pappus import ( # noqa: E402
PHI,
anharmonic_orbit,
construct_pappus_hexagon,
cross_ratio,
enable_divine_analysis,
find_golden_sections,
harmonic_conjugate_point,
project_point,
)
def run_demo() -> None:
"""Execute the Golden Projectivity demonstration."""
console = Console()
# 1. Canonical golden chain & anharmonic orbit
p0 = spg.Point(0, 0)
p1 = spg.Point(1, 0)
p2 = spg.Point(PHI, 0)
p3 = spg.Point(PHI + 1, 0)
cr_golden = cross_ratio(p0, p1, p2, p3)
orbit = anharmonic_orbit(cr_golden)
# 2. Fourth harmonic conjugate of 1 w.r.t. (0, phi) is phi^3 = 2*phi + 1
h_conj = harmonic_conjugate_point(p0, p2, p1)
cr_harm_gold = cross_ratio(p0, p2, p1, h_conj)
# 3. Central perspectivity (Synagoge VII.129) onto an oblique target line
center = spg.Point(1, 3)
target_line = spg.Line(spg.Point(0, 1), spg.Point(4, 2))
projected = [project_point(center, target_line, pt) for pt in (p0, p1, p2, p3)]
cr_projected = cross_ratio(*projected)
inv_table = Table(title="Golden Cross-Ratios & Book VII Prop. 129 Perspectivity")
inv_table.add_column("Property", style="cyan bold")
inv_table.add_column("Exact Symbolic Result", style="green")
inv_table.add_row("Golden Ratio φ", f"{PHI} ≈ {float(PHI.evalf()):.10f}")
inv_table.add_row("Chain Cross-Ratio (0, 1; φ, φ+1)", f"{cr_golden} (equals φ: {sp.simplify(cr_golden - PHI) == 0})")
inv_table.add_row("6-Value Anharmonic Orbit", ", ".join(str(v) for v in orbit))
inv_table.add_row("Harmonic Conjugate D of 1 w.r.t. (0, φ)", f"x = {h_conj.x} = 2φ + 1 = φ³ (equals φ³: {sp.simplify(h_conj.x - PHI**3) == 0})")
inv_table.add_row("Verify (0, φ; 1, φ³)", str(cr_harm_gold))
inv_table.add_row("Projected Cross-Ratio on x - 4y + 4 = 0", f"{cr_projected} (invariant: {sp.simplify(cr_projected - cr_golden) == 0})")
console.print(inv_table)
# 4. Golden Pappus Hexagon with geometor.divine analysis
model = enable_divine_analysis(Model("golden_pappus"))
gold_hex = construct_pappus_hexagon(model=model, preset="golden", perm=(0, 1, 2))
sections = find_golden_sections(gold_hex.model, register_sections=True)
g_table = Table(title="Golden Pappus Hexagon in Q(φ)")
g_table.add_column("Element", style="bold yellow")
g_table.add_column("Exact Symbolic Expression", style="cyan")
for m_id, m_pt in gold_hex.meets.items():
if m_pt is not None:
g_table.add_row(f"Meet {m_id}", f"({m_pt.x}, {m_pt.y})")
g_table.add_row("Pappus Line", f"{gold_hex.pappus_line.equation()} = 0")
g_table.add_row("Collinear over Q(φ)?", str(gold_hex.is_collinear))
g_table.add_row("Golden Sections Discovered", str(len(sections)))
for sec in sections:
g_table.add_row(f" Golden Section on {sec.line_id}", f"{sec.point_ids} -> ratio = {sec.ratio}")
console.print(g_table)
if __name__ == "__main__":
run_demo()
5. demos/pascal_hexagrammum.py — Pascal’s Hexagrammum Mysticum (1640)¶
Proves Pascal’s smooth-conic theorem universally over $\mathbb{Z}[t_0, \dots, t_5]$, compares
the Pythagorean unit circle and stretched affine ellipse $\frac{x^2}{4} + y^2 = 1$, enumerates all
60 Pascal lines, 20 Steiner points, 60 Kirkman points, and 15 Plücker lines, and uncovers the
emergent golden conic section / M25 P4 P0 / in $\mathbb{Q}(\phi)$.
uv run --no-sync python demos/pascal_hexagrammum.py
"""Standalone demonstration of Blaise Pascal's *Hexagrammum Mysticum* (1640).
Showcases:
1. Universal 6-variable polynomial proof over Z[t0..t5] and Veronese coconicity.
2. Pascal's Mystic Star Hexagram on the Pythagorean unit circle x^2 + y^2 = 1
and on the general ellipse x^2 + 4y^2 = 4.
3. Complete 60-line *Hexagrammum Mysticum* combinatorics: 15 chords, 45 diagonal
Pascal points, 60 Pascal lines, 20 Jakob Steiner points, 60 Thomas Kirkman
points, and 15 Julius Plücker lines.
4. Golden *Hexagrammum* in Q(phi): Chasles conic cross-ratio phi, golden meet
M25 = (-1/phi, -phi), and emergent geometor.divine golden section / M25 P4 P0 /.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC_DIR = Path(__file__).resolve().parents[1] / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
from rich.console import Console # noqa: E402
from rich.table import Table # noqa: E402
from geometor.pappus import ( # noqa: E402
PHI,
conic_cross_ratio,
conic_equation_through_points,
construct_pascal_hexagon,
construct_pascal_steiner_family,
enumerate_hexagrammum_mysticum,
find_golden_sections,
verify_pascal_symbolic,
)
def main() -> None:
"""Run the Pascal *Hexagrammum Mysticum* symbolic demonstration."""
console = Console()
console.rule("[bold amber1]Blaise Pascal's Hexagrammum Mysticum (1640)[/bold amber1]")
# 1. Universal 6-parameter symbolic proof
sym_det = verify_pascal_symbolic()
console.print(
f"[bold green]✓ Universal 6-variable homogeneous determinant det[M03, M14, M25]:[/bold green] {sym_det}"
)
# 2. Pythagorean Mystic Star Hexagram & Ellipse invariance
mystic = construct_pascal_hexagon(preset="hexagrammum")
ellipse_res = construct_pascal_hexagon(preset="ellipse")
conic_poly = conic_equation_through_points(mystic.points[:5])
hex_table = Table(title="Pascal's Mystic Hexagram <P0, P2, P4, P1, P3, P5> on Circle vs. Ellipse")
hex_table.add_column("Element", style="cyan bold")
hex_table.add_column("Unit Circle x^2 + y^2 = 1", style="green")
hex_table.add_column("General Ellipse x^2/4 + y^2 = 1", style="magenta")
for idx in range(6):
pc = mystic.points[idx]
pe = ellipse_res.points[idx]
hex_table.add_row(f"P{idx}", f"({pc.x}, {pc.y})", f"({pe.x}, {pe.y})")
for mid in ("M03", "M14", "M25"):
mc = mystic.meets[mid]
me = ellipse_res.meets[mid]
hex_table.add_row(
mid,
f"({mc.x}, {mc.y})" if mc else "∞",
f"({me.x}, {me.y})" if me else "∞",
)
hex_table.add_row(
"Pascal Line",
f"{mystic.pascal_line.equation()} = 0",
f"{ellipse_res.pascal_line.equation()} = 0",
)
hex_table.add_row("5-Point Veronese Conic", f"{conic_poly} = 0", "x^2 + 4*y^2 - 4 = 0")
console.print(hex_table)
# 3. Bi-Triangle S_3 Steiner Family & Full 60-Line Catalog
steiner_fam = construct_pascal_steiner_family(preset="hexagrammum")
catalog = enumerate_hexagrammum_mysticum(preset="hexagrammum")
cat_table = Table(title="Complete 19th-Century Hexagrammum Mysticum Incidence Catalog")
cat_table.add_column("Projective Invariant / Family", style="cyan bold")
cat_table.add_column("Exact Count", justify="right", style="bold yellow")
cat_table.add_column("Sample / Algebraic Highlight", style="green")
cat_table.add_row("Conic Vertices P0..P5", "6", "All 6 satisfy x^2 + y^2 - 1 = 0")
cat_table.add_row("Pairwise Chords [Pi Pj]", str(len(catalog.chords)), "15 secant lines across the circle")
cat_table.add_row(
"Pascal Diagonal Points",
str(len(set(catalog.diagonal_points.values()))),
"45 off-conic chord intersections (4 Pascal lines per point)",
)
cat_table.add_row(
"Distinct Pascal Lines",
str(len(set(catalog.pascal_lines.values()))),
"6! / (6 * 2) = 60 lines (3 diagonal points per line)",
)
cat_table.add_row(
"Jakob Steiner Points (1828)",
str(len(set(catalog.steiner_points.values()))),
f"Δ024 vs Δ135: G+ = ({steiner_fam.steiner_even.x}, {steiner_fam.steiner_even.y}), "
f"G- = ({steiner_fam.steiner_odd.x}, {steiner_fam.steiner_odd.y})",
)
cat_table.add_row(
"Thomas Kirkman Points (1849)",
str(len(set(catalog.kirkman_points.values()))),
"60 3-fold Pascal line concurrencies dual to Pascal lines",
)
cat_table.add_row(
"Julius Plücker Lines (1830)",
str(len(catalog.plucker_lines)),
"15 lines each carrying exactly 4 of the 20 Steiner points",
)
console.print(cat_table)
# 4. Golden Conic Hexagrammum in Q(phi)
gold_hex = construct_pascal_hexagon(preset="golden_conic")
gp = gold_hex.points
cr_from_p4 = conic_cross_ratio(gp[0], gp[1], gp[2], gp[3], observer=gp[4])
cr_from_p5 = conic_cross_ratio(gp[0], gp[1], gp[2], gp[3], observer=gp[5])
gold_secs = find_golden_sections(gold_hex.model)
g_table = Table(title="Golden Hexagrammum Mysticum in Q(phi)")
g_table.add_column("Discovery", style="bold yellow")
g_table.add_column("Exact Symbolic Result", style="green")
g_table.add_row("Phi = (1 + sqrt(5))/2", str(PHI))
g_table.add_row("Chasles Conic CR (P0, P1; P2, P3) from P4", str(cr_from_p4))
g_table.add_row("Chasles Conic CR (P0, P1; P2, P3) from P5", str(cr_from_p5))
m25 = gold_hex.meets["M25"]
if m25 is not None:
g_table.add_row("Golden Pascal Meet M25", f"({m25.x}, {m25.y}) = (-1/phi, -phi)")
for gs in gold_secs:
g_table.add_row(f"Divine Golden Section on {gs.line_id}", f"/ {' '.join(gs.point_ids)} / (ratio = {gs.ratio})")
console.print(g_table)
if __name__ == "__main__":
main()
6. demos/synagoge_three_means.py — Synagoge Book III: Three Means in One Semicircle¶
Constructs Pappus’s semicircle diagram (Hultsch I, pp. 68–84) on rational $(9, 16)$, Pythagorean $(4, 9)$, and golden $(1, \phi^2)$ segments, verifying $A \cdot H = G^2$, $A > G > H$, and the external harmonic tangent relation $(A, C; D, T) = -1$.
uv run --no-sync python demos/synagoge_three_means.py
r"""Standalone demo: Pappus's Three Classical Means in a Single Semicircle (*Synagoge* III.5–16).
Constructs both the rational $(9, 16)$ semicircle ($A = 25/2, G = 12, H = 288/25$)
and the golden $(1, \phi^2)$ semicircle ($G = \phi$) in 100% exact SymPy arithmetic,
verifying $A \cdot H = G^2$, $A > G > H$, and the harmonic tangent relation $(A, C; D, T) = -1$.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC_DIR = Path(__file__).resolve().parents[1] / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
import sympy as sp # noqa: E402
from rich.console import Console # noqa: E402
from rich.table import Table # noqa: E402
from geometor.pappus import PHI, construct_three_means # noqa: E402
def main() -> int:
"""Run the Book III semicircle means demonstration."""
console = Console()
table = Table(title="Pappus Synagoge III.5–16 — Three Means in One Semicircle")
table.add_column("Segments (a, b)", style="cyan bold")
table.add_column("A = (a+b)/2", style="yellow")
table.add_column("G = sqrt(ab)", style="green")
table.add_column("H = 2ab/(a+b)", style="magenta")
table.add_column("A*H - G^2", justify="right", style="white")
table.add_column("(A, C; D, T)", justify="right", style="cyan")
for label, a_val, b_val in (
("Rational (9, 16)", sp.Integer(9), sp.Integer(16)),
("Pythagorean (4, 9)", sp.Integer(4), sp.Integer(9)),
("Golden (1, phi^2)", sp.Integer(1), PHI**2),
):
res = construct_three_means(a_val, b_val)
identity_zero = sp.simplify(res.arithmetic_mean * res.harmonic_mean - res.geometric_mean**2)
table.add_row(
label,
str(res.arithmetic_mean),
str(res.geometric_mean),
str(res.harmonic_mean),
str(identity_zero),
str(res.harmonic_cross_ratio),
)
console.print(table)
return 0
if __name__ == "__main__":
raise SystemExit(main())
7. demos/pappus_area_theorem.py — Synagoge Book IV.1: Parallelogram Area Theorem¶
Demonstrates Pappus’s equiaffine generalization of Elements I.47 (Hultsch I, pp. 176–179) on an oblique scalene triangle ($13 + 15 = 28$), on the $3$-$4$-$5$ right triangle ($9 + 16 = 25$), and universally over $\mathbb{Z}[x_A, y_A, x_B, y_B, x_C, y_C, u_x, u_y, v_x, v_y]$.
uv run --no-sync python demos/pappus_area_theorem.py
r"""Standalone demo: Pappus's Area Theorem (*Synagoge* Book IV, Prop. 1).
Demonstrates Pappus's affine generalization of the Pythagorean Theorem (*Elements* I.47)
on an arbitrary scalene triangle with oblique parallelograms, on the $3$-$4$-$5$ right
triangle with squares, and universally over $\mathbb{Z}[x_A, y_A, x_B, y_B, x_C, y_C, u_x, u_y, v_x, v_y]$.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC_DIR = Path(__file__).resolve().parents[1] / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
from rich.console import Console # noqa: E402
from rich.table import Table # noqa: E402
from geometor.pappus import ( # noqa: E402
construct_pappus_area_theorem,
verify_pappus_area_symbolic,
)
def main() -> int:
"""Run the Book IV.1 Pappus Area Theorem demonstration."""
console = Console()
table = Table(title="Pappus Synagoge IV.1 — Area Theorem on Arbitrary Parallelograms")
table.add_column("Case", style="cyan bold")
table.add_column("Apex H = [DE] ∩ [FG]", style="white")
table.add_column("Area(ABDE)", justify="right", style="yellow")
table.add_column("Area(ACFG)", justify="right", style="yellow")
table.add_column("Area(BCML)", justify="right", style="green bold")
table.add_column("Residual", justify="right", style="magenta")
for preset in ("scalene", "pythagoras"):
res = construct_pappus_area_theorem(preset=preset)
table.add_row(
preset,
f"({res.apex_h.x}, {res.apex_h.y})",
str(res.area_ab),
str(res.area_ac),
str(res.area_bc),
str(res.area_residual),
)
sym_residual = verify_pappus_area_symbolic()
table.add_row("Universal 10-var Polynomial", "symbolic H", "det(A-B,u)", "det(v,A-C)", "det(B-C,A-H)", str(sym_residual))
console.print(table)
return 0
if __name__ == "__main__":
raise SystemExit(main())
8. demos/arbelos_circle_chain.py — Synagoge Book IV.14–18: Arbelos Circle Chain¶
Constructs the infinite tangent circle chain $C_1, \dots, C_5$ inside the arbelos (Hultsch I, pp. 208–232) in 100% exact rational coordinates and verifies both pairwise tangency quadrances and Pappus’s altitude law $y_n = n\,d_n = 2n\,r_n$.
uv run --no-sync python demos/arbelos_circle_chain.py
r"""Standalone demo: Pappus's *Ancient Proposition* on the Arbelos (*Synagoge* IV.14–18).
Constructs the tangent circle chain $C_1, \dots, C_5$ inside the shoemaker's knife
(*arbelos*) in 100% exact rational coordinates over $\mathbb{Q}$ and verifies both
pairwise tangency quadrances and Pappus's altitude law $y_n = n d_n = 2 n r_n$.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC_DIR = Path(__file__).resolve().parents[1] / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
from rich.console import Console # noqa: E402
from rich.table import Table # noqa: E402
from geometor.pappus import ( # noqa: E402
construct_pappus_arbelos_chain,
verify_arbelos_chain_symbolic,
)
def main() -> int:
"""Run the Book IV.14–18 Arbelos circle chain demonstration."""
console = Console()
res = construct_pappus_arbelos_chain(2, 1, 5)
sym_checks = verify_arbelos_chain_symbolic()
table = Table(title="Pappus Synagoge IV.14–18 — Infinite Arbelos Circle Chain (r1 = 2, r2 = 1)")
table.add_column("n", justify="right", style="cyan bold")
table.add_column("Rational Center K_n", style="white")
table.add_column("Radius r_n", justify="right", style="yellow")
table.add_column("Diameter d_n", justify="right", style="yellow")
table.add_column("Height y_n", justify="right", style="green")
table.add_column("y_n / d_n", justify="right", style="magenta bold")
for item in res.chain:
table.add_row(
str(item.index),
f"({item.center.x}, {item.center.y})",
str(item.radius),
str(item.diameter),
str(item.height),
str(item.height_over_diameter),
)
console.print(table)
console.print(f"Symbolic proof residuals over Q(r1, r2, n): {sym_checks}")
return 0
if __name__ == "__main__":
raise SystemExit(main())
9. demos/honeycomb_isoperimetry.py — Synagoge Book V.1 & VIII.23: Honeycomb & 7 Hexagons¶
Proves that $n \in \{3, 4, 6\}$ are the unique regular plane-tiling polygons (Hultsch I, pp. 304–312), evaluates exact symbolic areas at equal perimeter $P = 12$, and verifies the exact circumradius $R = s_6\sqrt{7}$ of Book VIII Proposition 23’s seven-hexagon circle inscription.
uv run --no-sync python demos/honeycomb_isoperimetry.py
r"""Standalone demo: The Sagacity of Bees & Honeycomb Isoperimetry (*Synagoge* V.1 & VIII.23).
Proves that $n \in \{3, 4, 6\}$ are the unique regular plane-tiling polygons,
computes exact symbolic areas for equal perimeter $P = 12$, and verifies the
circumradius $R = s_6 \sqrt{7}$ of Book VIII, Prop. 23's 7-hexagon rosette.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC_DIR = Path(__file__).resolve().parents[1] / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
from rich.console import Console # noqa: E402
from rich.table import Table # noqa: E402
from geometor.pappus import verify_honeycomb_isoperimetry # noqa: E402
def main() -> int:
"""Run the Book V Honeycomb Isoperimetry demonstration."""
console = Console()
res = verify_honeycomb_isoperimetry(12, build_model=True)
table = Table(title="Pappus Synagoge V.1 — Equal-Perimeter Regular Plane Tilings (P = 12)")
table.add_column("Polygon", style="cyan bold")
table.add_column("Interior Angle", justify="right", style="white")
table.add_column("Around Vertex", justify="right", style="yellow")
table.add_column("Side s_n", justify="right", style="white")
table.add_column("Exact Area", style="green bold")
names = {3: "Equilateral Triangle (n=3)", 4: "Square (n=4)", 6: "Regular Hexagon (n=6)"}
for n_gon in res.tiling_polygons:
table.add_row(
names[n_gon],
f"{res.interior_angles_deg[n_gon]}°",
str(res.polygons_per_vertex[n_gon]),
str(res.side_lengths[n_gon]),
str(res.areas[n_gon]),
)
console.print(table)
console.print(
f"Area_6 / Area_3 = {res.area_hex_over_tri}, "
f"Area_6 / Area_4 = {res.area_hex_over_sq}, "
f"Book VIII.23 7-hexagon circumradius R_7 = {res.circumradius_seven_hexagons}"
)
return 0
if __name__ == "__main__":
raise SystemExit(main())