Skip to content

Instantly share code, notes, and snippets.

@klaeufer
Created December 9, 2013 22:10
Show Gist options
  • Select an option

  • Save klaeufer/7881910 to your computer and use it in GitHub Desktop.

Select an option

Save klaeufer/7881910 to your computer and use it in GitHub Desktop.
minimal ScalaCheck example
import org.scalacheck.Properties
import org.scalacheck.Prop.forAll
object IntAbelianGroup extends Properties("Int") {
property("Associativity") = forAll { (a: Int, b: Int, c: Int) =>
(a + b) + c == a + (b + c)
}
}
// Closure
// For all a, b in A, the result of the operation a • b is also in A.
// Associativity
// For all a, b and c in A, the equation (a • b) • c = a • (b • c) holds.
// Identity element
// There exists an element e in A, such that for all elements a in A, the equation e • a = a • e = a holds.
// Inverse element
// For each a in A, there exists an element b in A such that a • b = b • a = e, where e is the identity element.
// Commutativity
// For all a, b in A, a • b = b • a.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment