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
下载
关闭预览

相关内容

人们为了让计算机解决各种棘手的问题,使用编程语言 编写程序代码并通过计算机运算得到最终结果的过程。
多语言大型语言模型:资源、分类和前沿综述
专知会员服务
53+阅读 · 2024年4月9日
【AAAI2024】使用大型语言模型的生成式多模态知识检索
专知会员服务
58+阅读 · 2024年1月19日
从语言模型到语言智能体,普林斯顿Shunyu Yao
专知会员服务
63+阅读 · 2023年9月18日
专知会员服务
12+阅读 · 2021年7月16日
论文笔记之Feature Selective Networks for Object Detection
统计学习与视觉计算组
21+阅读 · 2018年7月26日
语义分割中的深度学习方法全解:从FCN、SegNet到DeepLab
炼数成金订阅号
26+阅读 · 2017年7月10日
MNIST入门:贝叶斯方法
Python程序员
23+阅读 · 2017年7月3日
国家自然科学基金
8+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
VIP会员
相关VIP内容
多语言大型语言模型:资源、分类和前沿综述
专知会员服务
53+阅读 · 2024年4月9日
【AAAI2024】使用大型语言模型的生成式多模态知识检索
专知会员服务
58+阅读 · 2024年1月19日
从语言模型到语言智能体,普林斯顿Shunyu Yao
专知会员服务
63+阅读 · 2023年9月18日
专知会员服务
12+阅读 · 2021年7月16日
相关资讯
论文笔记之Feature Selective Networks for Object Detection
统计学习与视觉计算组
21+阅读 · 2018年7月26日
语义分割中的深度学习方法全解:从FCN、SegNet到DeepLab
炼数成金订阅号
26+阅读 · 2017年7月10日
MNIST入门:贝叶斯方法
Python程序员
23+阅读 · 2017年7月3日
相关基金
国家自然科学基金
8+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员