Merge Law Checker
Merge Law Checker
A state-based CRDT merge must be commutative, associative, and idempotent.
You are given a finite set of integer states states and a merge function represented as a table:
table[a][b] = merge(a, b)
Return whether the table satisfies all three laws over the provided states.
Function signature
func CheckMergeLaws(states []int, table map[int]map[int]int) LawsResult
Types
type LawsResult struct {
Commutative bool
Associative bool
Idempotent bool
Valid bool
}
Valid should be true only if all three laws are true.
Notes
If a table entry is missing, treat that law check as failed.
Run tests to see results
No issues detected