Looking for a study partner for intermediate/advanced prolog (no school level)

I’m a software developer (usually writing haskell), which became recently very interested in logic programming. I understand the concepts in the prolog world (what you can find in books) fairly well, but I lack the habits, and the familiarity with the environment that would make me a productive prolog programmer.
As I imagine I’m not the only one in this situation, I’m looking for a study partner to tackle some more advanced project with; currently my focus is on how to improve the type_check library (I’m not sure it has inference for lambdas from the yall pack), and how to write more immediate debugging tools.

ping me if you are interested (I speak english/italian)

1 Like

Dear Meditans,
I am Andrey from Latvia.
I am writting in connection with you letter "Looking for a study partner for intermediate/advanced prolog … ".

Let’s start correspondence.
Write, please, andreypozolotin@inbox.lv

Best regards

hi we could meet with google meeting with the webcam for 1 hour ( google meet auto disconnects after 1 hour ). i have been making prolog code for more than 15 years now.
currently i work everyday online with the meeting software with my current employer where my task is to make prolog code for the software this company delivers to clients. i always wanted to cooperate with other Prolog programmers but i have never been in that opportunity yet. in my current job i am confronted with prolog code which has been created by other (prolog) programmers. this code is in my opinion written in such a way that it is absolutely impossible to maintain it, that means to add or change code so that new functionalities are created.

In general it is not at all difficult to write code that is Difficult to maintain, the art is to write code that is Easy to maintain afterwards.
so for example if i want an extra line with a label and field in a dialog box, i would just have to add 1 fact declaration and not all kinds of weird loops or codes

Hi Meditans,
I also study it from time to time. It’s a nice tool (Prolog), I find. More recently the new things I have learned about it come from studying a famous book on intermediate/advanced Prolog programming: The Craft of Prolog by O’Keefe. One of the positive sides of the book is that each chapter deals with a self-contained argument and therefore can be studied/read without having to refer to the other chapters (it has a “modular design” I think one could phrase it like this). Anyways, I could be interested even though I have no clear idea of how the thing could be organized…

PS: I’m not a software developer. I’m a teacher, I was interested in Natural Language Processing

my opinion is that in prolog If you use Fail with backtracking that you will create much more easy to read code, ( and also less code ), compared to when you create recursive function calls Without specifying input and output flow patterns
it would never have written this here until the point in time where i was confronted with prolog-code which was written by other “programmers” which is impossible to maintain, modify or to change or to read

Are you referring to repeat-fail loops?

Could you give some examples of what you consider to be easy and difficult to understand Prolog code?

Instead of recursive functions, have you considered using meta-predicates such as maplist/3 and foldl/4? (And instead of repeat-fail: forall/2)

hi, yes i think i am referring to what is considered as repeat-fail loops.
i can give some very good examples of codes which are very difficult to read, here is 1 example, the flow patterns are not specified, and there are about 20-30 of such clauses repeated under eachother, you could re-write this with repeat fail loop a lot more simple, Could indeed be a good idea to use maplist because earlier i never understood the idea of maplist. the code i paste here is visual-prolog code.Currently i am writing in swi-prolog , / i have already written ( in a relative ugly way ( because i was in a hurry)), / i would like to write a swi-prolog small script which can isolate prolog code from existing source files, for example 1 predicate chosen with all other predicates it uses, and it isolates all the substracted code in a new file.


% = 8 options
	HAUT = 630,
	format(Si_pxopA,	"text \"%   \" at(%1.0,%1.0,%1.0,%1.0) fontname=%  fontsize=% border=0 alignment=right fontstyle=normal %  %",Dpop,1800,HAUT,2040,HAUT1,Style,Caractere,Color,";\n"),
	format(Sts1,		"%text \"%   \" at(%1.0,%1.0,%1.0,%1.0) fontname=%  fontsize=% border=0 alignment=left fontstyle=normal % %", "",D,200,HAUT,1500,HAUT1,Style,Caractere,Color,";\n"),
	format(St_2pages,	"%1%text \"%   \" at(%1.0,%1.0,%1.0,%1.0) fontname=%  fontsize=% border=0 alignment=right fontstyle=normal % %",Si_pxop,Sts1,Dp,1550,HAUT,1800,HAUT1,Style,Caractere,Color,";\n"),

	format(Si_pxopA,"text \"  %   \" at(%1.0,%1.0,%1.0,%1.0) fontname=%  fontsize=% border=0 alignment=right fontstyle=normal % %",	Dpop,1800,HAUT,2040,HAUT1,Style,Caractere,Color,";\n"),
	format(Sts1,"%text \"  %   \" at(%1.0,%1.0,%1.0,%1.0) fontname=%  fontsize=% border=0 alignment=left fontstyle=normal % %",	Anc_stt2page,D,200,HAUT,1500,HAUT1,Style,Caractere,Color,";\n"),
	format(St_2pages,"%1%text \"  %   \" at(%1.0,%1.0,%1.0,%1.0) fontname=%  fontsize=% border=0 alignment=right fontstyle=normal % %", Si_pxop,Sts1,Dp,1550,HAUT,1800,HAUT1,Style,Caractere,Color,";\n"),

	format(Si_pxopA,"text \"%\" at(%1.0,%1.0,%1.0,%1.0) fontname=%  fontsize=% border=0 alignment=right fontstyle=normal % %",	Dpop,1800,HAUT,2040,HAUT1,Style,Caractere,Color,";\n"),
	format(Sts1,"%text \" %\" at(%1.0,%1.0,%1.0,%1.0) fontname=%  fontsize=% border=0 alignment=left fontstyle=normal % %",	Ste,D,50,HAUT,1000,HAUT1,Style,Caractere,Color,";\n"),
	format(Sts,"%1%text \"%\" at(%1.0,%1.0,%1.0,%1.0) fontname=%  fontsize=% border=0 alignment=left fontstyle=normal % %",	Si_pxop,Sts1,Dp,1020,HAUT,2030,HAUT1,Style,Caractere,Color,";\n"),

Code with asserts and retracts is often suspicious. Also, they might not do what you expect with failure and backtracking: SWI-Prolog -- Transactions

(One way of getting rid of asserts and retracts is by using aggregation predicates, such as setof/3 or aggregate/4.)

I don’t understand what this code does (even though I can read French), so it’s difficult to suggest a replacement (BTW, I suspect that HAUT1=HAUT+Interligne should be HAUT1 is HAUT + Interligne).

(I would rename si_avec_prix_1_col/8 as avec_prix_1_col/8 – the “si” (if) is implicit in Prolog. Also, predicates with that many parameters are often (but not always) a sign of a design problem).

prolog_analyse_update.pl (65.8 KB)

this one file is a swi-prolog pl script, it hase code to walk through a directory of prolog-code files, and it substracts the prolog code function of choice, it can be called with the following command:
basic_walk( ‘20240101’, “cest_changer_offre_existante_preserve”, ‘C:/jdklog/sources/PR_12_NvoDesign/Trilog5_NouveauLook_Design_MalusPoids_rn28mars2024_nouv/’ ).

it has 3 arguments, 1: date after which should be read, 2: the predicate name it should extract, 3 : the directory name in which it should read all files

all the code is easy to read and modify ( in my opinion ) , it is created with
many fail backtrack constructions

** yes in visual prolog they use “=” instead of “is”,
i would also change si_avec_prix_1_col in avec_prix_1_col, Si / If
is misused here because most of the time they mean avec_prix_or_succeed with some default,

you can have lets say 10 arguments in a function but not if you go looping like that, it is indeed very bad design

if you want to run the script with swi prolog you have to put it somewhere in a directory, in this directory make sure 2 subdirectorys exist: 1 : data and 2: result,

make sure swi prolog is running in that directory for example
with the working_directory command, ( see example lines in de source file )
then you consult the file with : [prolog_analyse_update].
after that execute the above walk command with the right parameters ( see the above walk -example ) , dont forget a forward slash at the end of the directory path used as the 3rd argument/parameter

the code should be enhanced for the point where it substracts 1 prolog clause with head and body, currently it does this by scanning for “:-” and after that for scanning for a “.” with a newline after it. This should be done in a neat way for example with a prolog DCG grammar.