The paper proposes a framework for embedding logic programming and constraint programming methods in Scala by building a logical object-oriented language around the unification of typed logic based on monads. Two types of API are considered — high-level for language embeddings and low-level for organization of the bidirectional flow of data during the execution of logic programs. Differences in the capabilities of logical mechanisms can be expressed as subclasses of the class of unification monad types. This design makes it possible to share the implementation of custom unification between different frameworks and to use other languages’ embeddings in Scala from the declarative side. The monadic API provides the application developer with a simple and intuitive tool to implement custom logic within the unification. Our frameworks provide a clear representation of logical deduction: Scala code is only used for ad hoc unification. But the overall goal execution is an external interpretation that can implement different strategies. This design provides modularity and good integration with the rest of the ecosystem.
Read full abstract