Re:Interpreter for a simple Lisp, Written in Prolog
by jacinabox on Friday March 01, 2019 @02:09PM
(#19284222)
A while back I developed an approach to this in haskell; the idea is to use a logic monad transformer ("Backtracking, Interleaving, and Terminating Monad Transformers" 2005), working at a monad which implements a type class 'Costly' with a single method 'cost'. The implementation of 'cost' can terminate branches of the logic program or transform it in other ways. Then polymorphism over this monad accomplishes the generalization of the logic program over different search strategies.
Re:Interpreter for a simple Lisp, Written in Prolog
by tom_mellior on Friday March 01, 2019 @03:31PM
(#19284961)
If you want nonstandard search or other nonstandard semantics for Prolog, you typically write a metainterpreter. See some examples at https://www.metalevel.at/acomip/ (from the same author as the Lisp interpreter discussed here). It's really easy to implement something like breadth-first search, or depth-first search with iterative deepening, or random search, or some sort of best-first search.
As for your comment about size, Prolog was designed in part to parse things, so it's really good at it. Some other programs in it are trickier and require a certain affinity to Prolog way of thinking.
If someone made a Prolog with cleaner syntax that completely segregates rules from hints, I would probably use it a lot.