Logic programming languages present clear advantages in terms of declarativeness and conciseness. However, the ideas of logic programming have been met with resistance in other programming communities, and have not generally been adopted by other paradigms and languages. This paper proposes a novel way to incorporate logic programming in an existing codebase in a typed functional programming language. Our approach integrates with the host language without sacrificing static typing, and leverages strengths of typed functional programming such as polymorphism and higher-order. We do so by combining three ideas. First, we use the extensible types technique to allow values of the host language to contain logic variables. Second, we implement a unification algorithm that works for any data structure that supports certain operations.Third, we introduce a domain-specific language to define and query predicates. We demonstrate our proposal via a series of examples, and provide aids to make the notation convenient for users, showing that the proposed approach is not just technically possible but also practical. Our ideas have been implemented in the language Haskell with very good results.


翻译:逻辑编程语言在声明性与简洁性方面具有明显优势。然而,逻辑编程的思想在其他编程社区中遇到了阻力,并未被其他范式和语言普遍采纳。本文提出了一种在类型化函数式编程语言的现有代码库中融入逻辑编程的新方法。我们的方法在与宿主语言集成时不牺牲静态类型,并充分利用类型化函数式编程的优势,如多态性和高阶函数。我们通过结合三个核心理念实现这一目标:首先,采用可扩展类型技术,使宿主语言的值能够包含逻辑变量;其次,实现适用于任何支持特定操作的数据结构的统一算法;第三,引入领域特定语言来定义和查询谓词。我们通过一系列示例展示该方案的可行性,并提供辅助工具以提升用户书写便利性,证明所提方法不仅技术上可行且具有实用性。这些思想已在Haskell语言中实现并取得良好效果。

0
下载
关闭预览

相关内容

人们为了让计算机解决各种棘手的问题,使用编程语言 编写程序代码并通过计算机运算得到最终结果的过程。
【NTU博士论文】当深度学习遇上归纳逻辑程序设计
专知会员服务
24+阅读 · 2025年5月6日
【牛津大学博士论文】可微分编程的结构基础,176页pdf
专知会员服务
26+阅读 · 2023年8月20日
【2022新书】Python数学逻辑,285页pdf
专知会员服务
68+阅读 · 2022年11月24日
【书籍推荐】简洁的Python编程(Clean Python),附274页pdf
专知会员服务
183+阅读 · 2020年1月1日
【2022新书】Python数学逻辑,285页pdf
专知
13+阅读 · 2022年11月24日
绝对干货!NLP预训练模型:从transformer到albert
新智元
13+阅读 · 2019年11月10日
开年重磅——周志华团队综述归纳逻辑程序设计
计算机研究与发展
10+阅读 · 2019年1月22日
类脑计算的前沿论文,看我们推荐的这7篇
人工智能前沿讲习班
21+阅读 · 2019年1月7日
各编程领域最好的入门书籍
程序猿
28+阅读 · 2018年7月29日
这可能是学习Python最好的免费在线电子书
程序猿
56+阅读 · 2018年5月17日
用于数学的 10 个优秀编程语言
算法与数据结构
13+阅读 · 2018年1月5日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
Arxiv
0+阅读 · 1月28日
Arxiv
0+阅读 · 1月19日
VIP会员
相关资讯
【2022新书】Python数学逻辑,285页pdf
专知
13+阅读 · 2022年11月24日
绝对干货!NLP预训练模型:从transformer到albert
新智元
13+阅读 · 2019年11月10日
开年重磅——周志华团队综述归纳逻辑程序设计
计算机研究与发展
10+阅读 · 2019年1月22日
类脑计算的前沿论文,看我们推荐的这7篇
人工智能前沿讲习班
21+阅读 · 2019年1月7日
各编程领域最好的入门书籍
程序猿
28+阅读 · 2018年7月29日
这可能是学习Python最好的免费在线电子书
程序猿
56+阅读 · 2018年5月17日
用于数学的 10 个优秀编程语言
算法与数据结构
13+阅读 · 2018年1月5日
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员