Picat General 2 — Questions and Answers
Question 1: Which operator is used in Picat to unify two terms?
- = (Correct answer)
- ==
- :=
- =>
Correct answer: =
The = operator performs unification in Picat, binding variables so both sides become identical.
Question 2: What does the `not` predicate do in Picat?
- Negation as failure — succeeds if goal fails (Correct answer)
- Logical NOT returning a boolean
- Throws an exception if the goal succeeds
- Reverses list elements
Correct answer: Negation as failure — succeeds if goal fails
In Picat, `not(Goal)` succeeds when Goal fails and fails when Goal succeeds, implementing negation-as-failure.
Question 3: What is the role of the `module` declaration in a Picat source file?
- Defines a namespace for predicates and functions (Correct answer)
- Imports an external library
- Declares a constraint domain
- Sets the recursion limit
Correct answer: Defines a namespace for predicates and functions
A `module` declaration names the compilation unit and controls which predicates are exported as part of Picat's module system.
Question 4: In Picat, what symbol introduces a clause head-body separator in a rule?
- => (Correct answer)
- :-
- ->
- ::
Correct answer: =>
Picat uses `=>` (fat arrow) as the clause separator between the head pattern/guard and the body of a rule.
Question 5: Which built-in predicate checks whether a term is a free (uninstantiated) variable in Picat?
- var(X) (Correct answer)
- free(X)
- unbound(X)
- is_var(X)
Correct answer: var(X)
`var(X)` succeeds when X is an uninstantiated variable, following the standard logic-programming convention.
Question 6: What happens when a Picat rule uses `?=>` instead of `=>`?
- Backtracking into the rule is allowed (Correct answer)
- The rule becomes deterministic and cuts
- It defines a constraint propagator
- It imports a module conditionally
Correct answer: Backtracking into the rule is allowed
`?=>` marks a non-deterministic rule, allowing the runtime to backtrack into it on failure, while `=>` commits once the head matches.
Question 7: Which Picat module provides common list operations such as `append` and `member`?
- lists (Correct answer)
- util
- basic
- stdlib
Correct answer: lists
The `lists` module in Picat supplies standard list predicates including append/3, member/2, and related utilities.
Which operator is used in Picat to unify two terms?