Next Article in Journal
Solitons in Neurosciences by the Laplace–Adomian Decomposition Scheme
Previous Article in Journal
A Numerical Framework for Entropy Generation Using Second-Order Nanofluid Thin Film Flow over an Expanding Sheet: Error Estimation and Stability Analysis
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Formal Verification of a Topological Spatial Relations Model for Geographic Information Systems in Coq

Beijing Key Laboratory of Space-Ground Interconnection and Convergence, School of Electronic Engineering, Beijing University of Posts and Telecommunications, Beijing 100876, China
*
Author to whom correspondence should be addressed.
Mathematics 2023, 11(5), 1079; https://doi.org/10.3390/math11051079
Submission received: 29 January 2023 / Revised: 17 February 2023 / Accepted: 20 February 2023 / Published: 21 February 2023
(This article belongs to the Section Mathematics and Computer Science)

Abstract

:
Geographic information systems have undergone rapid growth for decades. Topology has provided valuable modeling tools in the development of this field. Formal verification ofthe model of topological spatial relations can provide a reliable guarantee for the correctness of geographic information systems. We present a proof of the topological spatial relations model that has been formally verified in the Coq proof assistant. After an introduction to the formalization of the axiomatic set theory of Morse–Kelley, the formal description of the elementary concepts and properties of general topology is developed. The topological spatial relations between two sets are described by using the concept of the intersection value. Finally, we formally proved the topological spatial relations between two sets which are restricted to the regularly closed and the planar spatial regions. All the proof details are strictly completed in Coq, which shows that the correctness of the theoretical model for geographic information systems can be checked by a computer. This paper provides a novel method to verify the correctness of the topological spatial relations model. This work can also contribute to the creation and validation of various geological models and software.

1. Introduction

Formal verification is a computer program to prove the correctness of a mathematical model in the manner of the mathematical theorem, in which every logical reasoning has been checked back to the fundamental axioms of mathematics [1]. This method ensures that there are no steps that are omitted in the proving process of the theorem [2]. The reason why we introduce the formal verification is to improve the precision and reliability of mathematics. In addition, the formal proof of fundamental mathematics can also extend to the security verification of engineering and computer systems [3]. Therefore, the complete formal verification can make the theoretical model in the field of spatial information science towards greater clarity and precision.
The first step of formal verification is to choose a theorem prover. With the development of computer science and logical fundamentals, there are numerous theorem provers for formal verification. These tools are based on various logical fundamentals and enjoy their unique preferences. Especially with the emergence of Coq [4,5], Isabelle/HOL [6], HOL Light [7], and Mizar [8], formal verification has attracted the great attention of many mathematicians and computer scientists. People argue about the relative advantages of the different tools in the same way that people argue about the relative advantages of various operating systems [2]. In this paper, we choose Coq because of its simple design and the existing basis of our formalization work.
There are many outstanding achievements in the formalization of mathematics. The most notable example is the formal proof of the “Four-color Theorem”, which was accomplished by Gonthier et al. in 2005 [9]. In addition, furthermore, they presented the formalization of the “Odd Order Theorem” using a Coq proof assistant [10]. Hales et al. accomplished the machine-checked proof of the “Kepler Conjecture” in 2017 [11]. On the other hand, our research team has accomplished the formalization of Landau’s “Foundations of Analysis” [12]. Based on this formal system, the equivalence among completeness theorems of real numbers and the formalization of calculus without limit theory are realized [13,14]. In addition, many researchers and teams have completed or are ready to complete the formal proof of the famous “A list of 100 theorems”, including Gödel’s First Incompleteness Theorem, Jordan Curve Theorem, and Prime Number Theorem [15]. In particular, Wiedijk pointed out that the formal mathematics currently underway is called the third mathematical revolution in the history of mathematics [1]. These achievements make formal mathematics more and more popular in academia, and the research in formal verification is of great significance.
Similar progress can also be found in the realm of computer program verification [3]. Leroy, the winner of the ACM Software System Award, led a project to formally prove the correctness of a compiler for the C programming language [16]. A project was led by Kelin to verify the correctness of an OS kernel using the Isabelle/HOL theorem prover [17]. There are also several formalization works on security verification of blockchain smart contracts [18,19]. Choi et al. introduced a Coq library (Kami) for hardware designs, and users can design, verify, and synthesize hardware systems within Coq [20]. In addition, in some fields of the computer industry, especially in the realm of avionics, formal verification technology has become increasingly important [3].
Geographic information systems (GIS) theory is one of the important parts in the realm of spatial information science and engineering, which is a computer system capable of assembling, storing, manipulating, and displaying geographically referenced data [21,22]. In addition, these data can be applied to help governments better plan the layout of facilities and digital urban management [23,24]. The user can analyze the spatial information by submitting queries to GIS. The classic GIS query needs to be combined with spatial relations to describe constraints about spatial objects [25]. Therefore, the description of spatial relations is critical for the analysis and display of spatial objects in a GIS.
The variety spatial relations can be divided into three major categories: relations described by prepositions, relations described by distances and directions (metric relations), and relations described by topologies (topological relations) [26]. The great development of general topology provides valuable modeling tools for GIS. The basic concept of topology can be used to define and distinguish relationships between two spatial objects [25]. Therefore, the concept of topological spatial relations is widely used in GIS. It also can be extended to the fields of engineering that deal with spatial data, especially for applications in surveying engineering, CAD/CAM, and image display [24,26,27]. Traditionally, spatial relations models are used for engineering and computer systems using paper-and-pencil proofs and numerical methods. However, these methods cannot ascertain accuracy due to their inherent limitations, such as human-error proneness and numerical errors. Thus, an accurate model of topological spatial relations has become a dire need.
There is a topological spatial relations model applied to GIS which is systematically proposed by Egenhofer and Franzosa [27]. This model may not be the best one, but it provides a sound theoretical basis for the development of GIS. In addition, it has also become a GIS-industry standard for the description of spatial objects [25]. Our formalization has referred to this topological spatial relations model and presents a more complete and precise version. It is worth mentioning that some basic properties proposed in [27] are not essential in the subsequent theorem-proving process. To ensure the conciseness of our paper, we only formally describe the essential properties in the formal system. In addition, the theorem prover Coq can find the details such as errors, redundancy, and the missing part in the process of paper-and-pencil proofs. In addition, our work also needs to be based on the formal system of general topology developed by ourselves. This formal system starts from the axiomatic set theory [28] and provides the formal verification of the basic topological concepts. As an application of this formal system, we completed the formal verification of the C.T. Yang Theorem [29] and some other classical properties in general topology [30].
In this paper, we formally prove a topological spatial relations model applied to GIS using Coq proof assistant. Our formalization work starts with the axiomatic set theory of Morse–Kelley (MK), and then the formal definition of general topology and verification of its various classical properties are introduced. Next, the concept of the intersection value between two sets is proposed. Finally, we formally prove the topological spatial relations between two sets which are restricted to the regularly closed and the planar spatial regions. All the proof details are strictly verified in Coq proof assistant, and the process of formal verification is rigorous and reliable. The main contributions of this paper are as follows. This method offers novel views of the topological spatial relations theoretical model at different levels of detail to suit the different need of readers. In addition, it also contributes to verifying the correctness of various GIS models and software, as well as storing, querying, and manipulating geographically referenced data.
This paper is organized as follows. Section 2 overviews the related work of topological spatial relations. Section 3 gives a brief account of the Coq theorem prover and the axiomatic set theory of Morse–Kelley, which act as preliminaries for the presented formalization. Section 4 introduces the formalization of general topology, which includes the formal definition of general topology and verification of its various classical properties. In Section 5, we present the formalization of the topological spatial relations model applied to GIS. Finally, we conclude the paper in Section 6.

2. Related Work

Egenhofer and Franzosa systematically proposed a point-set topological spatial relations model in 1991, in which the relations are defined using the intersections of the boundaries and interiors of a pair set [27]. In particular, this model has been used widely in GIS when the sets are restricted to the planar spatial regions. Based on this, Ref. [31] proposed an improved topological relations model between moving object trajectories. There is an application in hydrocarbon exploration for risk analysis based on the topological spatial relations model [32]. In addition, Leng et al. presented a generalized 9-Intersection model that can be used for spatial regions with holes [33]. In recent years, there has been some research to extend the concept of topology. Al-shami et al. developed some extensions of topology like supra-topology and infra-topology; these works will make the topological spatial relations between a pair set to become more diverse and accurate [34,35]. These achievements enrich the theoretical model of topological spatial relations.
There are several studies on the formalization of the spatial relations model, but most works are at the semantic level. Xu presented a method of formalizing the natural-language spatial relations between two linear objects with topological and metric indices, and these formalized rules can be used in ArcGIS [36]. In 2012, Bernad et al. described a formalization of the notion of semantic location granule and semantic granule map [37]. In addition, there is a novel framework to formally represent the semantics of structural geological models [38]. However, these formalizations are based on paper-and-pencil proofs and numerical methods. These methods cannot ascertain accuracy due to their inherent limitations, like human-error proneness and numerical errors. To overcome this limitation, we extend the formalization of the topological spatial relations to the Coq theorem prover. The Coq system is relying on a small, trusted core to construct and verify a proof. When verifying a theorem interactively, it requires every step to be spelled out in complete detail. In addition, all the proof details can be checked in this system, which can provide a reliable guarantee for the security of GIS [39].
The formalization of general topology is essential for the machine-checked proof of the topological spatial relations model. Set theory is the foundation of modern mathematics. Our research team has completed the formalization of the axiomatic set theory of MK using the Coq theorem prover [28]. In addition, there is also a project in Coq led by Zhang to formally verify the set theory based on the Zermelo–Fraenkel (ZF) axiom system [40]. The above formalization works provided a solid foundation for our paper. In addition, the formalization of general topology also appears in academics with varying degrees. The most representative is a Coq contribution library led by Schepler, which provides basic concepts of general topology and realized the formal proof of the Tietze Extension Theorem [41]. Another formalization work is completed in Isabelle by Friedrich, where the basic notions of general topology are presented [42]. We also formally proved the C.T. Yang Theorem in Coq [29], which provided a basis for the formalization of general topology. Our present work is based on the above formalization works.

3. Preliminaries

In this section, we give a brief introduction to the Coq proof assistant and an overview of the set theory, which provides foundational support for the presented formalization.

3.1. Coq

The underlying theory of the Coq system is the Calculus of Inductive Constructions, which is a formalism that combines some of the advances in logic from the point of view of λ -calculus [4,5,43]. Coq is an interactive theorem proving environment where the user and machine work together interactively to complete the formal proof. The user is given the possibility to decompose a complex theorem into a collection of already verified theorems or axioms by an inference rule [4,5,43]. The Coq system provides a wide variety of available built-in Coq tactics, including tactics specialized in reasoning about the inductive type, the main automatic tactics, and the tactics for numerical proofs, which are extensively used in our formalization work [4]. In addition, there is Ltac language in Coq for proof automation. The expert users have the possibility to add their own tactics, which will make the formalization more concise and smart.
To make the formalization more readable, the Coq proof assistant provides a Notation command [4,5,43]. The formalization presented in this paper uses a plentiful notation to make the paper more readable for non-experts of Coq. We use the notation “∀” and “∃” to denote the quantifiers; the “ λ t , ” notation for anonymous function “fun t , ”; the notation “∧” and “∨” to denote the logical connectives; the notation “→” and “↔” represent implication and equivalence; and not equal is written by “≠”. More notations and their formal description in our system can be seen in Table 1.
The Coq system implements constructive or intuitionistic logic, in which the law of excluded middle and Axiom of Choice do not hold [5]. However, these laws are indispensable in our formalization. Various basic logics have been formalized and saved as Coq library. The law of the excluded middle can be imported in our system by the Classical library, which is expressed below:
Mathematics 11 01079 i001
Based on the law of the excluded middle, we can prove more classical tautologies such as P P in our system. In addition, we will formally describe the Axiom of Choice based on the concept of function in Section 3.2. More details about the Coq system can obtain from the Coq reference manual [44].

3.2. Set Theory

The foundations of mathematics are crucial for the formalization of our paper. The naive set theory developed by Cantor is the profound embodiment of the strict mathematical foundation [45]. The first comprehensive formal system for logic and mathematics is introduced by Frege in 1879 [3]. However, the logic paradox in Frege’s system and Cantor’s naive set theory was later found [3,45]. In addition, this paradox triggered the third mathematical crisis in the history of mathematics [45].
There are two solutions to this paradox, axiomatic set theory and dependent type theory, to avoid such self-contradictory collections [3,46,47]. The dependent type theory introduces the concept of types to solving self-referentiality, which became very popular in the emerging field of computer science [46]. The axiomatic set theory is more friendly to mathematicians and did specify explicit axioms for set construction [45]. The most representative of axiomatic set theory is ZF set theory [2,48]. Zhang completed the formalization of set theory based on the ZF axiom system using the Coq theorem prover [40]. In addition, the MK set theory was originally published in an appendix format with Kelley’s textbook General topology [49]. Our research team presented the formalization of MK set theory using the Coq theorem prover in 2020 [28]. In addition, this theory system owns a wider range Class than Set, with an infinite axiomatic system [28,49]. Therefore, we select the method of axiomatic set theory to avoid Russell’s paradox. One of the primary reasons to choose the MK axiomatic set theory for the proposed formalization was the presence of extensive support of the MK set theory to general topology. On the other hand, we are familiar with the MK axiomatic set theory and have a relevant formal work foundation. Now, the goal of this section is to formally describe all axioms in our paper.
The type of sets and elements are both Class, and the type of Class is Type in our system. In addition, there are two undefined primitive constants in MK set theory, “∈” (is read belongs to) and “{ | }” (is read the class of all ⋯ satisfy ⋯). The formal description of these constants in Coq is as follows:
Mathematics 11 01079 i002
Several concepts are essential for the MK axiomatic set theory, including empty class, singleton class, include, union, intersection, and the union of the members of the class. We formalize the above definitions in Coq as follows:
Mathematics 11 01079 i003
The concepts of relation and function also play an important role in the MK axiomatic set theory. In our formal system, the relations are defined by the concepts of ordered pairs. In addition, the body of all mathematical constructions and theorems can be constructed from the notions of relation and function. Our formalization of these notions is as follows:
Mathematics 11 01079 i004
Now, we can present the formalization of the eight axioms in the MK set theory. The formal description of these axioms can be seen in Figure 1.
Another important axiom is the Axiom of Choice, which has numerous equivalent formats [50,51]. The format in our system is: Let X be a set; then, there is a function ε (the choice function of X) such that the domain of ε is the family of nonempty subsets of X, and such that ε [ A ] A for every nonempty subset A of X. The formal description of the Axiom of Choice and its corollaries is as follows:
Mathematics 11 01079 i005
With the eight axioms of the MK system and the Axiom of Choice, we can build a library of set theory. The complete details of our formalization for set theory can be found in source file Ensemble.v library.

4. Formalization of General Topology

The notions of interior and boundary play an important role in the presented model of topological spatial relations [27]. In this section, we formally describe the basic definitions and properties of general topology, including topological spaces, subspace topology, and connectedness. All details of formal proof can be found in our source files, and the paper-and-pencil proof can be found in most basic topology textbooks [25,49,52].

4.1. Basic Concepts

4.1.1. Topological Spaces and Neighborhoods

Topological spaces constitute a basic notion in several mathematical fields such as general topology, algebraic topology, and differential topology [53]. In the early stage of the development of topology, topological spaces are constructed by neighborhood systems and closure operations [54,55]. Topological spaces have many equivalent definitions, and the most popular one is the concept of an open set.
Let X be a set. A topology T on X is a collection of subsets of X, such that (i) and X are in T ; (ii) If A , B are in T , then A B is in T ; (iii) If T 1 T , then T 1 is in T . The pair ( X , T ) is called a topological space. When no confusion seems possible we may forget to mention the topology and write "X is a topological space." The sets in T are called open sets. In the remainder of this paper, we let X be a set with a topology T . The concept of topological spaces in our formalization work is described below:
Mathematics 11 01079 i006
Let U be a subset of X, x U ; if there is an open set V such that x V U , then U is said to be a neighborhood of x. The family of all neighborhoods of x is said to be the neighborhood system of x. From these, we can obtain several basic properties of neighborhoods. A subset U of X is an open set if and only if U is the neighborhood of each point. Let U x be a neighborhood system of a point x in X; then, (i) If U , V in U x , then U V U x ; (ii) If U in U x and U V , then V U x ; (iii) If U in U x , then there is a member V of U x such that (i) V U and, (ii) if y V , then V U y . The corresponding definitions and properties of the neighborhoods are described in Coq as follows:
Mathematics 11 01079 i007

4.1.2. Derived Sets, Closed Sets, and Closure

Let A X and x X ; if each neighborhood U of x has points in A other than x, then x is said to be an accumulation point of A. The set of all accumulation points of A is said to be the derived set of A, denoted by d ( A ) . Let A X ; then, (i) If A B , then d ( A ) d ( B ) ; (ii) d ( A B ) = d ( A ) d ( B ) ; (iii) d ( d ( A ) ) A d ( A ) . The above statements can be presented in our formalization as follows:
Mathematics 11 01079 i008
If A X and d ( A ) A , then A is said to be a closed set of topological space X. It is obvious that A is a closed set if and only if the complement set A of A is an open set.
Mathematics 11 01079 i009
If A X , then A d ( A ) is said to be the closure of A, denoted by A ¯ or c ( A ) . We obtain the classical properties for closure. The subset A of topological space X is a closed set if and only if A = A ¯ . We can easily prove that: (i) ¯ = ; (ii) A ¯ ¯ = A ¯ .
Mathematics 11 01079 i010

4.1.3. Interior and Boundary

The concepts of interior and boundary play an essential role in establishing the topological spatial relations model. Let A X and x X ; if A is a neighborhood of x, then x is said to be an interior point of A. The set of all interior points of A is said to be the interior of A, denoted by A . In addition, there are several important relationships between internal and closure. If A X , then (i) A = A ; (ii) A ¯ = A . In the properties of the interior, there are a set of properties that are completely dual to the properties of the closure. The subset A of topological space X is an open set if and only if A = A . If A X , then (i) A = A ; (ii) A is an open set. The corresponding definitions and properties of the interior are described in Coq as follows:
Mathematics 11 01079 i011
Let A X and x X ; if every neighborhood U of x intersects both A and the complement of A, then x is said to be a boundary point of A. The set of all boundary points of A is said to be the boundary of A, denoted by A . It is obvious that A ( A ) = . The relationships among closure, interior, and boundary are crucial to the discussions of the topological spatial relations model. If A is a subset of topological space X, then (i) ( A ) = A ¯ A ¯ = ( A A ) = ( A ) ; (ii) A ¯ = A = A ( A ) ; (iii) A = A = A ¯ ( A ) . In addition, several simple corollaries of the above theorems are frequently used in our formalization. If A is a subset of topological space X, then (i) A ¯ = A ( A ) , A = A ( A ) ; (ii) ( A ) ( A ) , ( A ¯ ) ( A ) . The formal description of definitions and classical properties for boundaries can be seen in Figure 2.

4.2. The Subspaces Topology

The concept of the subspace topology is essential for the rest of this paper. Let ( X , T ) be a topological space and Y X ; then, Y inherits a topology from T . Define A | Y = { A Y | A A } ; then, T | Y is called the subspace topology on Y, and ( Y , T | Y ) is called a subspace of ( X , T ) . Now, we formally prove some classical results about the subspace topology. If ( X , T ) is a topological space and Y X , then we can prove that the family T | Y is a topology on set Y by the Axiom of Choice. In addition, the property of a topological space that is preserved by its subspaces is called a hereditary property. Another frequently used theorem is: Y X Y ¯ = X ( Y ) . If Y is a subspace of topological space ( X , T ) , y Y and A Y , then (i) Let U y be a neighborhood system of a point y in X, and U y ˜ be a neighborhood system of a point y in Y; then, U y ˜ = U y | Y ; (ii) d Y ( A ) = d ( A ) Y ; (iii) c Y ( A ) = A ¯ Y . The above definitions and properties for the subspace topology are formally described in Coq as follows:
Mathematics 11 01079 i012

4.3. Connectedness

Another crucial topological concept which plays an important role in the study of GIS models is connectedness. Let A and B be the subset of topological space X; if ( A B ¯ ) ( B A ¯ ) = , then A and B is called a separation of X. The condition in the above definition is equivalent to A B ¯ = and B A ¯ = . Let Y be a subspace of topological space X, A and B are the subset of Y, and then A and B are a separation of Y if and only if A and B are a separation of X. We formalize the definition and properties of separation in the Coq theorem prover as follows:
Mathematics 11 01079 i013
If there exists a pair A , B of nonempty separation subsets of X such that X = A B , then X is said to be disconnected; otherwise, X is said to be connected. Let X be a topological space; then, the following conditions are equivalent: (i) X is disconnected; (ii) There is a pair A , B of nonempty closed subsets of X such that A B = and A B = X ; (iii) There is a pair A , B of nonempty open subsets of X such that A B = and A B = X ; (iv) There is a nonempty proper subset of X that is both an open set and a closed set.
Mathematics 11 01079 i014
Let Y be a subset of topological space X; if subspace ( Y , T | Y ) is connected, then Y is said to be the connected subset of X; otherwise, Y is said to be the disconnected subset of X. From this definition, we can obtain: if Y Z X , then Y is a connected subset of X if and only if Y is the connected subset of Z. Y is a disconnected subset of X if and only if there exists a pair of the nonempty set, A and B, which is a separation of X and A B = Y . Let Y be a connected subset of topological space X; if A , B form a separation of X and Y A B , then either Y A or Y B . Another property is frequently used in the study of the topological spatial relations model. Let Y be a subspace of topological space X; if Y and Y ¯ X , then Y and X Y ¯ form a separation of X Y . The corresponding definitions and properties of the connected subset in Coq are as follows:
Mathematics 11 01079 i015

5. Formalization of the Topological Spatial Relations Model

In this section, we first introduce the topological spatial relations using the concept of intersection value and then formally prove the topological spatial relations between two sets which are restricted to the regularly closed and the planar spatial regions. For the remainder of this paper, let A and B be a pair of closed subsets of a topological space X, and our goal is to use topological concepts to examine the different ways in which A and B are related to each other in X. Due to space limitations, we mainly present the formal description of relevant definitions and properties. The details of formal proof can be found in the source file Framework.v library, and the informal proof process can be seen in [27].

5.1. Topological Spatial Relations from the Intersection Value

The model is to describe the topological spatial relations between a pair subset A and B in topological space X. In addition, we consider the four intersections A B (called the boundary–boundary intersection), A B (called the interior–interior intersection), A B (called the boundary–interior intersection), and A B (called the interior–boundary intersection), examining whether or not they are empty. For a set Y, if Y is an empty set, then denote C Y = 0 ; otherwise, C Y = 1 . We formalize these definitions in the Coq theorem prover as follows:
Mathematics 11 01079 i016
Definition 1.
Let A , B be a pair of closed sets in X, and define  the intersection value  for A and B by
I A , B = ( C A B , C A B , C A B , C A B ) .
With the law of the excluded middle, a set is either empty or non-empty. Therefore, there are sixteen possibilities topological spatial relations between the closed sets A and B. The formal description of this definition can be seen in Figure 3.
On the other hand, these topological spatial relations provide complete coverage, that is, there is is always a topological relation between A and B. The sixteen possible topological spatial relations are described in Table 2.
The type of topological space X in which A and B lie is very important in the topological spatial relations between A and B. As shown in Figure 4, the same configuration for the set A and B has a different intersection value. On the left of Figure 4, the set A and B is embedded in a line. As the subsets of the line, the intersection value between A and B is I A , B = ( 0 , 1 , 1 , 1 ) . On the right of Figure 4, the set A and B is embedded in a plane. At this time, A = A , B = B , A = B = . Then, the intersection value between A and B is I A , B = ( 1 , 0 , 0 , 0 ) .
In addition, if X is in the real number plane R 2 , then these sixteen topological spatial relations can be seen in Figure 5. As shown in Figure 5, the intersection values r 0 , r 1 , r 3 , r 6 , r 7 , r 10 , r 11 , and r 15 can be easily obtained by the definitions of boundaries and interiors. For the situation r 2 , since A = B = R 2 , then A = B = and A = A , B = B , and it follows that A B = , A B , A B = , and A B = . Therefore, the intersection value between A and B is r 2 = ( 0 , 1 , 0 , 0 ) . In addition, the intersection values r 4 , r 5 , r 8 , r 9 , r 12 , and r 13 belong to the same category. Take the situation r 4 as an example. From the example in Figure 4, we can known that: if the line set A embedded in a plane, then A = A and A = ; it follows that A B = , A B = , A B , and A B = . Therefore, the intersection value between A and B is r 4 = ( 0 , 0 , 1 , 0 ) . For the situation r 14 , A is a circular ring and B is a circular; then, A B = , A B , A B , and A B , and it follows that the intersection value between A and B is r 14 = ( 0 , 1 , 1 , 1 ) .

5.2. Topological Spatial Relations between Regularly Closed

In the application of GIS, we need to restrict the types of sets under consideration. From the examples in Figure 5 we conclude that at least the relations r 0 , r 1 , r 2 , r 3 , r 6 , r 7 , r 10 , r 11 , r 14 , and r 15 exist between two regularly closed sets. Thus, the subsets A and B are restricted to the regularly closed in this section, which are defined as follows:
Definition 2.
For a set A, if A = A ¯ , then A is called regularly closed.
Regularly closed subsets of the plane have no whiskers attached, and all boundary points have interior points arbitrarily close by. This feature is crucial in modeling geographic areas. From the above definition, we obtain a fundamental property of regularly closed: Let A and B be regularly closed in X; if A B , then A B . The above notions are described in Coq as follows:
Mathematics 11 01079 i017
The following theorem shows that, when the sets are restricted to regularly closed, some situations do not occur.
Theorem 1.
For a pair of regularly closed sets A and B, the intersection values r 4 , r 5 , r 8 , r 9 , r 12 , and r 13 cannot occur.
The formal description of this theorem is shown in Figure 6.

5.3. Topological Spatial Relations between Planar Spatial Regions

In this section, the subsets A and B are restricted to the planar spatial region. This condition guarantees that the set does not have separate interior parts that are, for instance, only accessible from each other by going through the boundary.
Definition 3.
A  planar spatial regionin a connected topological space X is a nonempty proper subset A of X satisfying (i) A is regularly closed; (ii) A is a connected subset of X.
With this definition, we prove some basic results about the planar spatial region. For instance, the following statements state that: (i) The interior of each planar spatial region is nonempty; (ii) The closure of each planar spatial region is not equal to X; (iii) Each planar spatial region is a connected subset of X. The above definition and statements, formalized in our system, are:
Mathematics 11 01079 i018
The following theorem eliminates one more possible topological spatial relation, as long as we assume that X is a connected topological space.
Theorem 2.
Let X be a connected topological space; then, for two planar spatial regions A and B, the intersection value r 2 cannot occur.
There is a lemma that is essential for the proof of Theorem 2: the boundary of each planar spatial region is nonempty. These properties are described formally in the Coq theorem prover as follows:
Mathematics 11 01079 i019
Therefore, the only intersection values that are possible for two planar spatial regions are r 0 , r 1 , r 3 , r 6 , r 7 , r 10 , r 11 , r 14 , and r 15 . The following theorem describes the corresponding relationship between nine possible intersection values and their topological spatial relation.
Theorem 3.
Let A and B be planar spatial regions of connected topological space X; then, the possible intersection values for A and B are listed in the left column of Table 3, and the topological spatial relations between A and B are depicted in the right column.
The first four rows of Table 3 can be easily proved in our system, and the formal description can be seen in Figure 7.
The remaining conclusions of Theorem 3 are based on the property of connectedness. There is a lemma that is indispensable for the proof of Theorem 3. Let A and B be planar spatial regions; if A B and A B = , then A B and A B . Here is the formal statement we obtained in the Coq proof assistant corresponding to the above lemma.
Mathematics 11 01079 i020
As shown Figure 8, we completed the formal description of Theorem 3.
Since geographic areas are planar spatial regions, Theorem 3 can be used to describe the relationships between pairs of geographic areas. Furthermore, the descriptive expressions in Table 3 are mutually exclusive and cover all possibilities for the relationship between two geographic areas.

6. Conclusions

This paper presented a formalization of a topological spatial relations model applied to geographic information systems in the Coq theorem prover. The formalization proceeds from the Morse–Kelley set theory, and basic notions and results of general topology are further developed. The topological spatial relation is defined by using the concept of intersection value, and we studied the topological spatial relations between two sets which are restricted to the regularly closed and the planar spatial regions. Finally, we formally proved that there are only nine topological spatial relations between two sets when they are restricted to planar spatial regions. In addition, all the proof details of this model are verified in Coq 8.9.1. The complete Coq source files are available at https://github.com/BalanceYan/GIS_topology (accessed on 26 December 2022) for readers interested in viewing the Coq code.
The distinctive characteristics of our formalization work are: (i) It inherits the advantages of the MK axiomatic set theory, and the self-contradictory collections such as Russell’s paradox are excluded from our system; (ii) It profits from the Coq proof assistant and offers novel views of the topological spatial relations theoretical model at different levels of detail to suit the different need of readers; (iii) It also contributes to verifying the correctness of various GIS models and software, as well as storing, querying, and manipulating geographically referenced data.
In the future, we will formally verify more GIS models based on this paper. On the one hand, we can supplement the formalization of real theory, and then explore the topological spatial relations when the topological space X is n-dimensional Euclidean space. On the other hand, we will further improve the automation of formal proof by several automatic tactics and Ltac language. In addition, this will be an interesting attempt in the field of GIS. In addition, this model has an important effect on the design and implementation of geographic information systems. We can apply it for the formalization of topological spatial relations between spatial objects of different dimensions, such as a line and regions with holes. In particular, when the concept of topology is extended to supra-topology and infra-topology, the topological spatial relations between a pair set will become more diverse and accurate.

Author Contributions

Conceptualization, S.Y. and W.Y.; methodology, S.Y. and W.Y.; software, S.Y.; validation, S.Y. and W.Y.; formal analysis, S.Y. and W.Y.; investigation, S.Y. and W.Y.; resources, S.Y.; data curation, S.Y.; writing—original draft preparation, S.Y.; writing—review and editing, S.Y.; supervision, W.Y.; project administration, S.Y. 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. 61936008.

Data Availability Statement

No new data were created or analyzed in this study. Data sharing is not applicable to this article.

Acknowledgments

We are grateful to the anonymous reviewers, whose comments greatly helped to improve the presentation of our research in this article.

Conflicts of Interest

The authors declare no conflict of interest.

Abbreviations

The following abbreviations are used in this manuscript:
GIS Geographic Information System
MKMorse–Kelley
ZFZermelo–Fraenkel

References

  1. Wiedijk, F. Formal Proof—Getting Started. Not. Am. Math. Soc. 2008, 55, 1408–1414. [Google Scholar]
  2. Hales, T.C. Formal Proof. Not. Am. Math. Soc. 2008, 55, 1370–1380. [Google Scholar]
  3. Harrison, J. Formal Proof-Theory and Practice. Not. Am. Math. Soc. 2008, 55, 1395–1406. [Google Scholar]
  4. Bertot, Y.; Castéran, P. Interactive Theorem Proving and Program Development-Coq’Art: The Calculus of Inductive Constructions; Springer: Berlin, Germany, 2004. [Google Scholar]
  5. Chlipala, A. Certified Programming with Dependent Types: A Pragmatic Introduction to the Coq Proof Assistant; MIT Press: Massachusetts, DC, USA, 2013. [Google Scholar]
  6. Nipow, T.; Paulson, L.C.; Wenzel, M. Isabelle/HOL: A Proof Assistant for Higher-Order Logic; Springer: Berlin, Germany, 2002. [Google Scholar]
  7. Harrision, J. The HOL Light Theorem Prover. Available online: http://www.cl.cam.ac.uk/~jrh13/hol-light/ (accessed on 13 January 2017).
  8. Bancerek, G.; Bylinski, C.; Grabowski, A.; Kornilowicz, A.; Matuszewski, R.; Naumowicz, A.; Pak, K.; Urban, J. Mizar: State-of-the-art and beyond. In Proceedings of the International Conference on Intelligent Computer Mathematics (CICM 2015), Washington DC, USA, 13–17 July 2015; Volume 9150, pp. 261–279. [Google Scholar]
  9. Gonthier, G. Formal proof—The Four Color Theorem. Not. Am. Math. Soc. 2008, 55, 1382–1393. [Google Scholar]
  10. Gonthier, G.; Asperti, A.; Avigad, J.; Bertot, Y.; Cohen, C.; Garillot, F.; Le Roux, S.; Mahboubi, A.; O’Connor, R.; Biha, S.O.; et al. 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; Volume 7998, pp. 163–179. [Google Scholar]
  11. Hales, T.; Adams, M.; Bauer, G.; Dang, T.D.; Harrison, J.; Hoang, L.T.; Kaliszyk, C.; Magron, V.; Mclaughlin, S.; Nguyen, T.; et al. A Formal Proof of the Kepler Conjecture. In Forum of Mathematics, Pi; Cambridge University Press: Cambridge, UK, 2017; Volume 5, p. e2. [Google Scholar]
  12. Yu, W.S.; Fu, Y.S.; Guo, L.Q. Machine Proof System of Foundations of Analysis; Science Press: Beijing, China, 2022. [Google Scholar]
  13. Fu, Y.S.; Yu, W.S. Formalization of the Equivalence among Completeness Theorems of Real Number in Coq. Mathematics 2021, 9, 38. [Google Scholar] [CrossRef]
  14. Fu, Y.S.; Yu, W.S. Formalizing Calculus without Limit Theory in Coq. Mathematics 2021, 9, 1377. [Google Scholar] [CrossRef]
  15. Formalizing 100 Theorems. Available online: http://www.cs.ru.nl/~freek/100/ (accessed on 3 March 2021).
  16. Leroy, X. A Formally Verified Compiler Back-End. J. Autom. Reasoning 2009, 43, 363–446. [Google Scholar] [CrossRef] [Green Version]
  17. Klein, G.; Elphinstone, K.; Heiser, G.; Andronick, J.; Cock, D.; Derrin, P.; Elkaduwe, D.; Engelhardt, K.; Kolanski, R.; Norrish, M.; et al. seL4: Formal verification of an OS kernel. In Proceedings of the ACM SIGOPS 22nd Symposium on Operating Systems Principles (SOSP 2009), Big Sky, MT, USA, 11–14 October 2009; pp. 207–220. [Google Scholar]
  18. Bhargavan, K.; Delignat-Lavaud, A.; Fournet, C.; Gollamudi, A.; Gonthier, G.; Kobeissi, N.; Kulatova, N.; Rastogi, A.; Sibut-Pinote, T.; Swamy, N.; et al. Formal verification of smart contracts. In Proceedings of the 2016 ACM Workshop on Programming Languages and Analysis for Security (PLAS 2016), Vienna, Austria, 24 October 2016; pp. 91–96. [Google Scholar]
  19. Sun, T.Y.; Yu, W.S. A Formal Verification Framework for Security Issues of Blockchain Smart Contracts. Electronics 2020, 9, 255. [Google Scholar] [CrossRef] [Green Version]
  20. Choi, J.; Vijayaraghavan, M.; Sherman, B.; Chlipala, A. Kami: A Platform for High-Level Parametric Hardware Specification and Its Modular Verification. Proc. ACM Program. Lang. 2017, 1, 24. [Google Scholar] [CrossRef] [Green Version]
  21. Longley, P.A.; Goodchild, M.F.; Maguire, D.J.; Rhind, D.W. Geographic Information Science and Systems, 4th ed.; Wiley Publishing: New York, NY, USA, 2015. [Google Scholar]
  22. Wu, X.H.; Dong, W.H.; Wu, L.; Liu, Y. Research themes of geographical information science during 1991–2020: A retrospective bibliometric analysis. Int. J. Geogr. Inf. Sci. 2022, 36, 243–275. [Google Scholar] [CrossRef]
  23. Arief, M.; Ramdani, F.; Bachtiar, F.A. A Conceptual Framework for Uncertainty Analysis in Map-Based Urban Spatial Planning. In Proceedings of the 6th International Conference on Sustainable Information Engineering and Technology (SIET 2021), Malang, Indonesia, 13–14 September 2021; pp. 197–202. [Google Scholar]
  24. Jiang, J.Y.; Wang, X.; Liu, T.; Fang, Z.D.; Pei, T.; Song, C.; Du, P.J. Topological relationship model for geographical flows. Cartogr. Geogr. Inf. Sc. 2022, 49, 528–544. [Google Scholar] [CrossRef]
  25. Adams, C.; Franzosa, R. Introduction to Topology: Pure and Applied; Pearson Prentice Hall: Upper Saddle River, NJ, USA, 2008. [Google Scholar]
  26. Praing, R.; Schneider, M. Topological feature vectors for exploring topological relationships. Int. J. Geogr. Inf. Sci. 2009, 23, 319–353. [Google Scholar] [CrossRef]
  27. Egenhofer, M.J.; Franzosa, R.D. Point-set Topological Spatial Relations. Int. J. Geogr. Inf. SCI. 1991, 5, 161–174. [Google Scholar] [CrossRef] [Green Version]
  28. Yu, W.S.; Sun, T.Y.; Fu, Y.S. Machine Proof System of Axiomatic Set Theory; Science Press: Beijing, China, 2020. [Google Scholar]
  29. Yan, S.; Yu, W.S.; Fu, Y.S. Formalization of the C.T. Yang’s Theorem in Coq. J. Softw. 2022, 6, 2204–2218. [Google Scholar]
  30. Yan, S.; Fu, Y.S.; Guo, D.K.; Yu, W.S. A Formalization of Topological Spaces in Coq. In Proceedings of the 2021 International Conference on Wireless Communications, Networking and Applications (WCNA 2021), Berlin, Germany, 17–19 December 2021; Volume 942, pp. 196–204. [Google Scholar]
  31. Ma, L.B.; Deng, M.; Wu, J.; Liu, Q.L. Modeling spatiotemporal topological relationships between moving object trajectories along road networks based on region connection calculus. Cartogr. Geogr. Inf. Sc. 2016, 43, 346–360. [Google Scholar] [CrossRef]
  32. Seraj, S.; Delavar, M.R.; Rezaee, R. A hybrid GIS-assisted framework to integrate Dempster–Shafer theory of evidence and fuzzy sets in risk analysis: An application in hydrocarbon exploration. Geocartol. Int. 2021, 36, 820–838. [Google Scholar] [CrossRef]
  33. Leng, L.; Wang, F.Y.; Wang, M.C.; Yang, G.D.; Niu, X.F.; Zhang, X.Q. A Generalized 9-Intersection Model for Topological Relations between Regions with Holes. ISPRS Int. J. Geo-Inf. 2022, 11, 218. [Google Scholar] [CrossRef]
  34. Al-shami, T.M.; Alshammari, I. Rough sets models inspired by supra-topology structures. Artif. Intell. Rev. 2022. [Google Scholar] [CrossRef]
  35. Al-shami, T.M.; Mhemdi, A. Approximation operators and accuracy measures of rough sets from an infra-topology view. Soft Comput. 2023, 27, 1317–1330. [Google Scholar] [CrossRef]
  36. Xu, J. Formalizing natural-language spatial relations between linear objects with topological and metric properties. Int. J. Geogr. Inf. Sci. 2007, 21, 377–395. [Google Scholar] [CrossRef]
  37. Bernad, J.; Bobed, C.; Mena, E.; IlarrI, S. A formalization for semantic location granules. Int. J. Geogr. Inf. Sci. 2013, 27, 1090–1108. [Google Scholar] [CrossRef]
  38. Zhan, X.L.; Lu, C.; Hu, G.M. A Formal Representation of the Semantics of Structural Geological Models. Sci. Programming-Neth. 2022, 2022, 5553774. [Google Scholar] [CrossRef]
  39. Avigad, J.; Harrison, J. Formally Verified Mathematics. Commun. ACM 2014, 57, 66–75. [Google Scholar] [CrossRef]
  40. Zhang, Q.P. Set-Theory: Coq Encoding of ZFC and Formalization of the Textbook Elements of Set Theory. Available online: https://github.com/choukh/Set-Theory (accessed on 30 September 2021).
  41. Schepler, D. Topology: General Topology in Coq. Available online: https://github.com/coq-community/topology (accessed on 14 February 2022).
  42. Friedrich, S. The Topology of Lazy Lists. Archive of Formal Proofs. Available online: https://www.isa-afp.org/entries/Topology.html (accessed on 27 April 2004).
  43. Pierce, B.C.; Amorim, A.A.; Casinghino, C.; Gaboardi, M.; Greenberg, M.; Hriţcu, C.; Sjöberg, V.; Yorgey, B. Software Foundations (Version 6.1). Available online: https://softwarefoundations.cis.upenn.edu/ (accessed on 11 August 2021).
  44. The Coq Development Team. The Coq Reference Manual (Version 8.9.1). Available online: https://coq.inria.fr/distrib/V8.9.1/refman/ (accessed on 18 May 2018).
  45. Katz, V.J. A History of Mathematics: An Introduction, 3rd ed.; Addison-Wesley: Boston, MA, USA, 2009. [Google Scholar]
  46. Kirst, D. Foundations of Mathematics: A Discussion of Sets and Types. Bachelor’s Thesis, Saarland University, Saarbrücken, Germany, 2018. Available online: https://www.ps.uni-saarland.de/~kirst/hokbachelor.php (accessed on 11 April 2018).
  47. Barras, B. Sets in Coq, Coq in Sets. J. Formaliz. Reason. 2010, 3, 29–48. [Google Scholar]
  48. Enderton, H.B. Elements of Set Theory; Springer: New York, NY, USA, 1977. [Google Scholar]
  49. Kelly, J.L. General Topology; Springer: New York, NY, USA, 1955. [Google Scholar]
  50. Jech, T.J. The Axiom of Choice; North Holland Publishing Company: Amsterdam, The Netherlands, 1973. [Google Scholar]
  51. Paulson, L.C. The Relative Consistency of the Axiom of Choice Mechanized Using Isabelle/ZF. LMS J. Comput. Math. 2003, 6, 198–248. [Google Scholar] [CrossRef] [Green Version]
  52. Xiong, J.C. A Lecture on Point-Set Topology, 4th ed.; Higher Education Press: Beijing, China, 2011. [Google Scholar]
  53. Bourbaki, N. Elements of Mathematics: General Topology, Part 1; Springer: Berlin, Germany, 1995. [Google Scholar]
  54. You, S.J.; Yuan, W.J. The equivalent definition of topology. J. Guangzhou Univ. (Nat. Sci. Ed.) 2004, 10, 492–494. [Google Scholar]
  55. Moore, G.H. The Emergence of Open sets, Closed sets, and Limit points in Analysis and Topology. Hist. Math. 2008, 35, 220–241. [Google Scholar] [CrossRef] [Green Version]
Figure 1. The formalization of the eight axioms in the MK set theory.
Figure 1. The formalization of the eight axioms in the MK set theory.
Mathematics 11 01079 g001
Figure 2. The formalization of definitions and classical properties for boundaries.
Figure 2. The formalization of definitions and classical properties for boundaries.
Mathematics 11 01079 g002
Figure 3. The formal description of the intersection value.
Figure 3. The formal description of the intersection value.
Mathematics 11 01079 g003
Figure 4. The topological spatial relations for the same configuration when embedded in a different topological space.
Figure 4. The topological spatial relations for the same configuration when embedded in a different topological space.
Mathematics 11 01079 g004
Figure 5. The topological spatial relations in the real number plane.
Figure 5. The topological spatial relations in the real number plane.
Mathematics 11 01079 g005
Figure 6. The formal description of Theorem 1.
Figure 6. The formal description of Theorem 1.
Mathematics 11 01079 g006
Figure 7. The formal description of Theorem 3 ( r 0 , r 1 , r 14 , r 15 ).
Figure 7. The formal description of Theorem 3 ( r 0 , r 1 , r 14 , r 15 ).
Mathematics 11 01079 g007
Figure 8. The formal description of Theorem 3 ( r 3 , r 6 , r 7 , r 10 , r 11 ).
Figure 8. The formal description of Theorem 3 ( r 3 , r 6 , r 7 , r 10 , r 11 ).
Mathematics 11 01079 g008
Table 1. The notations in our formal system.
Table 1. The notations in our formal system.
NotationCoq DefinitionMathematical Meaning
a A In a Aa is an element of A
{ P } Classifier PThe set satisfying property P
A NoEmpty AThe non-void class
EmptyThe void class
{ x } Singleton xSingleton x
A B Included A BB contains A
A B ProperSub A BB properly contains A
P ( X ) PowerSet XThe power class of X
A B Union A BThe union of A and B
A B Inter A BThe intersection of A and B
A B Setmin A BThe difference of A and B
x EleU xThe union of the members of x
x EleI xThe intersection of the members of x
[ x | y ] Unorder x yAn unordered pair
[ x , y ] Order x yAn ordered pair
X × Y Cartesian X YThe Cartesian product
r a n ( R ) Range RThe range of a relation R
d o m ( R ) Domain RThe domain of a relation R
F [ x ] Value F xThe value of F at x
f | A Restriction f AThe restriction of f to A
X ˜ neSub XThe family of nonempty subsets of X
Table 2. The sixteen possible topological spatial relations between the closed sets A and B.
Table 2. The sixteen possible topological spatial relations between the closed sets A and B.
Number A B A B A B A B
r 0 0000
r 1 1000
r 2 0100
r 3 1100
r 4 0010
r 5 1010
r 6 0110
r 7 1110
r 8 0001
r 9 1001
r 10 0101
r 11 1101
r 12 0011
r 13 1011
r 14 0111
r 15 1111
Table 3. The nine relations between two planar spatial region A and B.
Table 3. The nine relations between two planar spatial region A and B.
Intersection ValueRelationship
r 0 = ( 0 , 0 , 0 , 0 ) A B =
r 1 = ( 1 , 0 , 0 , 0 ) A B = A B
r 14 = ( 0 , 1 , 1 , 1 ) A B
r 15 = ( 1 , 1 , 1 , 1 ) A B
r 3 = ( 1 , 1 , 0 , 0 ) A = B
r 6 = ( 0 , 1 , 1 , 0 ) A B
r 7 = ( 1 , 1 , 1 , 0 ) A B
r 10 = ( 0 , 1 , 0 , 1 ) B A
r 11 = ( 1 , 1 , 0 , 1 ) B A
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

Yan, S.; Yu, W. Formal Verification of a Topological Spatial Relations Model for Geographic Information Systems in Coq. Mathematics 2023, 11, 1079. https://doi.org/10.3390/math11051079

AMA Style

Yan S, Yu W. Formal Verification of a Topological Spatial Relations Model for Geographic Information Systems in Coq. Mathematics. 2023; 11(5):1079. https://doi.org/10.3390/math11051079

Chicago/Turabian Style

Yan, Sheng, and Wensheng Yu. 2023. "Formal Verification of a Topological Spatial Relations Model for Geographic Information Systems in Coq" Mathematics 11, no. 5: 1079. https://doi.org/10.3390/math11051079

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop