WAMpy 发布:用 NumPy 和 JIT 加速 Python 中 Prolog 程序合成
WAMpy: Efficient Synthesis of Prolog Programs in Python
要在 Python 里批量生成和测试 Prolog 程序的人可以看看,用 NumPy 加 Numba JIT 重写了编译执行,比从 Python 调 SWI-Prolog 快。
WAMpy 是一个专为合成 Prolog 程序设计的 Python 框架,面向反复生成并评估小型候选程序的负载。它将 Prolog 子句编译为基于 NumPy 数组的 WAM 指令,支持针对固定背景知识对假设进行部分重编译,并用 Numba JIT 加速关键性能路径。在重复编译与评估的基准测试中,其端到端性能优于通过 Janus 从 Python 调用 SWI-Prolog 的方案。
WAMpy: Efficient Synthesis of Prolog Programs in Python
We present WAMpy, a Python framework optimized for synthesizing Prolog programs. Unlike general-purpose Prolog systems, WAMpy targets workloads that repeatedly generate and evaluate small candidate programs. WAMpy compiles Prolog clauses into NumPy array-based WAM instructions and supports partial recompilation of hypotheses against fixed background knowledge. Performance-critical routines are accelerated using Numba just-in-time (JIT) compilation. In a benchmark of repeated compilation-and-evaluation workloads, WAMpy improves end-to-end performance compared with SWI-Prolog accessed from Python using Janus.