#+TAGS[]: constructive-mathematics lean4 topology
It should come as no surprise that an exhaustive search over a finite set can be performed algorithmically by enumeration. On the other hand, it is impossible to perform such an exhaustive enumeration over the natural numbers or the integers, as these sets are infinite. However, somewhat paradoxically, there are infinite sets that can be exhaustively searched in finite time. More precisely, there is at least one infinite set Lean4, unlike the original post which uses Haskell.
The primary example of an infinite exhaustively searchable type in this post will be the set of conatural numbers, defined as the set of decreasing infinite binary sequences. There is an embedding of the natural numbers into the conatural numbers, taking each natural number
/-- The conatural numbers -
the set of infinite decreasing binary sequences. -/
def InfNat := {f : ℕ → Bool // ∀ n, f n.succ → f n}
-- a conventient notation
notation "ℕ∞" => InfNat
/-- The image of `0`, which corresponds to
the constant sequence with the value `false`. -/
def zero : ℕ∞ := ⟨fun n => false, fun _ => id⟩
/-- The successor of a conatural number, defined as
the sequence obtained by appending `true` at the front. -/
def succ : ℕ∞ → ℕ∞
| ⟨f, inc⟩ =>
⟨fun
| .zero => true
| .succ a => f a,
fun
| .zero => fun _ => rfl
| .succ _ => inc _⟩
/-- The special point at infinity, which is defined as
the constant sequence with the value `true` -/
def inf : ℕ∞ := ⟨fun n => true, fun _ => id⟩