Skip to content

Commit

Permalink
docs(ERTP): toward Algebraic properties of amounts
Browse files Browse the repository at this point in the history
refs #557
CommutativeMonoid specification
  • Loading branch information
dckc committed Jan 21, 2022
1 parent 4b2d9fb commit bf1af1f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/ERTP/spec/Amount.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
------------------------------ MODULE Amount ------------------------------
EXTENDS Integers

Semigroup(S, combine(_, _)) ==
\A a \in S: \A b \in S: \A c \in S:
combine(a, b) \in S \* Closure
/\ combine(combine(a, b), c) = combine(a, combine(b, c)) \* Associativity

Monoid(M, combine(_, _)) ==
Semigroup(M, combine)
/\ \E id \in M : \A a \in M: combine(id, a) = a /\ combine(a, id) = a \* Identity

CommutativeMonoid(M, combine(_, _)) ==
Monoid(M, combine) /\
\A a \in M: \A b \in M: combine(a, b) = combine(b, a)

===============================================================================

0 comments on commit bf1af1f

Please sign in to comment.