Questions tagged [picat]

Picat is a logic-based multi-paradigm programming language with predicates, constraints, functions, and actors.

from Picat home page

Picat is a simple, and yet powerful, logic-based multi-paradigm programming language aimed for general-purpose applications. Picat is a rule-based language, in which predicates, functions, and actors are defined with pattern-matching rules. Picat incorporates many declarative language features for better productivity of software development, including explicit non-determinism, explicit unification, functions, list comprehensions, constraints, and tabling. Picat also provides imperative language constructs, such as assignments and loops, for programming everyday things. The Picat implementation, which is based on a well-designed virtual machine and incorporates a memory manager that garbage-collects and expands the stacks and data areas when needed, is efficient and scalable. Picat can be used for not only symbolic computations, which is a traditional application domain of declarative languages, but also for scripting and modeling tasks.

13 questions
5
votes
1 answer

How to use Picat to create CNF files from Minizinc files?

I'm interested in counting the number of solutions a problem have (not enumerating the solutions). For that, I have tools that uses CNF files. I want to convert Minizinc files (mzn or Flatzinc fzn format) and convert it to CNF. I learned Picat has…
Exeloz
  • 89
  • 6
4
votes
1 answer

Why picat says that the model is unsatisfiable?

The picat solver (v. 2.6#2) states that the example model knights.mzn contained in the minizinc repository and hereby copy-and-pasted: % RUNS ON mzn20_fd % RUNS ON mzn-fzn_fd % RUNS ON mzn20_mip % knights.mzn % Ralph Becket % vim: ft=zinc ts=4 sw=4…
Patrick Trentin
  • 7,126
  • 3
  • 23
  • 40
3
votes
2 answers

Using definite clause grammars in Picat

I know that it is possible to define definite clause grammars in Picat, but the syntax is much more verbose than in Prolog. In Prolog, definite clause grammars can be written more concisely: pronoun --> him,her,it. Surprisingly, Picat's official…
Anderson Green
  • 30,230
  • 67
  • 195
  • 328
2
votes
1 answer

Picat functions in constraints

In an introductory exercise, my goal is to generate patterns of 0, 1 values, subject to various constraints. While the code below works fine with the built-in sum/1 function, it fails (invalid_constraint_expression) with the hand crafted sum1/1…
Attila Karoly
  • 951
  • 5
  • 13
2
votes
2 answers

Partition function P in Picat

I got the following realization of the Partition function P in Prolog, took it from rosetta here: /* SWI-Prolog 8.3.21 */ :- table p/2. p(0, 1) :- !. p(N, X) :- aggregate_all(sum(Z), (between(1,inf,K), M is K*(3*K-1)//2, (M>N, !,…
user502187
2
votes
2 answers

Quine's algorithm with Single Sided Unification in Prolog

The new release 8.3.19 of SWI-Prolog introduces single sided unification inside new Picat style rules. This could be a welcome addition to any Prolog system. I was wondering whether we could rewrite Quine algorithm Prolog implementation of Quine's…
user502187
2
votes
1 answer

"Generating Numbers" Puzzle

I have come across the following puzzle and couldn't formulate a solution in Picat: You will generate 5-digit numbers, where each digit is in 1..5 and different from the others, with the constraint that any three adjacent digits used in one number…
mlg556
  • 419
  • 3
  • 13
1
vote
1 answer

Integer constraints and difference of two lists

I am trying to find a value score, which can be calculated imperatively from two equal length lists Xs, Ys as: for i in len(Xs): if Xs[i] == Ys[i]: score++ else: score-- So the idea is to basically check every element from…
mlg556
  • 419
  • 3
  • 13
1
vote
1 answer

Do evaluating constructors exist in Picat or is it more like Prolog?

I want to quickly create a structure in Picat. But the components of the structure should be evaluated when creating the structure. So far I tried, which gives me a structure when the components are already constants: Picat 2.0b5, (C)…
user502187
0
votes
1 answer

Does Picat support Program Synthesis?

Can I define a program synthesis task in Picat, similar to this definition in SyGuS format? (set-logic LIA) (synth-fun f ((color Int) (sortAsc Int) (sortDesc Int)) Int ((I Int) (B Bool)) ((I Int (color sortAsc sortDesc 0 1 2 3 4 …
Paul Jurczak
  • 7,008
  • 3
  • 47
  • 72
0
votes
1 answer

"=>" symbol definition in Picat

What is the definition of the symbol "=>" in Picat and how do you read it ? Is it an implication ? I have trouble to understand it since there seems to be no informations about it in the manual nor in the book. %example using "=>" main => A =…
0
votes
1 answer

How to build a Gray-code generator in Picat?

Encouraged by the knowledge I've gained from the answer to my previous post, I aim to generate Gray-codes of given length. The procedure hamming seems to work correctly, however, the Picat system finds no solution. Where's the mistake here? import…
Attila Karoly
  • 951
  • 5
  • 13
0
votes
3 answers

How to get int from float in picat?

I try to to read a line as string from console (stdin) in picat and get its half: main => L = read_line(), B = L.length/2, S = L.slice(1,B), println(S). crashes with error(integer_expected(2.0),slice) when int used instead of B - no crash.…
DuckQueen
  • 772
  • 10
  • 62
  • 134