← 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 the difference between `=` and `is` for the expression `X = 2 + 3`?

    Answer: = unifies X with the unevaluated term 2+3; is evaluates it and binds X to 5

    = performs structural unification, so X = 2+3 binds X to the compound term +(2,3), while X is 2+3 evaluates and binds X to 5.

  2. When Picat's unification encounters `f(X,X) = f(1,2)`, what is the result?

    Answer: Unification fails because X cannot be both 1 and 2

    Since X appears twice in the pattern, both arguments must unify to the same value; 1 ≠ 2, so unification fails.

  3. In Picat logic programming, what does 'resolution' refer to?

    Answer: The inference step that matches a goal with a clause head and produces new subgoals

    Resolution is the core inference step: a goal is matched against a clause head via unification, and the body of that clause becomes new subgoals.

  4. Which of the following correctly defines a Picat logic predicate for list membership?

    Answer: member(X,[X|_]). member(X,[_|T]) :- member(X,T).

    The two-clause recursive definition with a base case (head match) and recursive case (check tail) is the standard logic programming idiom for membership.

  5. In Picat, what does the `\=` operator test?

    Answer: That two terms cannot be unified (unification would fail)

    X \= Y succeeds if X and Y cannot be unified; it is equivalent to \+(X = Y) and does not bind variables.

  6. What is the 'depth-first search' strategy in Picat's logic programming execution model?

    Answer: Picat fully explores one clause branch before trying alternatives

    Picat (like Prolog) uses depth-first search: it commits to the first matching clause and explores it fully before backtracking to try alternatives.

  7. In Picat, which combination of goals demonstrates disjunction in a logic predicate body?

    Answer: goal1 ; goal2

    The semicolon (;) is the disjunction operator in Picat logic predicates, succeeding if either goal1 or goal2 succeeds.