@@ -11,17 +11,12 @@ import Decidable.Equality
11-- Preorders and Posets
11-- Preorders and Posets
12--------------------------------------------------------------------------------
12--------------------------------------------------------------------------------
15− data Preorder : (t -> t -> Type) -> Type where
14+class Preorder t (po : t -> t -> Type) where
16− transRefl : ((a : t) -> (b : t) -> (c : t) -> po a b -> po b c -> po a c) ->
15+ total transitive : (a : t) -> (b : t) -> (c : t) -> po a b -> po b c -> po a c
17− ((a : t) -> po a a) ->
16+ total reflexive : (a : t) -> po a a
20−
18+class (Preorder t po) => Poset t (po : t -> t -> Type) where
21− data Poset : (t -> t -> Type) -> Type where
22− preorderAntisym : Preorder {t = t} po ->
23− ((a : t) -> (b : t) -> po a b -> po b a -> a = b) ->
19+ total antisymmetric : (a : t) -> (b : t) -> po a b -> po b a -> a = b
26--------------------------------------------------------------------------------
21--------------------------------------------------------------------------------
27-- Natural numbers
22-- Natural numbers
@@ -41,16 +36,17 @@ NatLTEIsTransitive m n (S o) mLTEn (nLTESm nLTEo)
41total NatLTEIsReflexive : (n : Nat) -> NatLTE n n
36total NatLTEIsReflexive : (n : Nat) -> NatLTE n n
42NatLTEIsReflexive _ = nEqn
37NatLTEIsReflexive _ = nEqn
44−NatLTEIsPreorder : Preorder NatLTE
39+instance Preorder Nat NatLTE where
45−NatLTEIsPreorder = transRefl NatLTEIsTransitive NatLTEIsReflexive
40+ transitive = NatLTEIsTransitive
41+ reflexive = NatLTEIsReflexive
47total NatLTEIsAntisymmetric : (m : Nat) -> (n : Nat) -> po m n -> po n m -> m = n
43total NatLTEIsAntisymmetric : (m : Nat) -> (n : Nat) -> po m n -> po n m -> m = n
48NatLTEIsAntisymmetric n n nEqn nEqn = refl
44NatLTEIsAntisymmetric n n nEqn nEqn = refl
49NatLTEIsAntisymmetric n m nEqn (nLTESm _) impossible
45NatLTEIsAntisymmetric n m nEqn (nLTESm _) impossible
50NatLTEIsAntisymmetric n m (nLTESm _) nEqn impossible
46NatLTEIsAntisymmetric n m (nLTESm _) nEqn impossible
52−NatLTEIsPoset : Poset NatLTE
48+instance Poset Nat NatLTE where
53−NatLTEIsPoset = preorderAntisym NatLTEIsPreorder NatLTEIsAntisymmetric
49+ antisymmetric = NatLTEIsAntisymmetric
55total zeroNeverGreater : {n : Nat} -> NatLTE (S n) O -> _|_
51total zeroNeverGreater : {n : Nat} -> NatLTE (S n) O -> _|_
56zeroNeverGreater {n} (nLTESm _) impossible
52zeroNeverGreater {n} (nLTESm _) impossible
@@ -77,3 +73,5 @@ instance Rel NatLTE where
77instance Decidable NatLTE where
73instance Decidable NatLTE where
78 decide = decideNatLTE
74 decide = decideNatLTE
76+lte : (m : Nat) -> (n : Nat) -> Dec (NatLTE m n)
77+lte m n = decide {p = NatLTE} m n