โ† All Picat Flashcard Decks

Tabling for Memoization 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 Tabling for Memoization flashcards as text
  1. What is the difference between Picat's `table` and a hand-written assert/retract memoization pattern in Prolog?

    Answer: `table` is declarative and automatically managed, while assert/retract requires manual cache management.

    Picat's `table` directive automates cache storage and retrieval, eliminating error-prone manual assert/retract coding.

  2. In Picat, if you declare `table fib(+,-)` and call `fib(10, X)`, what is stored in the table?

    Answer: The pair (10, X_value) mapping input 10 to the computed output.

    The table stores the input argument(s) mapped to their corresponding output value(s).

  3. When tabling is used with a non-deterministic predicate in Picat, what does the table store?

    Answer: All answer tuples produced by the predicate for the given input.

    Picat's tabling system stores the complete set of answers for non-deterministic predicates, supporting full tabled search.

  4. Which of the following best describes a 'table entry' in Picat's tabling mechanism?

    Answer: A record associating a call pattern (input) with its set of computed answers.

    Each table entry pairs a call pattern with the answers accumulated for that pattern.

  5. What happens in Picat if you call a tabled predicate with an uninstantiated input argument declared as `+`?

    Answer: An instantiation error is raised because `+` requires a bound argument.

    Mode `+` requires the argument to be bound at call time; calling with an uninstantiated `+` argument causes an instantiation error.

  6. Which statement about memory usage in Picat tabling is accurate?

    Answer: Tabling uses more memory than naive recursion because it stores all computed results.

    The memoization cache consumes memory proportional to the number of distinct call patterns and their answers.

  7. In Picat tabling, what is a 'suspended call'?

    Answer: A recursive call that is waiting for the answer of a subgoal that is already being computed.

    Suspended calls arise in tabled evaluation when a call depends on results from an ancestor call that hasn't completed yet.