modules¶
geometor.model¶
Provides the core symbolic data structures, Euclidean construction kernel, and rational-trigonometry proof verifier for 2D constructive geometry in GEOMETOR.
Everything centers around Model.
Submodules¶
- geometor.model.__main__
- geometor.model.algebra
- geometor.model.ancestors
- geometor.model.chains
- geometor.model.circles
- geometor.model.cli
- geometor.model.colors
- geometor.model.delete
- geometor.model.element
- geometor.model.helpers
- geometor.model.intersections
- geometor.model.invariants
- geometor.model.lines
- geometor.model.model
- geometor.model.points
- geometor.model.polygons
- geometor.model.polynomials
- geometor.model.proof
- geometor.model.reports
- geometor.model.sections
- geometor.model.segments
- geometor.model.serialize
- geometor.model.utils
- geometor.model.wedges
Attributes¶
Exceptions¶
Raised when a compass-and-straightedge intersection violates its diorismos or selector. |
|
Raised when a deductive geometric assertion fails exact symbolic verification. |
Classes¶
Active scope state for |
|
First-class rectilinear angle |
|
The central class representing an exact symbolic geometric construction and proof. |
|
Chronological construction or demonstration step recorded by |
Functions¶
|
Canonicalize an expression in the golden field \(\mathbb{Q}(\phi)\). |
|
Canonicalize an expression in the degree-4 Kepler field \(\mathbb{Q}(\sqrt{\phi})\). |
|
Canonicalize a symbolic geometric coordinate without invoking |
|
Return the exact mathematical sign ( |
|
Construct and cache an explicit algebraic number field \(\mathbb{Q}(\alpha_1, \dots)\). |
|
Return the cached quadratic number field \(\mathbb{Q}(\phi) = \mathbb{Q}(\sqrt{5})\). |
|
Return the cached degree-4 Kepler number field \(\mathbb{Q}(\sqrt{\phi})\). |
|
Reduce an algebraic expression inside an explicit number field \(\mathbb{Q}(\alpha)\). |
|
Determine with 100% mathematical exactness whether |
|
Compute exact symbolic intersections of 2D lines, circles, and segments. |
|
Decorator marking a Euclidean construction function as a composable proposition. |
|
Compute the exact rational cross \(c(l_1, l_2) = \cos^2\theta = 1 - s(l_1, l_2)\). |
|
Compute the exact projective cross-ratio \((A, B; C, D) = \frac{\overline{AC}\cdot\overline{BD}}{\overline{BC}\cdot\overline{AD}}\). |
|
Return |
|
Compute the exact rational spread \(s(l_1, l_2) = \sin^2\theta\) between two lines. |
|
Return |
|
Compute the exact Euclidean quadrance \(Q = (x_2 - x_1)^2 + (y_2 - y_1)^2\). |
|
Compute the exact spread at vertex |
|
Load a |
Package Contents¶
- geometor.model.canonicalize_golden(expr: object) sympy.Expr¶
Canonicalize an expression in the golden field \(\mathbb{Q}(\phi)\).
- geometor.model.canonicalize_kepler(expr: object) sympy.Expr¶
Canonicalize an expression in the degree-4 Kepler field \(\mathbb{Q}(\sqrt{\phi})\).
- geometor.model.clean_expr(expr: object) sympy.Expr¶
Canonicalize a symbolic geometric coordinate without invoking
sp.simplify.Applies a fast tiered pipeline:
Immediate O(1) return for Python
intand SymPyRational/Integer.Fraction combination (
sympy.together()), bounded polynomial expansion, and denominator rationalization (sympy.radsimp()withsymbolic=False).Conditional
sympy.sqrtdenest()only when nested radicals are actually present.
- Parameters:
expr – A numeric value or SymPy expression.
- Returns:
A simplified exact
sympy.Expr.
- geometor.model.exact_sign(expr: object) int¶
Return the exact mathematical sign (
+1,-1, or0) of a real expression.- Parameters:
expr – A real numeric value or SymPy expression.
- Returns:
1ifexpr > 0,-1ifexpr < 0, or0ifexpr == 0.- Raises:
ValueError – If
exprhas free symbols whose sign cannot be determined or is non-real.
- geometor.model.get_algebraic_field(*generators: sympy.Expr) sympy.AlgebraicField¶
Construct and cache an explicit algebraic number field \(\mathbb{Q}(\alpha_1, \dots)\).
- Parameters:
*generators – Algebraic SymPy expressions generating the extension over
QQ.- Returns:
A cached
sympy.polys.domains.AlgebraicField.
- geometor.model.get_golden_field() sympy.AlgebraicField¶
Return the cached quadratic number field \(\mathbb{Q}(\phi) = \mathbb{Q}(\sqrt{5})\).
- geometor.model.get_kepler_field() sympy.AlgebraicField¶
Return the cached degree-4 Kepler number field \(\mathbb{Q}(\sqrt{\phi})\).
- geometor.model.reduce_in_field(expr: object, field_or_gen: sympy.AlgebraicField | sympy.Expr | tuple[sympy.Expr, ...]) sympy.Expr¶
Reduce an algebraic expression inside an explicit number field \(\mathbb{Q}(\alpha)\).
Handles nested square roots whose radicands simplify to squares inside the target field (such as \(\sqrt{1 + \phi} = \phi\) and \(\sqrt{\phi - 1} = \phi^{-1/2}\) in the Kepler field), and falls back cleanly when outer extensions (e.g. \(\sqrt{3}\)) are present.
- Parameters:
expr – Numeric value or SymPy expression to canonicalize.
field_or_gen – An
sympy.AlgebraicField, a generator expression, or tuple of generators.
- Returns:
Canonicalized
sympy.Expr.
- geometor.model.zero_test(expr: object) bool¶
Determine with 100% mathematical exactness whether
expr == 0.Uses a fast 3-tier decision procedure:
O(1) structural and rational check.
High-precision adaptive
evalf(20)rejection for non-zero constant expressions (rejects non-zeros in microseconds without symbolic expansion).Exact algebraic proof of zero via fraction numerator expansion,
clean_expr(),GoldenRatioradical substitution, and fallbacksimplify/minimal_polynomial.
- Parameters:
expr – A numeric value or SymPy expression.
- Returns:
Trueif and only ifexpris identically zero.
- exception geometor.model.ConstructionError¶
Bases:
ValueErrorRaised when a compass-and-straightedge intersection violates its diorismos or selector.
- class geometor.model.SubconstructionScope¶
Active scope state for
Model.subconstruction().
- geometor.model.intersect_2d(s1: sympy.geometry.entity.GeometryEntity, s2: sympy.geometry.entity.GeometryEntity) list[sympy.geometry.Point]¶
Compute exact symbolic intersections of 2D lines, circles, and segments.
Uses closed-form homogeneous cross-products (line-line), orthogonal projection discriminants (line-circle), and radical-axis projections (circle-circle) so nested radical expressions never fall into SymPy’s slow
Ellipsequartic solver.- Parameters:
s1 – First 2D geometric entity (
Line,Circle, orSegment).s2 – Second 2D geometric entity (
Line,Circle, orSegment).
- Returns:
Deterministically sorted list of exact real
sympy.geometry.Pointintersections.
- geometor.model.proposition(prop_id: str, *, g_id: str = '', kind: str = 'problem', title: str = '', hide_guides: bool = True, scope_intersections: bool = True) collections.abc.Callable[[collections.abc.Callable[..., Any]], collections.abc.Callable[..., Any]]¶
Decorator marking a Euclidean construction function as a composable proposition.
Executes the wrapped function inside
Model.subconstruction(), scoping automatic intersections to the proposition and automatically marking un-returned auxiliary lines, circles, and guide poles withguide=True.- Parameters:
prop_id – Proposition or center identifier (e.g.,
"I.1","X(13)").g_id – Optional G-Index node identifier (e.g.,
"G.17").kind –
"problem"(Q.E.F.) or"theorem"(Q.E.D.).title – Optional human-readable proposition title.
hide_guides – Default
hide_guidessetting when invoked.scope_intersections – Default
scope_intersectionssetting when invoked.
- class geometor.model.Angle(p1_or_points: sympy.geometry.Point | list[sympy.geometry.Point] | tuple[sympy.geometry.Point, ...], vertex: sympy.geometry.Point | None = None, p2: sympy.geometry.Point | None = None)¶
First-class rectilinear angle
< B A C )with vertexAand raysAB,AC.Stores exact algebraic spread, cross, and acute/right/obtuse dot-product sign without requiring transcendental
acosoratan2evaluation during equality proofs.- p1: sympy.geometry.Point¶
- vertex: sympy.geometry.Point¶
- p2: sympy.geometry.Point¶
- property ray1: sympy.geometry.Ray¶
First ray from
vertexthroughp1.
- property ray2: sympy.geometry.Ray¶
Second ray from
vertexthroughp2.
- property spread: sympy.Expr¶
Exact rational trigonometry spread \(s(\angle BAC) = \sin^2\theta\).
- property cross: sympy.Expr¶
Exact rational trigonometry cross \(c(\angle BAC) = \cos^2\theta\).
- property radians: sympy.Expr¶
Interior angle measure in radians in \([0, \pi]\).
- property degrees: sympy.Expr¶
Interior angle measure in degrees.
- geometor.model.cross(l1: sympy.geometry.Line | sympy.geometry.Segment | tuple[sympy.geometry.Point, sympy.geometry.Point], l2: sympy.geometry.Line | sympy.geometry.Segment | tuple[sympy.geometry.Point, sympy.geometry.Point]) sympy.Expr¶
Compute the exact rational cross \(c(l_1, l_2) = \cos^2\theta = 1 - s(l_1, l_2)\).
- geometor.model.cross_ratio(A: sympy.geometry.Point, B: sympy.geometry.Point, C: sympy.geometry.Point, D: sympy.geometry.Point) sympy.Expr¶
Compute the exact projective cross-ratio \((A, B; C, D) = \frac{\overline{AC}\cdot\overline{BD}}{\overline{BC}\cdot\overline{AD}}\).
Projects collinear displacements onto a shared line direction vector so the cross-ratio is computed purely rationally without introducing square roots.
- Parameters:
A – First base point.
B – Second base point.
C – First division point.
D – Second division point.
- Returns:
Exact simplified
sympy.Expr.- Raises:
ValueError – If the four points are not collinear or the denominator vanishes.
- geometor.model.is_harmonic(A: sympy.geometry.Point, B: sympy.geometry.Point, C: sympy.geometry.Point, D: sympy.geometry.Point) bool¶
Return
Trueiff(A, B; C, D) == -1forms an exact harmonic range.
- geometor.model.line_spread(l1: sympy.geometry.Line | sympy.geometry.Segment | tuple[sympy.geometry.Point, sympy.geometry.Point], l2: sympy.geometry.Line | sympy.geometry.Segment | tuple[sympy.geometry.Point, sympy.geometry.Point]) sympy.Expr¶
Compute the exact rational spread \(s(l_1, l_2) = \sin^2\theta\) between two lines.
- Parameters:
l1 – First line, segment, or
(P, Q)point pair.l2 – Second line, segment, or
(P, Q)point pair.
- Returns:
Exact simplified spread in \([0, 1]\).
- geometor.model.orientation(A: sympy.geometry.Point, B: sympy.geometry.Point, C: sympy.geometry.Point) int¶
Return
+1if(A, B, C)is counter-clockwise,-1if clockwise,0if collinear.
- geometor.model.quadrance(p1_or_seg: sympy.geometry.Point | sympy.geometry.Segment, p2: sympy.geometry.Point | None = None) sympy.Expr¶
Compute the exact Euclidean quadrance \(Q = (x_2 - x_1)^2 + (y_2 - y_1)^2\).
Accepts either two
sympy.geometry.Pointinstancesquadrance(P, Q)or a singlesympy.geometry.Segmentquadrance(seg).- Parameters:
p1_or_seg – First point
Por a segment/ P Q /.p2 – Second point
Qwhenp1_or_segis a point.
- Returns:
Exact simplified
sympy.Exprwith zero square roots introduced.
- geometor.model.vertex_spread(B: sympy.geometry.Point, A: sympy.geometry.Point, C: sympy.geometry.Point) sympy.Expr¶
Compute the exact spread at vertex
Abetween raysABandAC(< B A C )).- Parameters:
B – Point on the first ray.
A – The vertex of the angle.
C – Point on the second ray.
- Returns:
Exact simplified spread \(s(\angle BAC)\).
- geometor.model.GeometryObject¶
- class geometor.model.Model(name: str = '', logger: logging.Logger | bool | None = None, use_point_subscript: bool = False, *, auto_intersect: bool = True, use_multiprocessing: bool = False, enable_logging: bool | None = None)¶
Bases:
dict,geometor.model.points.PointsMixin,geometor.model.lines.LinesMixin,geometor.model.circles.CirclesMixin,geometor.model.intersections.IntersectionsMixin,geometor.model.polygons.PolygonsMixin,geometor.model.segments.SegmentsMixin,geometor.model.invariants.AnglesMixin,geometor.model.proof.ProofMixin,geometor.model.polynomials.PolynomialsMixin,geometor.model.serialize.SerializeMixin,geometor.model.reports.ReportMixin,geometor.model.delete.DeleteMixin,geometor.model.sections.SectionsMixin,geometor.model.wedges.WedgesMixin,geometor.model.ancestors.AncestorsMixinThe central class representing an exact symbolic geometric construction and proof.
- use_point_subscript = False¶
- auto_intersect = True¶
- use_multiprocessing = False¶
- ID_gen¶
- last_point_id = ''¶
- steps: list[geometor.model.proof.Step] = []¶
- property is_logging_enabled: bool¶
Return
Trueonly when INFO messages have at least one active non-null handler.
- set_analysis_hook(hook_function: collections.abc.Callable | None) None¶
Set a hook function to be called during analysis/point addition.
- set_simplifier(simplifier_function: collections.abc.Callable[[sympy.Expr], sympy.Expr] | None) None¶
Set an optional custom symbolic simplifier for point coordinates.
- property new_points: list[sympy.geometry.Point]¶
The points added since the most recent
clear_new_points().
- __setitem__(key: GeometryObject, value: geometor.model.element.Element) None¶
Set an item in the model, enforcing type checks.
- property structs: list[geometor.model.element.Struct]¶
Return non-guide structural elements (lines or circles) from the model.
- get_element_by_ID¶
- exception geometor.model.ProofAssertionError¶
Bases:
AssertionErrorRaised when a deductive geometric assertion fails exact symbolic verification.
- geometor.model.load_model(file_path: str | pathlib.Path, logger: logging.Logger | bool | None = None) geometor.model.Model¶
Load a
model.jsonfile (v1 or v2) and reconstitute aModel.