一种用于删除数字的贪心算法(函数珍珠)
A greedy algorithm for dropping digits (Functional Pearl)
AI总结:
本文针对删除 k 位数字使结果最大的谜题,结合谓词逻辑、依赖类型证明助手和等式推理,推导并验证了一种线性时间的贪心算法。
摘要:
考虑这样一个谜题:给定一个数字,删除其中 k 位数字,使得所得数字尽可能大。为了推导出该谜题的线性时间解法,我们采用了多种技术:使用谓词逻辑来论证贪心算法的结构合理性,使用依赖类型证明助手给出贪心条件的构造性证明,并使用等式推理来计算贪心步骤以及最终的线性时间优化。
英文摘要:
Consider the puzzle: given a number, remove $k$ digits such that the resulting number is as large as possible. Various techniques were employed to derive a linear-time solution to the puzzle: predicate logic was used to justify the structure of a greedy algorithm, a dependently-typed proof assistant was used to give a constructive proof of the greedy condition, and equational reasoning was used to calculate the greedy step as well as the final, linear-time optimisation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。