0 | module Data.Maybe.NothingMin
2 | import Control.Function
24 | data LT : (lt : a -> a -> Type) -> (m1,m2 : Maybe a) -> Type where
25 | LTNothing : LT lt Nothing (Just v)
26 | LTJust : {0 lt : a -> a -> Type}
28 | -> lt v w -> LT lt (Just v) (Just w)
31 | Uninhabited (LT lt m Nothing) where
32 | uninhabited LTNothing
impossible
33 | uninhabited (LTJust
_) impossible
36 | Total a lt => Uninhabited (LT lt (Just k) (Just k)) where
37 | uninhabited LTNothing
impossible
38 | uninhabited (LTJust refl) = void (irrefl refl)
41 | fromLT : LT lt (Just a) (Just b) -> lt a b
42 | fromLT (LTJust x) = x
46 | comp : Total a lt => (m1,m2 : Maybe a) -> Trichotomy (LT lt) m1 m2
47 | comp (Just x) (Just y) = case trichotomy {lt} x y of
48 | LT p c1 c2 => LT (LTJust p) (\r => c1 (injective r)) (\x => c2 (fromLT x))
49 | EQ c1 p c2 => EQ (\x => c1 (fromLT x)) (cong Just p) (\x => c2 (fromLT x))
50 | GT c1 c2 p => GT (\x => c1 (fromLT x)) (\r => c2 (injective r)) (LTJust p)
51 | comp Nothing (Just x) = LT LTNothing absurd absurd
52 | comp (Just y) Nothing = GT absurd absurd LTNothing
53 | comp Nothing Nothing = EQ absurd Refl absurd
58 | Total a lt => Total (Maybe a) (LT lt) where
61 | transLT LTNothing (LTJust y) = LTNothing
62 | transLT (LTJust x) (LTJust y) = LTJust $
trans x y
63 | transLT y LTNothing = absurd y