@@ -10,7 +10,7 @@ import Decidable.Equality
10--------------------------------------------------------------------------------
10--------------------------------------------------------------------------------
12--------------------------------------------------------------------------------
12--------------------------------------------------------------------------------
13−-- Preorders and Posets
13+-- Preorders, Posets and total Orders
14--------------------------------------------------------------------------------
14--------------------------------------------------------------------------------
16class Preorder t (po : t -> t -> Type) where
16class Preorder t (po : t -> t -> Type) where
@@ -23,6 +23,16 @@ class (Preorder t po) => Poset t (po : t -> t -> Type) where
23class (Poset t to) => Ordered t (to : t -> t -> Type) where
23class (Poset t to) => Ordered t (to : t -> t -> Type) where
24 total order : (a : t) -> (b : t) -> Either (to a b) (to b a)
24 total order : (a : t) -> (b : t) -> Either (to a b) (to b a)
26+minimum : (Ordered t to) => t -> t -> t
27+minimum x y with (order x y)
31+maximum : (Ordered t to) => t -> t -> t
32+maximum x y with (order x y)
26--------------------------------------------------------------------------------
36--------------------------------------------------------------------------------
27-- Natural numbers
37-- Natural numbers
28--------------------------------------------------------------------------------
38--------------------------------------------------------------------------------
@@ -101,15 +111,9 @@ instance Ordered Nat NatLTE where
101 order (S k) (S j) | Left prf = Left (shift k j prf)
111 order (S k) (S j) | Left prf = Left (shift k j prf)
102 order (S k) (S j) | Right prf = Right (shift j k prf)
112 order (S k) (S j) | Right prf = Right (shift j k prf)
104−minimum : (Ordered t to) => t -> t -> t
114+--------------------------------------------------------------------------------
105−minimum x y with (order x y)
115+-- Finite numbers
106− | Left _ = x
116+--------------------------------------------------------------------------------
109−maximum : (Ordered t to) => t -> t -> t
110−maximum x y with (order x y)
114using (k : Nat)
118using (k : Nat)
115 data FinLTE : Fin k -> Fin k -> Type where
119 data FinLTE : Fin k -> Fin k -> Type where