liveBook · Manning

Algebraic reasoning

As explained in Data-Oriented Programming in Java

Algebraic thinking is the practice of reasoning about software operations through equations and properties that characterize their behavior.

Algebraic reasoning makes software design and correctness more precise by examining the values an operation denotes and the relationships among them. A design earns simplicity when those relationships can be clearly described; otherwise, keep investigating its semantics. section 7.0

Express operations as equations and check the properties that should hold for every relevant state:

  • Associativity permits regrouping: (a + (b + c)) = ((a + b) + c), and can support parallel computation. section 7.12
  • Commutativity makes argument order irrelevant: a + b = b + a. section 7.12
  • Comparator ordering relies on reflexivity, antisymmetry, and transitivity; recognizing an order can simplify a problem. section 7.12
  • Monotonicity checks whether a function preserves ordering, such as a1 ≤ b1 and a2 ≤ b2 implying a1 + a2 ≤ b1 + b2. section 7.12

From examples to all states

A conventional test checks one chosen state. Randomized testing instead asks whether an operation behaves correctly for all states the randomizer can generate. That shift applies algebraic reasoning to testing and can produce a more robust, trustworthy test suite. section 11.5

Figure 11.8 The denotative view of the world. Every data type holds a set of states we should explore

Explore the denotative view: each data type represents a set of states, and randomized tests aim to exercise that state space. section 11.5

How Data-Oriented Programming in Java covers it

How deep it goes
Develops universal properties, notation, Java examples, testing applications, and implementation guidance without requiring algebraic interfaces.
Examples
Uses arithmetic-style equations, Comparator ordering laws, monotonicity, and randomized tests over generated states.
What you can do after
Evaluate correctness for all generated states and guide smaller implementations from explicit algebraic properties.
How it connects
Connects correctness with data types, associativity, commutativity, ordering, monotonicity, parallel computation, and randomized testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.