Functional logic languages are a high-level approach to programming by combining the most important declarative features. They abstract from small-step operational details so that programmers can concentrate on the logical aspects of an application. This is supported by appropriate evaluation strategies. Demand-driven evaluation from functional programming is amalgamated with non-determinism from logic programming so that solutions or values are computed whenever they exist. This frees the programmer from considering the influence of an operational strategy on the success of a computation, but it is a challenge to the language implementer. A non-deterministic demand-driven strategy might duplicate unevaluated choices of an expression, which could duplicate the computational effort. In recent implementations, this problem has been tackled by adding a kind of memoization of non-deterministic choices to the expression under evaluation. Since this has been implemented in imperative target languages, it was unclear whether this could also be supported in a functional programming environment like Haskell. This paper presents a solution to this challenge by transforming functional logic programs into a monadic representation. Although this transformation is not new, we present an implementation of the monadic interface which supports memoization in non-deterministic branches. Additionally, we include more advanced features of functional logic languages, namely functional patterns and encapsulated search, in our approach. By optimizing our implementation for purely functional computations with both a static and dynamic approach, we are able to achieve a promising performance that outperforms current compilers for Curry.


翻译:函数式逻辑语言通过结合最关键的声明式特性,提供了一种高级编程方法。它们抽象掉了小步操作细节,使程序员能够专注于应用的逻辑层面,这一特性通过适当的求值策略得以支持。函数式编程中的需求驱动求值与逻辑编程中的非确定性相融合,使得只要存在解或值就能进行计算,从而免去了程序员考虑操作策略对计算成功影响的负担,但这给语言实现者带来了挑战。非确定性的需求驱动策略可能复制未求值的表达式选择,从而导致计算开销的重复。在近期的实现中,这一问题通过向被求值表达式添加一种非确定性选择的记忆化机制得到了解决。由于这已在命令式目标语言中实现,此前尚不清楚是否也能在类似Haskell的函数式编程环境中支持。本文提出了一种解决方案,通过将函数式逻辑程序转换为单子表示来解决这一挑战。尽管这一转换并非新方法,但我们实现了一种支持非确定性分支中记忆化的单子接口。此外,我们在方法中纳入了函数式逻辑语言的更高级特性,即函数式模式和封装搜索。通过采用静态和动态两种方式优化面向纯函数式计算的实现,我们取得了优于当前Curry编译器的性能表现。

0
下载
关闭预览

相关内容

【牛津大学博士论文】可微分编程的结构基础,176页pdf
专知会员服务
26+阅读 · 2023年8月20日
【2022新书】Python数学逻辑,285页pdf
专知会员服务
68+阅读 · 2022年11月24日
【经典书】算法C语言实现,Algorithms in C. 672页pdf
专知会员服务
82+阅读 · 2020年8月13日
自动结构变分推理,Automatic structured variational inference
专知会员服务
41+阅读 · 2020年2月10日
【书籍推荐】简洁的Python编程(Clean Python),附274页pdf
专知会员服务
184+阅读 · 2020年1月1日
【2022新书】Python数学逻辑,285页pdf
专知
13+阅读 · 2022年11月24日
Effective.Modern.C++ 中英文版,334页pdf
专知
26+阅读 · 2020年11月4日
激活函数还是有一点意思的!
计算机视觉战队
12+阅读 · 2019年6月28日
Python 神经网络编程
人工智能头条
10+阅读 · 2019年2月27日
福利 | 当Python遇上大数据与机器学习,入门so easy!
用于数学的 10 个优秀编程语言
算法与数据结构
13+阅读 · 2018年1月5日
从点到线:逻辑回归到条件随机场
夕小瑶的卖萌屋
15+阅读 · 2017年7月22日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 4月28日
Arxiv
0+阅读 · 3月30日
VIP会员
相关主题
最新内容
网状网络及其在军事领域的运用
专知会员服务
4+阅读 · 今天6:18
无美国参与的欧洲战争方式(万字长文)
专知会员服务
4+阅读 · 今天5:54
《国防领域敏感性分析白皮书》
专知会员服务
5+阅读 · 今天3:42
综述 | 从问答到任务完成:Agent系统与Harness设计
Agentic RL:框架、实践与长程智能体训练
专知会员服务
4+阅读 · 6月24日
重新思考无人机时代的生存能力
专知会员服务
8+阅读 · 6月24日
装甲突击旅:现代战争思考、战斗与组织
专知会员服务
6+阅读 · 6月24日
在人工智能加速决策环境中拓展OODA循环
专知会员服务
8+阅读 · 6月24日
军事欺骗:供作战战术指挥官使用的工具
专知会员服务
6+阅读 · 6月24日
相关资讯
【2022新书】Python数学逻辑,285页pdf
专知
13+阅读 · 2022年11月24日
Effective.Modern.C++ 中英文版,334页pdf
专知
26+阅读 · 2020年11月4日
激活函数还是有一点意思的!
计算机视觉战队
12+阅读 · 2019年6月28日
Python 神经网络编程
人工智能头条
10+阅读 · 2019年2月27日
福利 | 当Python遇上大数据与机器学习,入门so easy!
用于数学的 10 个优秀编程语言
算法与数据结构
13+阅读 · 2018年1月5日
从点到线:逻辑回归到条件随机场
夕小瑶的卖萌屋
15+阅读 · 2017年7月22日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员