Git Product home page Git Product logo

Comments (4)

triska avatar triska commented on July 28, 2024 2

freeze/2 is one of the simplest constraints and comparatively easy to implement in C, so this may seem tempting.

dif/2 is already considerably harder to implement correctly, at least if you want it to be in some sense "clever". For example, even after several rounds of correction and rewrites, SWI-Prolog still has elementary mistakes in its (Prolog-based) dif/2 implementation. It stands to reason that a C-based implementation would be a lot harder still to get right and maintain.

Writing clpz and clpb in C will most likely end in a system that, even if you manage to implement it correctly, will be immune to large-scale improvements and rewritings due to its extreme code size. The situation will be similar to Gecode, where implementing significant improvements "is not hard, it is just very tedious" (https://www.gecode.org/users-archive/2017-August/004989.html), and hence not done.

Attributed variables, in addition to enabling the implementation of constraint solvers, also provide O(1) destructive access to terms, and that can be useful to implement graph-based algorithms efficiently.

Personally, I recommend to implement an (ideally: SICStus-compatible) interface for attributed variables as early as possible in a Prolog system, so that its implementation is taken into account at all stages during development. Doing this later may lead to unanticipated complications. Once the interface is available, more and more components (freeze/2, dif/2, when/2 etc. which you mentioned) can be written in Prolog itself, and that keeps the code of the system small and maintainable, and also provides motivation to make the interpreter itself fast. The more you write in C, the less important the Prolog-aspect of the system becomes: Doing as much as possible in C may result in a nice and very large C program, though one that will likely not be very good at running Prolog code.

I say "ideally" SICStus-compatible because SICStus provides correct implementations of dif/2, CLP(B), CLP(FD) and CLP(Q) based on its interface, and this shows that the interface is general enough to implement a wide range of constraint solvers correctly and efficiently.

from trealla.

guregu avatar guregu commented on July 28, 2024

Native freeze/2, dif/2, when/2 sounds cool. Tau Prolog doesn't support them at all, which is one of the big motivations to work on the WASM stuff for Trealla. After working with Tau a lot, I've been longing to use dif/2 :)
Attributed variables would be great to keep, of course, maybe for experimental stuff — but I'd consider these predicates a little more practical.

from trealla.

UWN avatar UWN commented on July 28, 2024

Dropping atvs means probably that there will never be a clpz nor clpq. Also, as a general remark on "native" built-in implementations, this has in my view often contributed to more instability than in other implementations. Finding an optimal tiny kernel to start with is certainly not obvious. My armchair advice...

from trealla.

infradig avatar infradig commented on July 28, 2024

from trealla.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.