Copilot Speaks Picat

37 views
Skip to first unread message

Neng-Fa Zhou

unread,
Sep 26, 2025, 10:54:46 AMSep 26
to Picat
I asked Copilot four Picat programming questions. Amazingly, it gave correct programs for the first three questions, and needed feedback twice to return a correct program for the coin-change question.

subsets.jpg
perms.jpg
primes.jpg
coins.jpg
Cheers,
NF

David Silverman

unread,
Sep 27, 2025, 2:20:08 PMSep 27
to Picat
I find Copilot both amazing and maddening, depending on the task. 

The 3 primes example didn't work for me as coded by Copilot. I had to modify the is_prime to be a constraint that doesn't rely on N being instantiated. As usual, I found some kode from Hakan.

import cp.


main =>
X :: 2..100,
Y :: 2..100,
Z :: 2..100,
X#<Y,
Y#<Z,
is_prime(X),
is_prime(Y),
is_prime(Z),
solve([X,Y,Z]),
println([X,Y,Z]).

% The co-pilot code doesn't work
% is_prime(N) =>
% N > 1, % error, needs to be N #> 1
% foreach(I in 2..floor(sqrt(N))) % error on sqrt
% uses #\=, which works, but isn't in picat manual, instead of #!=
% N mod I #\= 0
% end.

% is_prime(X) =>
% X #> 1,
% fd_max(X) = Max,
% Len = 1+ceiling(sqrt(Max)),
% % Have to hard code for 2 and 3
% (X #= 2 #\/ X #= 3 #\/
% sum([X mod I #> 0 : I in 2..Len]) #= Len-1
% ) #= 1.

is_prime(X) =>
Max = fd_max(X),
foreach(I in 2..Max // 2)
I #!= X #=> X mod I #> 0
end.




Neng-Fa Zhou

unread,
Sep 27, 2025, 2:51:28 PMSep 27
to Picat
LLMs are fast learners. With the enlargement of the Picat code base, LLMs will become more and more helpful assistants in Picat programming.

I am using Picat for part of my AI course. I received the following program from a student:

fact(0) = 1,
fact(N) = N * fact(N-1), N > 0.

map(F, []) = [].
map(F, [H|T]) = [F(H)|map(T)].

Probably the student used AI. The functions don't work with the current Picat version, but they do make sense. I had been thinking about extending the syntax to support short-form function definitions (shorten 'f(A1,...,An) = Res, Cond => true' to 'f(A1,...,An) = Res, Cond.') and higher-order predicate and function calls  in the form of F(A1,...,An) (as in XSB). It seems that AI is moving ahead of us.

Cheers,
Neng-Fa


--
You received this message because you are subscribed to the Google Groups "Picat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picat-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/picat-lang/858a30c4-9322-4075-aff4-3056eb2ddfd2n%40googlegroups.com.

Hakan Kjellerstrand

unread,
Sep 28, 2025, 4:56:43 AMSep 28
to Neng-Fa Zhou, Picat
Hi, Neng-Fa.

Supporting these two syntax extensions would be great, especially the higher order variant.

I'm not using Copilot, but ChatGPT-5 and Gemini, and both seem to get better and better with Picat. Though sometimes they forget and think that it's Prolog or - which is worse - Python. Some year ago I created a ChatGPT GPT for Picat - "Picat Prodigy" (https://chatgpt.com/g/g-EEpNUZ9H1-picat-prodigy) - which reads ("RAGs") both the Picat Guide and our Picat book before answering. It can be useful but is definitely not error free.

Best

Hakan





--

Neng-Fa Zhou

unread,
Sep 30, 2025, 10:52:01 AMSep 30
to Picat
Hi Hakan,

The syntax extensions will be available in the next major version, 4.0, together with a more efficient module system. 

We need to feed AI systems with training data before they can assist people in Picat programming. It's very exciting to witness the progress.

Best,
NF
Reply all
Reply to author
Forward
0 new messages