Lean4
/-- O(log n). Retrieve an element in the set that is equivalent to `x` in the order,
if it exists.
find 1 {1, 2, 3} = some 1
find 4 {1, 2, 3} = none
Using a preorder on `ℕ × ℕ` that only compares the first coordinate:
find (1, 1) {(0, 1), (1, 2)} = some (1, 2)
find (3, 1) {(0, 1), (1, 2)} = none -/
def find (x : α) : Ordnode α → Option α
| nil => none
| node _ l y r =>
match cmpLE x y with
| Ordering.lt => find x l
| Ordering.eq => some y
| Ordering.gt => find x r