The Stern-Brocot Tree

Peter Gammie 🌐 and Andreas Lochbihler 🌐

December 22, 2015

This is a development version of this entry. It might change over time and is not stable. Please refer to release versions for citations.

Abstract

The Stern-Brocot tree contains all rational numbers exactly once and in their lowest terms. We formalise the Stern-Brocot tree as a coinductive tree using recursive and iterative specifications, which we have proven equivalent, and show that it indeed contains all the numbers as stated. Following Hinze, we prove that the Stern-Brocot tree can be linearised looplessly into Stern's diatonic sequence (also known as Dijkstra's fusc function) and that it is a permutation of the Bird tree.

The reasoning stays at an abstract level by appealing to the uniqueness of solutions of guarded recursive equations and lifting algebraic laws point-wise to trees and streams using applicative functors.

License

BSD License

Topics

Session Stern_Brocot

Depends on