Convert Figma logo to code with AI

HoTT logoCoq-HoTT

A Coq library for Homotopy Type Theory

1,250
193
1,250
119

Top Related Projects

2,490

Agda is a dependently typed programming language / interactive theorem prover.

4,883

Coq is a formal proof management system. It provides a formal language to write mathematical definitions, executable algorithms and theorems together with an environment for semi-interactive development of machine-checked proofs.

A Dependently Typed Functional Programming Language

Quick Overview

The HoTT/Coq-HoTT repository is a Coq library that provides an implementation of Homotopy Type Theory (HoTT), a new foundation for mathematics based on the univalence axiom. This library allows users to work with and explore the concepts of HoTT within the Coq proof assistant.

Pros

  • Formal Foundations: HoTT provides a new, more expressive foundation for mathematics, with the potential to simplify and unify various areas of mathematics.
  • Coq Integration: The Coq-HoTT library allows users to work with HoTT concepts directly within the Coq proof assistant, leveraging Coq's powerful type system and proof automation.
  • Active Development: The project is actively maintained and developed, with regular updates and contributions from the HoTT research community.
  • Educational Resource: The library serves as a valuable educational resource for those interested in learning about HoTT and its applications.

Cons

  • Complexity: Homotopy Type Theory is a relatively new and complex field, which can make it challenging for newcomers to understand and work with.
  • Coq Dependency: The Coq-HoTT library is tightly coupled with the Coq proof assistant, which may limit its accessibility to users who are not familiar with Coq.
  • Limited Documentation: While the project has a growing community, the documentation and resources available for the Coq-HoTT library may not be as comprehensive as for more established Coq libraries.
  • Performance Concerns: Depending on the complexity of the proofs and definitions, the Coq-HoTT library may have performance limitations, which could impact its usability for large-scale projects.

Code Examples

The Coq-HoTT library provides a rich set of definitions and theorems related to Homotopy Type Theory. Here are a few examples:

  1. Defining a Circle Type:
Inductive S1 : Type :=
  | base : S1
  | loop : base = base.

This code defines the circle type S1 in Coq-HoTT, which is a fundamental example in Homotopy Type Theory.

  1. Proving the Univalence Axiom:
Axiom univalence : forall (A B : Type), (A <~> B) <-> (A = B).

The univalence axiom is a key principle in Homotopy Type Theory, which states that isomorphic types are equal.

  1. Defining a Pushout Type:
Inductive pushout {A B C : Type} (f : A -> B) (g : A -> C) : Type :=
  | inl : B -> pushout f g
  | inr : C -> pushout f g
  | glue : forall (a : A), inl (f a) = inr (g a).

This code defines the pushout type, which is a fundamental construction in Homotopy Type Theory and has applications in various areas of mathematics.

  1. Proving a Theorem about the Circle:
Theorem loop_is_not_constant : forall (p : base = base), p = loop.

This theorem states that the loop in the circle type S1 is not constant, which is a non-trivial result in Homotopy Type Theory.

Getting Started

To get started with the Coq-HoTT library, you'll need to have Coq installed on your system. You can then follow these steps:

  1. Clone the Coq-HoTT repository:
git clone https://github.com/HoTT/Coq-HoTT.git
  1. Change into the Coq-HoTT directory:
cd Coq-HoTT
  1. Build the library:
make
  1. Start the Coq interactive environment and load the library:
coqtop -R . HoTT
  1. You can now start exploring the definitions and theorems provided by the Coq-HoTT library. For example, you can try proving

Competitor Comparisons

2,490

Agda is a dependently typed programming language / interactive theorem prover.

Pros of Agda

  • Dependent Types: Agda is a dependently-typed programming language, which allows for more expressive and precise type systems compared to Coq-HoTT.
  • Powerful Type System: Agda's type system is highly expressive, enabling the construction of complex mathematical structures and proofs.
  • Interactive Development: Agda provides a powerful interactive development environment, allowing for a more seamless and iterative development process.

Cons of Agda

  • Steeper Learning Curve: Agda has a steeper learning curve compared to Coq-HoTT, particularly for those new to dependently-typed programming.
  • Ecosystem: The Agda ecosystem is generally smaller than the Coq ecosystem, with fewer available libraries and tools.
  • Proof Automation: Coq-HoTT may have more advanced proof automation features compared to Agda, which can make certain proofs easier to construct.

Code Comparison

Agda:

data Nat : Set where
  zero : Nat
  suc  : Nat → Nat

_+_ : Nat → Nat → Nat
zero + n = n
suc m + n = suc (m + n)

Coq-HoTT:

Inductive nat : Type :=
  | O : nat
  | S : nat -> nat.

Fixpoint plus (n m : nat) : nat :=
  match n with
  | O => m
  | S p => S (plus p m)
  end.
4,883

Coq is a formal proof management system. It provides a formal language to write mathematical definitions, executable algorithms and theorems together with an environment for semi-interactive development of machine-checked proofs.

Pros of Coq

  • Mature and well-established proof assistant with a large user community and extensive documentation.
  • Supports a wide range of mathematical and computer science domains, including type theory, functional programming, and formal verification.
  • Provides a powerful and expressive language for writing and verifying proofs.

Cons of Coq-HoTT

  • Coq-HoTT is a specialized extension of Coq that focuses on Homotopy Type Theory (HoTT), which may not be as widely used or supported as the core Coq system.
  • The learning curve for Coq-HoTT may be steeper than for the standard Coq, as it introduces additional concepts and features related to HoTT.
  • The development and maintenance of Coq-HoTT may not be as active or well-resourced as the main Coq project.

Code Comparison

Coq:

Theorem plus_comm : forall n m : nat, n + m = m + n.
Proof.
  intros n m.
  induction n as [| n' IHn'].
  - simpl. reflexivity.
  - simpl. rewrite IHn'. reflexivity.
Qed.

Coq-HoTT:

Theorem plus_comm : forall n m : nat, n + m = m + n.
Proof.
  intros n m.
  induction n as [| n' IHn'].
  - simpl. reflexivity.
  - simpl. rewrite IHn'. reflexivity.
Qed.

The code for the plus_comm theorem is essentially the same in both Coq and Coq-HoTT, as the core Coq language and proof tactics are shared between the two.

A Dependently Typed Functional Programming Language

Pros of Idris-dev

  • Dependent Types: Idris is a dependently-typed programming language, which allows for more expressive and type-safe code compared to Coq-HoTT.
  • Ease of Use: Idris has a more user-friendly syntax and development experience compared to the more academic-oriented Coq-HoTT.
  • Active Development: Idris-dev has a larger and more active community, with more frequent updates and a wider range of available libraries.

Cons of Idris-dev

  • Proof Automation: Coq-HoTT has more advanced proof automation features, which can make it easier to work with complex mathematical proofs.
  • Formal Verification: Coq-HoTT is more widely used and accepted for formal verification of critical systems, due to its strong mathematical foundations.
  • Ecosystem: Coq-HoTT has a larger and more established ecosystem, with a wider range of available libraries and tools.

Code Comparison

Idris-dev (Idris):

data Nat : Type where
  Z : Nat
  S : Nat -> Nat

plus : Nat -> Nat -> Nat
plus Z     y = y
plus (S x) y = S (plus x y)

Coq-HoTT (Coq):

Inductive nat : Type :=
  | O : nat
  | S : nat -> nat.

Fixpoint plus (n m : nat) : nat :=
  match n with
  | O => m
  | S p => S (plus p m)
  end.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Github Actions CI HoTT Zulip chat

Homotopy Type Theory is an interpretation of Martin-Löf’s intensional type theory into abstract homotopy theory. Propositional equality is interpreted as homotopy and type isomorphism as homotopy equivalence. Logical constructions in type theory then correspond to homotopy-invariant constructions on spaces, while theorems and even proofs in the logical system inherit a homotopical meaning. As the natural logic of homotopy, type theory is also related to higher category theory as it is used e.g. in the notion of a higher topos.

The HoTT library is a development of homotopy-theoretic ideas in the Coq proof assistant. It draws many ideas from Vladimir Voevodsky's Foundations library (which has since been incorporated into the UniMath library) and also cross-pollinates with the HoTT-Agda library. See also: HoTT in Lean2, Spectral Sequences in Lean2, and Cubical Agda.

More information about this library can be found in:

  • The HoTT Library: A formalization of homotopy type theory in Coq, Andrej Bauer, Jason Gross, Peter LeFanu Lumsdaine, Mike Shulman, Matthieu Sozeau, Bas Spitters, 2016 arXiv CPP17

Other publications related to the library can be found here.

Installation

The HoTT library is part of the Coq Platform and can be installed using the installation instructions there.

More detailed installation instructions are provided in the file INSTALL.md.

Usage

The HoTT library can be used like any other Coq library. If you wish to use the HoTT library in your own project, make sure to put the following arguments in your _CoqProject file:

-arg -noinit
-arg -indices-matter

For more advanced use such as contribution see INSTALL.md.

For recommended text editors see our recommended editors list. Other methods of developing in coq will work as long as the correct arguments are passed.

Contributing

Contributions to the HoTT library are very welcome! For style guidelines and further information, see the file STYLE.md.

Licensing

The library is released under the permissive BSD 2-clause license, see the file LICENSE.txt for further information. In brief, this means you can do whatever you like with it, as long as you preserve the Copyright messages. And of course, no warranty!

Wiki

More information can be found in the Wiki.