Groupoids and their generalizations, such as higher groupoids or ∞-groupoids, are fundamental to the field of Homotopy Type Theory (HoTT), which has significant applications in computer science, particularly in the areas of programming languages and formal verification.
One of the key ideas in HoTT is that types in a programming language can be considered as spaces (or ∞-groupoids), and that the equality between two elements of a type can be seen as a path in this space. This leads to a very rich and flexible notion of equality, which can be used to reason about programs in a very expressive way.
For instance, consider a type A and two elements x and y of A. In HoTT, we can form the identity type x = A y, which represents the proposition that x and y are equal. Elements of this identity type can be thought of as evidence for the equality of x and y, or as paths from x to y in the space A hott.github.io/book/hott-online-13-g2e736d1.pdf, page 59.
Furthermore, we can iterate this process, forming identity types between identity types. For example, if p and q are two elements of the identity type x = A y (i.e., two paths from x to y), then we can form the identity type p = (x = A y) q, which represents the proposition that p and q are equal. Elements of this identity type can be thought of as homotopies between the paths p and q hott.github.io/book/hott-online-13-g2e736d1.pdf, page 72.
This structure corresponds precisely to that of an ∞-groupoid. Just like a groupoid has objects and morphisms (with every morphism being invertible), an ∞-groupoid has objects (the elements of a type), 1-morphisms (the elements of an identity type), 2-morphisms (the elements of an identity type between identity types), and so on hott.github.io/book/hott-online-13-g2e736d1.pdf, page 72.
In computer science, this perspective allows us to reason about equality in a very flexible way. For example, it enables us to prove properties of programs up to homotopy, rather than just up to strict equality. This is particularly useful in the context of formal verification, where we often want to prove that two programs are "equivalent" in some sense, even if they are not strictly identical.
Moreover, many constructions in type theory correspond to well-known constructions in homotopy theory and higher category theory. For instance, the product of two types corresponds to the product of two spaces, and the function type from one type to another corresponds to the space of continuous maps from one space to another hott.github.io/book/hott-online-13-g2e736d1.pdf, page 91. This correspondence provides a deep connection between computer science and mathematics, opening up new possibilities for cross-fertilization between these fields.