Search NASASearch

NASA NTRS · 20240010266

Logic Programming with Extensible Types

Abstract

Logic 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.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Ivan Perez, Angel Herranz. 2024-08-17. Logic Programming with Extensible Types. https://ntrs.nasa.gov/citations/20240010266

Cite the original work for its findings. Save a collection to share your selection of sources.