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ATL2EQC6PLAQLWZMUTPDGDPQUEKVQC
Y25HAVMY4WAD43DQ5PHLHUPDKW7X6DWJVP3VKYVQ3AE25S6ESSXAC
2DQ47UENKWPVS6XYO73Q2KCHTNG6GQVP2CKP24V2OQ4F4T3KAFMAC
RUIGRXTKM6BQ532W7KU3RKDXMRNRGDVGMA2ODMX2D2F3PCLF3GAQC
WJJ6PMS6GYR5NIQI6Q6YH6WQSTJ3U56F3KZJOSYHTRAZ5MKIPXAAC
YEPLQQC3GXCKIMKHMG4QF42ZVEBE3AV2P7MXD2FBA4XAJSQNIBEQC
LKG7V6OC5VYTHY3YWWYMIDP5O6OQCWWSMHTMJKALLNQNPOVY375AC
AXIWYERYL2PU4JVN5WBIGTOLCVB2R7DVILTRJHU7WNMYPWPJNAOAC
proofMultRightDistributesPlus : (x, y, z : Natural)
-> mult (plus x y) z = plus (mult x z) (mult y z)
proofMultRightDistributesPlus x y z =
rewrite proofMultCommutative (plus x y) z in
rewrite proofMultLeftDistributesPlus z x y in
rewrite proofMultCommutative z x in
rewrite proofMultCommutative z y in
Refl
public export
Semiring Natural where
(+) = plus
(*) = mult
zero = 0
one = 1
proofSumZero = proofRightIdentity @{NaturalSumMonoid}
proofSumCommutative = proofCommutative @{NaturalSumCommutativeMagma}
proofSumAssociative = proofAssociative @{NaturalSumSemigroup}
proofMultOneLeft = proofLeftIdentity @{NaturalMultMonoid}
proofMultOneRight = proofRightIdentity @{NaturalMultMonoid}
proofMultAssociative = proofAssociative @{NaturalMultSemigroup}
proofMultDistributesSumLeft = proofMultLeftDistributesPlus
proofMultDistributesSumRight = proofMultRightDistributesPlus
zeroAnnihilatorLeft = proofMultLeftAnnihilation
zeroAnnihilatorRight = proofMultRightAnnihilation
proofAssociativity Nil f g = Refl
proofAssociativity (x::xs) f g with (f x)
proofAssociativity (x::xs) f g | Nil = rewrite proofAssociativity xs f g in Refl
proofAssociativity (x::xs) f g | (r::rs) = ?holeAssociativity
proofAssociative Nil f g = Refl
proofAssociative (x::xs) f g with (f x)
proofAssociative (x::xs) f g | Nil = rewrite proofAssociative xs f g in Refl
proofAssociative (x::xs) f g | (r::rs) = ?holeAssociative
module Algebra.Ring.Semiring
import Builtin
import Algebra.Group.Magma
import Algebra.Group.Monoid
infixl 5 +
infixl 6 *
public export
interface Semiring t where
(+) : t -> t -> t
(*) : t -> t -> t
zero : t
one : t
proofSumZero : (x : t) -> x + zero = x
proofSumCommutative : (x, y : t) -> x + y = y + x
proofSumAssociative : (x, y, z : t) -> x + (y + z) = (x + y) + z
proofMultOneLeft : (x : t) -> one * x = x
proofMultOneRight : (x : t) -> x * one = x
proofMultAssociative : (x, y, z : t) -> x * (y * z) = (x * y) * z
proofMultDistributesSumLeft : (x, y, z : t) -> x * (y + z) = x * y + x * z
proofMultDistributesSumRight : (x, y, z : t) -> (x + y) * z = x * z + y * z
zeroAnnihilatorLeft : (x : t) -> zero * x = zero
zeroAnnihilatorRight : (x : t) -> x * zero = zero