1

I would be greatly appreciative of a simple pseudo-code algorithm for implementing Prolog, where the pseudo-code is taken to be for a pure functional language.

Jimster
  • 131
  • 2
  • I cannot see your question in this... – fr00ty_l00ps Nov 11 '12 at 20:19
  • 1
    This is way too broad for this site, in addition to be a "gimme teh codez" question. – Kevin Nov 11 '12 at 20:20
  • It looks like this: `f : term -> bool`, where `f` is taken to be an implementation of unification algorithm for a prolog-like language. – Gian Nov 11 '12 at 20:22
  • In response to Kevin, I understand the concern, however I find that often some of the clearest definitions are those detailed in the form of pseudo-code or actual code. I agree that this question is a rather large one, however it seems like a useful thing to have a readily accessible definition of Prolog available for widespread comprehension. – Jimster Nov 11 '12 at 20:25
  • It's a fairly classic homework question, and the fact that you haven't even bothered to Google it makes me think you're looking for homework help, rather than having any more altruistic motive. – Gian Nov 11 '12 at 20:29
  • I've spent time with google, just I've found no functional implementations which contain rationale, or algorithms which do not require mutable state. To give more context, I'm attempting to implement type inference, however the intricate features in the type system of my language (Dependant types, refinement types, linear typing to name a few of the less common ones) make me feel that it would be useful to base my type inference off of the algorithms driving Prolog as to obtain a very general algorithm. I will note that I'm entirely self taught, so my knowledge is lacking in large areas. – Jimster Nov 11 '12 at 21:00
  • I refute Gian's proposed type signature on the function `f`, for the sake of others wishing to glean information from this question. Specifically addressing the unification function, one would expect the type to be `f:T->T->S` where T is the type of a term, and S is a list of 2-tuples pairing variables and their substitutions. Of course unification is not the only aspect of Prolog. – Jimster Nov 11 '12 at 21:16
  • I flaged this for the moderator. It is a duplicate of http://cs.stackexchange.com/q/6618/268 – Guy Coder Nov 11 '12 at 21:55
  • @Jimster I had similar problems when I first started using Stack Overflow and it's sites. Hang in there, we are here to help and don't let this question's responses become an obstacle to staying here. :) – Guy Coder Nov 11 '12 at 22:00
  • I agree that it is a duplicate, I merely realized after posting this here that it might be better suited for the cs.stackexchange and posted it there. Is it proper manner for me to delete this? Or is there someway of placing a marker of referral to the other question? – Jimster Nov 11 '12 at 22:29
  • google search "Haskell Prolog" and "Haskell Prolog hackage". see also http://stackoverflow.com/questions/10843563/conda-condi-conde-condu/10848902#10848902 – Will Ness Nov 14 '12 at 07:52
  • Hugs98 (the Nov 2002 version) has a whole folder of source files at demos/Prolog. – Will Ness Aug 27 '18 at 00:35

1 Answers1

4

The famous SICP book has a chapter on logic programming

Basile Starynkevitch
  • 1
  • 16
  • 251
  • 479
  • The book has a new home: [Structure and Interpretation of Computer Programs](https://mitpress.mit.edu/sites/default/files/sicp/index.html). – Per Mildner Aug 26 '18 at 12:16