Skip to content

Instantly share code, notes, and snippets.

@ikedaisuke
Created March 5, 2011 15:35
Show Gist options
  • Save ikedaisuke/856447 to your computer and use it in GitHub Desktop.
Save ikedaisuke/856447 to your computer and use it in GitHub Desktop.
reflexitive relation on natural numbers on Agda2
module FooBarNat where
-- cheat on the exam; look the Standard library
Relation : Set -> Set -> Set1
Relation A B = A -> B -> Set
Reflexivity : (A : Set) -> Relation A A -> Set
Reflexivity A P = (i : A) -> P i i
record ReflexiveRelation (A : Set) (_≈_ : Relation A A) : Set where
field
refl : Reflexivity A _≈_
data Nat : Set where
zero : Nat
succ : Nat -> Nat
data _≤_ : Relation Nat Nat where
zeroIsMinimal : ∀ {n} -> zero ≤ n
liftSuccessor : ∀ {m n} (p : m ≤ n) -> succ m ≤ succ n
≤-refl : (x : Nat) -> x ≤ x
≤-refl zero = zeroIsMinimal
≤-refl (succ n) = liftSuccessor (≤-refl n)
≤isReflexive : ReflexiveRelation Nat (_≤_)
≤isReflexive = record { refl = ≤-refl }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment