Pure, declarative, and constructive arithmetic relations (declarative pearl)

被引:0
|
作者
Kiselyov, Oleg
Byrd, William E.
Friedman, Daniel P.
Shan, Chung-Chieh
机构
来源
关键词
D O I
暂无
中图分类号
TP301 [理论、方法];
学科分类号
081202 ;
摘要
We present decidable logic programs for addition, multiplication, division with remainder, exponentiation, and logarithm with remainder over the unbounded domain of natural numbers. Our predicates represent relations without mode restrictions or annotations. They are fully decidable under the common, DFS-like, SLD resolution strategy of Prolog or under an interleaving refinement of DFS. We prove that the evaluation of our arithmetic goals always terminates, given arguments that share no logic variables. Further, the (possibly infinite) set of solutions for a goal denotes exactly the corresponding mathematical relation. (For SLD without interleaving, and for some infinite solution sets, only half of the relation's domain may be covered.) We define predicates to handle unary (for illustration) and binary representations of natural numbers, and prove termination and completeness of these predicates. Our predicates are written in pure Prolog, without cut (!), var/1, or other non-logical operators. The purity and minimalism of our approach allows us to declare arithmetic in other logic systems, such as Haskell type classes.
引用
收藏
页码:64 / 80
页数:17
相关论文
共 50 条
  • [1] Declarative Pearl: Rigged Contracts
    Vandenbroucke, Alexander
    Schrijvers, Tom
    FUNCTIONAL AND LOGIC PROGRAMMING, FLOPS 2024, 2024, 14659 : 99 - 114
  • [2] Undoing dynamic typing (declarative pearl)
    Benton, Nick
    FUNCTIONAL AND LOGIC PROGRAMMING, 2008, 4989 : 224 - 238
  • [3] Declarative Pearl: Deriving Monadic Quicksort
    Mu, Shin-Cheng
    Chiang, Tsung-Ju
    FUNCTIONAL AND LOGIC PROGRAMMING, FLOPS 2020, 2020, 12073 : 124 - 138
  • [4] Bluefish: Composing Diagrams with Declarative Relations
    Pollock, Josh
    Mei, Catherine
    Huang, Grace
    Evans, Elliot
    Jackson, Daniel
    Satyanarayan, Arvind
    arXiv, 2023,
  • [5] Bluefish: Composing Diagrams with Declarative Relations
    Pollock, Josh
    Mei, Catherine
    Huang, Grace
    Evans, Elliot
    Jackson, Daniel
    Satyanarayan, Arvind
    PROCEEDINGS OF THE 37TH ANNUAL ACM SYMPOSIUM ON USER INTERFACE SOFTWARE AND TECHNOLOGY, USIT 2024, 2024,
  • [6] Space-efficient acyclicity constraints: A declarative pearl
    Brock-Nannestad, Taus
    SCIENCE OF COMPUTER PROGRAMMING, 2018, 164 : 66 - 81
  • [7] Declarative Programming of Search Problems with Built-in Arithmetic
    Ternovska, Eugenia
    Mitchell, David G.
    21ST INTERNATIONAL JOINT CONFERENCE ON ARTIFICIAL INTELLIGENCE (IJCAI-09), PROCEEDINGS, 2009, : 942 - 947
  • [8] DECLARATIVE KNOWLEDGE TO USE DECLARATIVE KNOWLEDGE
    PITRAT, J
    MATHEMATICAL AND COMPUTER MODELLING, 1988, 11 : 408 - 412
  • [9] A Functional Account of Probabilistic Programming with Possible Worlds Declarative Pearl
    van den Berg, Birthe
    Schrijvers, Tom
    FUNCTIONAL AND LOGIC PROGRAMMING, FLOPS 2022, 2022, 13215 : 186 - 204
  • [10] Pure and Declarative Syntax Definition: Paradise Lost and Regained
    Kats, Lennart C. L.
    Visser, Eelco
    Wachsmuth, Guido
    ACM SIGPLAN NOTICES, 2010, 45 (10) : 918 - 932