In dependently typed programming, proofs of basic, structural properties can be embedded implicitly into programs and do not need to be written explicitly. Besides saving the effort of writing separate proofs, a most distinguishing and fascinating aspect of dependently typed programming is that it makes the idea of interactive type-driven development much more powerful, where expressive type information becomes useful hints that help the programmer to complete a program. There have not been many attempts at exploiting the full potential of the idea, though. As a departure from the usual properties dealt with in dependently typed programming, and as a demonstration that the idea of interactive type-driven development has more potential to be discovered, we conduct an experiment in "type-driven algorithm design": we develop algorithms from their specifications encoded in sophisticated types, to see how useful the hints provided by a type-aware interactive development environment can be. The algorithmic problem we choose is metamorphisms, whose definitional behaviour is consuming a data structure to compute an intermediate value and then producing a codata structure from that value, but there are other ways to compute metamorphisms. We develop Gibbons's streaming algorithm and Nakano's jigsaw model in the interactive development environment provided by the dependently typed language Agda, turning intuitive ideas about these algorithms into formal conditions and programs that are correct by construction.
翻译:在依附型式编程中,基本结构属性的证据可以隐含地嵌入程序之中,而不需要明确写出。除了节省撰写单独证明的努力外,一个最明显和吸引人的方面是,它使交互式类型驱动发展的概念更加强大,使表达型信息成为帮助程序员完成程序开发的有用提示。虽然没有多次尝试利用该想法的全部潜力。由于偏离了在依附型式编程中处理的通常属性,并表明交互式类型驱动发展的想法更有可能被发现,我们在“由类型驱动的算法设计”中进行了实验:我们从它们规范的精密类型编码中开发了算法,看看通过类型认知式互动发展环境提供的提示是多么有用。我们选择的算法问题是变形学,其定义行为正在消耗一种数据结构来计算一个中间值,然后从该值中生成一个 Codata 结构,但是还有其他方法可以对变形论进行解。我们在“由类型驱动式算法设计”中,我们从它们的规格编码中开发算算出算法,我们通过这些类型演算法将Gibbbas 格式演算法和Agnad vidu viduald vidud vidud vidudessmalogs