PiCAT (Pre-screening Internet-delivered Computerized Adaptive Test) — Questions and Answers
Question 1: What is the correct way to break out of a `foreach` loop early in Picat?
- Use the `break` keyword inside the loop
- Call `halt`
- Use a boolean flag variable with a while loop instead (Correct answer)
- Throw and catch an exception
Correct answer: Use a boolean flag variable with a while loop instead
Picat's foreach does not support break; the idiomatic workaround is to use a while loop with a flag or a recursive helper.
Question 2: Which flag setting causes Picat to throw an error when an undefined predicate is called?
- undefined_pred = true
- strict_mode = on
- unknown = error (Correct answer)
- error_on_undefined = true
Correct answer: unknown = error
Setting the `unknown` flag to `error` causes Picat to throw `existence_error` for undefined predicate calls.
Question 3: Which system does the catalytic converter belong to?
- Standard transmission
- Frequency
- Emission control system (Correct answer)
- Chemical
Correct answer: Emission control system
A catalytic converter is a crucial component in a vehicle's exhaust system, designed to reduce harmful pollutants from engine emissions. It converts toxic gases and pollutants into less harmful substances, making it an integral part of the overall emission control system.
Question 4: How do you convert the string "42" to the integer 42 in Picat?
- string_to_int("42")
- parse_int("42")
- to_integer("42") (Correct answer)
- integer("42")
Correct answer: to_integer("42")
`to_integer/1` is Picat's built-in for converting strings and other terms to integer values.
Question 5: After importing the `cp` module, what is the role of the `indomain/1` predicate?
- It checks if a specific value is within the initial domain of a variable.
- It constrains a variable to have a domain that is a subset of another variable's domain.
- It is a search strategy option used within the `solve/2` predicate.
- It is a non-deterministic predicate that, upon backtracking, assigns the next value from a variable's domain to that variable. (Correct answer)
Correct answer: It is a non-deterministic predicate that, upon backtracking, assigns the next value from a variable's domain to that variable.
The `indomain(Var)` predicate is a built-in search primitive. When called, it instantiates `Var` to a value from its domain. It is non-deterministic, meaning that if execution backtracks to this point, it will fail the previous assignment and try the next value in the domain until all values have been exhausted. It is a fundamental building block for custom search strategies.
Question 6: Which type of chemical bond involves the sharing of electrons between atoms?
- Covalent bond (Correct answer)
- Hydrogen bond
- Metallic bond
- Ionic bond
Correct answer: Covalent bond
Covalent bonds form when two atoms share one or more pairs of electrons.
Question 7: The word METICULOUS most nearly means:
- careless
- stubborn
- generous
- precise (Correct answer)
Correct answer: precise
Meticulous means showing great attention to detail; very careful and precise.
Question 8: How do you insert key K with value V into Picat map M?
- M[K] = V
- insert(M, K, V)
- put(M, K, V) (Correct answer)
- map_put(M, K, V)
Correct answer: put(M, K, V)
`put(M, K, V)` inserts or updates the key-value pair in the map, which is a mutable operation in Picat.
Question 9: How do you write formatted output to a specific file stream in Picat?
- fprint(Stream, Format)
- write_format(Stream, Format, Args)
- format(Stream, Format, Args) (Correct answer)
- fprintf(Stream, Format, Args)
Correct answer: format(Stream, Format, Args)
`format(Stream, Format, Args)` writes formatted output directed to the specified stream.
Question 10: Which Picat directive marks a predicate so that its results are automatically cached?
- table (Correct answer)
- persist
- memo
- cache
Correct answer: table
The `table` directive placed before a predicate definition enables automatic memoization in Picat.
Question 11: Honorable most nearly
- Discriminate
- Trust
- Condemn
- Revere (Correct answer)
Correct answer: Revere
To be 'honorable' means to be worthy of honor, respect, or admiration. The verb 'revere' means to feel deep respect or admiration for something or someone. Therefore, 'revere' is the closest action associated with someone or something honorable, as it implies holding them in high esteem.
Question 12: What does `var(X)` return immediately before X is bound to any value?
- true (Correct answer)
- Error — X must be bound first
- 'unbound'
- false
Correct answer: true
`var/1` succeeds (returns true) when its argument is an unbound logic variable.
Question 13: The term for the spiral groove that encircles a screw's shaft is the...
- Finishing Nail
- Power Train Warranty
- Masonry Nail
- Thread (Correct answer)
Correct answer: Thread
The spiral groove that wraps around the shaft of a screw is specifically called the 'thread.' This thread engages with a mating surface (like a nut or a pre-drilled hole) to provide fastening and holding power.
Question 14: Which of the following tools guards against current overloads in A circuit?
- Saw
- Knot
- Fuse (Correct answer)
- 3- Wire Cords And Plugs
Correct answer: Fuse
A fuse is a safety device designed to protect an electrical circuit from excessive current. It contains a metal wire or strip that melts and breaks the circuit if the current exceeds a safe level, thereby preventing damage to equipment and reducing the risk of fire.
Question 15: Which predicate forces buffered output to be written to a stream immediately in Picat?
- force_write(Stream)
- flush_output(Stream) (Correct answer)
- sync(Stream)
- flush_buffer()
Correct answer: flush_output(Stream)
`flush_output(Stream)` forces any buffered output to be physically written to the stream.
Question 16: Which Picat `lists` module predicate checks if an element is a member of a list?
- member/2 (Correct answer)
- elem/2
- in/2
- contains/2
Correct answer: member/2
`member/2` is the standard predicate to test whether an element belongs to a list.
Question 17: What does `listing(Predicate)` display in Picat's interactive session?
- The source clauses of the named predicate (Correct answer)
- The call graph of the predicate
- All files in the working directory
- All currently defined predicates
Correct answer: The source clauses of the named predicate
`listing(Predicate)` prints all source clauses for the specified predicate to standard output.
Question 18: Which of the following is a valid way to create a user-defined exception in Picat?
- user_error(Message) predicate call
- throw(error(my_error(Details), context)) only
- throw(user_error(Message)) only
- Both throw(user_error(Message)) and throw(error(my_error(Details), context)) are valid (Correct answer)
Correct answer: Both throw(user_error(Message)) and throw(error(my_error(Details), context)) are valid
Any Picat term can be thrown as an exception; both a plain term and the standard `error/2` wrapper are valid.
Question 19: What does `string_codes("ab", Cs)` bind Cs to in Picat?
- "ab"
- Error: use string_chars instead
- [a, b]
- [97, 98] (Correct answer)
Correct answer: [97, 98]
`string_codes/2` converts a string to a list of Unicode code points; 97 = 'a' and 98 = 'b'.
Question 20: Silicon chips are mostly utilized in
- suspension
- carbon atoms
- amplifier
- integrated circuits (Correct answer)
Correct answer: integrated circuits
Silicon chips are the fundamental building blocks of modern electronics. They are primarily utilized in integrated circuits (ICs), which are miniature electronic circuits fabricated on a single piece of semiconductor material, typically silicon. These ICs form the core components of computers, smartphones, and countless other electronic devices.
Question 21: Which predicate tests if X is a Picat string (double-quoted value)?
- atom(X)
- chars(X)
- is_str(X)
- string(X) (Correct answer)
Correct answer: string(X)
`string(X)` succeeds when X is a Picat string literal (double-quoted), distinguishing it from atoms.
Question 22: What does `round(3.7)` return in Picat?
- 4 (Correct answer)
- Error: round is not a Picat built-in
- 3
- 3.7
Correct answer: 4
`round/1` rounds to the nearest integer; 3.7 rounds up to 4.
Question 23: Which error type is thrown when a predicate requires an instantiated argument but receives a variable?
- instantiation_error (Correct answer)
- unbound_error
- binding_error
- variable_error
Correct answer: instantiation_error
`instantiation_error` is thrown when a predicate receives an insufficiently instantiated (unbound) argument.
Question 24: Which of the following imperative constructs in Picat is used to mark the end of a block for loops (`while`, `foreach`) and conditionals (`if-then-else`)?
- stop
- end (Correct answer)
- done
- fi
Correct answer: end
In Picat, the `end` keyword is consistently used to terminate imperative blocks, including `foreach` loops, `while` loops, and `if-then-else` statements. This provides a clear and uniform syntax for defining the scope of these constructs.
Question 25: An illustration of this would be a pot on a hot stove.
- Insulation
- Radiation
- Convection
- Conduction (Correct answer)
Correct answer: Conduction
Conduction is the transfer of heat energy through direct physical contact between substances. When a pot is placed on a hot stove, heat from the stove burner is directly transferred to the bottom of the pot through conduction. This direct contact allows thermal energy to pass from the hotter stove element to the cooler pot, causing the pot to heat up.
Question 26: Which equipment could be utilized when it's necessary to turn on an electrical current remotely?
- chemical (Correct answer)
- fuse
- a flower
- amplifier
Correct answer: chemical
This question is unconventional, as 'chemical' is not standard equipment for remotely turning on an electrical current. However, in highly specialized contexts, a chemical reaction could be used to activate a battery or trigger a switch remotely. For instance, a chemically-activated battery could power a remote control device, or a pyrotechnic switch could be initiated by a chemical reaction to close a circuit.
Question 27: What will be the result of the following Picat query? `go => X = 1, Y = X, $f(X, 2) = $f(1, Y), println(X), println(Y).`
- The query will fail because Y is not instantiated in the unification.
- It will print 1 and then a variable.
- The query will fail because X cannot be unified with 1.
- It will print 1 and then 1. (Correct answer)
Correct answer: It will print 1 and then 1.
The query first binds X to 1. Then Y is unified with X, so Y is also 1. The unification `$f(X, 2) = $f(1, Y)` succeeds because at this point, it is equivalent to `$f(1, 2) = $f(1, 1)`, which successfully unifies Y to be 2, but since X is already bound to 1 and Y is bound to X, Y becomes 1. The unification `$f(1,2) = $f(1,1)` will succeed, and the final values of X and Y will both be 1. The `println` calls will therefore print 1 and 1.
Question 28: What is the fundamental difference between the standard Picat unification operator `=` and the CP constraint equality operator `#=` within a `cp` model?
- The `#=` operator is used for destructive assignment, similar to `:=`, while `=` is for logical unification.
- There is no difference; they are interchangeable within a `cp` model.
- The `=` operator immediately attempts to bind a variable, whereas `#=` posts a constraint that must be satisfied in the final solution. (Correct answer)
- The `#=` operator works only with integers, while `=` works with any data type.
Correct answer: The `=` operator immediately attempts to bind a variable, whereas `#=` posts a constraint that must be satisfied in the final solution.
The standard unification operator `=` tries to make two terms identical immediately. If a variable is free, it will be bound. The CP constraint operator `#=`, however, does not perform immediate binding. Instead, it adds a constraint to the solver stating that the expressions on both sides must be equal in any valid solution found by `solve`.
Question 29: What is the occurs check, and does Picat's default unification perform it?
- Checks if a variable occurs in a term before binding; yes, always
- Prevents binding X to a term containing X to avoid circular structures; no, not by default (Correct answer)
- Verifies that all variables are ground; yes, always
- Checks argument count; no, arity is implicit
Correct answer: Prevents binding X to a term containing X to avoid circular structures; no, not by default
The occurs check prevents creating circular (infinite) terms by checking X ∉ T before X=T, but Picat (like most Prolog-family systems) skips it by default for performance.
Question 30: Which of the following Picat goals will succeed?
- f(1) = f(1,2)
- f(1,2) = f(2,1)
- f(X,X) = f(1,2)
- f(X,Y) = f(1,2) (Correct answer)
Correct answer: f(X,Y) = f(1,2)
f(X,Y) = f(1,2) succeeds by binding X=1 and Y=2; the other options fail due to structural or value mismatches.
Question 31: Which of the following is an example of a chemical change rather than a physical change?
- Iron rusting on a fence (Correct answer)
- A piece of paper being torn
- Ice melting into water
- Glass breaking into pieces
Correct answer: Iron rusting on a fence
Rusting is a chemical change because iron reacts with oxygen and water to form iron oxide, a new substance with different properties.
Question 32: Which function retrieves a value from Picat map M using key K?
- M.K
- lookup(M, K)
- get(M, K) (Correct answer)
- fetch(M, K)
Correct answer: get(M, K)
`get(M, K)` is the built-in to retrieve the value associated with key K from map M.
Question 33: What is the atomic number of carbon?
- 12
- 4
- 8
- 6 (Correct answer)
Correct answer: 6
Carbon has 6 protons in its nucleus, giving it an atomic number of 6.
Question 34: Which of the following statements correctly identifies the data type of the Picat term `'hello world'`?
- It is an atom. (Correct answer)
- It is a variable.
- It is a string, which is a list of characters.
- It is a list containing two atoms, `hello` and `world`.
Correct answer: It is an atom.
In Picat, any sequence of characters enclosed in single quotes is treated as a single atom. Strings, which are lists of characters, are enclosed in double quotes. Variables must begin with an uppercase letter or an underscore.
Question 35: What does the `table` declaration `table(+,+,min)` communicate to Picat's tabling system?
- The predicate takes exactly three arguments and uses min-cost search.
- The third argument must be a positive integer.
- The third argument is an optimization objective to be minimized over all answers. (Correct answer)
- Only calls where the third argument is minimal will be tabled.
Correct answer: The third argument is an optimization objective to be minimized over all answers.
Mode `min` instructs the tabling system to keep only the answer with the smallest value for that argument, enabling optimal substructure computations.
Question 36: Plain signifies serene or tranquil.
- Revoke (Correct answer)
- Confirm
- Send again
- Deny
Correct answer: Revoke
The statement 'Plain signifies serene or tranquil' is incorrect, as 'plain' typically means simple, unadorned, or clear, not serene or tranquil. Given the options, 'Revoke' is the action one would take to retract or cancel an incorrect statement or claim. It implies taking back the assertion that 'plain' means serene or tranquil.
Question 37: There's always the crunch at the beginning. Crunch comes before flavor and even the tang of acidity when you bite into a red or green apple, a red one stained with yellow, a yellow one blushing pink, round or oblong, baseball size or softball size. There had to be, at the very least. <br> <br> The passage suggests that the author believes that the most crucial quality of a good apple is its
- Viscosity
- Crispness (Correct answer)
- Masonry Nail
- Governonrs
Correct answer: Crispness
The passage repeatedly emphasizes the 'crunch' of an apple, stating that 'Crunch comes before flavor and even the tang of acidity.' This highlights the author's belief that the texture, specifically the crispness, is the primary and most important characteristic of a good apple, even more so than its taste.
Question 38: A programmer is writing a Picat function to calculate Fibonacci numbers, which is notoriously inefficient due to repeated calculations of the same subproblems. Which Picat directive should be used to automatically memoize the results of the function calls and significantly improve performance?
- table (Correct answer)
- cache
- memoize
- store
Correct answer: table
In Picat, the `table` directive is used to enable tabling, which is a form of memoization. When a predicate or function is declared with `table`, Picat stores the results of its calls and reuses them for subsequent identical calls, avoiding redundant computation. This is especially effective for functions like Fibonacci where the same subproblems are computed multiple times.
Question 39: How do you measure the execution time of a goal in Picat?
- benchmark(Goal)
- measure(Goal, Time)
- timer(Goal)
- time(Goal) (Correct answer)
Correct answer: time(Goal)
`time(Goal)` executes Goal and prints the elapsed wall-clock time and inference count.
Question 40: Mundane most closely resembles
- Extraordinary
- Unique
- Tired
- Ordinary (Correct answer)
Correct answer: Ordinary
The word 'mundane' means lacking interest or excitement; dull. Therefore, 'ordinary' is the closest synonym, describing something common, usual, or unexceptional. Options like 'unique' or 'extraordinary' are antonyms.
Question 41: She had a *relentlessly* positive attitude.
- Quiet
- Humble
- Tireless (Correct answer)
- Enormous
Correct answer: Tireless
'Relentlessly' means in an unceasingly intense or harsh way. When applied to a positive attitude, it suggests an attitude that never gives up or diminishes. 'Tireless' perfectly captures this meaning, implying an attitude that persists without becoming weary or exhausted.
Question 42: Which function in the Picat `string` module converts a string to uppercase?
- upcase_atom/1
- to_upper/1 (Correct answer)
- upper/1
- string_upper/1
Correct answer: to_upper/1
`to_upper/1` from the `string` module returns the uppercase version of a string.
Question 43: Watts serve as a measuring unit for
- Power (Correct answer)
- Speed
- Energy
- Pressure
Correct answer: Power
Watts (W) are the standard unit of power in the International System of Units (SI). Power is defined as the rate at which work is done or energy is transferred. One watt is equivalent to one joule per second (J/s), indicating the amount of energy consumed or produced per unit of time.
Question 44: The word PRUDENT most nearly means:
- proud
- lazy
- wise (Correct answer)
- rash
Correct answer: wise
Prudent means acting with or showing care and thought for the future; sensible.
Question 45: How do you import the `io` module in a Picat program?
- import io.
- :- import io. (Correct answer)
- module(io).
- :- use_module(io).
Correct answer: :- import io.
Picat uses the `:- import module_name.` directive to import a module.
Question 46: What does `compound(hello)` evaluate to in Picat?
- true
- Depends on how hello is declared
- false (Correct answer)
- Error
Correct answer: false
`compound/1` fails for atoms like `hello` — a compound term must have a functor and at least one argument.
Question 47: What does `arg(1, point(3, 4), X)` bind X to in Picat?
- Error: arg uses 0-based indexing
- 3 (Correct answer)
- point
- 4
Correct answer: 3
`arg/3` is 1-indexed in Picat: arg 1 of `point(3,4)` is `3`, the first argument.
Question 48: Why does Picat distinguish between pattern matching in rule heads and explicit unification (`=`), a feature that makes it different from traditional Prolog?
- To improve performance and scalability by facilitating better indexing of rules, as pattern matching is simpler than full unification. (Correct answer)
- To eliminate the need for the occurs check, which is computationally expensive.
- To enforce a functional programming style where rule heads cannot modify arguments.
- To allow for overloading of the `=` operator for different data types.
Correct answer: To improve performance and scalability by facilitating better indexing of rules, as pattern matching is simpler than full unification.
Picat uses pattern matching in rule heads instead of full unification primarily for scalability and performance. This one-sided check allows the system to more effectively index clauses, leading to faster predicate dispatch, especially in programs with many rules. It also contributes to making Picat code more reliable and often easier to reason about.
Question 49: What is the correct syntax to access element at index 2 of array A in Picat?
- get_array(A, 2)
- nth(2, A)
- A[2] (Correct answer)
- A.(2)
Correct answer: A[2]
Picat arrays use bracket notation `A[I]` for indexed access, with indexing starting at 1.
Question 50: In Picat tabling, what happens when a tabled predicate is called with arguments it has already been called with?
- The stored result is returned without re-executing the predicate body. (Correct answer)
- The predicate body is re-executed to verify consistency.
- An exception is raised to prevent duplicate calls.
- The call is silently ignored and fails.
Correct answer: The stored result is returned without re-executing the predicate body.
Tabling returns the cached result immediately, skipping redundant recomputation.
Question 51: What does `integer(3.0)` evaluate to in Picat?
- Error
- 3
- false (Correct answer)
- true
Correct answer: false
`integer/1` checks the type precisely; 3.0 is a float even though its value is whole, so it returns false.
Question 52: Which of the following statements correctly describes unification in Picat?
- Unification always succeeds, and if terms cannot be made equal, it throws an exception.
- The unification operator `=` is only used for arithmetic equality, not for structures or lists.
- Picat does not support explicit unification, relying solely on pattern matching in rule heads.
- Unification is the process of finding a substitution of variables that makes two terms identical, and it can fail if no such substitution exists. (Correct answer)
Correct answer: Unification is the process of finding a substitution of variables that makes two terms identical, and it can fail if no such substitution exists.
Unification is a core concept in logic programming. It is the process by which variables are instantiated to values or other variables to make two terms structurally identical. If the terms cannot be made identical (e.g., unifying `a` with `b`, or `f(X)` with `g(X)`), the unification goal fails.
Question 53: Which predicate extracts the functor name and arity from a compound term?
- term_info(T, F, A)
- decompose(T, F, A)
- functor(T, F, A) (Correct answer)
- struct(T, F, A)
Correct answer: functor(T, F, A)
`functor(T, F, A)` binds F to the principal functor of T and A to its arity.
Question 54: In Picat CP, what is reification of a constraint?
- Transforming a global constraint into primitive ones
- Converting a constraint to a boolean variable that is 1 iff the constraint holds (Correct answer)
- Removing redundant constraints from the store
- Propagating a constraint across all variables simultaneously
Correct answer: Converting a constraint to a boolean variable that is 1 iff the constraint holds
Reification links a boolean (0/1) CP variable to a constraint so the variable equals 1 exactly when the constraint is satisfied.
Question 55: The word BENEVOLENT most nearly means:
- hostile
- strict
- kind (Correct answer)
- jealous
Correct answer: kind
Benevolent means well-meaning and kindly disposed toward others.
Question 56: Which labeling option in Picat's CP `solve` tells the solver to choose the variable with the smallest remaining domain first?
- [min]
- [ffc]
- [ff] (Correct answer)
- [leftmost]
Correct answer: [ff]
`ff` (fail-first) selects the variable with the fewest remaining domain values, reducing early branching failures.
Question 57: A developer needs to store student IDs (integers) as keys and their corresponding grades (strings) as values, with frequent lookups. Which Picat code snippet correctly creates a map, adds a student's grade, and retrieves it?
- M = [101:"A"], Grade = M[101]
- import util. M = new_map(), M.put(101, "A"), Grade = M.get(101) (Correct answer)
- M = student(101, "A"), Grade = M.2
- M = new_map(), M[101] := "A", Grade = M[101]
Correct answer: import util. M = new_map(), M.put(101, "A"), Grade = M.get(101)
Picat's `util` module provides the `new_map/0` function to create a hash map. The map's methods, such as `put/3` and `get/2`, are used to add and retrieve key-value pairs. The other options use syntax for lists, structures, or incorrect assignment operators not applicable to maps.
Question 58: Which operator concatenates two strings or lists in Picat?
- append(S1, S2)
- join(S1, S2)
- S1 ++ S2 (Correct answer)
- concat(S1, S2)
Correct answer: S1 ++ S2
In Picat, the `++` operator concatenates two strings or lists.
Question 59: Can a Picat function be embedded directly inside an arithmetic expression such as `Y = f(X) + 3`?
- Only if `f` is declared as `arithmetic`
- Yes, because functions return values usable in expressions (Correct answer)
- No, functions must be called with `call/1`
- Only inside `once/1` wrappers
Correct answer: Yes, because functions return values usable in expressions
Picat functions return values and can appear anywhere an expression is expected.
Question 60: Which of the following lines of code correctly declares a list of three Picat variables `X`, `Y`, and `Z` as constraint variables, each with a domain of integers from 1 to 10, for use with the `cp` module?
- `domain([X, Y, Z], 1, 10)`
- `foreach(V in [X,Y,Z]) V in 1..10 end`
- `[X, Y, Z] :: 1..10` (Correct answer)
- `[X, Y, Z] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}`
Correct answer: `[X, Y, Z] :: 1..10`
In Picat's `cp` module, the `::` operator is used to associate a domain with one or more constraint variables. The syntax `Variables :: Domain` correctly assigns the specified integer range to each variable in the list.
Question 61: A Picat script needs to be executed from the command line with several arguments. How can the script access these arguments?
- By calling `os:get_cmd_args()`
- By reading from the `io:stdin` stream
- By calling `sys:get_args()` (Correct answer)
- By accessing the built-in `ARGS` list
Correct answer: By calling `sys:get_args()`
The `sys` module provides interaction with the Picat system environment. The `sys:get_args()` function returns a list of strings, where each string is a command-line argument passed to the script. [21, 24]
Question 62: In Picat CP, what is the correct way to post a constraint that X is strictly less than Y?
- less(X, Y)
- X @< Y
- X #< Y (Correct answer)
- X < Y
Correct answer: X #< Y
Arithmetic constraints on CP variables use the `#` prefix operators such as `#<`, `#>`, `#=`, and `#\=`.
Question 63: The word VIGILANT most nearly means:
- courageous
- watchful (Correct answer)
- sleepy
- reckless
Correct answer: watchful
Vigilant means keeping careful watch for possible danger or difficulties.
Question 64: In `plan/4`, what does the second argument (Limit) represent?
- The maximum number of clauses to try
- The timeout in milliseconds
- An upper bound on the total resource cost (Correct answer)
- The depth of the search tree
Correct answer: An upper bound on the total resource cost
`plan(State, Limit, Plan, Cost)` uses Limit as an upper bound on the accumulated action costs, not raw depth.
Question 65: When is it more appropriate to use a predicate instead of a function in Picat?
- When you need to perform a simple, deterministic calculation that returns a single value.
- When the primary purpose is to check if a certain condition is true or false without returning a specific value. (Correct answer)
- When you want to guarantee that the operation will never fail and always produce a result.
- When you want to embed the call directly into a mathematical formula for conciseness.
Correct answer: When the primary purpose is to check if a certain condition is true or false without returning a specific value.
Predicates are ideal for relational logic, where the outcome is success or failure. If the goal is simply to verify a condition (e.g., checking for membership in a list, `member/2`), a predicate is the natural choice. It succeeds if the condition holds and fails otherwise. While a function could be forced to return a boolean, a predicate more directly expresses this logic.
Question 66: Which built-in converts a number to its string representation in Picat?
- int_to_str(N)
- number_to_atom(N)
- to_string(N) (Correct answer)
- char_code(N)
Correct answer: to_string(N)
`to_string(N)` converts a number (or any term) to its string representation in Picat.
Question 67: Which Picat expression generates the list [1, 4, 9, 16, 25]?
- squares(5)
- [X*X : X in 1..5] (Correct answer)
- [X^2 | X <- [1,2,3,4,5]]
- map(X*X, 1..5)
Correct answer: [X*X : X in 1..5]
In Picat, [X*X : X in 1..5] uses a range generator to iterate X from 1 to 5 inclusive and computes X*X for each value, yielding [1,4,9,16,25].
Question 68: A developer is solving a crypto-arithmetic puzzle like `SEND + MORE = MONEY` in Picat. Which global constraint from the `cp` module is essential to ensure that each letter is assigned a unique digit?
- `global_cardinality/2`
- `element/3`
- `sum/1`
- `alldifferent/1` (Correct answer)
Correct answer: `alldifferent/1`
The core rule of crypto-arithmetic puzzles is that each letter must represent a different digit. The `alldifferent(List)` global constraint in the `cp` module enforces exactly this, ensuring that all variables in the given list are assigned distinct values from their respective domains.
Question 69: Which of the following is a valid way to call a Picat predicate `greet(Name)`?
- print(greet("Alice"))
- X = greet("Alice")
- greet("Alice") (Correct answer)
- Z is greet("Alice")
Correct answer: greet("Alice")
Predicates are called as statements; they do not return values and cannot appear inside expressions.
Question 70: What is the arity of the Picat term `foo(a)`?
- 0
- foo
- 1 (Correct answer)
- 2
Correct answer: 1
Arity is the number of arguments a compound term takes; `foo(a)` has exactly one argument, so its arity is 1.
Question 71: When defining a planning problem, what is the primary purpose of the optional `heuristic(State) = H` function?
- To define an alternative, more efficient cost for actions.
- To guide the search by providing an estimated cost from the current `State` to a final state, which is used to prune search paths. (Correct answer)
- To store and retrieve memoized results for frequently encountered states.
- To replace the `final/1` predicate with a more complex goal condition.
Correct answer: To guide the search by providing an estimated cost from the current `State` to a final state, which is used to prune search paths.
The `heuristic(State) = H` function is used by the planner's resource-bounded search algorithms. It provides an admissible estimate `H` of the cost to reach a goal from the given `State`. This estimate is compared with the current available resources; if the estimated cost is greater than the available resources, the search down that path is pruned, making the search more efficient.
Question 72: Which format specifier prints an integer inside Picat's `format` predicate?
- ~d (Correct answer)
- %d
- {d}
- %i
Correct answer: ~d
Picat's `format` predicate uses `~d` to print an integer argument.
Question 73: The programs' *permanent* underfunding
- Temporary
- Habitual (Correct answer)
- Massive
- Severe
Correct answer: Habitual
The word 'permanent' implies something lasting or intended to last indefinitely. In the context of 'underfunding,' 'habitual' is the closest synonym among the choices, suggesting that the underfunding is a regular, persistent, and long-standing practice rather than a temporary issue. It describes a recurring pattern.
Question 74: A developer is using tabling to optimize a function but notices that values from previous, unrelated runs of the program seem to be affecting the current results. What is the most likely cause and solution?
- The `table` directive is misspelled; it should be `memoize`.
- The table area was not cleared from a previous run; call `initialize_table` at the start of the program. (Correct answer)
- A destructive assignment operator (`:=`) is being used inside the tabled function, which is not allowed.
- The function is non-deterministic, and tabling only works on deterministic functions.
Correct answer: The table area was not cleared from a previous run; call `initialize_table` at the start of the program.
The table area in Picat persists during a session. If the program is run multiple times within the same Picat interpreter session without clearing the tables, the memoized results from the first run will still be there for subsequent runs. To ensure each program execution starts with a clean slate, the `initialize_table` predicate should be called, typically at the beginning of the `main` predicate, to clear all stored answers.
Question 75: In Picat, what is the fundamental difference between pattern matching in rule heads and explicit unification using the '=' operator in the rule body?
- Pattern matching in rule heads is a one-sided unification that does not bind variables in the call, whereas '=' performs full unification. (Correct answer)
- Pattern matching can only be used with structures, while explicit unification works with all data types.
- Pattern matching is bidirectional, while explicit unification is unidirectional.
- There is no difference; they are syntactically different but semantically identical.
Correct answer: Pattern matching in rule heads is a one-sided unification that does not bind variables in the call, whereas '=' performs full unification.
Picat's rule selection mechanism uses pattern matching, which is a form of one-sided unification. It checks if the call arguments are an instance of the head's patterns without binding variables in the call itself. Any required bindings must be performed explicitly in the rule's body using the '=' operator, which performs full, bidirectional unification.
Question 76: In the Picat `math` module, what does `gcd(12, 8)` return?
- 4 (Correct answer)
- 8
- 6
- 2
Correct answer: 4
`gcd/2` computes the greatest common divisor, and the GCD of 12 and 8 is 4.
Question 77: What happens when no pattern in a Picat function definition matches the given arguments?
- The program silently succeeds
- The last clause always matches as a fallback
- A runtime exception is thrown (Correct answer)
- The function returns `none`
Correct answer: A runtime exception is thrown
If no clause pattern matches the arguments, Picat throws an existence error or no-clause exception at runtime.
Question 78: Parity almost exactly entails
- Twice
- Separate'
- Equality (Correct answer)
- Difference
Correct answer: Equality
'Parity' refers to the state or condition of being equal, especially regarding status or pay. Thus, 'equality' is the term that most accurately captures its meaning. It signifies a balance or equivalence between different entities.
Question 79: How do you raise an exception in Picat?
- exception(Error)
- throw(Error) (Correct answer)
- error(Error)
- raise(Error)
Correct answer: throw(Error)
`throw(Error)` raises an exception carrying the given error term in Picat.
Question 80: Friendly most of the time
- Friendly (Correct answer)
- Shy
- Stern
- Disgruntled
Correct answer: Friendly
This question asks for a word that describes being 'friendly most of the time.' The most direct and accurate answer is simply 'Friendly,' as it directly matches the core meaning of the phrase. The other options describe different temperaments or states.
Question 81: A developer defines a predicate to verify if the two elements of a pair structure are identical. Which rule head correctly implements this check using only pattern matching?
- check_equal($p(X, Y)) => X = Y.
- check_equal($p(X, Y), X == Y).
- check_equal($p(X, X)) => true. (Correct answer)
- check_equal($p(X, Y)) => X == Y.
Correct answer: check_equal($p(X, X)) => true.
Picat supports non-linear patterns in rule heads. When a variable (in this case, `X`) appears more than once, it constrains the pattern to only match goals where the corresponding terms are identical. This enforces the equality check directly during the matching process without needing any code in the rule body.
Question 82: Which predicate reads a single character from an open stream in Picat?
- input_char(Char)
- read_char(Stream, Char)
- char_read(Char)
- get_char(Stream, Char) (Correct answer)
Correct answer: get_char(Stream, Char)
`get_char(Stream, Char)` reads one character from the stream and unifies Char with the character atom.
Question 83: A developer needs to find the shortest path in an unweighted graph and decides to use tabling. They want Picat to automatically keep only the answer with the minimum path length for any given pair of nodes. Which feature of Picat's tabling system would be most suitable for this scenario?
- A `foreach` loop with a manually managed minimum variable.
- The standard `table` directive.
- Mode-directed tabling. (Correct answer)
- The `planner` module without any special directives.
Correct answer: Mode-directed tabling.
Picat offers 'mode-directed' tabling, which provides more control over what gets stored. By specifying modes like `min` or `max` for output arguments, you can instruct the tabling system to store only the best answer found so far for a given set of input arguments. For a shortest path problem, declaring a mode of `min` for the path length argument will ensure that the table automatically retains the path with the minimum cost.
Question 84: What is the primary algorithmic benefit of tabling in recursive Picat programs?
- It parallelizes recursive calls across CPU cores.
- It prevents stack overflow by limiting recursion depth.
- It automatically optimizes tail recursion into a loop.
- It converts exponential-time recursion into polynomial-time computation by caching subproblem results. (Correct answer)
Correct answer: It converts exponential-time recursion into polynomial-time computation by caching subproblem results.
Tabling eliminates redundant recursive calls, reducing exponential blowups typical in naive recursion.
Question 85: What is the approximate speed of light in a vacuum?
- 30,000 km/s
- 300,000 km/s (Correct answer)
- 186 km/s
- 3,000,000 km/s
Correct answer: 300,000 km/s
Light travels at approximately 300,000 kilometers per second (about 186,000 miles per second) in a vacuum.
Question 86: Which of the following statements about Picat functions is FALSE?
- A function is considered a special kind of predicate.
- A function call can be used directly within an arithmetic expression.
- If a function call does not match any of its defining rules, it will raise an exception.
- A function can be defined with backtrackable rules (`?=>`) to provide multiple return values. (Correct answer)
Correct answer: A function can be defined with backtrackable rules (`?=>`) to provide multiple return values.
Functions in Picat are deterministic and must return exactly one value. They cannot be defined with backtrackable rules (`?=>`), as this operator is specifically for non-deterministic predicates that can yield multiple solutions through backtracking. Functions always succeed once or raise an exception if no rule matches.
Question 87: When two forces act against each other on an item, the resulting force is
- the sum of the two forces
- the product of the two forces
- the difference between the two forces (Correct answer)
- the ratio of the two forces
Correct answer: the difference between the two forces
When two forces act on an object in opposite directions, they counteract each other. The resulting or net force is calculated by finding the difference between the magnitudes of the two forces. The object will then accelerate in the direction of the larger force, or remain in equilibrium if the forces are equal.
Question 88: How do you access the Nth element of a string in Picat?
- char_at(S, N)
- get_char(S, N)
- nth(N, S)
- S[N] (Correct answer)
Correct answer: S[N]
Picat supports array-style indexing with `S[N]` to retrieve the Nth element of a string or list.
Question 89: The resultant of distance and force is
- Velocity
- Power
- Momentum
- Work (Correct answer)
Correct answer: Work
In physics, Work is defined as the product of force and the distance over which that force is applied in the direction of the displacement. It represents the energy transferred to or from an object by means of a force. Therefore, when force causes an object to move a certain distance, work is done.
Question 90: What is the output of the following Picat code snippet? main => Counter = 4, Result = 1, while (Counter > 1) Result := Result * Counter, Counter := Counter - 1 end, println(Result).
- 1
- 0
- 10
- 24 (Correct answer)
Correct answer: 24
The `while` loop initializes `Result` to 1 and `Counter` to 4. The loop continues as long as `Counter` is greater than 1. The loop executes for `Counter` values of 4, 3, and 2. The `Result` is updated as follows: `1 * 4 = 4`, then `4 * 3 = 12`, then `12 * 2 = 24`. When `Counter` becomes 1, the loop condition is false and it terminates, printing the final value of `Result`.
Question 91: A vector can be used to represent force. A vector is indicative of
- Speed
- Magnitude and Direction (Correct answer)
- Direction
- Magnitude
Correct answer: Magnitude and Direction
A vector is a mathematical quantity that possesses both magnitude (size or amount) and direction. Force is a classic example of a vector because it not only has a specific strength (e.g., 50 Newtons) but also acts in a particular direction (e.g., pushing upwards or pulling to the left). Representing force as a vector allows for accurate calculation of its effects.
Question 92: Newton's Third Law of Motion states that for every action there is:
- No reaction in a vacuum
- A greater reaction in the opposite direction
- An equal and opposite reaction (Correct answer)
- A proportional reaction in the same direction
Correct answer: An equal and opposite reaction
Newton's Third Law states that forces always come in equal and opposite pairs — if A pushes B, B pushes back on A with the same magnitude.
Question 93: The word ABRUPT most nearly means:
- gradual
- sudden (Correct answer)
- lengthy
- smooth
Correct answer: sudden
Abrupt means sudden and unexpected, or brief to the point of rudeness.
Question 94: In Picat, what is the result of executing `X := 5, X := X + 1`?
- X becomes 5+1 as an unevaluated term
- A runtime error is thrown because X is already bound
- X is bound to 5 permanently via unification
- X becomes 6 (Correct answer)
Correct answer: X becomes 6
The := operator allows reassignment, so X is first set to 5 and then updated to 6.
Question 95: The word CONCISE most nearly means:
- confusing
- outdated
- brief (Correct answer)
- wordy
Correct answer: brief
Concise means giving a lot of information clearly and in few words; brief but comprehensive.
Question 96: A programmer is building a scheduling model where two tasks, Task A and Task B, cannot overlap. Task A starts at time `S1` and has duration `D1`. Task B starts at `S2` and has duration `D2`. Which of the following constraints correctly models that Task A must finish before Task B starts OR Task B must finish before Task A starts?
- `S1 + D1 #!= S2`
- `alldifferent([S1, D1, S2, D2])`
- `S1 + D1 #< S2 + D2`
- `S1 + D1 #=< S2 #/ S2 + D2 #=< S1` (Correct answer)
Correct answer: `S1 + D1 #=< S2 #/ S2 + D2 #=< S1`
This is a classic disjunctive scheduling constraint. The condition `S1 + D1 #=< S2` means Task A finishes at or before Task B begins. The condition `S2 + D2 #=< S1` means Task B finishes at or before Task A begins. The disjunction operator `#\/` ensures that at least one of these two conditions must hold true in the final solution, preventing any overlap.
Question 97: A developer writes the following code, intending to set a variable `Status` based on a `Score`. What is the final value of `Status`? main => Score = 85, Status = '', if (Score >= 90) then Status := high elseif (Score >= 70) then Status := medium else Status := low end, println(Status).
- high
- medium (Correct answer)
- low
Correct answer: medium
The code evaluates the `if-elseif-else` conditions sequentially. The first condition, `Score >= 90` (85 >= 90), is false. The program proceeds to the `elseif` condition, `Score >= 70` (85 >= 70), which is true. The code block for this condition is executed, assigning `medium` to `Status`. The `else` block is then skipped, and the program prints the value 'medium'.
Question 98: A developer needs to read the entire content of a text file named `config.txt` into a single string. Which function from the `io` module should be used?
- io:get_file_contents("config.txt")
- io:read_all("config.txt")
- io:read_file_to_string("config.txt") (Correct answer)
- io:read_file("config.txt")
Correct answer: io:read_file_to_string("config.txt")
The `io:read_file_to_string/1` function is specifically designed to open, read the entire contents of a file, and return those contents as a single string, closing the file automatically.
Question 99: How can you write a catch clause that matches any exception regardless of type in Picat?
- catch_all(Goal, Handler)
- try(Goal, Handler)
- catch(Goal, _, Handler) (Correct answer)
- catch(Goal, *, Handler)
Correct answer: catch(Goal, _, Handler)
Using `_` as the error pattern in `catch/3` acts as a wildcard matching any exception term.
Question 100: Of the following, which one is NOT a fruit?
- Peppers
- Tomatoes
- Carrots (Correct answer)
- Corn
Correct answer: Carrots
Botanically, a fruit is defined as the mature ovary of a flowering plant, which typically contains seeds. Tomatoes, corn kernels, and peppers all fit this botanical definition as they develop from the flower's ovary and enclose seeds. Carrots, however, are root vegetables; they are the enlarged taproot of the plant and do not contain seeds, thus they are not fruits.
Question 101: What is the SI unit of electrical resistance?
- Watt
- Ampere
- Volt
- Ohm (Correct answer)
Correct answer: Ohm
The ohm (Ω) measures electrical resistance and is named after physicist Georg Simon Ohm.
Question 102: The word ARDUOUS most nearly means:
- strenuous (Correct answer)
- simple
- colorful
- pleasant
Correct answer: strenuous
Arduous means involving or requiring strenuous effort; difficult and tiring.
Question 103: How do you convert integer N to its atom representation in Picat?
- number_codes(N, Cs)
- atom_number(A, N)
- to_atom(N) (Correct answer)
- int_to_atom(N)
Correct answer: to_atom(N)
`to_atom(N)` converts any Picat term including integers to its atom representation.
Question 104: Which predicate reads a full line from standard input in Picat?
- read_line(L) (Correct answer)
- input_line(L)
- readline(L)
- get_line(L)
Correct answer: read_line(L)
`read_line(L)` reads one line from standard input and unifies it with L.
Question 105: What will be the strain in the card at the designated location when four weights are linked together and suspended from the ceiling?
- 100
- 240 Pounds (Correct answer)
- 968 square feet
- 50%
Correct answer: 240 Pounds
This question implies a calculation of total weight or force. Given the options, '240 Pounds' is the only one that represents a unit of force or weight, which would be relevant to 'strain' in a card supporting suspended weights. It suggests that four items, each weighing 60 pounds, are linked together (4 * 60 = 240 pounds).
Question 106: Any celestial body revolving around a massive body is referred to as
- A satellite (Correct answer)
- Carbon atoms
- Chemical
- Thread
Correct answer: A satellite
A satellite is defined as any object that orbits around a larger celestial body. This can include natural satellites like the Moon orbiting Earth, or artificial satellites launched by humans to orbit Earth or other planets.
Question 107: Which classic dynamic programming problem is most naturally expressed using Picat tabling?
- Binary search
- Bubble sort
- Breadth-first graph traversal
- Fibonacci sequence computation (Correct answer)
Correct answer: Fibonacci sequence computation
Fibonacci has heavily overlapping subproblems that tabling eliminates, making it a textbook tabling example.
Question 108: Which of the following statements about Picat's tabling mechanism is FALSE?
- It requires manual cache invalidation using a special built-in predicate. (Correct answer)
- It is implemented using a technique called linear tabling.
- The `table` keyword is placed immediately before the first rule of the predicate/function to be tabled.
- It can be applied to both predicates and functions.
Correct answer: It requires manual cache invalidation using a special built-in predicate.
Picat's tabling is largely automatic. Once a predicate is declared with `table`, the system manages the storage and retrieval of answers without requiring the programmer to manually invalidate or clear the cache during normal execution. While there is a built-in `initialize_table` to clear all tables, it's for resetting the state, not for manual cache invalidation as part of the core logic. The other statements are true: tabling applies to both predicates and functions, uses a linear tabling mechanism, and is enabled with the `table` keyword before the rules.
Question 109: What does [X : X in [1,2,3,4,5], X mod 2 =:= 0] evaluate to in Picat?
- [1, 3, 5]
- [false, true, false, true, false]
- [1, 2, 3, 4, 5]
- [2, 4] (Correct answer)
Correct answer: [2, 4]
The condition X mod 2 =:= 0 selects only even numbers; from [1,2,3,4,5] only 2 and 4 are even, so the result is [2, 4].
Question 110: What does `copy_term(f(X, X), Copy)` produce in Picat?
- Copy = f(_A, _A) with a single new shared variable (Correct answer)
- Copy = f(_A, _B) where _A and _B are distinct fresh variables
- Copy = f(X, X) (same original variables)
- Error: cannot copy terms with variables
Correct answer: Copy = f(_A, _A) with a single new shared variable
`copy_term/2` creates a renamed copy: both positions of X become the same new variable _A, preserving sharing.
Question 111: What is the standard ISO format for a type error term in Picat?
- error(type_error(Type, Value), _) (Correct answer)
- type_error(Type, Value)
- throw(type(Type))
- {type_error, Type, Value}
Correct answer: error(type_error(Type, Value), _)
ISO standard errors in Picat use `error(type_error(Type, Culprit), Context)` as the thrown term.
Question 112: What does the second argument of `plan/2` return after a successful call?
- The total cost of the plan
- The final goal state
- A list of action terms constituting the plan (Correct answer)
- The number of steps taken
Correct answer: A list of action terms constituting the plan
`plan(State, Plan)` unifies Plan with a list of action terms that lead from State to a final state.
Question 113: In Picat, what does the `?=>` operator signify in a rule head compared to `=>`?
- `?=>` is non-deterministic (allows backtracking); `=>` is deterministic (commits on match) (Correct answer)
- `?=>` is used for predicates only; `=>` is for functions only
- `?=>` requires a guard; `=>` does not
- `?=>` matches only atoms; `=>` matches compound terms
Correct answer: `?=>` is non-deterministic (allows backtracking); `=>` is deterministic (commits on match)
Rules using `?=>` are non-deterministic and allow the system to backtrack and try other clauses, while `=>` commits to the first matching clause.
Question 114: Which Picat construct provides a `do ... while` style loop that tests the condition at the end?
- Picat has no post-condition loop construct (Correct answer)
- loop ... end Cond
- repeat ... until Cond end
- do ... while Cond end
Correct answer: Picat has no post-condition loop construct
Picat does not have a built-in do-while construct; programmers simulate post-condition loops with while or recursion.
Question 115: In a Picat rule, a guard expression appears:
- As the last statement in the rule body
- Inside the rule body after `:-`
- Inside brackets following the predicate name
- After the rule head, preceded by a comma, before the neck operator (Correct answer)
Correct answer: After the rule head, preceded by a comma, before the neck operator
A guard is a condition placed after the pattern head and before the `=>` or `?=>` neck, separated by a comma.
Question 116: A programmer wants to handle lists, with a special case for lists starting with the atom 'a'. What is the result of the query `handle_list([a,b,c], Res)` with the following predicate definitions? ```picat handle_list(L, general) => length(L) > 0. handle_list([a|_], specific_a). handle_list([], empty). ```
- An error due to ambiguity.
- general (Correct answer)
- The query fails.
- specific_a
Correct answer: general
Picat attempts to match predicate rules from top to bottom. The goal `handle_list([a,b,c], Res)` first attempts to match `handle_list(L, general)`. This match succeeds, binding `L` to `[a,b,c]`. The guard `length(L) > 0` is then checked and succeeds. `Res` is bound to `general` and the call succeeds immediately. The second, more specific rule is never tried because a successful match was already found.
Question 117: In addition to the common `final(State)` predicate, the planner module also supports `final(State, Plan, Cost)`. What is the purpose of this alternative predicate?
- It forces the final state to be reached with a specific `Plan` and `Cost`, otherwise the entire search fails.
- It calculates the final cost of the plan by applying a bonus or penalty based on the `State`.
- It is used exclusively for debugging to log the final plan and cost found by the planner.
- It allows defining a condition where a final state can be reached from the current `State` by a known sequence of actions (`Plan`) with a given `Cost`. (Correct answer)
Correct answer: It allows defining a condition where a final state can be reached from the current `State` by a known sequence of actions (`Plan`) with a given `Cost`.
The `final(State, Plan, Cost)` predicate provides a way to specify a condition where a final state is reachable from the current `State` via a pre-determined `Plan` with a specific `Cost`. If the system is not provided with this predicate, it assumes a default definition: `final(S,Plan,Cost) => Plan=[], Cost=0, final(S)`. This is useful for defining sub-goals or macro-actions within a larger planning problem.
Question 118: In Picat pattern matching, what does matching against an integer literal in the head accomplish?
- It matches any numeric value
- It always fails at compile time
- It restricts the rule to fire only when the argument equals that exact integer (Correct answer)
- It converts the argument to an integer
Correct answer: It restricts the rule to fire only when the argument equals that exact integer
A literal in a pattern head acts as an equality constraint, so the rule only fires if the argument unifies with that exact value.
Question 119: Which two components make up the formal binomial nomenclature (or scientific name) of a living organism?
- Class and Family
- Order and Class
- Family and Species
- Genus and Species (Correct answer)
Correct answer: Genus and Species
Binomial nomenclature, the formal system for naming species, consists of two parts. The first part is the genus name, which is always capitalized, and the second part is the specific epithet, or species name, which is never capitalized. Both parts are typically italicized, such as in *Homo sapiens*, providing a unique and universally recognized scientific name for each organism.
Question 120: When a blown fuse stops current flow, what does the circuit become?
- fuse
- reciprocating saw
- open (Correct answer)
- cooper
Correct answer: open
When a fuse blows, its conductive element melts and breaks, creating a gap in the electrical path. This interruption prevents current from flowing through the circuit, effectively making it an 'open' circuit. An open circuit is one where the path for current is incomplete.
Question 121: Which type of energy is stored in a compressed spring?
- Elastic potential energy (Correct answer)
- Kinetic energy
- Chemical energy
- Thermal energy
Correct answer: Elastic potential energy
A compressed or stretched spring stores elastic potential energy, which is released when the spring returns to its natural length.
Question 122: Which word most closely resembles the definition of CURIOUS?
- Serenity
- Infatuation
- Inquisitive (Correct answer)
- Dexterity
Correct answer: Inquisitive
'Curious' means eager to know or learn something. 'Inquisitive' is a direct synonym, describing someone who is eager for knowledge or information, often asking many questions. Both words describe a strong desire to explore and understand.
Question 123: What does the `indomain` predicate do when called on a CP variable during search in Picat?
- It propagates constraints across the variable's domain
- It removes the smallest value from the variable's domain
- It assigns the variable each value in its domain on backtracking (Correct answer)
- It returns the current domain as a list
Correct answer: It assigns the variable each value in its domain on backtracking
`indomain(Var)` non-deterministically instantiates Var to successive values in its domain, supporting backtracking search.
Question 124: What does `atom_length(hello, N)` bind N to in Picat?
- 4
- 6
- 5 (Correct answer)
- Error: use string_length for atoms
Correct answer: 5
`atom_length/2` counts the characters in the atom's name; 'hello' has 5 characters.
Question 125: Starting from which index do Picat arrays begin?
- 0
- 1 (Correct answer)
- Depends on the declaration
- -1
Correct answer: 1
Picat arrays are 1-indexed by default, so the first element is at index 1.
Question 126: Given the Picat list `L = [a, b, c, d]`, which unification will successfully bind the variable `H` to the atom `a` and the variable `T` to the list `[b, c, d]`?
- [H | T] = L (Correct answer)
- H = L[1], T = L[2..4]
- L = H :: T
- [H, T] = L
Correct answer: [H | T] = L
The `[Head | Tail]` syntax is the fundamental pattern for deconstructing a list in Picat. The `|` operator separates the first element (the head) from the rest of the list (the tail). The other options use incorrect syntax or operators for this specific type of list decomposition.
Question 127: Which element is the most abundant in Earth's atmosphere?
- Argon
- Oxygen
- Carbon dioxide
- Nitrogen (Correct answer)
Correct answer: Nitrogen
Nitrogen (N₂) makes up approximately 78% of Earth's atmosphere by volume.
Question 128: What does the `final/1` predicate define in a Picat planning problem?
- The cost threshold for termination
- The last action to be executed
- The initial state of the problem
- The goal condition that a state must satisfy for the plan to succeed (Correct answer)
Correct answer: The goal condition that a state must satisfy for the plan to succeed
`final(State)` succeeds when State is a goal state, telling the planner when to stop searching.
Question 129: What an anemometer measures
- Temperature
- Humidity
- Wind Speed (Correct answer)
- Air Pressure
Correct answer: Wind Speed
An anemometer is a scientific instrument specifically designed to measure wind speed. It typically consists of cups mounted on arms that rotate as the wind blows, with the rotation speed indicating the wind's velocity. This tool is crucial in meteorology and for various environmental studies.
Question 130: What is the process by which a solid changes directly into a gas without passing through the liquid phase?
- Evaporation
- Sublimation (Correct answer)
- Condensation
- Deposition
Correct answer: Sublimation
Sublimation occurs when a solid converts directly to a gas; dry ice (solid CO₂) is a common example.
Question 131: Which predicate prints the current execution call stack in Picat?
- backtrace
- print_backtrace (Correct answer)
- print_stack()
- show_stack()
Correct answer: print_backtrace
`print_backtrace` prints the current execution stack, which is helpful for diagnosing errors.
Question 132: What is the size of a square garden if its perimeter is 84 feet?
- 220
- 441 (Correct answer)
- 2205
- 341
Correct answer: 441
For a square, all four sides are equal in length. If the perimeter is 84 feet, then each side length is 84 feet / 4 = 21 feet. The 'size' of a garden typically refers to its area. The area of a square is calculated by squaring the side length, so Area = 21 feet * 21 feet = 441 square feet.
Question 133: What is the core mechanism within Picat's planner module that prevents infinite loops when searching a state space that contains cycles?
- The mandatory definition of a `final/1` predicate.
- The use of a resource limit in predicates like `plan/4`.
- The requirement that all action costs must be positive integers.
- The automatic tabling of every state encountered during the search. (Correct answer)
Correct answer: The automatic tabling of every state encountered during the search.
The planner module is built on Picat's tabling feature. It automatically tables every state that is generated during the search. If the planner encounters a state that is already in the table, it will not expand that state again, thus avoiding redundant computations and preventing infinite loops in graphs with cycles. This effectively converts the state-space search from a tree search to a graph search.
Question 134: Most nearly, placid means
- Calm (Correct answer)
- Ruffled
- Cold
- Agitated
Correct answer: Calm
The word 'placid' describes something that is not easily upset or excited, or a body of water that is calm and peaceful. Therefore, 'calm' is the closest synonym, indicating a state of tranquility and absence of disturbance. The other options suggest agitation or coldness.
Question 135: What is the fundamental difference between `L1 = ["a", "b"]` and `L2 = [a, b]` in Picat?
- `L1` is a valid list, but `L2` will cause a syntax error.
- `L1` is a list of strings, while `L2` is a list of atoms. (Correct answer)
- `L1` is a list of variables, while `L2` is a list of atoms.
- There is no difference; they are syntactically equivalent.
Correct answer: `L1` is a list of strings, while `L2` is a list of atoms.
In Picat, double quotes `""` create strings (which are lists of character codes), while unquoted, lowercase identifiers are atoms. Therefore, `L1` is a list containing two strings, `"a"` and `"b"`. `L2` is a list containing two atoms, `a` and `b`.
Question 136: The six-year-old was *very intelligent*.
- Rude
- Outgoing
- Shy
- Advanced (Correct answer)
Correct answer: Advanced
Describing a six-year-old as 'very intelligent' suggests that their mental development or capabilities are beyond what is typically expected for their age. 'Advanced' is the most fitting synonym, indicating that they are ahead in their intellectual progress compared to their peers.
Question 137: Ascorbic acid is referred to as
- Vitamin B12
- Vitamin E
- Vitamin A (Correct answer)
- Vitamin C
Correct answer: Vitamin A
Ascorbic acid is the chemical name for Vitamin C. It is an essential water-soluble vitamin vital for various bodily functions, including tissue repair, collagen synthesis, and acting as an antioxidant. The other options are incorrect: Vitamin E is tocopherol, Vitamin B12 is cobalamin, and Vitamin A is retinol.
Question 138: How do you close a file stream after I/O operations in Picat?
- end_stream(Stream)
- fclose(Stream)
- stream_close(Stream)
- close(Stream) (Correct answer)
Correct answer: close(Stream)
`close(Stream)` closes an open file stream, freeing the associated resources.
Question 139: Which of the following is an INVALID rule head for a Picat predicate?
- find_pair([X, X | _]) => ...
- handle_default(Data) => ...
- sum_list([H|T], H + sum_list(T)) => ... (Correct answer)
- process(ID, $record(Name, Age@val(V))) => ...
Correct answer: sum_list([H|T], H + sum_list(T)) => ...
Rule heads in Picat are for pattern matching, not for evaluation of expressions. The term `H + sum_list(T)` contains an arithmetic operation and a recursive call. Such computations are not valid patterns and must be placed in the rule's body or, for functions, after the `=` symbol.
Question 140: What is the output of [X : X in 1..5] in Picat?
- [0, 1, 2, 3, 4]
- [1, 2, 3, 4, 5] (Correct answer)
- A lazy sequence that evaluates elements on demand
- 1..5 (an unevaluated range term)
Correct answer: [1, 2, 3, 4, 5]
The range 1..5 in a Picat list comprehension generates integers 1 through 5 inclusive, so [X : X in 1..5] produces the fully evaluated list [1,2,3,4,5].
Question 141: Which built-in activates Picat's execution tracer for debugging?
- trace (Correct answer)
- spy_all
- debug()
- set_trace(on)
Correct answer: trace
`trace` activates the Picat tracer, printing each goal as it is called, exited, or failed.
Question 142: In Picat, what type does the literal `"hello"` (double-quoted) have?
- Array of characters
- List of character codes
- String — its own distinct type (Correct answer)
- Atom
Correct answer: String — its own distinct type
In Picat, double-quoted literals are of the `string` type, which is distinct from atoms and lists.
Question 143: What is the result of the unification `$point(X, Y) = $point(10, 20)` in Picat?
- X is unified with `$point(10, 20)` and Y remains unbound.
- A syntax error occurs.
- X is unified with `10`, and Y is unified with `20`. (Correct answer)
- The unification fails because structures cannot be unified directly.
Correct answer: X is unified with `10`, and Y is unified with `20`.
Unification of structures succeeds if they have the same functor (name) and arity (number of arguments), and their corresponding arguments can be unified. Here, the functors are both `point` and the arity is 2, so the unification proceeds by unifying the arguments: `X` with `10` and `Y` with `20`.
Question 144: Consider the following Picat code: `process_data($point(A, B), Result) => Result = A + B. process_data([H|_], Result) => Result = H.` What happens when the query `process_data(Data, R)` is called if `Data` is the structure `$point(5, 10)`?
- The second rule is chosen, and R becomes 5.
- The first rule is chosen through pattern matching, and R is unified with 15. (Correct answer)
- Both rules match, leading to a compilation error.
- The query fails because `$point` is not a list.
Correct answer: The first rule is chosen through pattern matching, and R is unified with 15.
Picat's engine will try to match the call `process_data($point(5, 10), R)` with the defined rule heads. The structure `$point(5, 10)` matches the pattern `$point(A, B)`. This is a successful one-sided unification where A gets the value 5 and B gets the value 10 for the scope of the rule. The body `Result = A + B` is then executed, unifying `Result` with `5 + 10`, which is 15.
Question 145: A developer needs to get a list of all files and directories in the current working directory. Which predicate from the `os` module should be used for this purpose?
- os:scandir(".", List)
- os:list_files(List)
- os:files(.)
- os:listdir(".", List) (Correct answer)
Correct answer: os:listdir(".", List)
The `os:listdir(Path, List)` predicate is used to retrieve the names of entries in a directory. `Path` is the directory to scan, and `List` will be bound to a list of strings representing the files and subdirectories. Using `.` for the path refers to the current directory.
Question 146: Which directive correctly imports the Picat planner module?
- include planner.
- require planner.
- use planner.
- import planner. (Correct answer)
Correct answer: import planner.
The correct syntax is `import planner.` placed at the top of the Picat source file.
Question 147: The following equations' graphs are straight lines, with the exception of <br> <br> A 3x + 2y = 8 <br> B y = x / 2 - 5 <br> C x = 4y <br> D y = x ^ 2 + 3
- y=X^2+3 (Correct answer)
- y=x^1+3
- y=x^2+13
- y=x^3+3
Correct answer: y=X^2+3
A straight line graph is characteristic of a linear equation, where the highest power of the variables (x and y) is 1. Options A, B, and C are all linear equations. However, option D, `y = x^2 + 3`, contains an `x^2` term, indicating a quadratic equation whose graph is a parabola, not a straight line.
PiCAT (Pre-screening Internet-delivered Computerized Adaptive Test)
The PiCAT is an unproctored, at-home version of the ASVAB that assesses military aptitude across 10 subtests. Scores are verified in person at a MEPS/MET site within 45 days.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds
Practice questions written with AI assistance and published by Nathan Beja, founder of Practice Test Geeks. They are not real exam questions. Exam facts are checked against the official sources linked below. Editorial policy
Sources & references
Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy
- officialasvab.com — Test delivery, eligibility, registration deadline, retake policy, score release, time limit, score validity, exam information · verified Dec 2026