Picat logic programming language ported to Haiku

I took a few minutes and ported the Picat logic programming language to Haiku. A link to the tarball is here: Picat tarball

Picat is a powerful functional logic programming language. It is not a beginner’s programming language. You would likely need at least an undergraduate degree in computer science or a background in logic programming. Here are some links to get started:
Getting Started
Picat: A Logic-based Multi-paradigm Language
Constraint programming with Picat
http://www.picat-lang.org/

If someone wanted to take the time and make a package for Picat I would greatly appreciate it!

Sorry, I missed this post when it came out but I’ll take a swing at packaging it.

Thank you, Sir, much appreciated!

Clasqm could you build an IDE in yab :slight_smile:

No, sorry, it does not compile on my system. Not quite sure what I am missing.

~/unzip/Picat/emu> make
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX dis.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX init.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX init_sym.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX loader.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX inst_inf.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX main.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX toam.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX unify.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX file.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX domain.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX cfd.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX float1.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX arith.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX token.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX global.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX builtins.c
gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX mic.c
/boot/home/unzip/Picat/emu/mic.c:2785: warning: always_inline' attribute directive ignored gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX numbervars.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX cpreds.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX univ.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX assert.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX findall.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX clause.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX delay.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX clpfd.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX clpfd_libs.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX event.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX toamprofile.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX kapi.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX -c -o getline.o getline.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX table.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX gcstack.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX gcheap.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX -c -o gcqueue.o gcqueue.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX debug.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX expand.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX bigint.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX sapi.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX sat_bp.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX -Wall -DNLGLOG -DNLGLSTATS -DNDEBUG -DNLGLPICOSAT -Ilingeling lingeling/lglbnr.c gcc -DGCC -DGC -DPICAT -DSAT -D_FILE_OFFSET_BITS=64 -c -O3 -fno-strict-aliasing -finline-functions -fomit-frame-pointer -Dunix -DLINUX -DPOSIX -Wall -DNLGLOG -DNLGLSTATS -DNDEBUG -DNLGLPICOSAT -Ilingeling lingeling/lglib.c /boot/home/unzip/Picat/emu/lingeling/lglib.c: In functionlglassign’:
/boot/home/unzip/Picat/emu/lingeling/lglib.c:2132: warning: implicit declaration of function __builtin_prefetch' /boot/home/unzip/Picat/emu/lingeling/lglib.c: In functionlglprop’:
/boot/home/unzip/Picat/emu/lingeling/lglib.c:3347: warning: glue' might be used uninitialized in this function /boot/home/unzip/Picat/emu/lingeling/lglib.c: In functionlglsec’:
/boot/home/unzip/Picat/emu/lingeling/lglib.c:3916: parse error before int' /boot/home/unzip/Picat/emu/lingeling/lglib.c:3920:i’ undeclared (first use in this function)
/boot/home/unzip/Picat/emu/lingeling/lglib.c:3920: (Each undeclared identifier is reported only once
/boot/home/unzip/Picat/emu/lingeling/lglib.c:3920: for each function it appears in.)
/boot/home/unzip/Picat/emu/lingeling/lglib.c: In function lglcutwidth': /boot/home/unzip/Picat/emu/lingeling/lglib.c:5488: warning:res’ might be used uninitialized in this function
/boot/home/unzip/Picat/emu/lingeling/lglib.c: In function lglmap': /boot/home/unzip/Picat/emu/lingeling/lglib.c:5834: parse error beforeval’
/boot/home/unzip/Picat/emu/lingeling/lglib.c:5877: val' undeclared (first use in this function) /boot/home/unzip/Picat/emu/lingeling/lglib.c: In functionlgltrd’:
/boot/home/unzip/Picat/emu/lingeling/lglib.c:10438: parse error before int' /boot/home/unzip/Picat/emu/lingeling/lglib.c:10461:count’ undeclared (first use in this function)
/boot/home/unzip/Picat/emu/lingeling/lglib.c:10466: lit' undeclared (first use in this function) /boot/home/unzip/Picat/emu/lingeling/lglib.c:10478:success’ undeclared (first use in this function)
Makefile:121: recipe for target ‘lglib.o’ failed

It looks like you need gcc5. Use “setarch x86” before compiling.

Thanks, Adrian, that worked. I’ve taken the liberty of inserting a note to that effect in the README-Haiku.

If anyone wants to test the package before it gets into my repo: https://www.dropbox.com/s/hvnvnltlzcjofps/picat_x86-2.0-1-x86_gcc2.hpkg?dl=0

x86_64 package to follow.

If you need gcc5 to compile it, it shouldn’t have the ‘gcc2’ tag on the package, should it?:slight_smile:

(I’ve pulled it off BeShare, but haven’t played yet.)

It runs on gcc2 hybrid. The _x86 part of the name shows that it was compiled with gcc4/5

I probably could do that, but let’s see if the language catches on first.

Mnyehh. Guess I haven’t quite figured out the packaging nomenclature, yet!

:slight_smile: Certainly not something one can dive into! Any one else tried it?

I’ve never used Prolog or any other logic or functional language, but I suspect I could figure things out with a decent ‘primer’. I assume more established languages have such, but all the documentation here starts with expecting you to know all that! It wan’t clear to me for quite a while that – even though it runs from a Terminal – most of the language needs to be written into a script to be loaded. Only “queries” can be typed at the prompt.

And I was totally cofused by the fact that one can type “X = 1+2” and see the answer, but if you then try to “print(X)” it has no value! Nowhere did I see it mentioned that – as I eventually discovered – ending a statement with a comma maintains the environment… for that line only. Backslash doesn’t work to continue a line!

I’d probably have to find some really neat use to continue.

I agree. It is confusing. In the long run, IMHO, Haiku’s future lies in x86_64 and the nomencalture will be simplified a lot. But if we moved there today, we’d lose all the old BeOS apps for which we have no source code.

I have an interest in dynamic programming and constraint satisfaction solving, so I have a particular interest in Picat. The developers of Picat also developed Prolog-B, and refer to it heavily in Picat documentation. So I am going back and re-reading the Prolog I learned and forgot a long time ago. I hope to write up a simple primer for using Picat on Haiku, and also some programming examples.

I do think that Picat is EXTREMELY powerful as a programming language. I think it is worth learning the principles.

…and I guess I’m still confused. I thought that the point of a hybrid build is that it runs both gcc2 and gcc4/5 executables without worries. The same gcc5 executable should work on both a hybrid and a gcc5 only build shoudn’t it? Whenever I’ve compiled under gcc5, I’ve never given a thought to what it was supposed to run under. I notice that essentially everything in my ‘packages’ directory is tagged “x86_gcc2”; are they all gcc5?

That would be superb! It does look like a very interesting language, even though, as I said, I’m not familiar with the genre. The docs often completely lost me.

You mean B-Prolog, rather than Prolog-B I guess…

Several years ago I ported SWI Prolog. The recipe is in haikuports but I am not sure if it is still working. I’ll try and check tomorrow and fix it if there are any issues.

Great to get another language to code in on haiku!

EDIT: It works as long as you install readline_x86_devel and gmp_x86_devel manually first. Not sure why they aren’t being picked up automatically but will do some more digging.

while the binaries themselves should run, there are several differences between the architectures, first in terms of system paths (libraries in /boot/system/lib/x86 instead of /boot/system/lib, for example), and because of this, we need to build some packages twice.

As a result, the packages for gcc2-hybrid and gcc5-hybrid are not in sync, which means you don’t always have the same version of libraries, etc.

So, we must have two independant set of packages.

This is indeed rather confusing, so what I would suggest (and the current plan for beta1) is:

  • Deprecate the gcc5hybrid
  • Keep gcc2hybrid as the only variant which supports BeOS apps, with maximal compatibility
  • Keep x86_64 as the variant for people who don’t care about BeOS compatible apps

Eventually, we could build an x86_64 system with some gcc2-32-bit wrapper so it can still run BeOS apps. But there is some more work needed before we get to that, so it is likely that this will happen only in R2, or we may just give up on it if gcc2 support becomes too irrelevant.

1 Like

gcc2hybrid is anachronism, is there really is point for keeping it in highest position?
I think it is time to separate BeOS compatibility layer from Haiku, that layer can have separate beos directory (like in original BeOS).
Haiku should use new gcc, and gcc2 only for BeOS apps compatibility layer.

Eventually, we could build an x86_64 system with some gcc2-32-bit
wrapper so it can still run BeOS apps. But there is some more work
needed before we get to that, so it is likely that this will happen only
in R2, or we may just give up on it if gcc2 support becomes too
irrelevant.

Yes it should be handled as under windows, where you can install and use 32 bit applications with the 64 bit system?