Convert Figma logo to code with AI

agda logoagda

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

2,490
347
2,490
1,010

Top Related Projects

2,487

A purely functional programming language with first class types

4,774

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 Coq library for Homotopy Type Theory

4,597

Lean 4 programming language and theorem prover

5,443

The core OCaml system: compilers, runtime system, base libraries

96,644

Empowering everyone to build reliable and efficient software.

Quick Overview

Agda is a dependently typed functional programming language and proof assistant. It is designed for writing and verifying mathematical proofs and developing certified programs. Agda is based on intuitionistic type theory and serves as both a programming language and a tool for interactive theorem proving.

Pros

  • Strong type system with dependent types, allowing for precise specifications and proofs
  • Interactive development environment with powerful editor support (e.g., Emacs mode)
  • Ability to extract verified programs to other languages like Haskell
  • Active community and ongoing development

Cons

  • Steep learning curve, especially for those new to dependent types or formal verification
  • Limited ecosystem compared to more mainstream programming languages
  • Performance can be slower compared to traditional programming languages
  • Lack of extensive libraries for practical application development

Code Examples

Here are a few short code examples demonstrating Agda's syntax and features:

  1. Defining natural numbers and addition:
data ℕ : Set where
  zero : ℕ
  suc  : ℕ → ℕ

_+_ : ℕ → ℕ → ℕ
zero  + n = n
suc m + n = suc (m + n)
  1. Proving commutativity of addition:
+-comm : ∀ (m n : ℕ) → m + n ≡ n + m
+-comm zero    n = sym (+-identity-right n)
+-comm (suc m) n =
  begin
    suc m + n
  ≡⟨⟩
    suc (m + n)
  ≡⟨ cong suc (+-comm m n) ⟩
    suc (n + m)
  ≡⟨ sym (+-suc n m) ⟩
    n + suc m
  ∎
  1. Defining a simple polymorphic list type:
data List (A : Set) : Set where
  []  : List A
  _∷_ : A → List A → List A

infixr 5 _∷_

Getting Started

To get started with Agda:

  1. Install Agda: cabal install Agda
  2. Set up editor support (e.g., Emacs with agda2-mode)
  3. Create a new .agda file and start writing:
module Hello where

open import Agda.Builtin.String

hello : String
hello = "Hello, Agda!"
  1. Type-check your file using C-c C-l in Emacs or run agda YourFile.agda in the terminal.

For more detailed instructions and tutorials, visit the official Agda documentation: https://agda.readthedocs.io/

Competitor Comparisons

2,487

A purely functional programming language with first class types

Pros of Idris2

  • More focus on practical programming with dependent types
  • Better support for effects and resource management
  • Faster compilation times and improved performance

Cons of Idris2

  • Smaller community and ecosystem compared to Agda
  • Less mature tooling and IDE support
  • Fewer learning resources and academic papers

Code Comparison

Idris2:

data Vec : Nat -> Type -> Type where
  Nil  : Vec Z a
  (::) : a -> Vec n a -> Vec (S n) a

append : Vec n a -> Vec m a -> Vec (n + m) a
append Nil ys = ys
append (x :: xs) ys = x :: append xs ys

Agda:

data Vec (A : Set) : ℕ → Set where
  []  : Vec A zero
  _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)

_++_ : ∀ {A m n} → Vec A m → Vec A n → Vec A (m + n)
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)

Both examples demonstrate vector concatenation with length preservation, showcasing dependent types. Idris2's syntax is more similar to Haskell, while Agda's is more explicit about universe levels and uses Unicode symbols.

4,774

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

  • More mature ecosystem with extensive libraries and tactics
  • Stronger emphasis on automation and proof assistance
  • Better support for program extraction and code generation

Cons of Coq

  • Steeper learning curve due to more complex syntax and concepts
  • Less intuitive syntax for dependent types compared to Agda
  • Slower compilation times for large projects

Code Comparison

Agda example:

data ℕ : Set where
  zero : ℕ
  suc  : ℕ → ℕ

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

Coq example:

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

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

Both examples define natural numbers and addition, but Agda's syntax is more concise and readable. Coq's syntax is more verbose but offers more flexibility in defining recursive functions. Agda's pattern matching is more intuitive, while Coq's requires explicit recursion using Fixpoint.

A Coq library for Homotopy Type Theory

Pros of Coq-HoTT

  • Built on the well-established Coq proof assistant, benefiting from its mature ecosystem and tooling
  • Focuses specifically on Homotopy Type Theory, providing specialized libraries and tactics
  • Supports classical mathematics alongside constructive approaches

Cons of Coq-HoTT

  • Steeper learning curve due to Coq's syntax and proof style
  • Less intuitive syntax for dependent types compared to Agda
  • Smaller community and fewer learning resources specific to HoTT in Coq

Code Comparison

Agda:

data ℕ : Set where
  zero : ℕ
  suc  : ℕ → ℕ

_+_ : ℕ → ℕ → ℕ
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.

Both repositories provide foundations for formal verification and proof assistants. Agda offers a more intuitive syntax for dependent types and a gentler learning curve, while Coq-HoTT leverages Coq's established ecosystem and provides specialized support for Homotopy Type Theory. The choice between them depends on the specific needs of the project and the user's familiarity with each system.

4,597

Lean 4 programming language and theorem prover

Pros of Lean4

  • Faster proof checking and compilation times
  • More extensive metaprogramming capabilities
  • Better integration with mainstream programming languages

Cons of Lean4

  • Smaller community and ecosystem compared to Agda
  • Less mature documentation and learning resources
  • Fewer libraries and formalized mathematics available

Code Comparison

Lean4:

def factorial : Nat → Nat
  | 0 => 1
  | n + 1 => (n + 1) * factorial n

#eval factorial 5

Agda:

factorial : ℕ → ℕ
factorial zero = 1
factorial (suc n) = suc n * factorial n

_ : factorial 5 ≡ 120
_ = refl

Both Lean4 and Agda are dependently typed programming languages and proof assistants. Lean4 focuses on efficiency and metaprogramming, while Agda emphasizes expressiveness and flexibility in its type system. Lean4's syntax is more similar to mainstream programming languages, potentially making it easier for newcomers to adopt. Agda, on the other hand, has a larger community and more extensive libraries, particularly in formalized mathematics. The code comparison shows similar implementations of the factorial function, highlighting the syntactic differences between the two languages.

5,443

The core OCaml system: compilers, runtime system, base libraries

Pros of OCaml

  • More mature and widely adopted in industry and academia
  • Faster compilation and execution times
  • Extensive standard library and package ecosystem

Cons of OCaml

  • Less expressive type system compared to Agda's dependent types
  • Limited support for theorem proving and formal verification
  • Lacks some advanced features like holes and interactive development

Code Comparison

Agda:

data ℕ : Set where
  zero : ℕ
  suc  : ℕ → ℕ

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

OCaml:

type nat = Zero | Succ of nat

let rec add a b =
  match a with
  | Zero -> b
  | Succ n -> Succ (add n b)

The Agda code demonstrates its dependent type system and pattern matching on constructors, while OCaml shows its simpler type system and pattern matching syntax. Agda's code is more concise and allows for more advanced type-level programming, whereas OCaml's version is more straightforward but less expressive in terms of types.

96,644

Empowering everyone to build reliable and efficient software.

Pros of Rust

  • Larger community and more widespread adoption
  • Focuses on systems programming and performance
  • More mature ecosystem with a wider range of libraries and tools

Cons of Rust

  • Steeper learning curve due to complex ownership and borrowing concepts
  • Less emphasis on formal verification compared to Agda
  • May be overkill for simple projects or rapid prototyping

Code Comparison

Rust example:

fn main() {
    let x = 5;
    println!("The value of x is: {}", x);
}

Agda example:

module Main where

open import IO

main : IO ()
main = putStrLn "Hello, world!"

Key Differences

  • Rust is a systems programming language focused on safety and concurrency, while Agda is a dependently typed functional programming language and proof assistant.
  • Rust has a larger user base and more industry adoption, whereas Agda is primarily used in academic and research settings.
  • Agda provides stronger guarantees through its type system and is better suited for formal verification, while Rust offers a balance between safety and performance.
  • Rust's syntax is more familiar to developers coming from C-like languages, while Agda's syntax is closer to functional languages like Haskell.

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

Agda 2

Hackage version Stackage version Test Documentation Status Agda Zulip

The official Agda logo

Note that this README is only about Agda, not its standard library. See the Agda Wiki for information about the library.

Documentation

Getting Started

Contributing to Agda