The identity type is arguably one of the most interesting entities of Martin-Löf type theory. From any type , it is possible to construct the identity type . This type establishes the relation of identity between two terms of , i.e., if there is , then is a witness or proof that is indeed equal to . The proposal of the Univalence Axiom made the identity type one of the most studied aspects of type theory. It proposes that is equivalent to saying that , that is, the identity is an equivalence of equivalences. Another important aspect is the fact that it is possible to interpret the as paths between two points of the same space. This interpretation gives rise to the interesting interpretation of equality as a collection of homotopical paths. This connection of type theory and homotopy theory makes type theory a suitable foundation for both computation and mathematics. Nevertheless, this interpretation is only a semantical one  and it was not proposed with a syntactical counterpart for the concept of path in type theory. For that reason, the addition of paths to the syntax of homotopy type theory has been recently proposed by De Queiroz, Ramos and De Oliveira  , in these works, the authors use an entity known as ‘computational path’, proposed by De Queiroz and Gabbay in 1994 , and show that it can be used to formalize the identity type in a more explicit manner.
On the other hand, one of the main interesting points of the interpretation of logical connectives via deductive systems which use a labelling system is the clear separation between a functional calculus on the labels (the names that record the steps of the proof) and a logical calculus on the formulas [25, 8]. Moreover, this interpretation has important applications. The works of [5, 8, 15, 17] claim that the harmony that comes with this separation makes labelled natural deduction a suitable framework to study and develop a theory of equality for natural deduction. Take, for example, the following cases taken from the -calculus :
In the theory of the -equality of -calculus, we can indeed say that is equal to . Moreover, as we can see above, we have at least two ways of obtaining these equalities. We can go further, and call the first sequence of rewrites that establish that is indeed equal to . The second one, for example, we can call . Thus, we can say that this equality is established by and . As we will see in this paper, we and are examples of an entity known as computational path.
Since we now have labels (computational paths) that establishes the equality between two terms, interesting questions might arise: is different of or are they normal forms of this equality proof? If is equal to , how can we prove this? We can answer questions like this when we work in a labelled natural deduction framework. The idea is that we are not limited by the calculus on the formulas, but we can also define and work with rules that apply to the labels. That way, we can use these rules to formally establish the equality between these labels, i.e., establish equalities between equalities. In this work, we will use a system proposed by  and known as -.
In that context, the contribution of this paper will be to propose a surprising connection: it is possible to use a labelled natural deduction system together with - to obtain topological results about fundamental groups.
Indeed, in this paper we will develop a theory and show that it is powerful enough to calculate the fundamental group of a circle, torus and real projective plane. For this, e use a labelled deduction system based on the concept of computational paths (sequence of rewrites). Taking into account that in mathematics  the calculation of this fundamental group is quite laborious, we believe our work accomplishes this calculation in a less complex form. Nevertheless, to obtain this result we need to first formally define the concept of computational paths and define -.
2 Computational Paths
Before we enter in specific details of computational path theory, let’s recall what motivated the introduction of computational paths to type theory. In type theory, the types are interpreted using the so-called Brower-Heyting-Kolmogorov Interpretation. That way, a semantic interpretation of types are not given by truth-values, but by the concept of proof as a primitive notion. Thus, we have :
|a proof of the proposition:||is given by:|
|a proof of and a proof of|
|a proof of or a proof of|
|a function that turns a proof of into a proof of|
|a function that turns an element into a proof of|
|an element (witness) and a proof of|
Also, based on the Curry-Howard functional interpretation of logical connectives, one has :
|a proof of the proposition:||has the canonical form of:|
|3||where is a proof of and is a proof of|
|where is a proof of or where is a proof of|
|(‘’ and ‘’ abbreviate ‘into the left/right disjunct’)|
|where is a proof of B|
|provided is a proof of A|
|where is a proof of|
|provided is an arbitrary individual chosen|
|from the domain|
|where is a witness|
|from the domain , is a proof of|
If one looks closely, there is one interpretation missing in the BHK-Interpretation. What constitutes a proof of ? In other words, what is a proof of an equality statement? We answer this by proposing that an equality between those two terms should be a sequence of rewrites starting from and ending at . Thus, we would have :
|a proof of the proposition:||is given by:|
|(Perhaps a sequence of rewrites|
|starting from and ending in ?)|
We call computational path the sequence of rewrites between these terms.
2.1 Formal Definition
Since computational path is a generic term, it is important to emphasize the fact that we are using the term computational path in the sense defined by . A computational path is based on the idea that it is possible to formally define when two computational objects are equal. These two objects are equal if one can reach from applying a sequence of axioms or rules. This sequence of operations forms a path. Since it is between two computational objects, it is said that this path is a computational one. Also, an application of an axiom or a rule can transforms (or rewrite) an term. For that reason, a computational path is also known as a sequence of rewrites. Nevertheless, before we define formally a computational path, we can take a look at one famous equality theory, the :
The -equality is composed by the following axioms:
And the following rules of inference:
Definition 2 ().
is -equal or -convertible to (notation ) iff is obtained from by a finite (perhaps empty) series of -contractions and reversed -contractions and changes of bound variables. That is, iff there exist () such that , ,
(Note that equality has an existential force, which will show in the proof rules for the identity type.)
The same happens with -equality:
Definition 3 (-equality  ).
The equality-relation determined by the theory is called ; that is, we define
Take the term . Then, it is -equal to because of the sequence:
which starts from and ends with , and each member of the sequence is obtained via 1-step - or -contraction of a previous term in the sequence. To take this sequence into a path, one has to apply transitivity twice, as we do in the example below.
The term is -equal to because of the sequence:
Now, taking this sequence into a path leads us to the following:
The first is equal to the second based on the grounds:
The second is equal to the third based on the grounds:
Now, the first is equal to the third based on the grounds:
Now, the third is equal to the fourth one based on the grounds:
Thus, the first one is equal to the fourth one based on the grounds:
The aforementioned theory establishes the equality between two -terms. Since we are working with computational objects as terms of a type, we need to translate the -equality to a suitable equality theory based on Martin-Löf’s type theory. We obtain:
The equality theory of Martin-Löf’s type theory has the following basic proof rules for the -type:
We are finally able to formally define computational paths:
Let and be elements of a type . Then, a computational path from to is a composition of rewrites (each rewrite is an application of the inference rules of the equality theory of type theory or is a change of bound variables). We denote that by .
As we have seen in example2, composition of rewrites are applications of the rule . Since change of bound variables is possible, each term is considered up to -equivalence.
2.2 Equality Equations
One can use the aforementioned axioms to show that computational paths establish the three fundamental equations of equality: the reflexivity, symmetry and transitivity:
2.3 Identity Type
We have said that it is possible to formulate the identity type using computational paths. As we have seen, the best way to define any formal entity of type theory is by a set of natural deductions rules. Thus, we define our path-based approach as the following set of rules:
One can notice that our formation rule is exactly equal to the traditional identity type. From terms , one can form that is inhabited only if there is a proof of equality between those terms, i.e., .
The difference starts with the introduction rule. In our approach, one can notice that we do not use a reflexive constructor . In other words, the reflexive path is not the main building block of our identity type. Instead, if we have a computational path , we introduce as a term of the identity type. That way, one should see as a sequence of rewrites and substitutions (i.e., a computational path) which would have started from and arrived at
Let’s recall the notation being used. First, one should see as a functional expression which depends on . Also, one should notice the the use of ‘’ in . One should see ‘’ as an abstractor that binds the occurrences of the variable introduced in the local assumption as a kind of Skolem-type constant denoting the reason why was assumed to be equal to .
We also introduce the constructor . In a sense, it is similar to the constructor of the traditional approach, since both arise from the elimination rule of the identity type. The behavior of is simple. If from a computational path that establishes the equality between and one can construct , then if we also have this equality established by a term , we can put together all this information in to construct , eliminating the type in the process. The idea is that we can substitute for in , resulting in . This behavior is established next by the reduction rule.
Our introduction and elimination rules reassures the concept of equality as an existential force. In the introduction rule, we encapsulate the idea that a witness of a identity type only exists if there exist a computational path establishing the equality of and . Also, one can notice that our elimination rule is similar to the elimination rule of the existential quantifier.
2.4 Path-based Examples
The objective of this subsection is to show how to use in practice the rules that we have just defined. The idea is to show construction of terms of some important types. The constructions that we have chosen to build are the reflexive, transitive and symmetric type of the identity type. Those were not random choices. The main reason is the fact that reflexive, transitive and symmetric types are essential to the process of building a groupoid model for the identity type [hofmann1]. As we shall see, these constructions come naturally from simple computational paths constructed by the application of axioms of the equality of type theory.
Before we start the constructions, we think that it is essential to understand how to use the eliminations rules. The process of building a term of some type is a matter of finding the right reason. In the case of , the reason is the correct and that generates the adequate . In our approach, the reason is the correct path that generates the adequate .
One could find strange the fact that we need to prove the reflexivity. Nevertheless, just remember that our approach is not based on the idea that reflexivity is the base of the identity type. As usual in type theory, a proof of something comes down to a construction of a term of a type. In this case, we need to construct a term of type . The reason is extremely simple: from a term , we obtain the computational path :
The second proposed construction is the symmetry. Our objective is to obtain a term of type .
We construct a proof using computational paths. As expected, we need to find a suitable reason. Starting from , we could look at the axioms of definition 4.1 to plan our next step. One of those axioms makes the symmetry clear: the axiom. If we apply , we will obtain . From this, we can then infer that is inhabited by . Now, it is just a matter of applying the elimination :
The third and last construction will be the transitivity. Our objective is to obtain a term of type:
To build our path-based construction, the first step, as expected, is to find the reason. Since we are trying to construct the transitivity, it is natural to think that we should start with paths and and then, from these paths, we should conclude that there is a path that establishes that . To obtain , we could try to apply the axioms of definition 4.1. Looking at the axioms, one is exactly what we want: the axiom . If we apply to and , we will obtain a new path such that . Using that construction as the reason, we obtain the following term :
As one can see, each step is just straightforward applications of introduction, elimination rules and abstractions. The only idea behind this construction is just the simple fact that the axiom guarantees the transitivity of paths.
3 A Term Rewriting System for Paths
As we have just shown, a computational path establishes when two terms of the same type are equal. From the theory of computational paths, an interesting case arises. Suppose we have a paththat establishes that and a path that establishes that . Consider that and are formed by distinct compositions of rewrites. Is it possible to conclude that there are cases that and should be considered equivalent? The answer is yes. Consider the following example:
Consider the path . By the symmetry property, we obtain . What if we apply the property again on the path ? We would obtain a path . Since we applied symmetry twice in succession, we obtained a path that is equivalent to the initial path . For that reason, we conclude the act of applying symmetry twice in succession is a redundancy. We say that the path can be reduced to the path .
As one could see in the aforementioned example, different paths should be considered equal if one is just a redundant form of the other. The example that we have just seen is just a straightforward and simple case. Since the equality theory has a total of 7 axioms, the possibility of combinations that could generate redundancies are rather high. Fortunately, most possible redundancies were thoroughly mapped by . In that work, a system that establishes redundancies and creates rules that solve them was proposed. This system, known as -, originally mapped a total of 39 rules. For each rule, there is a proof tree that constructs it. We included all rules in appendix B. To illustrate those rules, take the case of example 2. We have the following [<Ruy1>]:
It is important to notice that we assign a label to every rule. In the previous case, we assigned the label .
Definition 6 (-rule ).
An -rule is any of the rules defined in -.
Definition 7 (-contraction ).
Let and be computational paths. We say that (read as: -contracts to ) iff we can obtain from by an application of only one -rule. If can be reduced to by finite number of -contractions, then we say that (read as -reduces to ).
Definition 8 (-equality ).
Let and be computational paths. We say that (read as: is -equal to ) iff can be obtained from by a finite (perhaps empty) series of -contractions and reversed -contractions. In other words, iff there exists a sequence , with , such that
-equality is transitive, symmetric and reflexive.
Comes directly from the fact that -equality is the transitive, reflexive and symmetric closure of . ∎
The above proposition is rather important, since sometimes we want to work with paths up to -equality. For example, we can take a path and use it as a representative of an equivalence class, denoting this by .
4 Fundamental Group of surfaces obtained by means of Computational Paths
The objective of this section is to show that it is possible to use computational paths to obtain the fundamental group of some surfaces. This is one of the main results of homotopy theory. We avoid the use of the heavy and rather complicated machinery of the code-encode-decode approach. In what follows we will get the fundamental group of some surfaces.
4.1 Fundamental Group of Circle S
Definition 9 (The circle ).
The circle is the type generated by:
A base point -
A base computational path - .
The first thing one should notice is that this definition does not use only the points of the type , but also a base computational path called between those points. That is why it is called a higher inductive type . Our approach differs from the one developed in the HTT book  on the fact that we do not need to simulate the path-space between those points, since we add computational paths to the syntax of the theory. We proceed with the following definition:
We can define and denote by
the path naturally obtained by the application the of path-axioms , and to the base path , where Particularly we can say:
, a base path.
, an inverse base path.
For example, we have:
Here we need to show relevant information regarding the equalities we can get using these paths. Consider the following examples:
Notice that the paths and initially look like distinct paths. Nevertheless, applying only the properties of computational paths, together with the rewrite rules (rw-rules), we end up with the path in both derivations. So we can say that:
and by ,
They are said to be rw-equal to the base path because they can be rewritten to after applying rw-rules. Therefore, we can say that these paths are in the same equivalence class as and thus, they are equal up to rw-equality.
For simplicity, we will denote by whenever we refer to a computational path that is equivalent to a , where for some .
In Martin-Löf’s type theory, the existence of those additional paths comes from establishing that the paths should be freely generated by the constructors . In our approach, we do not have to appeal to this kind of argument, since all paths come naturally from direct applications of the axioms and the inference rules which define the theory of equality.
With that in mind, one can define the fundamental group of a circle. In homotopy theory, the fundamental group is the one formed by all equivalence classes up to homotopy of paths (loops) starting from a point and also ending at . Since we use computational paths as the syntactic counterpart of homotopic paths in type theory, we use computational paths to propose the following definition:
is a structure defined as follows:
, for some
where is a type and is a base computational path that generates .
For simplicity, we denote by every time we refer to structure . We also need to show that it is indeed a group.
is a group.
The first thing to define is the group operation . Given any and , we define as . Thus, we now need to check the group conditions:
Closure: Given and , must be a member of the group. Indeed, is a computational path .
Inverse: Every member of the group must have an inverse. Indeed, if we have a path , we can apply . We claim that is the inverse of , since we have:
Since we are working up to -equality, the equalities hold strictly.
Identity: We use the path as the identity. Indeed, we have:
Associativity: Given any members of the group , and , we want that :
All conditions have been satisfied. is a group. ∎
Thus, is indeed a group. We call this group the fundamental group of . Therefore, the objective of this section is to show that .
Before we start to develop this proof, the following lemma will prove to be useful:
All paths in are generated by application , and in base path . And this paths are -equals to a path , for .
We have said that from a base path , one can freely generate different paths by applying composition and the symmetry . Our objective with this lemma is to show that, in fact, any path in can be reduced to a path of the form , for .
For the base case , it is trivially true, since we define it to be equal to . From , one can construct more complex paths by composing with or on each step. Concatenating paths we have:
A path of the form concatenated with :
A path of the form concatenated with :
A path of the form concatenated with :
A path of the form concatenated with :
A path of the form concatenated with :
a path of the form concatenated with :