Next Article in Journal
Feature Paper Collection of Mathematical and Computational Applications—2025
Previous Article in Journal
Research on Scheduling of Metal Structural Part Blanking Workshop with Feeding Constraints
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Rocq-Based Formalization of Hilbert’s Geometry: Building a Reusable Foundation for 3D Perpendicularity Theory and Verification

Beijing Key Laboratory of Space-Ground Interconnection and Convergence, School of Electronic Engineering, Beijing University of Posts and Telecommunications, Beijing 100876, China
*
Authors to whom correspondence should be addressed.
Math. Comput. Appl. 2026, 31(1), 25; https://doi.org/10.3390/mca31010025
Submission received: 14 October 2025 / Revised: 3 February 2026 / Accepted: 5 February 2026 / Published: 7 February 2026

Abstract

Hilbert’s axiom system for geometry is a landmark in formal methods. This paper presents a complete formalization of spatial perpendicularity—a theory not fully developed in Hilbert’s original work—using the Rocq proof assistant. We systematically defined the relations of perpendicularity between lines and planes based solely on Hilbert’s primitive notions and axioms. Within this framework, we mechanized the proof of a significant spatial congruence theorem that Hilbert stated without proof—a theorem that fundamentally reveals the relationship between congruence and motion. The formal proof of this theorem demonstrates the intrinsic completeness of Hilbert’s system for three-dimensional (3D) space. Crucially, no additional spatial congruence axioms are needed, as all properties are derived rigorously from the original planar axioms. All proofs are mechanically verified by Rocq, ensuring logical correctness. This work completes Hilbert’s geometry system. It also delivers a reusable Rocq library that offers a rigorous foundation for verifying geometric reasoning in safety-critical software systems.

1. Introduction

Euclid’s Elements is widely regarded as the origin of mathematical axiomatization, laying the foundation for geometry [1]. Even today, it continues to influence modern research in areas such as formal systems and verification [2,3]. Euclid’s major contribution was his organization of geometric knowledge through a system of axioms and deductive reasoning, thereby establishing a structured approach to geometry. However, from a strict logical perspective, Euclid’s work contained several limitations: it relied on undefined concepts, included an insufficient set of axioms, and invoked the controversial Fifth Postulate (the Parallel Postulate) [2]. These issues motivated later mathematicians to seek a more logically rigorous axiomatic system for geometry. Among these efforts, Hilbert’s Foundations of Geometry [4] stands out as a landmark achievement.
Hilbert’s Foundations of Geometry has significantly influenced modern mathematics and formal methods. In this work, Hilbert proposed a complete and concise axiom system from which all of Euclidean geometry could be derived without relying on external intuition or assumptions. The achievement marked the birth of the modern axiomatic method [5,6,7]. Hilbert’s axiom system began with three primitive geometric objects—points, lines, and planes—and three basic relations: incidence, betweenness, and congruence. Unlike Euclid, who provided descriptive definitions, Hilbert treated points, lines, and planes as purely abstract entities, emphasizing that their interpretation could be arbitrary—famously stating that one could replace “points, lines, and planes” with “tables, chairs, and beer mugs” without affecting the logical structure [7]. Furthermore, Hilbert reorganized Euclid’s axioms into five logically independent groups: incidence, order, congruence, parallels, and continuity. This clear classification clarified the underlying logical architecture of geometry and provided a robust foundation for further mathematical development.
The formalization of mathematics, which involves encoding mathematical proofs into a computer, has become an essential endeavor in modern computational mathematics and artificial intelligence [8]. This process, known as formalization, relies on programs called proof assistants to verify the correctness of such encoded reasoning [9]. By establishing rigorous mathematical and logical foundations, researchers can advance their work with greater confidence and efficiency [10,11]. Prominent proof assistants currently in use include Rocq, which was formerly known as Coq [12,13,14], Isabelle/HOL [15], HOL Light [16], and Lean [17,18], among others. Each has its own theoretical foundation, distinctive features, and target application scenarios. Rocq, for instance, is an interactive theorem prover based on the Calculus of Inductive Constructions (CIC). It provides highly expressive higher-order logic, enables logical derivation through imperative commands, and supports automated reasoning using previously proven propositions. Its system of inductive types extends traditional type definitions found in functional programming languages, analogous to recursive type constructions [12,13,14]. With the help of proof assistants like Rocq, formalized mathematics may emerge as a new standard of mathematical rigor [19]. Wiedijk describes the current formalization movement as the third mathematical revolution, following Euclid’s introduction of the concept of proof and the development of rigorous methods in the 19th century [9]. Similarly, Buzzard emphasized in an invited lecture at the 2022 International Congress of Mathematicians that mathematicians should employ machines for proof verification, allowing them to concentrate on deeper theoretical problems.
There are many notable achievements in the formalization of complex mathematical theorems. In 2005, Gonthier and Werner used Rocq to provide a computer-aided proof of the Four Color Theorem [20]. Gonthier’s team later verified the Odd Order Theorem in 2012, a process involving approximately 4300 definitions and 15,000 theorems, totaling around 170,000 lines of Rocq code [21]. This achievement has earned Rocq widespread recognition in academia. In 2015, Hales and his team verified the Kepler Conjecture using HOL Light and Isabelle/HOL [22]. In June 2021, Fields Medalist Peter Scholze announced that Lean had verified core parts of his “condensed mathematics” theory [23]. Wiedijk has highlighted in his work that global research teams have completed or plan to complete formal proofs of 100 famous mathematical theorems, including Gödel’s First Incompleteness Theorem, the Jordan Curve Theorem, the Prime Number Theorem, and Fermat’s Last Theorem [9]. These accomplishments have significantly increased the academic influence of proof assistants.
There are also many achievements in the formalization of geometry. In the domain of projective geometry, Magaud, Narboux, and Schreck introduced alternative axiom systems for plane and spatial projective geometry based on the concept of ranks, as a substitute for the traditional framework [24]. They formally verified in Coq that Desargues’ property holds within their system [25]. Subsequently, Braun, Magaud, and Schreck completed a formal proof in Coq demonstrating the mutual interpretability between this system and the traditional axiom sets [26]. Coghetto has also made significant contributions to projective geometry formalization in Mizar, including proofs of Pascal’s theorem in the real projective plane [27]. Furthermore, he developed analytical approaches to duality notions in the real projective plane, enabling concise proofs of dual theorems such as the converses of Desargues’ and Pappus’ theorems through systematic dual definitions [28]. Formalization has also reached complex geometry, notably through Marić and Petrović’s work [29] on the extended complex plane and Möbius transformations. Additionally, the intersection of geometry with non-standard analysis has been explored in Isabelle by Fleuriot, who mechanized geometric propositions from Newton [30] and Kepler [31]. Discrete models of the continuum, such as the Hartong–Reeb line, have also been implemented in both Coq [32] and Isabelle [33], demonstrating the versatility of proof assistants.
Researchers have also shown significant interest in the formalization of Hilbert’s Foundations of Geometry. Dehlinger, Dufourd, and Schreck focused on formalizing the first two groups of axioms, along with several theorems, within the intuitionistic setting of Rocq [34]. Simultaneously, Meikle and Iwama employed Isabelle/HOL to formalize the planar portion of the first three groups of axioms and their associated theorems [35,36,37]. Scott continued Meikle’s work, rectifying some errors and emphasizing code readability [38]. His contribution extended to verifying Theorem 9—the Polygonal Jordan Curve Theorem on the plane—from Foundations of Geometry [39]. Richter also employed HOL Light to formalize Hilbert’s axioms for plane geometry, along with numerous theorems including the Crossbar Theorem and parallelogram properties, in 3300 lines of code, providing a rigorous treatment suitable for high school students [40]. In a parallel effort, Braun, Boutry, and Narboux concentrated primarily on Tarski’s system [41,42]. They confirmed the equivalence between Hilbert’s axioms and Tarski’s axioms in the realm of plane geometry, except for the continuity axiom [43,44,45]. Beeson and Wos explored automated theorem proving in Tarskian geometry, developing methods to find proofs within Tarski’s axiom system and deriving Hilbert’s 1899 axioms from Tarski’s axioms [46]. Grabowski and Coghetto focused on formalizing Tarski’s in Mizar, developing advanced techniques with structures, inheritance, and automated theorem proving, while proving that the Euclidean plane satisfies all eleven of Tarski’s axioms and demonstrating the parallel postulate’s independence [47]. Their comprehensive series spans five parts, systematically formalizing Schwabhäuser, Szmielew, and Tarski’s foundational work on geometry [48,49,50,51].
This collective endeavor has largely completed the formalization of planar geometry within Hilbert’s system. However, a transition to three-dimensional space introduces formidable new challenges. Formalizing spatial geometry, particularly concepts like perpendicularity between lines and planes, demands managing a vastly increased complexity of incidence relations and geometric configurations that have no direct analog in the plane. Proving spatial theorems often requires novel constructive methods and a rigorous chain of derived lemmas that cannot be straightforwardly extrapolated from their planar counterparts. Consequently, while the planar foundation is robust, the spatial theory of perpendicularity—a cornerstone of solid geometry—remains a significant gap in the formalization of Hilbert’s work.
Our work addresses this gap by presenting the complete formalization of 3D perpendicularity theory within the Rocq proof assistant, which is publicly available at: https://github.com/a-qmeng/Formal-Hilbert-Geometry (accessed on 14 October 2025). We begin with a full encoding of Hilbert’s primitive notions and axiom groups, then systematically develop the theory of spatial perpendicularity with machine-verified proofs, and finally apply this framework to prove Hilbert’s previously unproven spatial congruence theorem. The paper is structured as follows: Section 2 details our formalization of Hilbert’s first three axiom groups (incidence, order, and congruence), which serve as the basis for all subsequent work. In Section 3, we formalize basic geometry propositions derivable from these axioms, creating the necessary groundwork for spatial theory. Section 4 presents our core contribution: the systematic construction of spatial perpendicularity theory, including formal definitions and machine-verified properties. Section 5 demonstrates the power of this theory by applying it to the computer-verified proof of Hilbert’s spatial congruence theorem. The paper concludes in Section 7 with a summary of contributions and future research directions.

2. Hilbert’s Axioms and Formalizations

In this section, we delve into the formalization of Hilbert’s first three groups of axioms (incidence, order, and congruence), which provide the necessary foundation for all subsequent works.

2.1. Group I

There are 8 axioms in Group I that establish the incidence relations between three basic entities: points, lines, and planes. These axioms articulate fundamental geometric truths, such as the determinations of a line by two points, a plane by three points, and the existence of non-collinear and non-coplanar points. The details of these axioms are available in [4], we focus here on the formalization process.
Before formalizing the axioms, we first establish the fundamental geometric entities and their incidence relations in Rocq. Using the Parameter declaration (see Appendix A for an introduction to Rocq syntax), we define points, lines, and planes as distinct types, along with their basic incidence relations:
  • Parameter Point Line Plane : Set.
  • Parameter Incid : Point -> Line -> Prop(* Point-line incidence *)
  • Parameter Incid_P_F : Point -> Plane -> Prop(* Point-plane incidence *)
  • (* Line-plane incidence: a line lies on a plane if all its points do *)
  • Definition Incid_L_F (l : Line) (f : Plane) : Prop :=
  •   forall A, Incid A l -> Incid_P_F A f.
Based on these definitions, we further formalize collinearity (three points on a line) and coplanarity (four points on a plane):
  • Definition ColH (A B C : Point) : Prop :=
  •   exists l, Incid A l /\ Incid B l /\ Incid C l.
  • Definition Cof A B C D := exists f, Incid_P_F A f /\
  •   Incid_P_F B f /\ Incid_P_F C f /\ Incid_P_F D f.
Now we can formalize the axioms of Group I as follows:
  • Axiom Incid_1 : forall A B, A<>B -> exists l, Incid A l /\ Incid B l.
  • Axiom Incid_2 : forall A B l1 l2, A<>B ->
  •   Incid A l1 -> Incid B l1 ->Incid A l2 -> Incid B l2 -> l1=l2.
  • Axiom Incid_3_1 : forall l, exists A B, A<>B /\ Incid A l /\ Incid B l.
  • Axiom Incid_3_2 : exists A B C, ~ ColH A B C.
  • Axiom Incid_4_1 : forall A B C, ~ ColH A B C -> exists! f,
  •   Incid_P_F A f /\ Incid_P_F B f /\ Incid_P_F C f.
  • Axiom Incid_4_2 : forall f, exists A, Incid_P_F A f.
  • Axiom Incid_6 : forall l f A B, A<>B -> Incid A l -> Incid B l ->
  •   Incid_P_F A f -> Incid_P_F B f -> Incid_L_F l f.
  • Axiom Incid_7 : forall A f1 f2, f1<>f2 -> Incid_P_F A f1 -> Incid_P_F A f2 ->
  •   exists B, A<>B /\ Incid_P_F B f1 /\ Incid_P_F B f2.
  • Axiom Incid_8 : exists A B C D,  ~ Cof A B C D.

2.2. Group II

The second group of axioms defines the concept of “betweenness” (denoted BetH), which establishes an order for points on lines, in planes, and in space. We begin by defining the betweenness relation. The first three axioms establish its basic geometric properties.
  • Parameter BetH : Point -> Point -> Point -> Prop(* B is between A and C *)
  • Axiom BetH_1_1 : forall A B C, BetH A B C -> ColH A B C.
  • Axiom BetH_1_2 : forall A B C, BetH A B C -> A <> C.
  • Axiom BetH_1_3 : forall A B C, BetH A B C -> BetH C B A.
  • Axiom BetH_2 : forall A B, A <> B -> exists C, BetH A B C.
  • Axiom BetH_3 : forall A B C, BetH A B C -> ~ BetH B C A.
Axiom II, 4 (Pasch’s Axiom) states that if a line enters the interior of a triangle, it must exit again. We first formalize the key concept of a line cutting a segment.
  • (* line l intersects segment AB *)
  • Definition cut (l : Line) (A B : Point) :=
  •  ~ Incid A l /\ ~ Incid B l /\ exists I, Incid I l /\ BetH A I B.
  • (* Pasch’s Axiom *)
  • Axiom BetH_4: forall A B C l (H: ~ ColH A B C),
  •   (forall D, Incid D l -> Cof A B C D) ->
  •   ~ Incid C l -> cut l A B -> cut l A C \/ cut l B C.
Removing the condition that the line l lies on the plane A B C in Pasch’s Axiom restricts the space to two dimensions. Dehlinger and Iwama’s work omits this condition from their formal description [34,35,36], while Scott and Boutry include it by introducing a plane f and specifying four conditions involving points A, B, C, and line l within that plane [39,43]. Our approach uses the assumption (forall D, Incid D l -> Cof A B C D) to avoid introducing a plane f. Notably, our formalization does not complicate subsequent verification efforts.
Building upon the primitive notion of betweenness (BetH) and the intersection relation (cut), we can also introduce key derived geometric concepts essential for further development. These definitions formalize the intuitive notions of points lying on the “same side” or “opposite side” relative to a point, a line, or a plane.
  • (* Points A and A’ are on the same side of Point O *)
  • Definition Ipsilateral_P A A’ O :=
  •   A <> O /\ A’ <> O /\ ColH A O A’ /\ ~ BetH A O A’.
  • (* Points A and B are on the different sides of Point O *)
  • Definition Heteromeral_P A B O := BetH A O B.
  • (*  Points A and A’ are on the same side of line l *)
  • Definition Ipsilateral_L A A’ l := exists P, cut l A P /\ cut l A’ P.
  • (*   Points A and B are on the different sides of line l *)
  • Definition Heteromeral_L A B l := cut l A B.
  • (* Points C and D are on the same side of line AB *)
  • Definition Ipsilateral_S A B C D := A<>B /\
  •   forall l, Incid A l -> Incid B l -> Ipsilateral_L C D l.
  • (* Points C and D are on the different sides of line AB *)
  • Definition Heteromeral_S A B C D := A<>B /\
  •   forall l, Incid A l -> Incid B l -> cut l C D.
  • (* Points A and B are on the same side of flat f *)
  • Definition Ipsilateral_f A A’ f := ~ Incid_P_F A f /\ ~ Incid_P_F A’ f /\
  •   ~ (exists P, BetH A P A’ /\ Incid_P_F P f).
  • (* Points A and B are on the different sides of flat f *)
  • Definition Heteromeral_f A B f := ~ Incid_P_F A f /\ ~ Incid_P_F B f /\
  •   (exists P, BetH A P B /\ Incid_P_F P f).
A significant design choice in our formalization concerns the definition of two points being on the same side of a line. Hilbert’s original definition, which can be formalized as Ipl_S_Hil, is plane-dependent: it requires specifying a plane f containing the points and the line, and states that the segment A A does not intersect l [4].
  • Definition Ipl_S_Hil A A’ l f := Incid_P_F A f /\ Incid_P_F A’ f /\
  •   Incid_L_F l f /\ ~ Incid A l /\ ~ Incid A’ l /\ ~ cut l A A’.
In contrast, our definition Ipsilateral_L, inspired by Braun’s description of Tarski’s system [44], is intrinsic and operates without reference to an ambient plane. It states that points A and A are on the same side of l if there exists a point P such that both segments A P and A P are intersected by l. The equivalence of Ipsilateral_L and Ipl_S_Hil has been proven in our prior work [52]. Other researchers, like Scott and Iwama, have followed Hilbert’s original description by using Ipl_S_Hil. However, we chose Ipsilateral_L because it does not include plane parameters, thereby simplifying and streamlining subsequent formalization.

2.3. Group III

Hilbert’s third group of axioms introduces the concept of congruence for segments and angles, which is fundamental to Euclidean geometry. This group consists of five axioms: three governing segment congruence, one for angle congruence, and one connecting the two via the triangle congruence condition (SAS). Our formalization captures these notions Rocq as follows.

2.3.1. Congruence of Segments

We begin by declaring a primitive relation “CongH A B C D”, meaning segment A B and segment C D are congruent, which can be denoted as A B C D .
  • Parameter CongH : Point -> Point -> Point -> Point -> Prop.
The axioms about segment congruence can be formally described as follows:
  • Axiom CongH_1 : forall A B A’ P, A<>B -> A’<>P ->
  •   exists B’, Ipsilateral_P B’ P A’ /\ CongH A B A’ B’.
  • Axiom CongH_2 : forall A B C D E F, A<>B -> C<>D -> E<>F ->
  •   CongH A B E F -> CongH C D E F -> CongH A B C D.
  • Axiom CongH_3 : forall A B C A’ B’ C’, BetH A B C->
  •   BetH A’ B’ C’ -> CongH A B A’ B’ -> CongH B C B’ C’-> CongH A C A’ C’.
From these axioms, we derive three fundamental corollaries that establish key properties of segment congruence.
  • (* Reflexivity *)
  • Corollary CongH_self : forall A B, A<>B -> CongH A B A B.
  • (* Symmetry *)
  • Corollary CongH_symmetry : forall A B C D, A<>B -> C<>D ->
  •   CongH A B C D -> CongH C D A B.
  • (* Transitivity *)
  • Corollary CongH_transitivity : forall A B C D E F, A<>B ->
  •   C<>D -> E<>F -> CongH A B C D -> CongH C D E F -> CongH A B E F.
Hilbert emphasizes that congruence is a property of the segment itself, independent of the order of its endpoints. To capture this, we add the following axiom, from which all other permutations can be derived.
  • Axiom CongH_exc34 : forall A B C D, A<>B -> C<>D ->
  •   CongH A B C D -> CongH A B D C.

2.3.2. Congruence of Angles

We now introduce angle congruence, denoted “CongaH A B C D E F” for A B C D E F . The primary axiom for angles (Axiom III.4) states that an angle can be uniquely transferred to a given ray in a specified half-plane.
  • Parameter CongaH : Point -> Point -> Point -> Point -> Point -> Point -> Prop.
  • Axiom CongH_4_exists : forall A B C P’ A’ B’, ~ ColH A B C -> ~ ColH A’ B’ P’ ->
  •   exists C’, Ipsilateral_S A’ B’ C’ P’ /\ CongaH A B C A’ B’ C’.
  • Axiom CongH_4_unique : forall A B C P’ A’ B’ C’ D’, ~ ColH A B C ->
  •   ~ ColH A’ B’ P’ -> Ipsilateral_S A’ B’ C’ P’ -> Ipsilateral_S A’ B’ D’ P’ ->
  •   CongaH A B C A’ B’ C’ -> CongaH A B C A’ B’ D’ -> Ipsilateral_P C’ D’ B’.
  • Axiom CongH_4_self : forall A B C, ~ ColH A B C -> CongaH A B C A B C.
Similar to segments, the congruence of angles is independent of the order of the rays. We formalize this with an exchange axiom and an additional axiom stating that congruent angles remain congruent when their sides are extended.
  • Axiom CongH_4_exc : forall A B C D E F, CongaH A B C D E F ->
  •   CongaH A B C F E D /\ CongaH C B A D E F /\ CongaH C B A F E D.
  • (* Congruence is preserved under extension of the angle’s sides *)
  • Axiom CongH_4_CongaH : forall A B C D E F A’ C’ D’ F’, ~ ColH A B C ->
  •   ~ ColH D E F -> CongaH A B C D E F -> Ipsilateral_P A A’ B ->
  •   Ipsilateral_P C C’ B -> Ipsilateral_P D D’ E ->
  •   Ipsilateral_P F F’ E -> CongaH A’ B C’ D’ E F’.

2.3.3. The Side-Angle-Side (SAS) Axiom

Axiom III, 5 (SAS Axiom) plays a crucial role in Group III. It gives the connection between the congruence of segments and the congruence of angles. It posits that if two sides and the included angle of one triangle are congruent to those of another, then the corresponding angles opposite the first congruent side are also congruent.
  • Axiom CongH_5 : forall A B C A’ B’ C’, ~ ColH A B C ->
  •   ~ ColH A’ B’ C’ -> CongH A B A’ B’ -> CongH A C A’ C’ ->
  •   CongaH B A C B’ A’ C’ -> CongaH A B C A’ B’ C’.
This completes the formalization of Hilbert’s congruence axioms, providing the foundation for all subsequent results about congruent triangles and geometric equality.

3. Formalization of Elementary Consequences

Having established Hilbert’s axiom system in Rocq, we now present a suite of fundamental geometric theories formally derived from these axioms. The development of these theories is crucial, as they form the bedrock for our subsequent construction of the spatial perpendicularity theory.

3.1. Key Lemmas About Order and Congruence

The initial step involves deriving essential, often non-trivial, lemmas that extend the axiomatic foundation. These results, while not explicitly stated in Hilbert’s original work, are indispensable for more complex proofs.

3.1.1. Original Lemmas for Spatial Order

We first introduce two original lemmas concerning point–plane relationships that are critical for 3D reasoning. These lemmas address the geometric configuration when a point lies outside a given line or plane.
  • Lemma exists_He : forall A B C P, Cof A B C P -> ~ ColH A B C ->
  •   ~ ColH A B P -> exists P’, ColH A C P’ /\ Heteromeral_S A B P P’.
  • Lemma exists_uncof : forall f A B D P, ~ Incid_P_F D f
  •   -> ~ Incid_P_F P f -> Incid_P_F A f -> ~ Cof A B D P
  •   -> exists Q, Cof A B D Q /\ Heteromeral_f Q P f.
exists_He: Given a point P on the plane A B C , where the P does not lie on the line A B , there exists a distinct point P along the line A C , ensuring that P and P are on opposite sides of the line A B .
exists_uncof: Given two different planes, f and A B D , which are share a common point A, and a point P not lying on either plane, there exists a point Q situated on plane A B D such that P and Q are on opposite sides of plane f.

3.1.2. Strengthening the Congruence Axioms

We further establish stronger properties of segment congruence, such as the uniqueness of segment transfer and a variant for segment subtraction, which are implied by but not explicit in Hilbert’s axioms.
  • Corollary CongH_1_unique : forall A B A’ P B’ B’’, A <> B -> A’ <> P ->
  •   Ipsilateral_P B’ P A’ -> Ipsilateral_P B’’ P A’->
  •   CongH A B A’ B’ -> CongH A B A’ B’’ -> B’=B’’.
  • Corollary CongH_3_BetH : forall A B C A’ B’ C’, BetH A B C -> BetH A’ B’ C’ ->
  •   CongH A C A’ C’ -> CongH A B A’ B’ -> CongH B C B’ C’.
  • Corollary CongH_3_exists_Ips : forall A B C A’ B’, Ipsilateral_P B C A ->
  •   B<>C -> A’<>B’ -> CongH A B A’ B’ -> exists C’, Ipsilateral_P B’ C’ A’ /\
  •   CongH A C A’ C’ /\ CongH B C B’ C’ /\ C’<>B’.
CongH_1_unique establishes the uniqueness of segment transfer, derived from the uniqueness of angle transfer and Axiom III, 5. CongH_3_BetH is a variant of CongH_3, requiring the subtraction of segments.
Using CongH_1_unique and CongH_3, we can derive CongH_3_exists_Ips: Given three points A, B, and C on a line, with B and C on the same side of A, we can assert that for any segment A B congruent to A B , there exists a point C on the line A B ensuring that B and C are on the same side of A , and A C A C , B C B C .

3.2. Hilbert’s Key Theorems

In this subsection, we present several important theorems from Hilbert’s Foundations of Geometry.

3.2.1. Theorems on Triangle Congruence

We define triangle congruence (CongtH) and prove the three classic criteria: SAS (Theorem12), ASA (Theorem13), and SSS (Theorem18). Their machine-verified proofs validate the logical soundness of Hilbert’s system.
  • Definition CongtH A B C A’ B’ C’ := ~ ColH A B C /\ ~ ColH A’ B’ C’ /\
  • CongH A B A’ B’ /\ CongH A C A’ C’ /\
  • CongH B C B’ C’ /\ CongaH B A C B’ A’ C’ /\
  • CongaH A B C A’ B’ C’ /\ CongaH A C B A’ C’ B’.
  • Theorem Theorem12 : forall A B C A’ B’ C’, ~ ColH A B C -> ~ ColH A’ B’ C’ ->
  • CongH A B A’ B’ -> CongH A C A’ C’ ->
  • CongaH B A C B’ A’ C’ -> CongtH A B C A’ B’ C’.
  • Theorem Theorem13 : forall A B C A’ B’ C’, ~ ColH A B C -> ~ ColH A’ B’ C’ ->
  • CongH A B A’ B’ -> CongaH B A C B’ A’ C’ ->
  • CongaH A B C A’ B’ C’ -> CongtH A B C A’ B’ C’.
  • Theorem Theorem18 : forall A B C A’ B’ C’, ~ ColH A B C -> ~ ColH A’ B’ C’ ->
  • CongH A B A’ B’ -> CongH A C A’ C’ ->
  • CongH B C B’ C’ -> CongtH A B C A’ B’ C’.

3.2.2. Theorem on Angles and Midpoints

We begin by formalizing the concept of a right angle, defined as an angle congruent to its supplement.
  • Definition Right_angle A B C := ~ ColH A B C /\
  •   forall C’, BetH C B C’ -> CongaH A B C A B C’.
The significance of right angles is established through the following key results, with (Theorem21) being particularly fundamental.
  • Theorem Theorem21 : forall A B C A’ B’ C’, Right_angle A B C ->
  •   Right_angle A’ B’ C’ -> CongaH A B C A’ B’ C’.
  • Corollary Cor_Theorem21 : forall A B C A’ B’ C’, ~ ColH A’ B’ C’ ->
  •   CongaH A B C A’ B’ C’ -> Right_angle A B C -> Right_angle A’ B’ C’.
(Theorem14) establishes the critical behavior of angles with respect to supplementation, from which important corollaries about vertical angles and the existence of right angles follow.
  • Theorem Theorem14 : forall A B C D A’ B’ C’ D’, ~ ColH A B C ->
  •   ~ ColH A’ B’ C’ -> BetH A B D -> BetH A’ B’ D’ ->
  •   CongaH A B C A’ B’ C’ -> CongaH C B D C’ B’ D’.
  • Corollary Cor1_Theorem14 : forall A B C A’ C’, ~ ColH A B C ->
  •   BetH A B A’ -> BetH C B C’-> CongaH C’ B A’ A B C.
  • Corollary Cor2_Theorem14 : exists A B C, Right_angle A B C.
(Theorem19) establishes that angle congruence is an equivalence relation, a property not directly assumed by Hilbert’s axioms but derived from them.
  • Theorem Theorem19 : forall H O K H’ O’ K’ H’’ O’’ K’’, ~ ColH H O K ->
  •   ~ ColH H’ O’ K’ -> ~ ColH H’’ O’’ K’’ -> CongaH H’ O’ K’ H O K ->
  •   CongaH H’’ O’’ K’’ H O K -> CongaH H’ O’ K’ H’’ O’’ K’’.
  • Corollary CongaH_symmetry : forall A B C A’ B’ C’, ~ ColH A B C ->
  •   ~ ColH A’ B’ C’ -> CongaH A B C A’ B’ C’ -> CongaH A’ B’ C’ A B C.
  • Corollary CongaH_trans : forall A B C A’ B’ C’ A’’ B’’ C’’, ~ ColH A B C ->
  •   ~ ColH A’ B’ C’ -> ~ ColH A’’ B’’ C’’ -> CongaH A B C A’ B’ C’ ->
  •   CongaH A’ B’ C’ A’’ B’’ C’’ -> CongaH A B C A’’ B’’ C’’.
(Theorem26) resolves the fundamental geometric construction of finding the midpoint of a segment, relying critically on the properties of congruence and betweenness.
  • Definition MidPoint C A B := BetH A C B /\ CongH A C B C.
  • Theorem Theorem26 : forall A B, A<>B -> exists C, MidPoint C A B.

3.3. Advanced Lemmas on Congruence and Configuration

The final set of lemmas establishes profound connections between congruence and geometric configurations.
The following lemmas establish relationships between congruent segments and their corresponding collinear and non-collinear configurations.
  • Definition diff_th (A B C : Point) := A<>B /\ A<>C /\ B<>C.
  • Lemma Cong_colh : forall A B C A’ B’ C’, diff_th A B C -> CongH A B A’ B’ ->
  •   CongH A C A’ C’ -> CongH B C B’ C’ -> ColH A B C -> ColH A’ B’ C’.
  • Lemma Cong_uncolh : forall A B C A’ B’ C’, diff_th A’ B’ C’ -> CongH A B A’ B’ ->
  •   CongH A C A’ C’ -> CongH B C B’ C’ -> ~ ColH A B C -> ~ ColH A’ B’ C’.
  • Lemma Cong_bet : forall A B C A’ B’ C’, A’<>B’ -> A’<>C’ -> CongH A B A’ B’ ->
  •   CongH A C A’ C’ -> CongH B C B’ C’ -> BetH A B C -> BetH A’ B’ C’.
  • Lemma Cong_Ips : forall A B C A’ B’ C’, A <> B -> A’<>B’ ->
  •   A’<>C’ -> B’<>C’ -> CongH A B A’ B’-> CongH A C A’ C’ ->
  •   CongH B C B’ C’ -> Ipsilateral_P A B C -> Ipsilateral_P A’ B’ C’.
These lemmas collectively state that if two sets of points are pairwise congruent ( A B A B , A C A C , B C B C , ) then the configuration is preserved. Specifically, if points A, B, and C are collinear, points A , B , and C are also collinear, with the same order as A, B, and C. Conversely, if points A, B, and C are non-collinear, then points A , B , and C are likewise non-collinear.
Building upon the previous results, the next lemmas handle more complex scenarios involving a fourth point, demonstrating that congruence can be extended consistently.
  • Lemma CongH_colh : forall A B C P A’ B’ C’ P’, P<>C -> B<>P ->
  •   B’<>P’ -> A<>C -> B<>C -> A’<>C’ -> B’<>C’ ->
  •   Ipsilateral_P B P A -> Ipsilateral_P B’ P’ A’ ->
  •   ColH A B C -> CongH C A C’ A’ -> CongH C B C’ B’->
  •   CongH A B A’ B’ -> CongH A P A’ P’ ->
  •   CongH B P B’ P’ -> CongH C P C’ P’
  • Lemma CongH_col : forall A B C P A’ B’ C’ P’,
  •   ~ ColH A B C -> diff_th A’ B’ C’ ->
  •   CongH A B A’ B’ -> CongH A C A’ C’ -> CongH B C B’ C’ ->
  •   ColH A B P -> A<>P -> B<>P -> A’<>P’ -> B’<>P’->
  •   CongH A P A’ P’ -> CongH B P B’ P’ -> CongH C P C’ P’.
CongH_colh and CongH_col establish congruence relationships based on the congruence of three segments. Specifically, if segments A B , A C , and B C are congruent to segments A B , A C , and B C respectively, and points P and P are chosen on lines A B and A B in such a way that A P A P and B P B P , then C P C P holds, regardless of whether points A, B, and C share a common line.
The final lemmas leverage the concept of midpoints to establish deep spatial relationships, which are pivotal for our later work on perpendicularity and symmetry.
  • Lemma Midpoint_Conga : forall A A’ B B’ C C’ M, ~ ColH A B C ->
  •   MidPoint M A A’ -> MidPoint M B B’ ->
  •   MidPoint M C C’ -> CongaH A B C A’ B’ C’.
  • Lemma Mid_Cong_BetH : forall A O B A’ B’ P Q, ~ ColH A O B ->
  •   BetH A O A’ -> BetH B O B’ ->
  •   CongH O A O B -> CongH O A’ O B’ ->
  •   MidPoint P A B -> MidPoint Q A’ B’ -> BetH P O Q.
Midpoint_Conga states that if point M is the midpoint of segments A A , B B , and C C , then A B C A B C . Mid_Cong_BetH states that if segments A A and B B intersect at point O, with O A O B , O A O B , and if P and Q are the midpoints of segments A B and A B respectively, then point O lies between P and Q.

4. Establishment of Perpendicularity Theory in Hilbert’s System

A significant gap in Hilbert’s Foundations of Geometry and its subsequent formalizations is the lack of a rigorous theory of perpendicularity for lines and planes in three-dimensional space. Although Hilbert defines the concept of a right angle, he does not systematically extend it to establish fundamental properties of spatial perpendicularity, such as the existence and uniqueness of perpendiculars from a point to a line or a plane.
The primary objective of this section is to demonstrate how, starting strictly from Hilbert’s axioms, one can rigorously prove the essential properties concerning perpendicularity between lines and planes. We construct this theory from the ground up, formalizing and machine-verifying it in Rocq.

4.1. Foundation Definitions and Planar Propositions

Based on Hilbert’s system, perpendicularity can be understood as follows:
  • Line–Line Perpendicularity: Given a right angle P B A , we can say that the line P B is perpendicular to the line A B , with B as the intersection point. P B is also referred to as the perpendicular to A B .
  • Line–Plane Perpendicularity: If point A lies outside the plane f, and B is a point on f, such that for any other point C on the plane f, angle A B C is a right angle, we say that the line A B is perpendicular to the plane f, with B as the foot of the perpendicular. The line A B is also called the perpendicular to f.
With these definitions in place, we begin the first stage of our theory, establishing critical planar properties that serve as the building blocks for spatial reasoning.
Proposition 1.
Given points A, B, C, and P, where P is outside line A B , and B is the midpoint of segment A C , if P A P C , then angle P B A is a right angle.
Proposition 2.
Given points A, B, C, and P, where B is the midpoint of segment A C and angle P B A is a right angle, then P A P C .
The above two propositions are inverse relations that link perpendicularity to symmetric distances, proven using triangle congruence theorems (Theorem18, Theorem12).
Having established a basic characterisation of perpendicularity, we now prove the following uniqueness property: in a given plane, there is only one perpendicular direction to a line through a point on it.
Proposition 3.
Given two angles, A B C and A B D , on a plane, if both are right angles, then points B, C, and D must be collinear.
Proof. 
Points C and D lie either on the same side or on opposite sides of line A B .
When C and D are on the same side of the line A B , both A B C and A B D are right angles. According to Theorem21, A B C A B D . Then, by the uniqueness of angle transfer, points C and D are positioned on the same side of B, making B, C, and D collinear.
When C and D reside on opposite sides of line A B , we consider another point C on line B C such that C and C are positioned on different sides of point B. Thus, C and D share the same side of line A B . According to the definition of a right angle, A B C A B C . Since angle A B C is a right angle, by Cor_Theorem21, angle A B C is also a right angle. From the above proof, it follows that points B, C , and D are collinear. Hence, D lies on line B C . Moreover, since C lies on line B C , B, C, and D are also situated on the same line.    □
The natural progression from uniqueness is to establish existence. The next proposition guarantees that a perpendicular line can always be constructed from a point on a given line.
Proposition 4.
Given three points A, B, and P not lying on the same line, there must exist a point C such that the angle A B C forms a right angle, and C and P are positioned on the same side of the line A B . In other words, a perpendicular can be drawn from a point on the given line.
Proof. 
According to Cor2_Theorem14, a right angle exists, denoted as angle A B C . According to Hilbert’s Axiom III, 4 (CongH_4_exists), an angle A B C , congruent to angle A B C , can be constructed with ray B A serving as one of its sides, and C lies on the side of line A B as point P. According to Cor_Theorem21, angle A B C is also a right angle.    □

4.2. Key Properties About Line–Line Perpendicularity

Next, we address the fundamental problem of dropping a perpendicular from an external point to a line. This is a much more complex construction than the previous propositions.
Proposition 5.
Given a line l and a point C that does not lie on l, there exists a point X on l such that, for any other point X also on the line l, the angle C X X forms a right angle. In other words, through a point C external to line l, a perpendicular can always be drawn to l.
Proof. 
By Incid_3_1, two distinct points, A and B, lie on the line l (see Figure 1). A point Y is chosen on line l such that Y and B are situated on opposite sides of point A and A C A Y .
The midpoint of segment Y C is denoted as P (Theorem26). A point Z is selected on line l such that Z and A are on opposite sides of point Y and Y P Y Z . A point Q is chosen on line Y P , ensuring that points Q and P lie on opposite sides of point Y and Y A Y Q . Thus, Q and C are also situated on opposite sides of Y. A point Q is chosen on line Z Q in such a way that Q and Q are on opposite sides of point Z and Q Z Q Z . In other words, Z serves as the midpoint of segment Q Q . A point C is chosen on line Y Q such that C and Q are situated on opposite sides of point Y and Y C Y C . The midpoint of segment C C is denoted as X.
We assert that X is the desired point.
According to Theorem18, triangle Y P A is congruent to triangle C P A . Thus, Y P A C P A . And P lies between Y and C. By the definition of a right angle, angle Y P A is a right angle. In triangles Y Z Q and Y P A , according to Cor1_Theorem14, we have Z Y Q P Y A and Y A Y Q , Y Z Y P . According to Theorem12, these two triangles are congruent, so Y Z Q Y P A . Thus, Y Z Q is also a right angle (Cor_Theorem21). By the definition of a right angle, angle Y Z Q is congruent to its supplementary angle Y Z Q , and we have Q Z Q Z , Z Y Z Y . According to Theorem12, Y Q Y Q . And according to Mid_Cong_BetH, Y lies between Z and X, meaning X lies on line l. According to Theorem18, triangle C Y X is congruent to C Y X . Thus, angle C X Y is congruent to angle C X Y , with X lying between C and C . By the definition of a right angle, angle C X Y is a right angle.
For any other point X on line l, angle C X X either coincides with angle C X Y or is complementary to angle C X Y . In either case, angle C X X is a right angle. Therefore, X is the desired point.    □
We then prove a powerful spatial congruence theorem that is essential for transferring angle measures between different perpendicular setups.
Proposition 6.
Given six points A, B, C, A , B , and C in space (see Figure 2), where A, B, and C are not on the same line, points B and B lie on the same side of the line A A , and points C and C also lie on the same side of the line A A ,  if the lines A B and A C are perpendicular to the line A A at point A, and the lines A B and A C are perpendicular to the line A A at point A , then we have
B A C B A C .
Proof. 
M denotes the midpoint of segment A A . Points B and C are chosen on lines B M and C M , respectively, such that M is the midpoint of segments B B and C C . According to Midpoint_Conga, B A C B A C . In triangles B M A and B M A , by Cor1_Theorem14, B M A B M A . Moreover, A M A M , B M B M . Thus, by Hil_Theorem12, B A M B A M .
Since B A M coincides with B A A , B A M is a right angle. Therefore, by Cor_Theorem21, B A M is also a right angle. Similarly, B A M coincides with B A A , indicating that B A A is a right angle. By Proposition 3, points B , A , and B are collinear, and B and B are positioned on opposite sides of A . Similarly, it is easy to prove that C , A , and C are collinear, with C and C on opposite sides of A .
Angles B A C and B A C are vertical angles, so B A C B A C .
Therefore, both B A C and B A C are congruent to B A C . According to Theorem19, B A C B A C .    □

4.3. Key Properties About Line–Plane Perpendicularity

Next, we investigate the properties of perpendicularity between lines and planes.
Proposition 7.
Given four points A, B, C, D in space. If angles A B C and A B D are right angles and points B, C, D are not collinear, then for any other point E on the plane B C D , angle A B E is also a right angle. In other words, a line perpendicular to two intersecting lines in a plane is perpendicular to that plane.
Proof. 
A point A is chosen on the line A B in such a way that B is the midpoint of the segment A A . According to Proposition 2, we have: A C A C , A D A D . Furthermore, since A B A B , by uncol_cong, for any point E on the plane B C D , A E A E . According to Proposition 1, angle A B E is a right angle.    □
Proposition 8.
Given points P, Q, P , Q and a plane A B C , where P Q is perpendicular to the plane A B C , with Q as the intersection point, and point Q lies on the plane A B C while P lies on the plane P Q Q . If angle P Q Q is a right angle, then P Q is perpendicular to plane A B C .
Proof. 
P and P are either on opposite sides or situated on the same side of the line Q Q .
When P and P are situated on the same side of the line Q Q , a perpendicular C Q is drawn through point Q on the plane A B C , forming a right angle C Q Q . Then, through point Q , another perpendicular C Q is drawn on the plane A B C , also forming a right angle C Q Q and ensuring that points C and C are on the same side of the line Q Q .
Since P Q is the perpendicular from the plane A B C , angles P Q Q and P Q C are also right angles. According to Proposition 6, P Q C P Q C . Therefore, by Cor_Theorem21, angle P Q C is also a right angle. According to Proposition 7, the line P Q is perpendicular to the plane A B C .
When P and P are located on opposite sides of the line Q Q , we select a point P lying on the line P Q in such a way that Q lies between P and P . This ensures that P and P are situated on the same side of Q Q . P Q Q forms a right angle. According to the definition of a right angle, angle P Q Q is also a right angle. Following the previous proof, the line P Q is perpendicular to the plane A B C , and since P lies on the line P Q , it follows that P Q is also perpendicular to the plane A B C .    □
Proposition 9.
For any plane A B C and a point P outside the plane, There exists a specific point D on the plane such that for any other point E on the plane, the angle E D P is a right angle. In other words, a perpendicular can be drawn from a point outside a plane to the plane.
Proof. 
Draw a line l within the plane A B C . A perpendicular line is drawn from point P to line l, and its foot is denoted as D 0 . For any other point Q on line l, the angle P D 0 Q is a right angle. On the plane A B C , construct the perpendicular line D 0 D 1 to the given line l. If P D 0 is perpendicular to D 0 D 1 , then according to Proposition 7, P D 0 is perpendicular to the plane A B C , and D 0 is the desired point.
If P D 0 is not perpendicular to D 0 D 1 , a perpendicular line is drawn from point P to line D 0 D 1 , and its foot is denoted as D. We assert that D is the desired point.
Angle P D D _ 0 is already a right angle. If P D is also perpendicular to line D Q , meaning angle P D Q is a right angle, then according to Proposition 7, P D is perpendicular to the plane A B C .
On the lines P D , D 0 D , and Q D , points P , D 0 , and Q are chosen respectively, in such a way that D serves as the midpoint of the the segments P P , D 0 D 0 , and Q Q . According to Midpoint_Conga, angle P D 0 Q is congruent to angle P D 0 Q .
Since angles P D 0 Q and D D 0 Q are right angles, and according to Proposition 7, line D 0 Q is perpendicular to plane P D D 0 . Since point P lies on a plane P D D 0 , angle P D 0 Q is a right angle. According to Cor_Theorem21, angle P D 0 Q is also a right angle. Therefore, by Theorem21, P D 0 Q P D 0 Q .
In triangles D D 0 Q and D D 0 Q ,
D Q D Q , D D 0 D D 0 , D 0 D Q D 0 D Q .
By Hil_T12, triangles D D 0 Q and D D 0 Q are congruent, so D 0 Q D 0 Q . And by Proposition 2, D 0 P D 0 P . Therefore, by Theorem12, triangles P D 0 Q and P D 0 Q are congruent, so P Q P Q . Since D is the midpoint of Q Q , according to Proposition 1, P D Q is a right angle.    □

4.4. Formalization Summary

The Rocq formalization code of the above propositions is as follows:
  • Proposition Per_Mid : forall A B C P, ~ ColH P B A ->
  •   MidPoint B A C -> CongH P A P C -> Right_angle P B A.
  • Proposition Mid_Per : forall A B C P, MidPoint B A C ->
  •   Right_angle P B A -> CongH P A P C.
  • Proposition ColH_Right : forall A B C D, Cof A B C D ->
  •   Right_angle A B C -> Right_angle A B D -> ColH B C D.
  • Proposition  Right_exists : forall A B P, ~ ColH A B P ->
  •   exists C, Right_angle A B C /\ Ipsilateral_S A B C P.
  • Proposition Right_exists_to_line : forall l C, ~ Incid C l ->
  •   exists X, Incid X l /\
  •  (forall X’, X’ <>X -> Incid X’ l -> Right_angle X’ X C).
  • Proposition Conga_flat : forall A B C A’ B’ C’, ~ ColH B A C ->
  •   Ipsilateral_S A A’ B B’ -> Ipsilateral_S A A’ C C’ ->
  •   Right_angle B A A’ -> Right_angle A A’ B’ ->
  •   Right_angle C A A’ -> Right_angle A A’ C’ ->
  •   CongaH B A C B’ A’ C’.
  • Proposition Perp_flat : forall A B C D E, Right_angle A B C ->
  •   Right_angle A B D -> ~ ColH B C D -> B<>E ->
  •   Cof B C D E -> Right_angle A B E.
  • Proposition Per_move : forall A B C P Q P’ Q’, ~ ColH A B C ->
  •   Cof A B C Q -> Cof A B C Q’ -> Cof Q Q’ P P’ ->
  •   (forall D, D<>Q -> Cof A B C D -> Right_angle P Q D) ->
  •   Right_angle P’ Q’ Q ->
  •   (forall D, D<>Q’ -> Cof A B C D -> Right_angle P’ Q’ D).
  • Proposition Per_flat_exists : forall A B C P, ~ Cof A B C P ->
  •   exists D, Cof A B C D /\ (forall E, Cof A B C E ->
  •   E<>D -> Right_angle E D P).

5. Applications of the Perpendicularity Theory

This section demonstrates a central application of the perpendicularity theory formalized in the previous section: proving a theorem on the congruence of geometric figures that was posited by Hilbert but never proven. We begin by defining geometric figures and their congruence relations in Rocq. Next, we formalize and prove the theorem for the restricted case of plane figures. Finally, building upon the perpendicularity theory established in the previous section, we extend the result to its full generality in three-dimensional space, completing the proof. The entire development is accompanied by its machine verification in Rocq.

5.1. The Formalization of the Definitions

Hilbert defines a geometric figure and the congruence of two figures as follows:
Definition 1.
Any finite number of points is referred to as a figure. If all the points of a figure are situated within a plane, it is called a plane figure. Two figures are considered congruent when their points can be paired in such a way that all corresponding segments and angles are equivalent.
Figures can be formalized using Rocq’s List structure with elements of type Point. Importing the Lists.List library introduces this structure. Additionally, basic linear arithmetic operations on natural numbers can be facilitated by directly importing the micromega.Lia library [53]. The following code defines a type graph_f, which represents a plane figure.
  • Require Import micromega.Lia.
  • Require Export Coq.Lists.List.
  • Definition dP : Point.
  • Proof.
  •   ...
  • Defined.
  • Class graph_f :={
  •   gr_fun : list Point;
  •   gr_Cof : exists f, forall A, In A gr_fun -> Incid_P_F A f;
  •   gr_noteq : forall n m, n<>m -> n < length gr_fun ->
  •                  m < length gr_fun -> (nth n gr_fun dP) <> (nth m gr_fun dP)
  • }
The type graph_f includes three constructors:
  • gr_fun: Represents a list of points, forming a finite set of points A 1 , A 2 , A 3 , …, A n in a plane figure.
  • gr_Cof: Declares the existence of a plane f, on which all points in the list gr_fun lie. The function In, defined in Rocq’s Lists.List library, is used to denote that elements are present in a list.
  • gr_noteq: Indicates that the points in gr_fun are pairwise distinct.
Together, these three constructors inductively define a plane figure.
In the following code, CongH_L defines congruence between two sequences of points, L 1 and L 2 , indicating that L 1 and L 2 have equal lengths and that corresponding segments and angles are congruent. When applied to sequences of points, CongH_L denotes congruence between two plane figures, which is formalized as CongH_gf.
  • Definition CongH_L (L1 L2 : list Point) : Prop := length L1 = length L2 /\
  •   (forall m1 m2, m1<>m2 -> m1 < length L1 -> m2 < length L1 ->
  •     CongH (nth m1 L1 dP) (nth m2 L1 dP) (nth m1 L2 dP) (nth m2 L2 dP)) /\
  •   (forall m0 m1 m2, m0 < length L1 -> m1 < length L1 -> m2 < length L1 ->
  •     ~ ColH (nth m0 L1 dP) (nth m1 L1 dP) (nth m2 L1 dP) ->
  •     CongaH (nth m0 L1 dP) (nth m1 L1 dP) (nth m2 L1 dP)
  •       (nth m0 L2 dP) (nth m1 L2 dP) (nth m2 L2 dP)).
  • Definition CongH_gf x y: Prop := CongH_L (@gr_fun x) (@gr_fun y).
Similarly, we can define a type graph representing figures, and CongH_g defines congruence between two figures.
  • Class graph := {
  •   g_fun : list Point;
  •   g_noteq : forall n m, n<>m -> n < length g_fun -> m < length g_fun ->
  •                 (nth n g_fun dP) <> (nth m g_fun dP)
  • }.
  • Definition CongH_g x y: Prop := CongH_L (@g_fun x) (@g_fun y).

5.2. The Congruence Theorem for Plane Figures

Theorem 1.
If ( A 1 , A 2 , A 3 , , A n ) and ( A 1 , A 2 , A 3 , , A n ) are congruent plane figures and P denotes a point within the plane of the first, then a point P can be found within the plane of the second figure, in such a way that ( A 1 , A 2 , A 3 , , A n , P ) and ( A 1 , A 2 , A 3 , , A n , P ) are again congruent figures. If the figure ( A 1 , A 2 , A 3 , , A n ) contains at least three points that are not collinear, then the construction of P is possible in only one way.
We formalize the theorem as Hil_T28. Hil_T28 is a formal proof of unique existence which is divided into proving existence and uniqueness separately, where the assumption that the figure ( A 1 , A 2 , A 3 , , A n ) contains at least three points that are not collinear is only used in the uniqueness proof.
  • Theorem Hil_T28 : forall x y P,  CongH_gf x y->
  •   (forall A B C, In A (@gr_fun x) -> In B (@gr_fun x) ->
  •       In C (@gr_fun x) -> Cof A B C P) ->
  •   (forall Q, In Q (@gr_fun x) -> P<>Q) ->
  •   (exists A B C, In A (@gr_fun x) /\ In B (@gr_fun x) /\
  •       In C (@gr_fun x) /\ ~ ColH A B C) ->
  •   exists! P’,
  •      (exists f, forall A’, In A’ ((@gr_fun y)++[P’]) -> Incid_P_F A’ f) /\
  •      (forall n m, n<>m -> n<length ((@gr_fun y)++[P’]) ->
  •        m < length ((@gr_fun y)++[P’])->
  •        nth n ((@gr_fun y)++[P’]) dP <> nth m ((@gr_fun y)++[P’]) dP) /\
  •      CongH_L ((@gr_fun x)++[P]) ((@gr_fun y)++[P’]).
The mathematical proof of this plane theorem has been provided in the annotations of the Russian translation of the 7th edition of Grundlagen der Geometrie. We will provide a more detailed version of the proof and formalize it in Rocq.
Depending on the location of point P relative to the figure ( A 1 , A 2 , A 3 , , A n ) , three cases can be distinguished for the proof.
  • Case 1: There are two points A and B in the figure which are collinear with P.
  • Case 2: P does not lie on the same line with any two points in the figure ( A 1 , A 2 , A 3 , , A n ) , and A 1 , A 2 , A 3 , A n are not all collinear.
  • Case 3: All points of the figure ( A 1 , A 2 , A 3 , , A n ) lie on a line, and P is outside this line.

5.2.1. Proof and Formalization for Case 1 in Theorem 1

Suppose point P is collinear with two points A and B from the figure ( A 1 , A 2 , A 3 , , A n ) .
If B and P are on the same side of A, then according to CongH_3_exists_Ips, there is a point P lying on the line A B and the order of A , B , P corresponds exactly to the order of A, B, P, and A P A P , B P B P .
Now prove that P is indeed the desired point.
Existence: First, P is not a point in the figure ( A 1 , A 2 , A 3 , , A n ) , otherwise, according to the uniqueness of segment transfer (CongH_1_unique), P would also be a point in the figure ( A 1 , A 2 , A 3 , , A n ) .
Let C be a point in the figure ( A 1 , A 2 , A 3 , , A n ) , and let C be the corresponding point in the figure ( A 1 , A 2 , A 3 , , A n ) . If A, B, and C are collinear, then according to CongH_colh, C P C P . If A, B, and C are not collinear, according to CongH_col, C P C P .
In summary, in the extended figures with points P and P , all corresponding segments remain congruent. According to Theorem18, corresponding angles are also congruent.
Uniqueness: Suppose there exists another point Q such that the extended figures with points P and Q remain congruent. According to Cong_Ips, Q lies on the line A B , and the order of A , B , Q is also identical to the order of A, B, P. By the uniqueness of segment transfer, Q must be equal to P . Therefore, if the point P exists, it will be uniquely determined by the method specified in CongH_3_exists_Ips.
If B and P are on opposite sides of A, simply interchange A and B in the above proof process.
Case 1 of Theorem 1 can be formalized as follows:
  • Lemma L1_T28 : forall x y P, CongH_gf x y ->
  •   (forall Q, In Q (@gr_fun x) -> P<>Q) ->
  •   (exists A B, In A (@gr_fun x) /\ In B (@gr_fun x) /\
  •     A<>B /\ ColH A B P) ->
  •   exists! P’,
  •     (exists f, forall A’, In A’ ((@gr_fun y)++[P’]) -> Incid_P_F A’ f) /\
  •     (forall n m, n<>m -> n < length ((@gr_fun y)++[P’]) ->
  •       m < length ((@gr_fun y)++[P’])->
  •       nth n ((@gr_fun y)++[P’]) dP <> nth m ((@gr_fun y)++[P’]) dP) /\
  •     CongH_L ((@gr_fun x)++[P]) ((@gr_fun y)++[P’]).

5.2.2. Proof and Formalization for Case 2 in Theorem 1

Suppose P does not lie on the same line with any two points in the figure ( A 1 , A 2 , A 3 , A n ) , and A 1 , A 2 , A 3 , …, A n are not all collinear.
In this case, three non-collinear points, such as A, B, and C, can be identified in the figure. According to exists_He, a point P 1 can be selected on the line A C such that points P and P 1 lie on opposite sides of the line A B . Thus, the segment P P 1 intersects A B at a point denoted as P 2 .
Consequently, point P lies on the line P 1 P 2 , where P 1 is chosen on line A C and P 2 is chosen on line A B .
Following the proof of Case 1, points P 1 and P 2 can be uniquely identified on the lines A C and A B , respectively, such that the extended figures ( A 1 , A 2 , A 3 , , A n , P 1 , P 2 ) and ( A 1 , A 2 , A 3 , , A n , P 1 , P 2 ) are congruent.
Similarly, P lies on the line P 1 P 2 and a point P can be identified on the line P 1 P 2 such that figures ( A 1 , A 2 , A 3 , , A n , P 1 , P 2 , P ) and ( A 1 , A 2 , A 3 , , A n , P 1 , P 2 , P ) are congruent.
Let’s prove that the point P is uniquely determined. Suppose there is another point P such that the figures ( A 1 , A 2 , A 3 , , A n , P ) and ( A 1 , A 2 , A 3 , , A n , P ) are congruent. Then, according to the conclusion of Case 1, points P 1 and P 2 can be found such that ( A 1 , A 2 , A 3 , , A n , P , P 1 , P 2 ) and ( A 1 , A 2 , A 3 , , A n , P , P 1 , P 2 ) are congruent. If we eliminate P and P from these two figures, the resulting figures should still be congruent. However, points P 1 and P 2 have already been uniquely determined. Therefore, P 1 coincides with P 1 , and P 2 coincides with P 2 .
In conclusion, the figures
( A 1 , A n , A 3 , , A n , P 1 , P 2 , P )
and
( A 1 , A 2 , A 3 , , A n , P 1 , P 2 , P )
are congruent. Based on the uniqueness of the construction of P , comparing these two congruent figures shows that P is equal to P . The proof is complete.
In the proof of Case 2, we assume that the figures ( A 1 , A 2 , A 3 , , A n , P , P 1 , P 2 ) and ( A 1 , A 2 , A 3 , , A n , P 1 , P 2 , P ) are the same. Consequently, if ( A 1 , A 2 , A 3 , , A n , P , P 1 , P 2 ) is congruent to another figure, then ( A 1 , A 2 , A 3 , , A n , P 1 , P 2 , P ) must also be congruent to that figure. In essence, for figures, rearranging or removing points does not affect their congruence.
However, in the formalization process, we represent figures as lists, where the order of elements matters. As a result, rearranging elements in a list L 1 produces a different list L 2 , but this does not affect the conclusion that the two lists are congruent. The same principle applies when elements are removed from a list.
To reconcile the differences between manual and formal proofs, we need certain lemmas to account for these distinctions.
  • Lemma exc_Cong : forall L1 L2 P P1 P’ P1’,
  •    (forall Q, In Q L1 -> P1 <> Q) ->
  •    (forall Q, In Q (L1++[P1]) -> P <> Q) ->
  •    (forall n m, n<>m -> n < length ((L2++[P1’])++[P’]) ->
  •       m <length ((L2++[P1’])++[P’]) ->
  •       nth n ((L2++[P1’])++[P’]) dP <> nth m ((L2++[P1’])++[P’]) dP) ->
  •   CongH_L ((L1++[P1])++[P]) ((L2++[P1’])++[P’]) ->
  •   CongH_L ((L1++[P])++[P1])((L2++[P’])++[P1’]).
  • Lemma remove_Cong_simpl : forall L1 L2 P P1,
  •   CongH_L (L1++[P]) (L2++[P’]) ->
  •   CongH_L  L1 L2.
Case 2 in Theorem 1 can be formalized as the following lemma.
  • Lemma L2_T28: forall x y P, CongH_gf x y ->
  •   (forall Q, In Q (@gr_fun x) -> P<>Q) ->
  •   (exists A B C, In A (@gr_fun x) /\ In B (@gr_fun x) /\
  •     In C (@gr_fun x) /\ ~ ColH A B C /\ Cof A B C P) ->
  •   (forall A B, In A (@gr_fun x) ->In B (@gr_fun x) ->
  •     A<>B -> ~ ColH A B P) ->
  •   exists! P’,
  •     (exists f, forall A’, In A’ ((@gr_fun y)++[P’]) -> Incid_P_F A’ f) /\
  •     (forall n m, n<>m -> n < length ((@gr_fun y)++[P’]) ->
  •       m < length ((@gr_fun y)++[P’])->
  •       nth n ((@gr_fun y)++[P’]) dP <> nth m ((@gr_fun y)++[P’]) dP) /\
  •     CongH_L ((@gr_fun x)++[P]) ((@gr_fun y)++[P’]).

5.2.3. Proof and Formalization for Case 3 in Theorem 1

Suppose all points of the figure ( A 1 , A 2 , A 3 , , A n ) lie on a line, and P is outside this line.
According to Cong_colh and Cong_bet, points A 1 , A 2 , A 3 , …, A n are also collinear and they have the same order as A 1 , A 2 , A 3 , …, A n .
Take any two points A and B from ( A 1 , A 2 , A 3 , , A n ) , and their corresponding points A and B from ( A 1 , A 2 , A 3 , , A n ) . Next, construct an angle Q A B on the ray A B such that angle Q A B is congruent to angle P A B , and on the ray A Q , construct segment A P congruent to A P . Consequently, we have:
P A B P A B , A P A P .
We conclude that P is indeed the desired point. Indeed, consider any point C in the first figure. Either P A C and P A B coincide or they are supplementary angles. In the former case, angles P A C and P A B coincide, and in the latter case, they are supplementary angles(Cong_Ips).
Since P A B P A B , it follows that in either case, P A C P A C . Furthermore, A P A P , A C A C . From Theorem12, it follows that P C P C .
Therefore, ( A 1 , A 2 , A 3 , , A n , P ) and ( A 1 , A 2 , A 3 , , A n , P ) are congruent figures. It is worth noting that in the considered scenario, point P is not uniquely determined, because it can be replaced by a point that is symmetric to it relative to the line A 1 A 2 A 3 A n .
The formalization of this case is also straightforward.
  • Lemma L3_T28 : forall x y P, CongH_gf x y ->
  •   (forall Q, In Q (@gr_fun x) -> P<>Q) ->
  •   (forall A B C, In A (@gr_fun x) -> In B (@gr_fun x) ->
  •     In C (@gr_fun x) -> ColH A B C) ->
  •   (forall A B, In A (@gr_fun x) -> In B (@gr_fun x) ->
  •     A<>B -> ~ ColH A B P) ->
  •   exists P’,
  •     (exists f, forall A’, In A’ ((@gr_fun y)++[P’]) ->
  •       Incid_P_F A’ f) /\
  •     (forall n m, n<>m -> n<length ((@gr_fun y)++[P’]) ->
  •       m < length ((@gr_fun y)++[P’])->
  •       nth n ((@gr_fun y)++[P’]) dP <> nth m ((@gr_fun y)++[P’]) dP) /\
  •     CongH_L ((@gr_fun x)++[P]) ((@gr_fun y)++[P’]).

5.3. The Congruence Theorem for Space Figures

Theorem 2.
Given two congruent geometric figures, ( A 1 , A 2 , A 3 , , A n ) and ( A 1 , A 2 , A 3 , , A n ) , any point P can be corresponded to a point P such that the extended figures ( A 1 , A 2 , A 3 , , A n , P ) and ( A 1 , A 2 , A 3 , , A n , P ) remain congruent. If the figure ( A 1 , A 2 , A 3 , , A n ) contains at least four non-coplanar points, then the construction of P is possible in only one way.
The formalization of Theorem 2 is as follows.
  • Theorem Hil_T29 : forall x y P, CongH_g x y ->
  •   (forall Q, In Q (@g_fun x) -> P<>Q) ->
  •   (exists A B C D, In A (@g_fun x) /\ In B (@g_fun x) /\
  •     In C (@g_fun x) /\ In D (@g_fun x) /\ ~ Cof A B C D) ->
  •   exists! P’,
  •     (forall n m, n<>m -> n < length ((@g_fun y)++[P’]) ->
  •       m < length ((@g_fun y)++[P’]) ->
  •       nth n ((@g_fun y)++[P’]) dP <> nth m ((@g_fun y)++[P’]) dP) /\
  •     CongH_L ((@g_fun x)++[P]) ((@g_fun y)++[P’]).
Proof. 
Still based on the position of point P, the proof is divided into four cases.
1. Suppose P and three non-collinear points from ( A 1 , A 2 , A 3 , , A n ) , such as A, B, and C, lie on the same plane.
In this case, if P lies on the same line as any two points of the first figure, according to the proof of Case 1 in Theorem 1, it is known that a unique point P exists such that the figures ( A 1 , A 2 , A 3 , , A n , P ) and ( A 1 , A 2 , A 3 , , A n , P ) are congruent.
When P does not share a common line with any two points of the figure ( A 1 , A 2 , A 3 , , A n ) , according to Case 2 of Theorem 1, Theorem 2 can also be proved.
The formalization of this case is as follows.
  • Lemma L1_T29 : forall x y P, CongH_g x y ->
  •   (forall Q, In Q (@g_fun x) -> P<>Q) ->
  •   (exists A B C, In A (@g_fun x) /\ In B (@g_fun x) /\
  •     In C (@g_fun x) /\ ~ ColH A B C /\ Cof A B C P) ->
  •   exists! P’,
  •     (forall n m, n<>m -> n < length ((@g_fun y)++[P’]) ->
  •       m < length ((@g_fun y)++[P’]) ->
  •       nth n ((@g_fun y)++[P’]) dP <> nth m ((@g_fun y)++[P’]) dP) /\
  •     CongH_L ((@g_fun x)++[P]) ((@g_fun y)++[P’]).
2. Suppose P does not lie in the same plane as any three non-collinear points of the figure ( A 1 , A 2 , A 3 , , A n ) , and A 1 , A 2 , A 3 , …, A n are not all coplanar.
In this case, we can identify four non-coplanar points in the first figure, such as A, B, C, D. By exists_uncof, a point P 1 can be chosen in the plane A B D such that P and P 1 lie on opposite sides of the plane A B C . Consequently, the segment P P 1 intersects the plane A B C at a certain point P 2 .
Thus, point P lies on the plane A P 1 P 2 , where P 1 is chosen in the plane A B D and P 2 is chosen in the plane A B C .
Following a similar proof method as in Case 2 of Theorem 1, a unique point P can be found such that the figures ( A 1 , A 2 , A 3 , , A n , P ) and ( A 1 , A 2 , A 3 , , A n , P ) are congruent.
We can also directly give the formalization of this case.
  • Lemma L2_T29 : forall x y P, CongH_g x y ->
  •   (forall Q, In Q (@g_fun x) -> P<>Q) ->
  •   ~ (exists A B C, In A (@g_fun x) /\ In B (@g_fun x) /\
  •     In C (@g_fun x) /\ ~ ColH A B C /\ Cof A B C P) ->
  •   (exists A B C D, In A (@g_fun x) /\ In B (@g_fun x) /\
  •     In C (@g_fun x) /\ In D (@g_fun x) /\ ~ Cof A B C D) ->
  •   exists! P’,
  •     (forall n m, n<>m ->n < length ((@g_fun y)++[P’]) ->
  •       m < length ((@g_fun y)++[P’]) ->
  •       nth n ((@g_fun y)++[P’]) dP <> nth m ((@g_fun y)++[P’]) dP) /\
  •     CongH_L ((@g_fun x)++[P]) ((@g_fun y)++[P’]).
3. Suppose all points of the figure ( A 1 , A 2 , A 3 , , A n ) lie on a plane, and P is outside this plane, but the points ( A 1 , A 2 , A 3 , , A n ) are not collinear.
Before beginning the proof, let’s introduce the following lemma:
  • Lemma Cof_ConHg : forall x y m0 m1 m2 m3, CongH_g x y ->
  •   m0 < length (@g_fun x) -> m1 < length (@g_fun x) ->
  •   m2 < length (@g_fun x) -> m3 < length (@g_fun x) ->
  •   Cof (nth m0 (@g_fun x) dP) (nth m1 (@g_fun x) dP)
  •    (nth m2 (@g_fun x) dP) (nth m3 (@g_fun x) dP) ->
  •   Cof (nth m0 (@g_fun y) dP) (nth m1 (@g_fun y) dP)
  •    (nth m2 (@g_fun y) dP) (nth m3 (@g_fun y) dP).
Cof_ConHg: Given two congruent figures ( A 1 , A 2 , A 3 , , A n ) and ( A 1 , A 2 , A 3 , , A n ) , if any four points such as A, B, C, D in ( A 1 , A 2 , A 3 , , A n ) are coplanar, then the corresponding points A , B , C , D in ( A 1 , A 2 , A 3 , , A n ) are also coplanar.
Since all the points ( A 1 , A 2 , A 3 , , A n ) lie in one plane, by Cof_ConHg and Incid_4_1, all the points of the figure ( A 1 , A 2 , A 3 , , A n ) also lie in one plane.
In the figure ( A 1 , A 2 , A 3 , , A n ) , we have three non-collinear points, such as A, B, C. Consequently, the corresponding points A , B and C are also non-collinear (Cong_uncolh).
According to Proposition 9, a perpendicular from P to the plane A B C can be constructed, with the intersection point denoted as M. Similarly, for a point Q outside the plane A B C , we can construct a perpendicular from Q to the plane A B C , with the intersection point referred to as Q . By Case 1 of Theorem 2, a point M can be found such that the figures ( A 1 , A 2 , A 3 , , A n , M ) and ( A 1 , A 2 , A 3 , , A n , M ) are congruent, with M lying on the plane A B C .
According to Proposition 4, there exists a point P 0 passing through M such that M P 0 is perpendicular to M Q , with P 0 and Q located on the same side of Q M . On the ray M P 0 , a segment M P is constructed congruent to M P . We assert that point P is the desired point.
Angle P 0 M Q is a right angle, and since it coincides with angle P M Q , angle P M Q must also be a right angle. Since Q Q is perpendicular to plane A B C , Proposition 8 implies P M is also perpendicular to plane A B C with M being the point where the perpendicular meets the plane.
Let C be any point in the figure ( A 1 , A 2 , A 3 , , A n ) , and let C be its corresponding point.
In triangles P M C and P M C , angles P M C and P M C are both right angles. According to Hil_T21, these two angles are congruent. Also,
M P M P , M C M C .
By Theorem12,
P C P C .
In conclusion, in the figures extended by points P and P , all corresponding segments remain congruent. According to Theorem18, corresponding angles are also congruent.
This scenario extends Case 3 of Theorem 1 into three dimensions, but the proof cannot be achieved as simply as in Theorem 1 through straightforward angle and segment transfer. Constructing point P requires additional theories of perpendicularity.
The formalization of this case is also straightforward.
  • Lemma L3_T29 : forall x y P f, CongH_g x y ->
  •   (forall Q, In Q (@g_fun x) -> P<>Q) ->
  •   (forall A, In A (@g_fun x) -> Incid_P_F A f) ->
  •   ~ Incid_P_F P f ->
  •   (exists A B C, In A (@g_fun x) /\ In B (@g_fun x) /\
  •     In C (@g_fun x) /\ ~ColH A B C) ->
  •   exists P’,
  •     (forall n m, n<>m -> n < length ((@g_fun y)++[P’]) ->
  •       m < length ((@g_fun y)++[P’]) ->
  •       nth n ((@g_fun y)++[P’]) dP <> nth m ((@g_fun y)++[P’]) dP) /\
  •     CongH_L ((@g_fun x)++[P]) ((@g_fun y)++[P’]).
4. When the figure degenerates into a straight line, we have already completed the proof in Theorem 1.    □

6. Technical Comparison with GeoCoq

This section provides a substantive technical comparison between our Hilbert-native formalization and the Tarski-based GeoCoq library. We focus on the extension of dimensionality, the architectural differences, and the resulting impact on proof density.

6.1. Dimensional Extension Beyond Planar Constraints

While Braun and Narboux established that Hilbert’s and Tarski’s systems are mutually interpretable [44,45], their formal verification is strictly confined to two-dimensional geometry. This dimensional constraint is reflected in the fundamental structure of their framework: it omits the spatial axioms (Group I, 4–8) and operates on a reduced sort hierarchy that includes only points and lines, omitting the primitive notion of a plane. Furthermore, their implementation employs the planar version of Pasch’s Axiom, which is insufficient for capturing the intersection properties inherent in three-dimensional configurations. Our work addresses these structural limitations by providing a native 3D formalization with a complete multi-sorted hierarchy and the full suite of spatial axioms, thereby extending the verified Hilbert’s framework beyond the planar scope of prior studies.
The technical necessity of this 3D extension is best demonstrated by the mechanization of Hil_T29 in Section 5. Unlike purely planar theorems, the verification of spatial congruence requires the rigorous management of incidence between lines and planes—structures that are structurally absent in the Hilbert’s interfaces of GeoCoq.

6.2. Architectural Distinctions

The most fundamental technical divergence between the two libraries lies in their underlying sort hierarchy. GeoCoq is based on Tarski’s axiomatization, which utilizes a single-sorted first-order logic where “Point” is the exclusive primitive entity. In their framework, higher-order geometric structures such as lines and planes are not first-class types. Conversely, our implementation natively incorporates Hilbert’s multi-sorted logic, elevating Points, Lines, and Planes to distinct primitive types.
On the one hand, our design internalizes dimensional constraints within the type system. Sort-inconsistent statements are rejected during static type-checking, shifting the verification burden from the proof script to the Rocq kernel. On the other hand, our framework reduces the complexity of managing non-degeneracy hypotheses in 3D configurations by avoiding the recurrent unfolding of point relations.

6.3. Semantic Fidelity and Definitional Primitivity

A key technical distinction between the two libraries lies in the methodology of geometric definitions. GeoCoq often adopts constructive definitions that facilitate Tarski’s quantifier-based reasoning. In contrast, our work adheres to Hilbert’s synthetic approach, where definitions are derived from more primitive axiomatic notions. This leads to a higher degree of semantic fidelity relative to classical geometric intuition.
The formalization of a Right Angle serves as a representative case study. Following Hilbert’s original prose, we define a right angle as an angle that is congruent to its adjacent supplementary angle:
  • Definition Right_angle A B C := ~ ColH A B C /\
  •   forall C’, BetH C B C’ -> CongaH A B C A B C’.
This definition relies solely on the primitive notions of betweenness (BetH) and angle congruence (CongaH), capturing the intrinsic symmetry of perpendicularity without invoking auxiliary constructions. GeoCoq employs a constructive definition (Per), which characterizes a right angle via the existence of a midpoint and equidistant segments:
  • Definition Per A B C := exists C’, Midpoint B C C’ /\ Cong A C A C’.
While these two definitions are logically equivalent in Euclidean geometry, our work demonstrates that the property used by GeoCoq as a definition is, in fact, a derived theorem in the Hilbert’s framework. Specifically, we have mechanized the proof of Mid_Per, which establishes that Hilbert’s definition implies Tarski’s definition.
  • Proposition Mid_Per : forall A B C P, MidPoint B A C ->
  •   Right_angle P B A -> CongH P A P C.

7. Conclusions

This paper has successfully addressed a significant gap in the formalization of Hilbert’s Foundations of Geometry by establishing a theory of spatial perpendicularity based on the first three groups of Hilbert’s axioms (incidence, order, and congruence) and proving the congruence theorem for three-dimensional figures. The theory is independent of the parallel postulate and continuity axioms, and thus holds in both Euclidean and non-Euclidean settings. Our work demonstrates that Hilbert’s axiom system is intrinsically complete for spatial geometry, requiring no additional spatial congruence axioms beyond the original set. The entire development has been rigorously formalized and machine-verified in the Rocq proof assistant, ensuring absolute logical correctness.
Our research makes three primary contributions:
1.
Axiom Formalization and Foundational Theories: We began with a complete and careful formalization of Hilbert’s first three groups of axioms (Incidence, Order, and Congruence) in Rocq. Beyond merely restating the axioms, we derived an extensive library of fundamental geometric theories, including the classic triangle congruence theorems (SAS, ASA, SSS) and key properties of angles and midpoints. This library serves as a reusable foundation for future work in formalized geometry.
2.
Theory of Spatial Perpendicularity: The core of our contribution lies in systematically constructing the theory of perpendicularity for lines and planes in space—a theory not fully developed by Hilbert himself. We introduced nine interconnected propositions, progressing from planar properties to sophisticated spatial theorems, such as the existence and uniqueness of perpendiculars from a point to a line or a plane. This theory filled a critical conceptual gap and provided the necessary tools for spatial reasoning.
3.
Mechanized Proof of the Figures Congruence Theorem: Leveraging the perpendicularity theory, we achieved our ultimate goal: the formal proof of the congruence theorem for figures. The successful machine-checked proof conclusively demonstrates that all spatial congruence properties can be derived from Hilbert’s original, planar axioms, confirming the self-sufficiency of his system for three-dimensional space.
The significance of this work extends beyond mere theorem proving, as it serves as a valuable complement to the formalization of Hilbert’s geometry. Unlike libraries based on Tarski’s system, such as GeoCoq, our research is not intended to replace existing systems. Instead, it provides a reusable Rocq library for Hilbert’s geometry by creating a new foundation that enables subsequent researchers to perform formalizations directly based on Hilbert’s axioms. This library includes complete axiom encoding, derived theories, and perpendicularity theory, supporting the direct verification of Hilbert’s original propositions and lowering the barrier for conducting advanced geometric reasoning within the Hilbert framework. In the future, this resource can promote the application of Hilbert’s geometry in education, historical research, and the verification of safety-critical systems, thereby enriching the diversity of formalized geometry.
Our future work will focus on advancing the thorough formalization of Hilbert’s axiom system. And then we plan to investigate the compatibility and independence of the axioms.

Author Contributions

Conceptualization, Q.Z. and W.Y.; methodology, Q.Z. and W.Y.; software, Q.Z.; validation, Q.Z. and W.Y.; formal analysis, Q.Z. and W.Y.; investigation, Q.Z. and W.Y.; resources, Q.Z.; data curation, Q.Z.; writing—original draft preparation, Q.Z.; writing—review and editing, Q.Z.; supervision, W.Y.; project administration, Q.Z. and W.Y.; funding acquisition, W.Y. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the National Natural Science Foundation (NNSF) of China under Grant No. 62476028.

Data Availability Statement

The Rocq formalization code supporting the results of this study is openly available at https://github.com/a-qmeng/Formal-Hilbert-Geometry (accessed on 4 February 2026).

Acknowledgments

We would like to acknowledge the support provided by the National Natural Science Foundation (NNSF) of China under Grant No. 62476028, which made this research possible.

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviation

The following abbreviation is used in this manuscript:
CICCalculus of Inductive Constructions

Appendix A. Introduction to Rocq Syntax

ParameterDeclare axioms or parameters
SetRepresents types
PropRepresents the proposition type
DefinitionDefine new concepts
AxiomDeclare an axiom
forallUniversal quantifier, meaning “for all”
existsExistential quantifier, meaning “there exists”
->Implication, meaning “if…then”
\/Conjunction, meaning “and”
\/Disjunction, meaning “or”
~Negation, meaning “not”
TheoremDeclare a theorem
LemmaDeclare a lemma
CorollaryDeclare a corollary
PropositionDeclare a proposition
Proof … QedProof start and end markers
FixpointDeclare a fixpoint function
FactDeclare a fact
HypothesisDeclare a hypothesis
LetDeclare a let-in expression

References

  1. Mueller, I. Euclid’s Elements and the Axiomatic Method. Br. J. Philos. Sci. 1969, 20, 289–309. [Google Scholar] [CrossRef]
  2. Avigad, J.; Dean, E.; Mumma, J. A Formal System for Euclid’s Elements. Rev. Symb. Log. 2009, 2, 700–768. [Google Scholar] [CrossRef]
  3. Beeson, M.; Narboux, J.; Wiedijk, F. Proof-Checking Euclid. Ann. Math. Artif. Intell. 2019, 85, 213–257. [Google Scholar] [CrossRef]
  4. Hilbert, D. Foundations of Geometry, 2nd ed.; Translated from the 10th edition of the Grundlagen der Geometrie; Open Court Classics: Chicago, IL, USA, 1971. [Google Scholar]
  5. Wu, W.T. Mechanical Theorem Proving in Geometries: Basic Principles; Springer: Vienna, Austria, 1944. [Google Scholar]
  6. Birkhoff, G.; Bennett, M.K. Hilbert’s “Grundlagen der Geometrie”. Rend. Circ. Mat. Palermo 1987, 36, 343–389. [Google Scholar] [CrossRef]
  7. Weyl, H. David Hilbert and His Mathematical Work. Bull. Am. Math. Soc. 1944, 50, 612–654. [Google Scholar] [CrossRef]
  8. Chen, S.; Yu, W.; Dou, G.; Zhang, Q. A Review on Mechanical Proving and Formalization of Mathematical Theorems. IEEE Access 2025, 13, 50672–50686. [Google Scholar] [CrossRef]
  9. Wiedijk, F. Formal Proof–Getting Started. Not. AMS 2008, 55, 1408–1414. [Google Scholar]
  10. Hales, T.C. Formal Proof. Not. AMS 2008, 55, 1370–1380. [Google Scholar]
  11. Guo, D.; Yu, W. A Comprehensive Formalization of Propositional Logic in Coq: Deduction Systems, Meta-Theorems, and Automation Tactics. Mathematics 2023, 11, 2504. [Google Scholar] [CrossRef]
  12. Bertot, Y.; Castéran, P. Interactive Theorem Proving and Program Development: Coq’Art: The Calculus of Inductive Constructions; Springer Science & Business Media: Berlin/Heidelberg, Germany, 2013. [Google Scholar]
  13. Pierce, B.C.; Amorim, A.A.; Casinghino, C.; Gaboardi, M.; Greenberg, M.; Hriţcu, C.; Sjöberg, V.; Yorgey, B. Software Foundations (Version 6.7). Available online: http://softwarefoundations.cis.upenn.edu/ (accessed on 25 August 2024).
  14. The Coq Development Team. The Coq Proof Assistant Reference Manual (Version 8.13.2). 2021. Available online: https://rocq-prover.org/doc/V8.13.2/refman/ (accessed on 14 October 2025).
  15. Nipow, T.; Paulson, L.; Wenzel, M. Isabelle/HOL: A Proof Assistant for Higher-Order Logic; Springer: Berlin/Heidelberg, Germany, 2002. [Google Scholar]
  16. Harrison, J. The HOL Light Theorem Prover. Available online: http://www.cl.cam.ac.uk/~jrh13/hol-light/ (accessed on 18 May 2018).
  17. Avigad, J.; de Moura, L.; Kong, S. Theorem Proving in Lean. Release 2015, 3, 1–4. [Google Scholar]
  18. de Moura, L.; Ullrich, S. The Lean 4 Theorem Prover and Programming Language. In Proceedings of the Automated Deduction–CADE 28: 28th International Conference on Automated Deduction, Virtual Event, 12–15 July 2021; Proceedings 28; Springer: Berlin/Heidelberg, Germany, 2021; pp. 625–635. [Google Scholar]
  19. Avigad, J.; Harrison, J. Formally Verified Mathematics. Commun. ACM 2014, 57, 66–75. [Google Scholar] [CrossRef]
  20. Gonthier, G. Formal Proof–the Four-Color Theorem. Not. AMS 2008, 55, 1382–1393. [Google Scholar]
  21. Gonthier, G.; Asperti, A.; Avigad, J.; Bertot, Y.; Cohen, C.; Garillot, F.; Le Roux, S.; Mahboubi, A.; O’Connor, R.; Ould Biha, S. A Machine-Checked Proof of the Odd Order Theorem. In Proceedings of the 4th International Conference on Interactive Theorem Proving, ITP 2013, Rennes, France, 22–26 July 2013; Springer: Berlin/Heidelberg, Germany, 2013; pp. 163–179. [Google Scholar]
  22. Hales, T.; Adams, M.; Bauer, G.; Dang, T.D.; Harrison, J.; Le Truong, H.; Kaliszyk, C.; Magron, V.; McLaughlin, S.; Nguyen, T.T. A Formal Proof of the Kepler Conjecture. In Proceedings of the Forum of Mathematics, Pi; Cambridge University Press: Cambridge, UK, 2017; Volume 5, p. e2. [Google Scholar]
  23. Castelvecchi, D. Mathematicians Welcome Computer-Assisted Proof in ‘Grand Unification’ Theory. Nature 2021, 595, 18–19. [Google Scholar] [CrossRef]
  24. Coxeter, H.S.M. Projective Geometry, 2nd ed.; Springer Science & Business Media: New York, NY, USA, 2003. [Google Scholar]
  25. Magaud, N.; Narboux, J.; Schreck, P. A Case Study in Formalizing Projective Geometry in Coq: Desargues Theorem. Comput. Geom. 2012, 45, 406–424. [Google Scholar] [CrossRef]
  26. Braun, D.; Magaud, N.; Schreck, P. An Equivalence Proof Between Rank Theory and Incidence Projective Geometry. In Proceedings of Automated Deduction in Geometry (ADG 2016); Springer: Berlin, Germany, 2016; pp. 62–77. [Google Scholar]
  27. Coghetto, R. Pascal’s Theorem in Real Projective Plane. Formaliz. Math. 2017, 25, 107–119. [Google Scholar] [CrossRef][Green Version]
  28. Coghetto, R. Duality Notions in Real Projective Plane. Formaliz. Math. 2021, 29, 161–173. [Google Scholar] [CrossRef]
  29. Marić, F.; Petrović, D. Formalizing Complex Plane Geometry. Ann. Math. Artif. Intell. 2015, 74, 271–308. [Google Scholar] [CrossRef]
  30. Fleuriot, J. Theorem Proving in Infinitesimal Geometry. Logic J. IGPL 2001, 9, 447–474. [Google Scholar] [CrossRef]
  31. Fleuriot, J. Nonstandard Geometric Proofs. In Automated Deduction in Geometry (ADG 2000); Richter-Gebert, J., Wang, D., Eds.; Springer: Berlin/Heidelberg, Germany, 2001; pp. 246–267. [Google Scholar]
  32. Magaud, N.; Chollet, A.; Fuchs, L. Formalizing a Discrete Model of the Continuum in Coq from a Discrete Geometry Perspective. Ann. Math. Artif. Intell. 2015, 74, 309–332. [Google Scholar] [CrossRef]
  33. Fleuriot, J. Exploring the Foundations of Discrete Analytical Geometry in Isabelle/HOL. In Automated Deduction in Geometry (ADG 2010); Lecture Notes in Computer Science; Springer: Berlin/Heidelberg, Germany, 2010; Volume 6877, pp. 34–50. [Google Scholar]
  34. Dehlinger, C.; Dufourd, J.; Schreck, P. Higher-order Intuitionistic Formalization and Proofs in Hilbert’s Elementary Geometry. In Proceedings of the Automated Deduction in Geometry, Zurich, Switzerland, 25–27 September 2000; Springer: Berlin/Heidelberg, Germany, 2001; pp. 306–323. [Google Scholar]
  35. Iwama, F.; Takahashi, T. On the Proof of the Theorems of Foundations of Geometry Using Isabelle/HOL. J. Comput. Innov. Anal. 2022, 1, 45–69. [Google Scholar]
  36. Iwama, F. Foundation of Geometry in Planes, And Some Complements: Excluding the Parallel Axioms. Arch. Formal Proofs 2021. Available online: https://isa-afp.org/entries/Foundation_of_geometry.html (accessed on 14 October 2025).
  37. Meikle, L.I.; Fleuriot, J.D. Formalizing Hilbert’s Grundlagen in Isabelle/Isar. In Proceedings of the Theorem Proving in Higher Order Logics; Springer: Berlin/Heidelberg, Germany, 2003; pp. 319–335. [Google Scholar]
  38. Scott, P. Mechanising Hilbert’s Foundations of Geometry in Isabelle. Master’s Thesis, University of Edinburgh, Edinburgh, UK, 2008. [Google Scholar]
  39. Scott, P. Ordered Geometry in Hilbert’s Grundlagen der Geometrie. Ph.D. Thesis, University of Edinburgh, Edinburgh, UK, 2015. [Google Scholar]
  40. Richter, W. Formalizing Rigorous Hilbert Axiomatic Geometry Proofs in the Proof Assistant HOL Light. Available online: https://github.com/a-qmeng/papers/blob/main/Richter-HOLlight.pdf (accessed on 4 February 2026).
  41. Schwabhäuser, W.; Szmielew, W.; Tarski, A. Metamathematische Methoden in der Geometrie; Springer: Berlin/Heidelberg, Germany, 2013. [Google Scholar]
  42. Beeson, M.; Boutry, P.; Braun, G.; Gries, C.; Narboux, J. GeoCoq. 2018. Available online: https://github.com/GeoCoq/GeoCoq (accessed on 14 October 2025).
  43. Boutry, P. On the Formalization of Foundations of Geometry. Ph.D. Thesis, University of Strasbourg, Strasbourg, Frnace, 2018. [Google Scholar]
  44. Braun, G.; Boutry, P.; Narboux, J. From Hilbert to Tarski. In Proceedings of the Automated Deduction in Geometry, Strasbourg, France, 26–28 June 2016; Springer: Berlin/Heidelberg, Germany, 2016; p. 19. [Google Scholar]
  45. Braun, G.; Narboux, J. From Tarski to Hilbert. In Proceedings of the Automated Deduction in Geometry; Springer: Berlin/Heidelberg, Germany, 2013; pp. 89–109. [Google Scholar]
  46. Beeson, M.; Wos, L. Finding Proofs in Tarskian Geometry. J. Autom. Reason. 2017, 58, 181–207. [Google Scholar] [CrossRef]
  47. Grabowski, A.; Coghetto, R. Tarski’s Geometry and the Euclidean Plane in Mizar. In Proceedings of the 6th International Conference on Mathematical Software (ICMS 2016); Lecture Notes in Computer Science; Springer: Berlin/Heidelberg, Germany, 2016; pp. 189–198. [Google Scholar]
  48. Coghetto, R.; Grabowski, A. Tarski Geometry Axioms. Part II. Formaliz. Math. 2016, 24, 157–166. [Google Scholar] [CrossRef]
  49. Coghetto, R.; Grabowski, A. Tarski Geometry Axioms. Part III. Formaliz. Math. 2017, 25, 289–313. [Google Scholar] [CrossRef]
  50. Coghetto, R.; Grabowski, A. Tarski Geometry Axioms. Part IV—Right Angle. Formaliz. Math. 2019, 27, 75–85. [Google Scholar] [CrossRef]
  51. Coghetto, R.; Grabowski, A. Tarski Geometry Axioms. Part V—Half-planes and Planes. Formaliz. Math. 2023, 31, 325–339. [Google Scholar] [CrossRef]
  52. Zhang, Q.; Yu, W. A Case Study in Formalizing Hilbert’s Foundations of Geometry in Coq: Establishing Key Properties of Lines in Hilbert’s Axiom System. In Proceedings of the 2023 China Automation Congress (CAC), Chongqing, China, 17–19 November 2023; IEEE: New York, NY, USA, 2024; pp. 1926–1930. [Google Scholar]
  53. Besson, F. Fast Reflexive Arithmetic Tactics the Linear Case and Beyond. In Proceedings of the International Workshop on Types for Proofs and Programs (TYPES 2006); Lecture Notes in Computer Science; Springer: Berlin/Heidelberg, Germany, 2007; Volume 4502, pp. 48–62. [Google Scholar]
Figure 1. Proposition 5.
Figure 1. Proposition 5.
Mca 31 00025 g001
Figure 2. The nonplanar configuration of Proposition 6.
Figure 2. The nonplanar configuration of Proposition 6.
Mca 31 00025 g002
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Zhang, Q.; Yu, W. A Rocq-Based Formalization of Hilbert’s Geometry: Building a Reusable Foundation for 3D Perpendicularity Theory and Verification. Math. Comput. Appl. 2026, 31, 25. https://doi.org/10.3390/mca31010025

AMA Style

Zhang Q, Yu W. A Rocq-Based Formalization of Hilbert’s Geometry: Building a Reusable Foundation for 3D Perpendicularity Theory and Verification. Mathematical and Computational Applications. 2026; 31(1):25. https://doi.org/10.3390/mca31010025

Chicago/Turabian Style

Zhang, Qimeng, and Wensheng Yu. 2026. "A Rocq-Based Formalization of Hilbert’s Geometry: Building a Reusable Foundation for 3D Perpendicularity Theory and Verification" Mathematical and Computational Applications 31, no. 1: 25. https://doi.org/10.3390/mca31010025

APA Style

Zhang, Q., & Yu, W. (2026). A Rocq-Based Formalization of Hilbert’s Geometry: Building a Reusable Foundation for 3D Perpendicularity Theory and Verification. Mathematical and Computational Applications, 31(1), 25. https://doi.org/10.3390/mca31010025

Article Metrics

Back to TopTop