[HN Gopher] Scryer Prolog
       ___________________________________________________________________
        
       Scryer Prolog
        
       Author : aarroyoc
       Score  : 96 points
       Date   : 2023-02-03 12:54 UTC (1 days ago)
        
 (HTM) web link (www.scryer.pl)
 (TXT) w3m dump (www.scryer.pl)
        
       | joeatwork wrote:
       | Hey,folks who are working with Prolog - what sort of work are you
       | doing?
        
         | triska wrote:
         | There was a recent thread _Prolog at work_ with many
         | interesting links and posts:
         | 
         | https://news.ycombinator.com/item?id=34164221
        
         | YeGoblynQueenne wrote:
         | I work on an ancient, legacy system that manages company car
         | rentals, written in Visual Prolog. Visual Prolog is an ojbect-
         | oriented, typed, compiled, version of Prolog, so it's very,
         | _very_ different than ordinary Prolog ( "ordinary" for me
         | anyway).
         | 
         | To be honest, it's not the most exciting system to be working
         | on. It's basically using Prolog to encode business rules and
         | perform calculations that you would sometimes expect to see in
         | a spreadsheet (but then, there are parallels between logic
         | programming and spreadsheets, e.g. see [1,2]). Prolog of course
         | is a great language for that sort of use. On the other hand, I
         | think the idea of turning Prolog into an object-oriented
         | language is the worst idea of all times. I mean, when I quit my
         | job in the industry to do a PhD, a big draw was that I could
         | work with Prolog, but not OOP. And now I'm back in the industry
         | working with an OOP Prolog. Resistance is futile.
         | 
         | The fun part is that the project I'm working on has been
         | developed over 20 years by multiple people with very, ah, let's
         | say varied opinions on the necessity of maintainability of old
         | code. There are missing sources, old configurations that break
         | compilation, no structured comments whatsoever, no version
         | control (NO VERSION CONTROL!!! AAAAAH!!!), about 1/10th of the
         | LOCs are commented-out for reasons unknown and unspecified in
         | any comments, and so on, so forth.
         | 
         | So it's really cool to work with. I absolutely love digital
         | archeology! :D
         | 
         | _________________
         | 
         | [1]
         | https://www.j-paine.org/spreadsheet_structure_discovery.html
         | 
         | [2] https://dl.acm.org/doi/10.1145/67449.67466
        
           | mst wrote:
           | I keep seriously considering trying https://logtalk.org/ to
           | get myself object orientation in prolog - haven't done so
           | yet, expressing no opinion as to whether it's a good idea in
           | practice, but it definitely looks like it'd be fun to play
           | with.
        
           | pjmlp wrote:
           | Now that is a name I didn't saw for a while.
           | 
           | I remember the ads in Dr Dobbs!
           | 
           | Thanks for sharing.
        
       | sriku wrote:
       | SWIProlog[1] has so far been my go to due to the extensive
       | support system it has. However, I've been meaning to explore
       | higher order logic a bit and Ciao[2] caught my attention there,
       | with sugar for function-like notation and higher order
       | programming including "lambda" style predicate expressions ....
       | and it compiles down to executable. The function notation in this
       | context is along the same lines as Mozart/Oz and can be
       | convenient. Not explore the higher order aspects much though.
       | 
       | [1]: https://www.swi-prolog.org/
       | 
       | [2]: https://en.wikipedia.org/wiki/Ciao_(programming_language)
        
         | YeGoblynQueenne wrote:
         | Hey, if you're interested in higher-order logic programming
         | then you might want to have a look at Meta-Interpretive
         | Learning (MIL). It's a new approach to Inductive Logic
         | Programming (ILP) that learns by SLD-resolution with first- and
         | second-order definite clauses (hence, "higher-order").
         | 
         | You won't find much on MIL as "higher-order logic programming"
         | but that's really what it is: it's logic programming; with a
         | higher-order program (i.e. one containing both first- and
         | second-order clauses). The catch is that once you do this any
         | proof you complete gives you instantiations into the second-
         | order variables in the second-order clauses and now you have
         | yourself a first-order program, that you didn't have before;
         | hence "inductive". So it's basically a form of machine learning
         | of logic programs, from other logic programs.
         | 
         | There are a few papers you can find online about MIL, but I
         | recommend (PLUG ALERT) the documentation of the MIL system I
         | created for my doctoral thesis as a starting point:
         | 
         | https://github.com/stassa/louise
         | 
         | I recommend that as a starting point because it's written for
         | people who are familiar with logic programming, but not
         | necessarily ILP. Anyway, plug over. I think MIL is an exciting
         | new development that has of course gone under the radar of the
         | logic programming community at large.
        
           | cvalka wrote:
           | Beware of the license -
           | https://github.com/stassa/louise/blob/master/LICENSE.md
        
             | YeGoblynQueenne wrote:
             | Eh? What's wrong with the license? :P
        
               | javbit wrote:
               | It's not a free software license as it restricts freedom
               | zero, the ability to use it for any purpose.
               | 
               | https://www.gnu.org/philosophy/free-sw.html#four-freedoms
               | 
               | It's interesting because I'm sure no free software author
               | wants to inadvertently support a dubious cause. The Anti-
               | Mil clause prevents that (in theory at least, as license
               | enforcement is hard for everyone). However, it also
               | nominally prevents use by good causes as well (you can
               | grant exceptions, however). Good and bad here are
               | relative to the author.
               | 
               | I guess it's a balancing act between upholding ones own
               | sense of right and wrong, and the freedom for someone
               | else to have a differing opinion than you.
               | 
               | Edit: Removed "strictly" from "strictly free software".
               | It's unfree.
               | 
               | Edit: Added some words for clarification.
        
       | eddsh1994 wrote:
       | Are there any nice temporal logic libraries?
        
       | Avshalom wrote:
       | Nice, this project has been sorely missing some documentation.
        
       | mark_l_watson wrote:
       | I work with Mark Thom, a Scryer Prolog developer. That said I
       | have used Swi-Prolog for 20 years so it may be a while before
       | switching.
       | 
       | Coincidentally I just started re-reading The Art of Prolog
       | yesterday. It is an old book, but good. For some types of
       | applications, Prolog is pretty much amazing.
       | 
       | EDIT: nice documentation pages, BTW.
        
         | jeff-davis wrote:
         | Is the difficulty switching from SWI due to tooling issues or
         | because source code changes are required?
        
         | noloblo wrote:
         | mark, which type of applications is prolog amazing for?
        
       | triska wrote:
       | Scryer Prolog was most recently discussed here in October 2021:
       | 
       | https://news.ycombinator.com/item?id=28966133
       | 
       | Since then, a great number of improvements have become available,
       | among them:
       | 
       | The system is now much faster, thanks to a much more compact
       | internal representation of WAM heap cells. In addition, goals
       | that occur as arguments of meta-predicates are now automatically
       | compiled much more efficiently, avoiding superfluous lookups at
       | runtime. Also, Adrian Arroyo Calle has contributed new and much
       | improved HTTP server and client libraries, based on the Rust
       | crate "hyper".
       | 
       | Scryer Prolog 0.9.1 and later versions ship with all these
       | improvements and several smaller corrections and additional
       | features.
       | 
       | Adrian also built the documentation system DocLog that he uses to
       | generate this nice home page of the project:
       | 
       | https://github.com/aarroyoc/doclog
       | 
       | DocLog uses Djota, a Prolog implementation of the markup language
       | Djot:
       | 
       | https://github.com/aarroyoc/djota
       | 
       | Such systems show that nice applications can already be built
       | with Scryer Prolog and its innovations.
       | 
       | Thank you a lot to Mark and everyone who contributed to Scryer
       | Prolog, please keep up the great work!
        
         | kinow wrote:
         | I had seen the news about the new website, but didn't know that
         | there were more great improvements in Scryer. Going to check it
         | out, thanks for the nice summary of updates.
        
       | tannhaeuser wrote:
       | Nit: a page advertising ISO Prolog shouldn't start with non-ISO
       | builtins such as append/3 however widespread append or the belief
       | it's in ISO may be. Here's a variant using atom_concat/3 which is
       | actually defined by ISO:                   ?- atom_concat('Hello,
       | ', X, 'Hello, ISO Prolog!')
       | 
       | You can paste that Prolog code into eg [1] and other sites for
       | execution in the browser btw.
       | 
       | [1]: https://quantumprolog.sgml.io/browser-demo/browser-demo.html
        
         | triska wrote:
         | append/3 is a so-called _extension_ of the standard:
         | 3.70 extension: A facility provided by the processor
         | that is not specified in this part of ISO/IEC 13211 but that
         | would not cause any ambiguity or contradiction if added
         | to this part of ISO/IEC 13211.
         | 
         | This means that every conforming system is free to provide
         | append/3, because it causes no ambiguity or contradiction with
         | the standard. However, by 5.1, every conforming Prolog system
         | must offer a _strictly conforming mode_ :                 e)
         | Offer a strictly conforming mode which shall reject       the
         | use of an implementation specific feature in Prolog       text
         | or while executing a goal.
         | 
         | In the case of append/3, this means that there must be a way to
         | run the system _without_ the presence of this predicate. Scryer
         | Prolog satisfies this criterion: In Scryer Prolog, append /3 is
         | only available if library(lists) is loaded, otherwise it is not
         | available. For example, we get:                   $ scryer-
         | prolog -f         ?- append("Hello, ", X, "Hello, Scryer
         | Prolog!").
         | error(existence_error(procedure,append/3),append/3).
         | 
         | append/3 is part of the suggested Prologue for Prolog:
         | 
         | https://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue
         | 
         | Strings are a good representation for ephemeral data, where
         | allocating an atom would yield additional overhead, via an
         | entry in the atom table that is not needed elsewhere and can
         | only be reclaimed by GC instead of much faster on backtracking.
         | 
         | Another major attraction of strings is that we can use DCGs to
         | reason about them, and we can write this specific example
         | equivalently as:                   ?- phrase(("Hello,
         | ",seq(Cs)), "Hello, Scryer Prolog!").            Cs = "Scryer
         | Prolog!".
         | 
         | DCGs are another example of a conforming extension, and they
         | are themselves currently being drafted for inclusion in the
         | Prolog ISO standard. In Scryer Prolog, DCGs are available only
         | when library(dcgs) is loaded, so that its default mode after
         | invocation remains strictly conforming.
        
           | tannhaeuser wrote:
           | > _append /3 is only available if library(lists) is loaded_
           | 
           | But it isn't loaded in the example Prolog showcase; that was
           | my point ;)
           | 
           | Now, _if_ it 's being loaded via use_module (ie using flawed
           | ISO/IEC 13211-2 modules that shall be forgotten since
           | portability isn't achieved), then it would be at odds with
           | the Prologue for Prolog which assumes it's being imported via
           | ISO-conformant ensure_loaded, rather than as a module.
        
       ___________________________________________________________________
       (page generated 2023-02-04 23:01 UTC)