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

被引:0
|
作者
Kiselyov, Oleg
Byrd, William E.
Friedman, Daniel P.
Shan, Chung-Chieh
机构
来源
FUNCTIONAL AND LOGIC PROGRAMMING | 2008年 / 4989卷
关键词
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 条
  • [11] Declarative routing: Extensible routing with declarative queries
    Loo, BT
    Hellerstein, JM
    Stoica, I
    Ramakrishnan, R
    ACM SIGCOMM COMPUTER COMMUNICATION REVIEW, 2005, 35 (04) : 289 - 300
  • [12] Towards declarative monitoring of declarative service compositions
    Taylor, Kerry
    Brebner, Paul
    Kearney, Michael
    Zhang, Dana
    Lam, Kelly
    Tosic, Vladimir
    2007 IEEE 23RD INTERNATIONAL CONFERENCE ON DATA ENGINEERING WORKSHOP, VOLS 1-2, 2007, : 315 - +
  • [13] Hybrid Verification of Declarative Programs with Arithmetic Non-fail Conditions
    Hanus, Michael
    PROGRAMMING LANGUAGES AND SYSTEMS, APLAS 2024, 2025, 15194 : 109 - 129
  • [14] Far beyond declarative and non-declarative memories
    Dere, Ekrem
    Zlomuzica, Armin
    FRONTIERS IN BEHAVIORAL NEUROSCIENCE, 2014, 8 : 1 - 2
  • [15] DECLARATIVE UPDATE
    POUNTAIN, D
    BYTE, 1985, 10 (08): : 341 - &
  • [16] Declarative Networking
    Loo, Boon Thau
    Condie, Tyson
    Garofalakis, Minos
    Gay, David E.
    Hellerstein, Joseph M.
    Maniatis, Petros
    Ramakrishnan, Raghu
    Roscoe, Timothy
    Stoica, Ion
    COMMUNICATIONS OF THE ACM, 2009, 52 (11) : 87 - 95
  • [17] Declarative memory
    Davachi, Lila
    Dobbins, Ian G.
    CURRENT DIRECTIONS IN PSYCHOLOGICAL SCIENCE, 2008, 17 (02) : 112 - 118
  • [18] DECLARATIVE GRAPHICS
    HELM, R
    MARRIOTT, K
    LECTURE NOTES IN COMPUTER SCIENCE, 1986, 225 : 513 - 527
  • [19] A declarative tool
    Konopasek, M
    IEEE SPECTRUM, 1997, 34 (04) : 6 - 6
  • [20] DECLARATIVE FEEDBACK
    MENADUE, A
    BYTE, 1985, 10 (13): : 30 - &