0 | module Algebra.Solver.Prod
2 | import public Data.List.Elem
16 | data Prod : (a : Type) -> (as : List a) -> Type where
18 | (::) : (exp : Nat) -> Prod a xs -> Prod a (x :: xs)
23 | mult : Prod a as -> Prod a as -> Prod a as
25 | mult (x :: xs) (y :: ys) = (x + y) :: mult xs ys
30 | compProd : Prod a as -> Prod a as -> Ordering
32 | compProd (x :: xs) (y :: ys) = case compare x y of
35 | EQ => compProd xs ys
39 | one : {as : List a} -> Prod a as
41 | one {as = x :: xs} = 0 :: one
45 | fromVar : {as : List a} -> Elem x as -> Prod a as
46 | fromVar {as = x :: xs} Here = 1 :: one
47 | fromVar {as = x :: xs} (There y) = 0 :: fromVar y
48 | fromVar {as = []
} Here
impossible
49 | fromVar {as = []
} (There y
) impossible
55 | Uninhabited (LT = EQ) where
56 | uninhabited _ impossible
58 | Uninhabited (GT = EQ) where
59 | uninhabited _ impossible
62 | 0 pcompNat : (x,y : Nat) -> (compare x y === EQ) -> x === y
63 | pcompNat 0 0 prf = Refl
64 | pcompNat (S k) (S j) prf = cong S $
pcompNat k j prf
65 | pcompNat 0 (S k) Refl impossible
66 | pcompNat (S k) 0 Refl impossible
71 | -> (compProd x y === EQ)
73 | pcompProd [] [] prf = Refl
74 | pcompProd (x :: xs) (y :: ys) prf with (compare x y) proof eq
75 | _ | EQ = cong2 (::) (pcompNat x y eq) (pcompProd xs ys prf)
78 | pcompProd []
(_ ::
_) Refl
impossible
79 | pcompProd (_ ::
_) [] Refl
impossible