Discrete mathematics is the foundation of computer science. It focuses on concepts and reasoning methods that are studied using math notations. It has long been argued that discrete math is better taught with programming, which takes concepts and computing methods and turns them into executable programs. What has been lacking is a principled approach that supports all central concepts of discrete math -- especially predicate logic -- and that directly and precisely connects math notations with executable programs. This paper introduces such an approach. It is based on the use of a powerful language that extends the Python programming language with proper logic quantification ("for all" and "exists some"), as well as declarative set comprehension (also known as set builder) and aggregation (e.g., sum and product). Math and logical statements can be expressed precisely at a high level and be executed directly on a computer, encouraging declarative programming together with algorithmic programming. We describe the approach, detailed examples, experience in using it, and the lessons learned.
翻译:分解数学是计算机科学的基础。 它侧重于使用数学符号研究的概念和推理方法。 长期以来人们一直认为, 离散数学用编程来教得更好, 编程采用概念和计算方法, 并将它们转化为可执行的程序。 缺少的是支持离散数学所有核心概念的原则性方法, 特别是上游逻辑, 并且直接和准确地将数学符号与可执行的程序联系起来。 本文介绍了这样一种方法。 它基于使用一种强大的语言, 将Python 编程语言扩展为适当的逻辑量化( “ 面向所有人 ” 和“ 存在部分” ), 以及宣示性一套理解( 也称为 设置构建器 ) 和 聚合( 例如, 总和产品 ) 。 数学和逻辑性陈述可以精确地在高层次上表达, 直接在计算机上执行, 鼓励与算法编程一起进行说明性编程。 我们描述了该方法、 详细的例子、 使用它的经验和学到的教训。