Demo Trees in Lean
Tracks
Check a result Declarations Bibliography Lean source

Chapter 2The cost of an access

Key result · Sleator and Tarjan 1985
An access costs at least the size of the tree

For every tree tt, the cost of an access is at least the number of nodes of tt:

size(t)≤cost(t).\mathrm{size}(t) \le \mathrm{cost}(t).
The Lean statement
theoremsize_le_costpropext · Quot.soundAbstract.lean:53
/-- The cost of an access is at least the number of nodes. -/theorem size_le_cost (t : Tree) : t.size ≤ cost t := … by  unfold cost  omega
Statement reads only Abstract.lean and its imports
3 definitions in 2 chapters · reading list

2.1 The fixed charge

defbaseno axiomsAbstract.lean:24
/-- The fixed charge added to every access. It is zero: an access costs what it touches. -/def base : Nat := 0

2.2 Cost

The cost adds the fixed charge base to the size Tree.size from Section 1.2.

defcostno axiomsAbstract.lean:27
/-- The cost of an access that touches the whole tree: the fixed charge plus the number of nodes. -/def cost (t : Tree) : Nat := base + t.size
theoremsize_le_costpropext · Quot.soundAbstract.lean:53
/-- The cost of an access is at least the number of nodes. -/theorem size_le_cost (t : Tree) : t.size ≤ cost t := … by  unfold cost  omega
Statement reads only Abstract.lean and its imports