← All Picat Flashcard Decks

Logic Programming and Unification Flashcards

7 cards from real Picat practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Logic Programming and Unification flashcards as text
  1. In Picat, what is a 'choice point' in the context of logic programming?

    Answer: A saved execution state that Picat can return to on backtracking

    A choice point is a snapshot of the interpreter state saved when multiple clauses can match, allowing resumption on failure.

  2. How does Picat's cut (`!`) affect choice points in a logic predicate?

    Answer: Removes all choice points created since the parent call, committing to the current clause

    Cut removes all choice points for the predicate that contains it, preventing backtracking into alternative clauses.

  3. In Picat unification, which of the following is a valid unification of a list?

    Answer: [H|T] = [1,2,3] → H=1, T=[2,3]

    List unification [H|T] = [1,2,3] binds the head H to 1 and the tail T to the remaining list [2,3].

  4. What does `findall(X, member(X,[1,2,3]), Bag)` return in Picat?

    Answer: Bag = [1,2,3]

    findall/3 collects all X that satisfy the goal into Bag, so Bag = [1,2,3].

  5. In Picat, what distinguishes `bagof/3` from `findall/3`?

    Answer: bagof groups results by unbound variables and fails if there are no solutions; findall never fails

    bagof/3 fails when the goal has no solutions and can group answers by free variables, unlike findall/3 which always succeeds with [] on no solutions.

  6. What is the meaning of a 'ground' term in Picat logic programming?

    Answer: A term that contains no unbound variables

    A ground term has no free (uninstantiated) variables — every part of the term is fully bound.

  7. Which Picat predicate tests whether a term is currently an unbound variable?

    Answer: var(X)

    var(X) succeeds if X is currently an uninstantiated (unbound) variable at the time of the call.