Predicates [004F]

Before we can formally define quantifiers, we must come to terms with parameterized propositions, which will allow us to talk about more than one thing. For example, consider the statement x + 2 = 5. By itself, this is not a proposition because we can’t say whether it is true or false; it depends on x.

Disco> :test x + 2 == 5
Error: there is nothing named x.
https://disco-lang.readthedocs.io/en/latest/reference/unbound.html

However, it’s almost a proposition: it’s “waiting for” a value of x to be filled in, at which point it will be a proposition. We can make this explicit by defining P(x) to be the statement “x + 2 = 5”; then P(x) is a predicate, that is, a function that takes x as input and outputs a proposition.

P : N -> Bool
P(x) = x + 2 == 5

  • P(2) represents the proposition 2 + 2 = 5 (which happens to be false).
  • P(3) represents the proposition 3 + 2 = 5 (which happens to be true).

We can also make multi-argument predicates, just like we can have functions of multiple variables. For example, let J(x,y) mean “x is less than the square of y”.

J : N * N -> Bool
J(x,y) = x < y^2