NASA Logo

NTRS

NTRS - NASA Technical Reports Server

Back to Results
Logic Programming with Extensible TypesLogic programming allows structuring code in terms of predicates or relations, rather than functions. Although logic programming languages present advantages in terms of declarativeness and conciseness, the introduction of static types has not become part of most popular logic programming languages, increasing the difficulty of testing and debugging of logic programming code. This paper demonstrates how to implement logic programming in Haskell, thus empowering logic programs with types, and functional programs with relations or predicates. We do so by combining three
ideas. First, we use extensible types to generalize a type by a parameter type function. Second, we use a sum type as an argument to introduce optional variables in extensible types. Third, we implement a unification algorithm capable of working with any data structure, provided that certain operations are implemented for the given type. We demonstrate our proposal via a series of increasingly complex examples inspired by educational texts in logic programming, and leverage the host language's features to make new notation convenient for users, showing that the proposed approach is not just technically possible but also practical.
Document ID
20240010266
Acquisition Source
Ames Research Center
Document Type
Technical Memorandum (TM)
Authors
Ivan Perez
(Wyle (United States) El Segundo, California, United States)
Angel Herranz
(Universidad Politécnica de Madrid Madrid, Spain)
Date Acquired
August 7, 2024
Publication Date
August 17, 2024
Subject Category
Mathematical and Computer Sciences (General)
Funding Number(s)
CONTRACT_GRANT: 80ARC020D0010
Distribution Limits
Public
Copyright
Portions of document may include copyright protected material.
Technical Review
NASA Peer Committee
Keywords
logic programming
functional programming
domain-specific languages
type-level programming
No Preview Available