Skip to content

feat(Algorithms): comparison sort lower bound via decision-tree induction - #770

Open
SamuelSchlesinger wants to merge 1 commit into
leanprover:mainfrom
SamuelSchlesinger:comparison-sort-lower-bound
Open

feat(Algorithms): comparison sort lower bound via decision-tree induction#770
SamuelSchlesinger wants to merge 1 commit into
leanprover:mainfrom
SamuelSchlesinger:comparison-sort-lower-bound

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

An attempt to prove the comparison sort lower bound of #685 taking, in my view, a more natural proof approach for this model. The original proof analyzes traces of the computation, while this approach takes direct advantage of the inductive structure of the free monad and essentially does induction on the program. At a high level, #685 formalizes the encoding argument whereas we formalize the decision tree argument. The arithmetic estimate of log_2 n! is adapted from #685.

Claude Fable 5 authored this code under my direction and review.

…tion

A comparison program is a free monad over a single comparison query,
i.e. a binary decision tree. card_image_run_le_two_pow_of_cost_le bounds
its distinct results over a finite comparator family by 2 ^ t whenever
every comparator in the family costs at most t comparisons, by structural
induction: the family splits at the root comparison. A program that sorts
under every hidden permutation order on Fin n therefore takes at least
log2(n!) comparisons in the worst case; (n/2) * log2(n/2) follows as a
corollary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant