Let's use Disco to check the injectivity of our example functions from before.
Disco can tell us for sure that g is injective:
Disco> :test forall x:Bool, y:Bool. g(x) == g(y) -> x == y
- Certainly true: ∀x, y. g(x) == g(y) -> x == y
No counterexamples exist; all possible values were checked.With h, on the other hand, Disco cannot tell for sure, but reports that it tried a bunch of examples without finding a counterexample. This makes sense: since the domain of h is the natural numbers, there are infinitely many inputs to try, so Disco cannot try them all. (Of course, we can prove that h is injective, but Disco is not doing anything that sophisticated.)
Disco> :test forall x:N, y:N. h(x) == h(y) -> x == y
- Possibly true: ∀x, y. h(x) == h(y) -> x == y
Checked 100 possibilities without finding a counterexample.The function l is not injective, and Disco finds a counterexample immediately:
Disco> :test forall x:N, y:N. l(x) == l(y) -> x == y
- Certainly false: ∀x, y. l(x) == l(y) -> x == y
Found counterexample:
x = 0
y = 3
- Certainly true: l(x) == l(y)
- Left side: F
- Right side: F
- Certainly false: x == y
- Left side: 0
- Right side: 3Disco also easily finds a counterexample showing that j is not injective (try it yourself!).
As one last example, we can try making a function which is "almost" injective, which fools Disco:
k : N -> N
k(193) = 0
k(n) = 2n
Disco> :test forall x:N, y:N. k(x) == k(y) -> x == y
- Possibly true: ∀x, y. k(x) == k(y) -> x == y
Checked 100 possibilities without finding a counterexample.We can easily see that k is not injective, since k(0) = k(193) = 0, but Disco happened not to try those particular inputs. When Disco says that something is "possibly" true or false, we must take it with a grain of salt!