liveBook · Manning

Mathematical constant

As explained in Fabulous Adventures in Data Structures and Algorithms

A constant is a fixed symbolic term that represents a particular value or atom and cannot be bound by substitution.

A mathematical constant is a term with a fixed value. In a binary term, it is distinct from a hole, which can receive a substitution, and from a symbol, which has a name and child terms. section 10.1

Constants participate in equality and unification in specific ways:

  • Two constants are equal exactly when their values are equal. section 10.1
  • A constant can occupy a term position without becoming a substitution target; substitutions map holes to terms. section 10.1
  • Type-inference terms use constants such as List, Func, and double to represent fixed type components. section 10.3

Values inside a binary term

The term ImStack(2, Y) contains the constant 2 and the hole Y. Unification can determine a value for Y, but the constant 2 already has its value; it matches another constant only when that constant also represents 2. section 10.1

Figure 10.2 Our immutable stack unification problem looks nearly identical when drawn as a binary term. Again, holes are squares, symbols are ovals, and constants are circles.

The diagram distinguishes constants as circles from symbols as ovals and holes as squares. section 10.1

How Fabulous Adventures in Data Structures and Algorithms covers it

How deep it goes
Defines constants, compares their values for equality, and contrasts them with holes and symbols without extending equality modulo theories.
Examples
Uses 2, EmptyStack, double, List, Func, 1, 5, and 6 as constant values in constructed terms.
What you can do after
Evaluate/understand which term components can match by value and which components can receive substitutions.
How it connects
Connects constants to binary terms, unification, substitution, type inference, and anti-unification.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fabulous Adventures in Data Structures and Algorithms. The section links point to the parts of the book it draws on.