Hacker News new | ask | show | jobs
by datadon 5435 days ago
I did a university module in Prolog (for programming intelligent systems). Although I have not used it since, I always remember it fondly. It is a totally different paradigm to the Pythons/Rubies/Cs/Javas and really quite refreshing when you get in to it.

Unfortunately I now struggle to think of a use for it on a day to day basis.

4 comments

I think Prolog still has a place in modern software development. It provides a natural way of carrying out a backwards chaining depth first search through a state space (good for game AI, planning and scheduling etc). Also constraint solving is a very useful feature built into most logic programming languages now.

Prolog pureists argue that the whole of Prolog can be used for applications, but I tend to take a different approach that integration of Prolog with other languages can help you to do the things its really good and you can get the best out of multiple languages.

That's why I developed a (now open source) platform for integrating Prolog with other applications via web services... see http://kms.intelligent-architectures.co.uk/

I'm a logic fan so I like prolog a lot, though for many people admittedly its greatest attribute will be expanding the way you think about programming.

However for some problems you might want to go right to constraint programming as you mentioned if you need speed and ease of modeling. I like MiniZinc for many problems, or if you're interested you could try my constraint programming language (http://sabrlang.org) which is based on spatial and temporal logic.

+1 for the pragmatic use of Prolog.

One can have Prolog-as-a-service. The SWI-PL implementation has excellent webserver out of the box. We feed the Prolog database from some external sources, do the reasoning and expose results via dead simple JSON API. It Just Works (tm) !!

Same here, all University of Amsterdam CS students (informatics, AI and information sciences) took a compulsory course in Prolog.

Except I was lucky enough to have a use for it after uni (about two years ago), writing generators for various puzzle games. It's one of the tasks that has Prolog written all over it.

Hi, do you do freelance? You don't have any contact inf on your profile.
offt: i do now.
Our (natural language) parser/generator is for the largest part written in Prolog (the rest is C/C++/Tcl):

http://www.let.rug.nl/vannoord/alp/Alpino/

Prolog matches very well with the grammar formalism that we use (attribute-value grammars), since attribute-value structures with arbitrary depth and re-entrancy can easily be represented as Prolog terms and larger analyses can be constructed through unification.

E.g. the grammar rules are plain Prolog rules where one argument argument is a list that represents the right hand side of a grammar rule, and another argument is the left-hand side. The rule goals define relations between the RHS and LHS by unifying parts of the RHS structures with the LHS structure. For instance, the rule for np -> det, n is this:

  grammar_rule(np_det_n, NP, [ Det, N ] ) :-
      np_det_n_struct(NP,Det,N).
Where np_det_n_struct unifies paths between NP <-> Det, NP <-> N, and unifies some paths with atoms. Completing a grammar rule is simply a matter of unifying members of the RHS list.
This looks like the purpose for which DCGs are designed (http://en.wikipedia.org/wiki/Definite_clause_grammar). It's hard to tell from your example, but would the syntax not fit your applications? (Also, why

    grammar_rule(np_det_n, NP, [ Det, N ] )
instead of

    np_det_n(NP, [ Det, N ] )
?)
This looks like the purpose for which DCGs are designed

DCGs are not really practical when implementing different parsing/generation strategies, where you usually want to be able to access categories easily (ie. not as Prolog goals). Also, once you represent RHS constituents as a list rather than goals, you do not need DCG's difference lists to maintain adjacency.

Also, why ... instead of ...

Since the rule identifiers are never used as goals. They are just for printing pretty parse trees, and to see which rules fired for constructing an attribute-value structure (e.g. rule counts are used as features in the disambiguation component). Rules match on category (remember, there is more than one way to construct on np), which is a type in the type hierarchy for feature structures. An av-structure with type np will be structured as a Prolog term with the functor np.

Btw. note that the representation above is only the representation that the grammar writer will use. For parsing/generation transformed terms will be used. E.g. during generation grammar rules use the syntactic head as the first term argument, and chart edges use the next unprocessed RHS slot as the first term argument. Both to make use of first argument indexing.

http://www.sics.se/sicstus/docs/latest3/html/sicstus.html/In...

I did a module in logic and prolog for a CS masters and agree it's very refreshing. I actually got a lot more out of it as a language in the context of predicate logic (which I started hating but by the end really enjoyed).