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

Hi,
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
Andrey

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…
Regards,
Marco

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.

imp_op_interne(_,_,_,_,_,N,N,_Font,_Nom_par_ligne,_Caractere,_HAUT,_Interligne,_Nomb_col,_Gauche,_Largeur,St,St,_,_,Si_bold):-!.
imp_op_interne(_,_,[],_,_,_,_,_Font,_Nom_par_ligne,_Caractere,_HAUT,_Interligne,_Nomb_col,_Gauche,_Largeur,St,St,_,_,Si_bold):-!.

% = 8 options
imp_op_interne(NbOptSel,Avec_prix,[D|F],[Dp|Fp],[Dpop|Fpop],8,99,FONT,1,Caractere,_,Interligne,Nomb_col,Gauche,Largeur,Ste,StX,Style,Color,Si_bold):-
	HAUT = 630,
	HAUT1=HAUT+Interligne,
	retractall(option_2_pages_string(_)),	
	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"),
	si_avec_prix_1_col(Avec_prix,1,"",Si_pxopA,_,Caractere,_,Si_pxop),
	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"),
	retractall(option_2_pages_bas(_)),	
	asserta(option_2_pages_bas(HAUT1)),	
	asserta(option_2_pages_string(St_2pages)),!,	
	imp_op_interne(NbOptSel,Avec_prix,F,Fp,Fpop,9,99,Font,1,Caractere,HAUT1,Interligne,Nomb_col,Gauche,Largeur,Ste,StX,Style,Color,Si_bold).

imp_op_interne(NbOptSel,Avec_prix,[D|F],[Dp|Fp],[Dpop|Fpop],N,99,FONT,1,Caractere,HAUT,Interligne,Nomb_col,Gauche,Largeur,Ste,StX,Style,Color,Si_bold):-
	HAUT1=HAUT+Interligne,
	retract(option_2_pages_string(Anc_stt2page)),	
	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"),
	si_avec_prix_1_col(Avec_prix,1,"",Si_pxopA,_,Caractere,_,Si_pxop),
	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"),
	asserta(option_2_pages_string(St_2pages)),	
	retractall(option_2_pages_bas(_)),	
	asserta(option_2_pages_bas(HAUT1)),	
	NN=N+1,!,
	imp_op_interne(NbOptSel,Avec_prix,F,Fp,Fpop,NN,99,Font,1,Caractere,HAUT1,Interligne,Nomb_col,Gauche,Largeur,Ste,StX,Style,Color,Si_bold).

imp_op_interne(NbOptSel,Avec_prix,[D|F],[Dp|Fp],[Dpop|Fpop],N,Maxi,FONT,1,Caractere,HAUT,Interligne,Nomb_col,Gauche,Largeur,Ste,StX,Style,Color,Si_bold):-
	HAUT1=HAUT+Interligne,
	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"),
	si_avec_prix_1_col(Avec_prix,1,"",Si_pxopA,_,Caractere,_,Si_pxop),
	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"),
	NN=N+1,!,
	imp_op_interne(NbOptSel,Avec_prix,F,Fp,Fpop,NN,Maxi,Font,1,Caractere,HAUT1,Interligne,Nomb_col,Gauche,Largeur,Sts,StX,Style,Color,Si_bold).

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.

Hi guys, I didn’t expect this question to get steam again after 4 years, but I welcome it, it’s nice to see activity in the prolog community!

However, since then, my focus slightly changed. I’m not trying to type prolog anymore (although I’m still interested in developer tools relying on reification). I’m still up to meet for a collaboration group if we can rally around a project that interests us all (I think some library would be nice).

So, feel free to propose what you want to work on, either here or via dm (but here is best). To kickoff things, I am still interested in mechanisms that reify the trace of a prolog program, so that you can query it to aid in debugging.

@meditans I’m interested in collaborating on a common subject, on your reification of traces or other subjects :slight_smile:
If you have some code up somewhere and maybe some issue describing a simple problem, we could try and start tackling it together ?

On my end, I’ve recently started to make swi-prolog bindings to the graphics library SDL and tried to make a proof of concept GUI library that works a bit like QML (in the Qt C++ world).
I think this is a nice subject to collaborate on because making bindings is a lot of grunt work for a single person ^^
If anyone is interested, ping me and I’ll post the code on github.

Awesome @kwon-young, I’m out for a couple of weeks but I’ll dm you as I’m back and we’ll figure out something!