PiCAT (Pre-screening Internet-delivered Computerized Adaptive Test) ā Questions and Answers
Question 1: Which of the following is an example of a chemical change rather than a physical change?
- Glass breaking into pieces
- Ice melting into water
- Iron rusting on a fence (Correct answer)
- A piece of paper being torn
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 2: What does the pattern `{X, Y, Z}` match in Picat?
- A set containing X, Y, and Z
- A list of three elements
- A struct named tuple
- A tuple with exactly three elements (Correct answer)
Correct answer: A tuple with exactly three elements
Curly braces in Picat denote tuples, so `{X, Y, Z}` matches a three-element tuple and binds each position.
Question 3: 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 4: How does Picat's tabling differ from standard Prolog memoization libraries?
- It caches only ground answers
- It only works for functions, not predicates
- It requires explicit hash maps managed by the programmer
- Tabling is built into the language with the `table` directive and handles cycles automatically (Correct answer)
Correct answer: Tabling is built into the language with the `table` directive and handles cycles automatically
Picat's `table` directive enables SLG-resolution tabling that correctly handles cyclic calls and avoids infinite loops without programmer intervention.
Question 5: In Picat's CP module, the `circuit/1` global constraint is used to model which type of problem?
- Shortest-path routing between nodes
- Flow conservation in directed networks
- Spanning tree construction on a weighted graph
- Hamiltonian cycle over a set of successor variables (Correct answer)
Correct answer: Hamiltonian cycle over a set of successor variables
`circuit(Succ)` constrains the array Succ so that the successor relation forms a single Hamiltonian cycle visiting every node exactly once.
Question 6: When would you choose `best_plan` over `plan` in a Picat program?
- When you want faster execution regardless of plan quality
- When actions have no associated costs
- When the state space is very small
- When you need the minimum-cost solution, not just any valid solution (Correct answer)
Correct answer: When you need the minimum-cost solution, not just any valid solution
`best_plan` exhausts the search to guarantee cost optimality, while `plan` returns the first solution it finds which may not be cheapest.
Question 7: The programs' *permanent* underfunding
- Habitual (Correct answer)
- Massive
- Temporary
- 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 8: Which Picat pattern would match a struct term `point(X, Y)` only when both coordinates are integers?
- point(int X, int Y) => ...
- point(X:int, Y:int) => ...
- point(integer, integer) => ...
- point(X, Y), integer(X), integer(Y) => ... (Correct answer)
Correct answer: point(X, Y), integer(X), integer(Y) => ...
Picat uses guard conditions to further restrict matches; `integer(X)` and `integer(Y)` in the guard enforce the type constraint.
Question 9: What is the effect of the `[max]` value-ordering option in Picat CP's solve predicate?
- It sorts all domains in descending order before search
- It picks the largest value in the chosen variable's domain first (Correct answer)
- It selects the variable with the maximum domain size first
- It assigns the global maximum bound to each variable first
Correct answer: It picks the largest value in the chosen variable's domain first
The `max` value-ordering option makes the labeling procedure try the largest value in a variable's domain at each choice point.
Question 10: How do you insert key K with value V into Picat map M?
- put(M, K, V) (Correct answer)
- insert(M, K, V)
- M[K] = V
- 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 11: Which Picat predicate tests whether a term is currently an unbound variable?
- free(X)
- unbound(X)
- atom(X)
- var(X) (Correct answer)
Correct answer: var(X)
var(X) succeeds if X is currently an uninstantiated (unbound) variable at the time of the call.
Question 12: What is the output of the Picat code: `X := 3, (X > 2 -> Y := "big" ; Y := "small"), print(Y)`?
- A runtime error
- small
- big (Correct answer)
- true
Correct answer: big
Since X is 3 which is greater than 2, the then-branch executes and Y is assigned "big", which is then printed.
Question 13: In Picat logic programming, what does 'resolution' refer to?
- The inference step that matches a goal with a clause head and produces new subgoals (Correct answer)
- The screen pixel density of the debugger
- The mechanism for catching exceptions
- The process of sorting a list of answers
Correct 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.
Question 14: What is the output of `writeln(2 ** 10)` in Picat?
- 210
- 1024 (Correct answer)
- 1024.0
- 20
Correct answer: 1024
The `**` operator in Picat performs integer exponentiation when both operands are integers, so 2**10 evaluates to 1024.
Question 15: What is the term for the point on Earth's surface directly above the focus of an earthquake?
- Fault line
- Epicenter (Correct answer)
- Hypocenter
- Seismic zone
Correct answer: Epicenter
The epicenter is the surface point directly above where seismic energy is released underground (the focus).
Question 16: Which predicate tests whether a CP variable is already instantiated (ground) in Picat?
- fd_ground(Var)
- instantiated(Var)
- ground(Var) (Correct answer)
- is_fixed(Var)
Correct answer: ground(Var)
`ground(Var)` succeeds if Var is fully instantiated and contains no unbound logical variables.
Question 17: The word DEPLETE most nearly means:
- preserve
- collect
- exhaust (Correct answer)
- increase
Correct answer: exhaust
Deplete means to use up the supply or resources of something.
Question 18: Most nearly, placid means
- Agitated
- Ruffled
- Cold
- Calm (Correct answer)
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 19: The word CONCISE most nearly means:
- brief (Correct answer)
- outdated
- wordy
- confusing
Correct answer: brief
Concise means giving a lot of information clearly and in few words; brief but comprehensive.
Question 20: In a tabled Picat predicate with mode (+,+,-), what do the `-` signs indicate?
- Output arguments whose values are stored in the table. (Correct answer)
- Arguments that are ignored by the tabling mechanism.
- Arguments that must be uninstantiated when called.
- Arguments that trigger a new table lookup.
Correct answer: Output arguments whose values are stored in the table.
In tabling mode declarations, `-` denotes output (answer) arguments that the table records.
Question 21: In a Picat function, what happens if execution reaches the end of the body without a `return`?
- The function implicitly returns true
- An error is raised
- The function returns a free (unbound) variable
- The function returns the last evaluated expression (Correct answer)
Correct answer: The function returns the last evaluated expression
In Picat, if no explicit return is reached, the value of the last expression in the function body is returned.
Question 22: In Picat, what type does the literal `"hello"` (double-quoted) have?
- Atom
- String ā its own distinct type (Correct answer)
- Array of characters
- List of character codes
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 23: Which type of blood cell is primarily responsible for fighting infections?
- Red blood cells
- Plasma cells
- White blood cells (Correct answer)
- Platelets
Correct answer: White blood cells
White blood cells (leukocytes) are the main components of the immune system that identify and destroy pathogens.
Question 24: What an anemometer measures
- Wind Speed (Correct answer)
- Air Pressure
- Temperature
- Humidity
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 25: 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 function is non-deterministic, and tabling only works on deterministic functions.
- The table area was not cleared from a previous run; call `initialize_table` at the start of the program. (Correct answer)
- The `table` directive is misspelled; it should be `memoize`.
- A destructive assignment operator (`:=`) is being used inside the tabled function, which is not allowed.
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 26: They're expecting for *realistic* advancements.
- Real (Correct answer)
- Subtle
- Long lasting
- Speedy
Correct answer: Real
The word 'realistic' means having or showing a sensible and practical idea of what can be achieved or expected. Therefore, 'real' is the most direct and accurate synonym, implying advancements that are genuine, achievable, and not merely theoretical or imaginary. It captures the essence of practicality and authenticity.
Question 27: The word VAGUE most nearly means:
- honest
- specific
- detailed
- unclear (Correct answer)
Correct answer: unclear
Vague means not clearly expressed or defined; uncertain or indistinct.
Question 28: The word VALIDATE most nearly means:
- reject
- confirm (Correct answer)
- ignore
- delay
Correct answer: confirm
Validate means to demonstrate or support the truth or value of something; to confirm.
Question 29: 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).
- 0
- 10
- 24 (Correct answer)
- 1
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 30: Picat functions can be higher-order. Which call correctly applies function `F` to value `X` and uses the result?
- Result = apply(F, X)
- call(F, X, Result)
- Result = call(F, X) (Correct answer)
- Result = F.apply(X)
Correct answer: Result = call(F, X)
In Picat, `call(F, X)` invokes a function reference `F` with argument `X` and returns the result.
Question 31: Ascorbic acid is referred to as
- Vitamin A (Correct answer)
- Vitamin C
- Vitamin E
- Vitamin B12
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 32: Which predicate prints the current execution call stack in Picat?
- print_stack()
- print_backtrace (Correct answer)
- backtrace
- show_stack()
Correct answer: print_backtrace
`print_backtrace` prints the current execution stack, which is helpful for diagnosing errors.
Question 33: Which of the following correctly defines a Picat logic predicate for list membership?
- member(X,[X|_]). member(X,[_|T]) :- member(X,T). (Correct answer)
- member(X,L) := foreach(E in L, E==X).
- member(X,L) :- L contains X.
- member(X,L) => X in L.
Correct 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.
Question 34: Which built-in opens a file for writing in Picat?
- open(File, write, Stream) (Correct answer)
- write_file(File)
- fopen(File, "w")
- file_open(File, write)
Correct answer: open(File, write, Stream)
`open(File, write, Stream)` opens a file for writing and binds the resulting stream to Stream.
Question 35: Mundane most closely resembles
- Tired
- Ordinary (Correct answer)
- Extraordinary
- Unique
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 36: Approximately how long does it take Earth to complete one full orbit around the Sun?
- 400 days
- 365.25 days (Correct answer)
- 28 days
- 24 hours
Correct answer: 365.25 days
Earth's orbital period is approximately 365.25 days, which is why a leap day is added every four years.
Question 37: What is the arity of the `action` predicate used in Picat's planner module?
- 5
- 4 (Correct answer)
- 2
- 3
Correct answer: 4
`action/4` takes four arguments: the current state, next state, the action term, and its cost.
Question 38: In Picat, what is the difference between `==` and `=` when used in a rule body?
- `==` performs unification; `=` tests equality without binding
- There is no difference between them
- `==` tests strict equality without binding; `=` performs unification which may bind variables (Correct answer)
- `==` is for arithmetic; `=` is for structural terms
Correct answer: `==` tests strict equality without binding; `=` performs unification which may bind variables
`==` checks that two terms are identical without unifying them, while `=` attempts unification and may bind uninstantiated variables.
Question 39: Which type of chemical bond involves the sharing of electrons between atoms?
- Hydrogen bond
- Metallic bond
- Covalent bond (Correct answer)
- Ionic bond
Correct answer: Covalent bond
Covalent bonds form when two atoms share one or more pairs of electrons.
Question 40: In a Picat `if-then-else` expression, what is required if the else branch is omitted?
- An implicit else true is added
- Omitting else is a syntax error in function mode (Correct answer)
- The if expression returns a free variable on failure
- The condition must always be true
Correct answer: Omitting else is a syntax error in function mode
In Picat's functional/imperative mode, if without else is a syntax error; both branches must be present.
Question 41: In Picat, what does the `\=` operator test?
- Logical negation of a predicate call
- That two terms cannot be unified (unification would fail) (Correct answer)
- Arithmetic inequality
- Structural inequality after evaluation
Correct 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.
Question 42: In Picat, what is the outcome when a predicate is called with arguments that do not match the pattern of any of its defined rules?
- A syntax error is reported at compile time.
- The call implicitly returns a `fail` atom.
- The call simply fails, and execution backtracks. (Correct answer)
- The program halts with an instantiation error.
Correct answer: The call simply fails, and execution backtracks.
If a goal is called and Picat cannot find any rule (or fact) whose head matches the goal's arguments, the call fails. This is a fundamental concept of logic programming. Execution will then backtrack to the most recent choice point to try an alternative path. If no alternatives exist, the top-level query will fail.
Question 43: What is the correct way to define a recursive Picat function `fact(N)` for the factorial of N?
- fact(0) = 1. fact(N) = N * fact(N-1). (Correct answer)
- fact(N) :- N =:= 0, 1 ; N * fact(N-1).
- fact(N) = (N == 0 -> 1 ; N * fact(N-1))
- fact(0) => 1. fact(N) => N * fact(N-1).
Correct answer: fact(0) = 1. fact(N) = N * fact(N-1).
Recursive Picat functions use `=` and pattern-match across multiple clauses.
Question 44: Which expression correctly sums all elements in a list List using a list comprehension in Picat?
- total([X : X in List])
- sum([X : X in List]) (Correct answer)
- add_all([X : X in List])
- reduce(+, List, 0)
Correct answer: sum([X : X in List])
sum/1 accepts any list and returns its arithmetic total; [X : X in List] evaluates to a copy of the same list, so sum([X : X in List]) is equivalent to sum(List).
Question 45: What is the primary characteristic that distinguishes a Picat function from a Picat predicate?
- Functions can only be used for mathematical calculations, while predicates handle logic.
- Functions cannot call predicates, but predicates can call functions.
- Functions must always succeed and return exactly one value, while predicates can fail, succeed, or provide multiple answers via backtracking. (Correct answer)
- Functions are defined using the `function` keyword, whereas predicates use the `pred` keyword.
Correct answer: Functions must always succeed and return exactly one value, while predicates can fail, succeed, or provide multiple answers via backtracking.
In Picat, a function is a specialized form of a predicate. The key difference is that a function is deterministic; it must always succeed and yield a single return value. Predicates, on the other hand, are more general: they can succeed (once or multiple times through backtracking) or they can fail.
Question 46: Given `double(X) = 2 * X`, what does `Y = double(5) + double(3)` evaluate to?
- A syntax error is raised
- Y = 6
- Y = 16 (Correct answer)
- Y = 10
Correct answer: Y = 16
`double(5)` returns 10 and `double(3)` returns 6, so `Y = 16`.
Question 47: What is the core mechanism within Picat's planner module that prevents infinite loops when searching a state space that contains cycles?
- 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)
- The mandatory definition of a `final/1` predicate.
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 48: What does `arg(1, point(3, 4), X)` bind X to in Picat?
- point
- 4
- Error: arg uses 0-based indexing
- 3 (Correct answer)
Correct answer: 3
`arg/3` is 1-indexed in Picat: arg 1 of `point(3,4)` is `3`, the first argument.
Question 49: Which `math` module predicate computes the ceiling of a floating-point number?
- ceil/1
- floor_add/1
- ceiling/1 (Correct answer)
- round_up/1
Correct answer: ceiling/1
`ceiling/1` returns the smallest integer greater than or equal to the given floating-point number.
Question 50: Which type of reproduction requires only one parent and produces offspring that are genetically identical to the parent?
- Fertilization
- Sexual reproduction
- Asexual reproduction (Correct answer)
- Cross-pollination
Correct answer: Asexual reproduction
Asexual reproduction, such as budding or binary fission, produces genetically identical clones from a single parent.
Question 51: When a blown fuse stops current flow, what does the circuit become?
- reciprocating saw
- cooper
- fuse
- open (Correct answer)
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 52: A vector can be used to represent force. A vector is indicative of
- Magnitude
- Direction
- Magnitude and Direction (Correct answer)
- Speed
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 53: In Picat, what does the `@` symbol signify when used in a term like `[H|T]@List`?
- It aliases the whole list to List while also destructuring (Correct answer)
- It represents string concatenation
- It is not standard syntax; Picat uses [H|T] without @
- It marks a lazy evaluation thunk
Correct answer: It aliases the whole list to List while also destructuring
Picat supports as-patterns with `@`, so `[H|T]@List` matches a non-empty list, binding H to the head, T to the tail, and List to the entire structure simultaneously.
Question 54: How do you iterate over both index and value of a list in a Picat `foreach` loop?
- foreach(I in 1..List.len, V = List[I]) (Correct answer)
- foreach(I-V in List)
- foreach(I:V in List)
- foreach({I,V} in zip(1..len(List), List))
Correct answer: foreach(I in 1..List.len, V = List[I])
The standard idiom is to iterate over an index range and access List[I], since foreach over a list gives values only.
Question 55: 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 first rule is chosen through pattern matching, and R is unified with 15. (Correct answer)
- The second rule is chosen, and R becomes 5.
- The query fails because `$point` is not a list.
- Both rules match, leading to a compilation error.
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 56: Parity almost exactly entails
- Equality (Correct answer)
- Twice
- Separate'
- 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 57: How do you create a new empty map in Picat?
- empty_map()
- {}
- make_map()
- new_map() (Correct answer)
Correct answer: new_map()
Picat provides the built-in `new_map()` function to create an empty hash map.
Question 58: What is the pH value of a neutral solution at room temperature?
- 14
- 0
- 5
- 7 (Correct answer)
Correct answer: 7
Pure water and neutral solutions have a pH of 7, where hydrogen and hydroxide ion concentrations are equal.
Question 59: Which format specifier prints an integer inside Picat's `format` predicate?
- %d
- {d}
- %i
- ~d (Correct answer)
Correct answer: ~d
Picat's `format` predicate uses `~d` to print an integer argument.
Question 60: 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
- Masonry Nail
- Viscosity
- Governonrs
- Crispness (Correct answer)
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 61: What is the approximate speed of light in a vacuum?
- 300,000 km/s (Correct answer)
- 30,000 km/s
- 3,000,000 km/s
- 186 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 62: What is the role of the anonymous variable `_` in Picat unification?
- It matches only numbers
- It matches only atoms
- It matches any term and is never shared across occurrences (Correct answer)
- It is an alias for nil
Correct answer: It matches any term and is never shared across occurrences
Each occurrence of _ is a distinct fresh variable that matches anything but shares no binding with other _ occurrences.
Question 63: In Picat's constraint module `cp`, which predicate declares an integer decision variable with a domain?
- domain(X, Lo, Hi)
- int_var(X, Lo, Hi)
- var(X, Lo..Hi)
- X :: Lo..Hi (Correct answer)
Correct answer: X :: Lo..Hi
The `::` operator assigns a finite-domain range to a decision variable, e.g., `X :: 1..10` constrains X to integers 1 through 10.
Question 64: Which Picat module should you import to use SAT-based constraint solving instead of CP propagation?
- sat (Correct answer)
- boolean
- smt
- cp
Correct answer: sat
Picat's `sat` module encodes finite-domain constraints as propositional SAT clauses and calls a built-in SAT solver, offering an alternative to the `cp` propagation engine.
Question 65: In Picat, what does the `foreach` loop construct do?
- Applies a constraint to each variable in a list
- Iterates over a list or range, executing a goal for each element without building a return value (Correct answer)
- Filters elements satisfying a condition
- Collects results into a new list like map
Correct answer: Iterates over a list or range, executing a goal for each element without building a return value
`foreach(E in List, Goal)` executes Goal for each element E in List purely for side effects, analogous to a for-each loop in imperative languages.
Question 66: In Picat, which operator separates the head from the body in a deterministic predicate clause?
- =
- ?=>
- => (Correct answer)
- :-
Correct answer: =>
`=>` is the neck operator for a deterministic predicate clause in Picat.
Question 67: The word METICULOUS most nearly means:
- careless
- stubborn
- precise (Correct answer)
- generous
Correct answer: precise
Meticulous means showing great attention to detail; very careful and precise.
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?
- `sum/1`
- `element/3`
- `global_cardinality/2`
- `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: What is the difference between Picat's `table` and a hand-written assert/retract memoization pattern in Prolog?
- `table` only works for deterministic predicates, while assert/retract works for all predicates.
- There is no practical difference; both are equally automatic.
- assert/retract is faster because it uses native memory.
- `table` is declarative and automatically managed, while assert/retract requires manual cache management. (Correct answer)
Correct 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.
Question 70: Given the goal `[A, B | C] = [x, y, z, w]`, which set of bindings for the variables A, B, and C is correct after successful unification in Picat?
- A = x, B = [y], C = [z, w]
- A = x, B = y, C = z
- A = x, B = y, C = [z, w] (Correct answer)
- Unification fails because the list lengths do not match.
Correct answer: A = x, B = y, C = [z, w]
In Picat (as in Prolog), the `[Head | Tail]` syntax deconstructs a list. The elements before the `|` are unified with the initial elements of the list on the right. The variable after the `|` is unified with the rest of the list. Therefore, `A` unifies with `x`, `B` unifies with `y`, and `C` unifies with the remaining list `[z, w]`.
Question 71: The word NOTORIOUS most nearly means:
- unknown
- generous
- famous for something bad (Correct answer)
- respected
Correct answer: famous for something bad
Notorious means famous or well-known, typically for some bad quality or deed.
Question 72: Which of the following correctly computes the sum of squares of even numbers from 1 to 10 in Picat?
- aggregate_sum(X*X, member(X, 1..10), X mod 2 =:= 0)
- reduce(+, [X*X : X in 1..10, X rem 2 == 0])
- sum([X*X : X in 1..10, X mod 2 =:= 0]) (Correct answer)
- sum_of(X*X, X in 1..10, X mod 2 =:= 0)
Correct answer: sum([X*X : X in 1..10, X mod 2 =:= 0])
Wrapping a list comprehension in sum/1 first builds the list of even squares (4,16,36,64,100) and then sums them, giving 220.
Question 73: The word ABRUPT most nearly means:
- lengthy
- gradual
- sudden (Correct answer)
- smooth
Correct answer: sudden
Abrupt means sudden and unexpected, or brief to the point of rudeness.
Question 74: Which of the following tools guards against current overloads in A circuit?
- Knot
- Saw
- 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 75: Which type of energy is stored in a compressed spring?
- Chemical energy
- Thermal energy
- Elastic potential energy (Correct answer)
- Kinetic 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 76: What is the atomic number of carbon?
- 4
- 8
- 12
- 6 (Correct answer)
Correct answer: 6
Carbon has 6 protons in its nucleus, giving it an atomic number of 6.
Question 77: The six-year-old was *very intelligent*.
- Outgoing
- Shy
- Rude
- 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 78: Which pattern matches a non-empty list in Picat?
- [_]
- [_|_] (Correct answer)
- []
- list(_)
Correct answer: [_|_]
`[_|_]` matches any list with at least one element, binding both head and tail to anonymous variables.
Question 79: Which statement about `return` in a Picat function is correct?
- return Expr exits the function with value Expr (Correct answer)
- Functions cannot return values; only predicates can
- return must appear at the end of every clause
- return is not a keyword; the last expression's value is returned
Correct answer: return Expr exits the function with value Expr
Picat supports the return Expr statement to exit a function early and produce a return value.
Question 80: Which syntax correctly defines a Picat function that returns the square of X?
- square(X) -> X * X
- square(X) = X * X (Correct answer)
- square(X) => X * X
- square(X) :- X * X
Correct answer: square(X) = X * X
Picat functions are defined with `=` between the head and the return expression.
Question 81: The word VIGILANT most nearly means:
- watchful (Correct answer)
- reckless
- sleepy
- courageous
Correct answer: watchful
Vigilant means keeping careful watch for possible danger or difficulties.
Question 82: What is the chemical symbol for sodium?
- So
- Na (Correct answer)
- Ni
- Sd
Correct answer: Na
Sodium's symbol Na comes from the Latin word 'Natrium.'
Question 83: What is the correct syntax to access element at index 2 of array A in Picat?
- A.(2)
- get_array(A, 2)
- A[2] (Correct answer)
- nth(2, A)
Correct answer: A[2]
Picat arrays use bracket notation `A[I]` for indexed access, with indexing starting at 1.
Question 84: 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 X cannot be unified with 1.
- It will print 1 and then a variable.
- The query will fail because Y is not instantiated in the unification.
- 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 85: In the Picat `maps` module, which predicate creates a new empty map?
- maps:empty/1
- maps:new/1
- {}
- new_map/1 (Correct answer)
Correct answer: new_map/1
`new_map/1` binds a variable to a fresh, empty map data structure in Picat.
Question 86: Which `math` module function raises a number to a power in Picat?
- ** operator only
- pow/2 (Correct answer)
- power/2
- exp/2
Correct answer: pow/2
`pow/2` computes X to the power Y; the `**` infix operator also works for the same purpose.
Question 87: What distinguishes a Picat `function` (using = in the head) from a `predicate`?
- There is no distinction ā they compile identically
- A function must return exactly one value via the last argument position, while a predicate succeeds or fails (Correct answer)
- Functions use backtracking; predicates do not
- Functions are compiled to C; predicates are interpreted
Correct answer: A function must return exactly one value via the last argument position, while a predicate succeeds or fails
In Picat, a function definition uses `f(Args) = Value => Body`, returning a deterministic value, whereas a predicate succeeds or fails without an explicit return.
Question 88: Which Picat predicate retrieves all solutions of a goal as a list?
- collect(Goal, List)
- all_solutions(Goal, List)
- findall(Template, Goal, List) (Correct answer)
- bagof(Template, Goal, List)
Correct answer: findall(Template, Goal, List)
`findall/3` collects every Template instantiation for which Goal succeeds into List, returning [] if Goal always fails.
Question 89: 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.
- 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)
- Picat does not support explicit unification, relying solely on pattern matching in rule heads.
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 90: For the longest common subsequence (LCS) problem, why is tabling particularly effective in Picat?
- LCS has overlapping subproblems of the form lcs(i,j) that are recomputed many times without tabling. (Correct answer)
- Tabling converts LCS from O(n²) to O(n log n).
- LCS has no recursive structure so tabling reduces the code size.
- Tabling allows LCS to run in parallel across multiple cores.
Correct answer: LCS has overlapping subproblems of the form lcs(i,j) that are recomputed many times without tabling.
LCS subproblems overlap heavily (each cell depends on three adjacent cells), making tabling essential for polynomial performance.
Question 91: What does the `table` mode specifier `max` do when applied to an argument in Picat?
- It stores the maximum number of answers for that predicate.
- It makes the argument optional with a default maximum.
- It keeps only the answer with the largest value for that argument, useful for maximization problems. (Correct answer)
- It sets an upper bound on the argument's value.
Correct answer: It keeps only the answer with the largest value for that argument, useful for maximization problems.
The `max` mode retains only the answer maximizing that argument, enabling optimal-value dynamic programming.
Question 92: What mechanism does the Picat planner use to avoid re-expanding already-visited states?
- A global hash set maintained by the user
- Constraint propagation
- Tabling (memoization of visited states) (Correct answer)
- Depth cutoff only
Correct answer: Tabling (memoization of visited states)
The planner automatically tables visited states so that the same state is never expanded twice, preventing infinite loops and redundant work.
Question 93: Which Picat CP predicate retrieves all solutions to a constraint problem as a list?
- findall_solutions(Vars, List)
- all_solutions(Vars, List)
- findall(Vars, solve(Vars), List) (Correct answer)
- solve_all(Options, Vars, List)
Correct answer: findall(Vars, solve(Vars), List)
Standard `findall(Template, Goal, List)` is used with `solve(Vars)` as the goal to collect all satisfying assignments into a list.
Question 94: 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.
- There is no difference; they are syntactically different but semantically identical.
- Pattern matching is bidirectional, while explicit unification is unidirectional.
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 95: The word RESCIND most nearly means:
- enforce
- issue
- extend
- cancel (Correct answer)
Correct answer: cancel
Rescind means to revoke, cancel, or repeal a law, order, or agreement.
Question 96: How does Picat handle a call to a function for which no pattern-matching rule applies?
- The call enters an infinite loop.
- The call raises an exception and terminates the program. (Correct answer)
- The call fails silently, and the program continues.
- The call succeeds and returns a `null` or `undefined` value.
Correct answer: The call raises an exception and terminates the program.
Unlike predicates which can simply fail, a function in Picat is expected to always succeed with one answer. If a function is called with arguments that do not match any of its defining rules, it cannot produce a value. This situation is treated as an error, and Picat will raise an exception.
Question 97: If the initial state already satisfies `final/1`, what does `plan/2` return?
- An exception indicating the problem is trivial
- The single-element list containing the initial state
- Failure, because no actions were taken
- An empty list, since no actions are needed (Correct answer)
Correct answer: An empty list, since no actions are needed
When the start state is already a goal state, `plan/2` succeeds immediately with Plan = [], reflecting that zero actions are required.
Question 98: Which predicate checks if X is an atom (not a string or number) in Picat?
- symbol(X)
- atom(X) (Correct answer)
- term(X)
- is_atom(X)
Correct answer: atom(X)
`atom(X)` is the standard Picat predicate that succeeds when X is an unquoted atom like `hello` or `foo`.
Question 99: Which operator decomposes a compound term into a list `[Functor | Args]` in Picat?
- struct_to_list/2
- =.. (the univ operator) (Correct answer)
- decomp/3
- term_to_list/2
Correct answer: =.. (the univ operator)
The `=..` (univ) operator decomposes `f(a,b)` into `[f, a, b]` and can also construct terms from such lists.
Question 100: The word ELOQUENT most nearly means:
- fluent (Correct answer)
- silent
- rude
- confused
Correct answer: fluent
Eloquent means fluent or persuasive in speaking or writing.
Question 101: The word LUCID most nearly means:
- dim
- clear (Correct answer)
- heavy
- silent
Correct answer: clear
Lucid means expressed clearly; easy to understand, or mentally alert and coherent.
Question 102: The word SUBDUE most nearly means:
- release
- question
- overcome (Correct answer)
- excite
Correct answer: overcome
Subdue means to overcome, quieten, or bring under control by force or persuasion.
Question 103: Which of the following statements about Picat's tabling mechanism is FALSE?
- It can be applied to both predicates and functions.
- The `table` keyword is placed immediately before the first rule of the predicate/function to be tabled.
- It requires manual cache invalidation using a special built-in predicate. (Correct answer)
- It is implemented using a technique called linear tabling.
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 104: What does sort([X : X in [3,1,4,1,5,9,2,6]]) produce in Picat?
- [1, 1, 2, 3, 4, 5, 6, 9]
- [9, 6, 5, 4, 3, 2, 1]
- [3, 1, 4, 1, 5, 9, 2, 6]
- [1, 2, 3, 4, 5, 6, 9] (Correct answer)
Correct answer: [1, 2, 3, 4, 5, 6, 9]
Picat's sort/1, like Prolog's, sorts the list in ascending order and removes duplicates, so the repeated 1 appears only once in the result [1,2,3,4,5,6,9].
Question 105: In Picat, what does `_` (underscore) guarantee about variable binding?
- It only matches atoms
- It binds to the first value it sees and reuses that binding
- It must match an uninstantiated variable
- It matches any value and is never bound, even if it appears multiple times (Correct answer)
Correct answer: It matches any value and is never bound, even if it appears multiple times
Each occurrence of `_` is a fresh anonymous variable that matches anything without creating a binding or linking occurrences.
Question 106: Which type of wave does sound travel as through air?
- Transverse wave
- Surface wave
- Electromagnetic wave
- Longitudinal wave (Correct answer)
Correct answer: Longitudinal wave
Sound travels as a longitudinal wave, where particle displacement is parallel to the direction of wave propagation.
Question 107: What does `bp.pred_name(Args)` syntax allow in Picat?
- Bypassing type checking for performance
- Accessing a byte-code primitive
- Calling a C foreign function
- Calling a B-Prolog built-in predicate not natively exposed in Picat (Correct answer)
Correct answer: Calling a B-Prolog built-in predicate not natively exposed in Picat
The `bp.` prefix lets Picat code call B-Prolog predicates directly, since Picat is built on the B-Prolog engine and exposes its built-ins this way.
Question 108: What does `compound(hello)` evaluate to in Picat?
- Error
- true
- false (Correct answer)
- Depends on how hello is declared
Correct answer: false
`compound/1` fails for atoms like `hello` ā a compound term must have a functor and at least one argument.
Question 109: In Picat, which of the following correctly adds a guard to a predicate clause?
- classify(X) => if X > 0 then println(positive) end
- classify(X) :- X > 0 | println(positive)
- classify(X), X > 0 => println(positive) (Correct answer)
- classify(X) => positive, X > 0 => println(positive)
Correct answer: classify(X), X > 0 => println(positive)
In Picat, a guard is placed between the head and the `=>` neck using a comma: `Head, Guard => Body`.
Question 110: What happens if no `catch` clause matches a thrown exception in Picat?
- The program silently continues
- The program halts immediately with exit code 1
- A default handler runs
- The exception propagates up the call stack (Correct answer)
Correct answer: The exception propagates up the call stack
An unmatched exception continues propagating up the call stack until a matching catch or the top level is reached.
Question 111: The word PLAUSIBLE most nearly means:
- reasonable (Correct answer)
- impossible
- useless
- obvious
Correct answer: reasonable
Plausible means seeming reasonable or probable; believable.
Question 112: What will be the strain in the card at the designated location when four weights are linked together and suspended from the ceiling?
- 50%
- 240 Pounds (Correct answer)
- 100
- 968 square feet
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 113: How does Picat handle multiple generators in [X+Y : X in [1,2], Y in [10,20]]?
- It interleaves the lists alternately: [11, 12, 21, 22]
- It raises an error because multiple generators are not supported
- It computes only the diagonal pairs: (1,10) and (2,20), giving [11, 22]
- It computes the Cartesian product, yielding [11, 21, 12, 22] (Correct answer)
Correct answer: It computes the Cartesian product, yielding [11, 21, 12, 22]
Multiple generators in Picat form a Cartesian product with the leftmost generator varying slowest: X=1 pairs with Y=10 and Y=20, then X=2 pairs with Y=10 and Y=20, yielding [11,21,12,22].
Question 114: What is the output of [X : X in 1..5] in Picat?
- [0, 1, 2, 3, 4]
- A lazy sequence that evaluates elements on demand
- 1..5 (an unevaluated range term)
- [1, 2, 3, 4, 5] (Correct answer)
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 115: What search strategy does `[up]` specify when passed to `solve` in Picat's CP module?
- Orders variables by ascending domain size before labeling
- Performs search upward through the constraint hierarchy
- Assigns values starting from the upper bound of each variable's domain
- Tries the largest value first during value selection (Correct answer)
Correct answer: Tries the largest value first during value selection
The `up` value-ordering option makes the solver try the largest value in the domain first at each choice point.
Question 116: Can a Picat function be embedded directly inside an arithmetic expression such as `Y = f(X) + 3`?
- No, functions must be called with `call/1`
- Only inside `once/1` wrappers
- Yes, because functions return values usable in expressions (Correct answer)
- Only if `f` is declared as `arithmetic`
Correct answer: Yes, because functions return values usable in expressions
Picat functions return values and can appear anywhere an expression is expected.
Question 117: Which directive correctly imports the Picat planner module?
- include planner.
- import planner. (Correct answer)
- use planner.
- require planner.
Correct answer: import planner.
The correct syntax is `import planner.` placed at the top of the Picat source file.
Question 118: If a Picat function clause has the head `f(0)` and a body, for which calls will this clause be tried?
- Only calls where the argument is a positive integer
- Only calls where the argument unifies with 0 (Correct answer)
- Only calls at the top level
- All calls to f regardless of argument
Correct answer: Only calls where the argument unifies with 0
The literal `0` in the head pattern means the clause is only attempted when the first argument can unify with (equals) 0.
Question 119: What value does `max_list([3,1,4,1,5,9])` return in Picat?
- 5
- 1
- 3
- 9 (Correct answer)
Correct answer: 9
`max_list/1` returns the largest element of the list, which is 9 in this case.
Question 120: What is the correct way to break out of a `foreach` loop early in Picat?
- Use the `break` keyword inside the loop
- Throw and catch an exception
- Call `halt`
- Use a boolean flag variable with a while loop instead (Correct answer)
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 121: How does Picat handle an `if` condition that raises an exception during evaluation?
- The if statement is silently skipped
- The condition is treated as false
- The else branch executes automatically
- The exception propagates up the call stack (Correct answer)
Correct answer: The exception propagates up the call stack
Uncaught exceptions in an if condition propagate normally up the call stack just as they would in any other position.
Question 122: The word TENACIOUS most nearly means:
- fragile
- persistent (Correct answer)
- timid
- forgetful
Correct answer: persistent
Tenacious means holding firmly to something; not giving up easily; persistent.
Question 123: When Picat's tabling handles a mutually recursive pair of predicates (e.g., even/1 and odd/1), what mechanism ensures termination?
- Picat inserts an automatic depth counter to cut off recursion.
- The tabling system converts mutual recursion into a single non-recursive predicate.
- An exception is raised for mutual recursion in tabled predicates.
- The iterative fixpoint computation detects when no new answers are added and halts. (Correct answer)
Correct answer: The iterative fixpoint computation detects when no new answers are added and halts.
Picat's tabling uses iterative fixpoint evaluation: it repeats evaluation rounds until the answer set stops growing, guaranteeing termination for finite models.
Question 124: In Picat's imperative mode, what does `X @= Y` mean?
- There is no @= operator in Picat
- X is element-wise equal to array Y
- X is assigned the value of Y only if X is unbound (Correct answer)
- X is unified with Y using occurs check
Correct answer: X is assigned the value of Y only if X is unbound
The @= operator in Picat assigns Y to X only when X is an unbound (free) variable, leaving it unchanged otherwise.
Question 125: Which `string` module function splits a string by a delimiter character?
- partition/2
- explode/2
- split/2 (Correct answer)
- tokenize/2
Correct answer: split/2
`split/2` takes a string and a delimiter string, returning a list of substrings.
Question 126: Of the following, which one is NOT a fruit?
- Peppers
- Corn
- Tomatoes
- Carrots (Correct answer)
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 127: Which element is the most abundant in Earth's atmosphere?
- Carbon dioxide
- Nitrogen (Correct answer)
- Oxygen
- Argon
Correct answer: Nitrogen
Nitrogen (Nā) makes up approximately 78% of Earth's atmosphere by volume.
Question 128: Which Picat module provides common list operations such as `append` and `member`?
- lists (Correct answer)
- stdlib
- util
- basic
Correct answer: lists
The `lists` module in Picat supplies standard list predicates including append/3, member/2, and related utilities.
Question 129: The word ADHERE most nearly means:
- collapse
- wander
- separate
- stick (Correct answer)
Correct answer: stick
Adhere means to stick firmly to a surface or substance, or to follow a rule or belief closely.
Question 130: The word TEDIOUS most nearly means:
- dangerous
- boring (Correct answer)
- creative
- exciting
Correct answer: boring
Tedious means too long, slow, or dull; tiresome and monotonous.
Question 131: What does `spy(Predicate)` do in Picat?
- Prevents a predicate from backtracking
- Monitors memory allocation
- Sets a breakpoint on a specific predicate (Correct answer)
- Logs all calls to a log file
Correct answer: Sets a breakpoint on a specific predicate
`spy(Predicate)` sets a spy point so the debugger activates only when that predicate is called.
Question 132: Which of the following is a valid way to call a Picat predicate `greet(Name)`?
- print(greet("Alice"))
- greet("Alice") (Correct answer)
- X = greet("Alice")
- Z is greet("Alice")
Correct answer: greet("Alice")
Predicates are called as statements; they do not return values and cannot appear inside expressions.
Question 133: The word BENEVOLENT most nearly means:
- strict
- jealous
- kind (Correct answer)
- hostile
Correct answer: kind
Benevolent means well-meaning and kindly disposed toward others.
Question 134: How many elements does [X : X in 1..5, Y in 1..5, X =:= Y] produce in Picat?
- 10 (each matching pair is counted twice due to symmetry)
- 5 (one element for each pair where X equals Y) (Correct answer)
- 0 (X and Y are distinct variables so =:= always fails)
- 25 (one element per combination in the Cartesian product)
Correct answer: 5 (one element for each pair where X equals Y)
For each value of X in 1..5, only the matching Y satisfies X =:= Y, so the five diagonal pairs (1,1),(2,2),(3,3),(4,4),(5,5) each contribute one X value, giving [1,2,3,4,5].
Question 135: Which `util` module function returns the minimum value in a list?
- min_list/1 (Correct answer)
- least/1
- min/1
- first_sorted/1
Correct answer: min_list/1
`min_list/1` returns the smallest element of a numerical list, symmetric to `max_list/1`.
Question 136: What is the primary cause of Earth's seasons?
- The Moon's gravitational pull
- The tilt of Earth's axis (Correct answer)
- Earth's varying distance from the Sun
- Changes in the Sun's energy output
Correct answer: The tilt of Earth's axis
Earth's 23.5° axial tilt causes different hemispheres to receive more direct sunlight at different times of year, creating seasons.
Question 137: How do you close a file stream after I/O operations in Picat?
- fclose(Stream)
- stream_close(Stream)
- close(Stream) (Correct answer)
- end_stream(Stream)
Correct answer: close(Stream)
`close(Stream)` closes an open file stream, freeing the associated resources.
Question 138: Which two components make up the formal binomial nomenclature (or scientific name) of a living organism?
- Genus and Species (Correct answer)
- Class and Family
- Family and Species
- Order and Class
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 139: Which solve option in Picat CP enables randomized restarts to escape local search traps?
- [random]
- [shuffle]
- [rand_val] (Correct answer)
- [restart]
Correct answer: [rand_val]
`rand_val` is a value-selection heuristic that picks values randomly, helping escape symmetric or structured dead ends.
Question 140: How does Picat handle arithmetic evaluation ā must you use a special operator?
- Yes, use X = Y evaluates; without it, expressions remain unevaluated terms (Correct answer)
- Use eval(Expr, Result) for all arithmetic
- Arithmetic is always lazy and evaluated on demand
- No, = automatically evaluates arithmetic
Correct answer: Yes, use X = Y evaluates; without it, expressions remain unevaluated terms
In Picat, `X = Expr` evaluates arithmetic when Expr contains numeric operations, but unlike Prolog you do not need a separate `is` operator ā the = operator evaluates arithmetic expressions automatically.
Question 141: A developer is using Picat's planner module to find a path in a maze. There are multiple paths from the start to the goal, with costs of 12, 15, and 18. The developer uses the call `plan(StartState, 20, Plan, Cost)`. Which of the following outcomes is guaranteed?
- The planner will find one of the valid paths, but not necessarily the one with the cost of 12. (Correct answer)
- The planner will fail because an optimal plan was not explicitly requested.
- The planner will find all possible paths with a cost less than or equal to 20.
- The planner will deterministically find the path with the cost of 12.
Correct answer: The planner will find one of the valid paths, but not necessarily the one with the cost of 12.
The `plan/4` predicate performs a resource-bounded search. It finds a plan that can transform the initial state to a final state with a cost that does not exceed the given limit. However, it does not guarantee optimality. It will succeed with the first valid plan it discovers that meets the cost constraint, which may or may not be the shortest path.
Question 142: Which of the following Picat operators is used for destructive assignment of a value to a variable within an imperative loop?
- := (Correct answer)
- =>
- ==
- =
Correct answer: :=
In Picat, the `:=` operator is specifically used for imperative-style destructive assignment, where the value of a variable is updated. The `=` operator is used for unification, `==` is for structural equality testing, and `=>` is part of a rule definition.
Question 143: Which predicate in Picat's CP module finds a solution that minimizes a given objective expression?
- optimal(Vars, Obj)
- solve([min(Obj)], Vars) (Correct answer)
- minimize(Obj, Vars)
- solve_min(Vars, Obj)
Correct answer: solve([min(Obj)], Vars)
Passing `min(Obj)` as a solve option instructs the CP solver to use branch-and-bound to minimize the objective Obj.
Question 144: Which built-in activates Picat's execution tracer for debugging?
- debug()
- trace (Correct answer)
- spy_all
- set_trace(on)
Correct answer: trace
`trace` activates the Picat tracer, printing each goal as it is called, exited, or failed.
Question 145: What does `f(a, b, c) =.. L` bind L to in Picat?
- f([a, b, c])
- [f, a, b, c] (Correct answer)
- [a, b, c]
- (f, a, b, c)
Correct answer: [f, a, b, c]
The univ operator produces a list whose head is the functor and whose tail is the argument list: `[f, a, b, c]`.
Question 146: In Picat, which syntax is used to define a function with multiple return clauses including a default case?
- Picat only allows one clause per function
- Use `switch` with `case` labels
- Write multiple `= Expr` clauses with pattern matching or guards, ending with a catch-all (Correct answer)
- Use `if-then-else` inside a single `=>` clause
Correct answer: Write multiple `= Expr` clauses with pattern matching or guards, ending with a catch-all
Multiple function clauses with patterns or guards are the idiomatic way to handle multiple cases.
Question 147: In the Picat `io` module, what does `writef/2` do?
- Writes a list of terms to a file
- Writes a float with fixed precision
- Writes formatted output using a format string (Correct answer)
- Writes with full quoting enabled
Correct answer: Writes formatted output using a format string
`writef/2` takes a format string and a list of arguments, printing formatted output similar to `printf`.
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