Bug reports for count_all and cl_facts

5 views
Skip to first unread message

Woosuk Kwak (Bubbler)

unread,
Jul 3, 2026, 7:07:18 AM (7 days ago) Jul 3
to Picat
  • When count_all is nested, the outer call gives wrong numbers.
f(X, Y) = count_all((member(X, Y))). main => Range = 1..5, Y = [1, 2], Ans = count_all((member(X, Range), f(X, Y) == 0, println(X))), println(Ans).

The inner predicate is true for X = 3, 4, and 5, but Ans is 1.

  • cl_facts does not accept index declarations of 3 or more arguments.
main => Triples = [$triple(1, 2, 3)], % cl_facts(Triples, [(+,+)]). % is fine cl_facts(Triples, [(+,+,+)]). % ** Error : wrong_index_info:_7e8

If I understand the index declaration correctly, each index declaration must have its length equal to the number of arguments, but cl_facts seems to insist that each of them be of length 2.

Neng-Fa Zhou

unread,
Jul 3, 2026, 10:57:30 AM (7 days ago) Jul 3
to Woosuk Kwak (Bubbler), Picat
Thank you for the reports. 

The current implementation does not expect nested calls to count_all. It uses the same counter variable to store the count. This should be fixed.

Regarding cl_facts, the index info should include the predicate name. In your case, the call should be:

cl_facts(Triples, $[triple(+,+,+)]).

As there is only one predicate, you can also write:

cl_facts(Triples, [{+,+,+}]).

Cheers,
NF

--
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/bc20b90c-d5d8-4087-9e23-7ec27b50fc8bn%40googlegroups.com.

Neng-Fa Zhou

unread,
Jul 3, 2026, 11:14:51 AM (7 days ago) Jul 3
to Woosuk Kwak (Bubbler), Picat
In Picat, as in Prolog, the tuple (1, 2, 3) is represented internally as (1, (2, 3)). That's why len((1,2,3)) returns 2, not 3. It's confusing to people who are familiar with functional and scripting languages. Unfortunately, it's too late to change the representation.

Cheers,
NF

Reply all
Reply to author
Forward
0 new messages