0 | module Algebra.Solver.Semiring.Prod
2 | import Algebra.Solver.Semiring.Expr
3 | import public Algebra.Solver.Prod
4 | import Algebra.Solver.Semiring.Util
17 | eprod : Semiring a => {as : List a} -> Prod a as -> a
18 | eprod {as = []} [] = 1
19 | eprod {as = x :: xs} (e :: es) = pow x e * eprod es
27 | 0 pone : Semiring a => (as : List a) -> eprod (one {as}) === 1
29 | pone (x :: xs) = Calc $
30 | |~ 1 * eprod (one {as = xs})
31 | ~~ 1 * 1 ... cong (1 * ) (pone xs)
32 | ~~ 1 ... multOneRightNeutral
37 | {auto _ : Semiring a}
40 | -> eprod (fromVar {as} e) === x
41 | pvar (x :: vs) Here = Calc $
42 | |~ (x * 1) * eprod (one {as = vs})
43 | ~~ (x * 1) * 1 ... cong ((x*1) *) (pone vs)
44 | ~~ x * 1 ... multOneRightNeutral
45 | ~~ x ... multOneRightNeutral
47 | pvar (v :: vs) (There y) = Calc $
48 | |~ 1 * eprod (fromVar {as = vs} y)
49 | ~~ 1 * x ... cong (1*) (pvar vs y)
50 | ~~ x ... multOneLeftNeutral
52 | pvar [] Here
impossible
53 | pvar []
(There y
) impossible
60 | {auto _ : Semiring a}
61 | -> (p,q : Prod a as)
62 | -> eprod (mult p q) === eprod p * eprod q
63 | pmult [] [] = sym multOneLeftNeutral
64 | pmult {as = h :: t} (x :: xs) (y :: ys) = Calc $
65 | |~ pow h (x + y) * eprod (mult xs ys)
66 | ~~ (pow h x * pow h y) * eprod (mult xs ys)
67 | ... cong (* eprod (mult xs ys)) (ppow x y h)
68 | ~~ (pow h x * pow h y) * (eprod xs * eprod ys)
69 | ... cong ((pow h x * pow h y) *) (pmult xs ys)
70 | ~~ (pow h x * eprod xs) * (pow h y * eprod ys)