Symmetry

Symmetry is a type of invariance. It states that the operand will have its original form after the application of some ordered set of operations . Often this set is limited to a pair of operations or even to a single symmetric operation.

For our usual experimental string, there is a symmetric operation reverse; for numbers, we could define a pair of addition and subtraction:

scala> forAll((a: String) => a.reverse.reverse == a).check
+ OK, passed 100 tests.
scala> forAll((a: Int, b: Int) => a + b - b == a).check
+ OK, passed 100 tests.

It is possible to define another pair with multiplication and division as operands (with respect to division by zero, overflow, and precision).

The symmetry property is often called a round-trip property. For a single operation it must hold for any inversible function.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.158.32