Absurd pattern: ()
(kinda like False
in Coq)
tt
: not exactly unit type as in Coq. It's like the I
constructor (of True
type) in Coq.
postulate
: like Axiom
in Coq
Each file should have module name.
Type names should start with upper-case letter.
Dotted expression
No step-by-step evaluation as in Coq.
Mixfix notations
'Function' associates to right
A -> B -> C
is A -> (B -> C)
Looks like space is needed before :
in type annotations
zero: ℕ
and zero :ℕ
give parse error, zero : ℕ
doesn't.--without-K
and --safe
seems like not-so-good-to-use flags.
--safe
option 'to avoid possible misuses of certain features which could lead to logical inconsistencies' ʳ--cubical
: implements a computational interpretation of HoTT.
UIP: Uniqueness of identity proofs
Axiom K: Equivalent to UIP ??
Setoid: Set equipped with an equivalence relation
Extensional vs intentional type theory
postulate
: like Axiom
in Coq
open import Data.List using ([]; [_]; _++_; List; sum)
open import Data.Nat using (ℕ; _+_)
mutual
keywordExample from here:
mutual
data ty-ctx : Set where
: ty-ctx
ε _,-_ : (Δ : ty-ctx) → defn Δ → ty-ctx
data defn : ty-ctx → Set where
: ∀ {Δ} → ty Δ → defn Δ
synonym : ∀ {Δ} → ty Δ → defn Δ
newtype
data ty : ty-ctx → Set where
: ∀ {Δ τ} → ty Δ → ty (Δ ,- τ)
wk : ∀ {Δ τ} → ty (Δ ,- τ)
defd : ∀ {Δ} → ty Δ
bit _⇒_ : ∀ {Δ} → ty Δ → ty Δ → ty Δ
https://agda.readthedocs.io/en/latest/language/record-types.html
.fieldname
record RecName : Set where
field
: ℕ
a : 𝔹 b
—
'Open' a record to bring their field names into default scope.
open RecName
Example from docs:
record Pair (A B : Set) : Set where
field
: A
fst : B
snd
: Pair A B geta
Level
lzero: Level
: lowest levellsuc: Level -> Level
: Next level_⊔_: Level -> Level -> Level
: Least upper bound of 2 levelsSet
: Like Type
in Coq
Set
: Set0Set₁
: Set ∈ Set₁ ??Set₂
: Set₁ ∈ Set₂ ??0ℓ
: Level zero
Example from docs:
data _×_ {n m : Level} (A : Set n) (B : Set m) : Set (n ⊔ m) where
_,_ : A → B → A × B
Example import:
open import Level using (0ℓ) renaming (suc to lsuc)
Standard library need to be installed separately.
—
~/.agda/defaults
: list of agda libraries loaded by default
~/.agda/libraries
~/.agda/libraries
: list of paths complete paths to agda-lib files of packages (including the agda-lib file name with extension)AGDA_DIR
in unix: ~/.agda
Special comments.
Example:
{-# BUILTIN NATURAL ℕ #-}
agda
associates numbers with elements of the ℕ
type. So 2 would implicitly mean suc (suc zero)
.
See: https://plfa.github.io/Naturals/#a-pragma
—
{-# BUILTIN NATURAL ℕ #-}
zero
)Int
(log₂ space) instead of unary nat.{-# OPTIONS --exact-split #-}
a : Set
vs a: Set
The space matters. Looks if we do a: Set
, a:
will be considered a name.
For example, this works:
data Type : Set where
: Type Nat
But this doesn't:
data Type: Set where
: Type
Nat {-
Missing type signature for data definition Type:
when scope checking the declaration
data Type: Set where
Nat : Type
-}
False type:
data 𝟘 : Type where
Inductive False : Prop :=.
Following comparison is probably a bit too approximative…
Coq | Agda | |
---|---|---|
False | 𝟘 / () | |
unit | 𝟙 | Unit type |
I | tt |
Lower precedence value => higher precedence
infixl
: left associativityinfixr
: right associativityinfix
: no associativity (parenthesis always needed)C-c C-w: Show definition of a name
C-c C-c: Case split
C-c C-,: Show current goal info
C-c C-Space: Finish hole after filling it
C-c C-l: Type check buffer
Right click on a typechecked part to go to its definiton
Find type of an expression: C-c C-d
Evaluate (find normal form) of an expression: C-c C-n
—
C-c C-f
C-c C-b
C-c C-n
C-c C-d
https://agda.readthedocs.io/en/latest/tools/emacs-mode.html#keybindings
—
M-x quail-show-key