PiCAT (Pre-screening Internet-delivered Computerized Adaptive Test) — Questions and Answers
Question 1: 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 2: Can the result of a Picat list comprehension be used as the source list in another comprehension?
- Only when tabling mode is enabled for the predicate
- No, comprehensions cannot be nested and cause a compile error
- Yes, a comprehension evaluates to a plain list and can serve as the generator in an outer comprehension (Correct answer)
- Only if the inner comprehension uses a numeric range generator
Correct answer: Yes, a comprehension evaluates to a plain list and can serve as the generator in an outer comprehension
A Picat list comprehension evaluates eagerly to an ordinary list, so it can appear wherever a list is expected, including as the generator source in another comprehension.
Question 3: What is a potential pitfall when using global variables inside a tabled Picat predicate?
- Tabling automatically resets global variables on each reuse.
- Global variable side effects are not captured in the table, so replayed answers may reflect stale or incorrect state. (Correct answer)
- Global variables are forbidden inside tabled predicates.
- Global variables cause tabling to store extra state, increasing memory use.
Correct answer: Global variable side effects are not captured in the table, so replayed answers may reflect stale or incorrect state.
Tabling only caches logical outputs; if the predicate relies on or modifies global state, cached replays won't re-execute that state change.
Question 4: Which two components make up the formal binomial nomenclature (or scientific name) of a living organism?
- Class and Family
- Family and Species
- Order and Class
- 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 5: How many chambers does the human heart have?
- 3
- 2
- 6
- 4 (Correct answer)
Correct answer: 4
The human heart has four chambers: the left and right atria and the left and right ventricles.
Question 6: What type of rock is formed when magma cools and solidifies?
- Sedimentary
- Limestone
- Igneous (Correct answer)
- Metamorphic
Correct answer: Igneous
Igneous rock forms from the cooling and crystallization of molten rock (magma or lava).
Question 7: The word VALIDATE most nearly means:
- confirm (Correct answer)
- reject
- delay
- ignore
Correct answer: confirm
Validate means to demonstrate or support the truth or value of something; to confirm.
Question 8: How does Picat's tabling differ from standard Prolog memoization libraries?
- It only works for functions, not predicates
- It requires explicit hash maps managed by the programmer
- It caches only ground answers
- 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 9: Which organelle is responsible for producing most of the energy (ATP) in a cell?
- Golgi apparatus
- Ribosome
- Nucleus
- Mitochondria (Correct answer)
Correct answer: Mitochondria
Mitochondria generate ATP through cellular respiration and are often called the powerhouse of the cell.
Question 10: What does `compound(hello)` evaluate to in Picat?
- true
- Error
- Depends on how hello is declared
- false (Correct answer)
Correct answer: false
`compound/1` fails for atoms like `hello` — a compound term must have a functor and at least one argument.
Question 11: In the Picat `util` module, what does `max_list/1` return?
- The maximum element in the list (Correct answer)
- The sum of all elements
- The length of the list
- The last element of the list
Correct answer: The maximum element in the list
`max_list/1` traverses the list and returns the largest numerical element.
Question 12: Starting from which index do Picat arrays begin?
- Depends on the declaration
- -1
- 1 (Correct answer)
- 0
Correct answer: 1
Picat arrays are 1-indexed by default, so the first element is at index 1.
Question 13: How many degrees does water go from its boiling point to its freezing point on a Celsius thermometer?
- 212 degrees
- 180 degrees
- 32 degrees
- 100 degrees (Correct answer)
Correct answer: 100 degrees
On the Celsius temperature scale, the freezing point of water is defined as 0 degrees Celsius (°C) at standard atmospheric pressure. The boiling point of water is defined as 100 degrees Celsius (°C) under the same conditions. Therefore, the temperature difference between water's boiling point and freezing point on a Celsius thermometer is exactly 100 degrees.
Question 14: The word OBSTINATE most nearly means:
- talented
- flexible
- stubborn (Correct answer)
- nervous
Correct answer: stubborn
Obstinate means stubbornly refusing to change one's opinion or course of action.
Question 15: What phenomenon causes ocean tides on Earth?
- Solar wind pressure
- Gravitational pull of the Moon (Correct answer)
- Earth's rotation speed
- Atmospheric pressure changes
Correct answer: Gravitational pull of the Moon
The Moon's gravitational force pulls on Earth's oceans, creating bulges that produce high tides on the side facing the Moon and the opposite side.
Question 16: Which Picat pattern correctly matches a list with exactly two elements?
- [X, Y] (Correct answer)
- [X, Y | _]
- [X | Y]
- [X | [Y | []]]
Correct answer: [X, Y]
`[X, Y]` matches a list of exactly two elements, binding X to the first and Y to the second.
Question 17: What is the difference between Picat's `table` and a hand-written assert/retract memoization pattern in Prolog?
- assert/retract is faster because it uses native memory.
- `table` is declarative and automatically managed, while assert/retract requires manual cache management. (Correct answer)
- `table` only works for deterministic predicates, while assert/retract works for all predicates.
- There is no practical difference; both are equally automatic.
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 18: What distinguishes a Picat `function` (using = in the head) from a `predicate`?
- Functions are compiled to C; predicates are interpreted
- Functions use backtracking; predicates do not
- A function must return exactly one value via the last argument position, while a predicate succeeds or fails (Correct answer)
- There is no distinction — they compile identically
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 19: What are the two user-defined predicates that the Picat planner module requires?
- action/4 and final/1 (Correct answer)
- move/3 and goal/1
- transition/2 and done/1
- step/4 and terminal/2
Correct answer: action/4 and final/1
The planner requires `action(State, NextState, Action, Cost)` and `final(State)` to be defined by the user.
Question 20: What is the process by which a solid changes directly into a gas without passing through the liquid phase?
- Evaporation
- Deposition
- Sublimation (Correct answer)
- Condensation
Correct answer: Sublimation
Sublimation occurs when a solid converts directly to a gas; dry ice (solid CO₂) is a common example.
Question 21: Which keyword in Picat is used to import a module at the top of a file?
- use_module
- import (Correct answer)
- require
- include
Correct answer: import
The `import` declaration at the top of a Picat file makes predicates from a named module available in the current file.
Question 22: What is the length of the list produced by [X : X in 1..10, X mod 3 =:= 0] in Picat?
- 10
- 3 (Correct answer)
- 4
- 33
Correct answer: 3
Multiples of 3 from 1 to 10 are 3, 6, and 9 — exactly 3 values — so len([X : X in 1..10, X mod 3 =:= 0]) equals 3.
Question 23: 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 24: The word TENACIOUS most nearly means:
- timid
- persistent (Correct answer)
- fragile
- forgetful
Correct answer: persistent
Tenacious means holding firmly to something; not giving up easily; persistent.
Question 25: 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 26: The word SUBDUE most nearly means:
- overcome (Correct answer)
- excite
- question
- release
Correct answer: overcome
Subdue means to overcome, quieten, or bring under control by force or persuasion.
Question 27: What is the output of `writeln(2 ** 10)` in Picat?
- 1024.0
- 1024 (Correct answer)
- 20
- 210
Correct answer: 1024
The `**` operator in Picat performs integer exponentiation when both operands are integers, so 2**10 evaluates to 1024.
Question 28: They're expecting for *realistic* advancements.
- Speedy
- Real (Correct answer)
- Long lasting
- Subtle
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 29: Newton's Third Law of Motion states that for every action there is:
- A greater reaction in the opposite direction
- No reaction in a vacuum
- A proportional reaction in the same direction
- An equal and opposite reaction (Correct answer)
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 30: What does it mean when Picat documentation says a predicate is `det` (deterministic)?
- The predicate uses tail recursion
- The predicate is defined using `=` instead of `=>`
- The predicate runs in constant time
- The predicate always succeeds exactly once without leaving a choice point (Correct answer)
Correct answer: The predicate always succeeds exactly once without leaving a choice point
A `det` predicate succeeds exactly once and leaves no choice points, behaving predictably like a function call.
Question 31: The word COHERENT most nearly means:
- silent
- scattered
- logical (Correct answer)
- angry
Correct answer: logical
Coherent means logical and consistent; forming a unified whole that is easy to understand.
Question 32: When modeling the N-Queens problem in Picat CP, which two all_different constraints are typically combined?
- all_different on rows and all_different on columns
- all_different on columns and all_different on diagonals
- all_different on diagonals and all_different on rows
- all_different on column positions and all_different on both diagonals (Correct answer)
Correct answer: all_different on column positions and all_different on both diagonals
Queens must differ in column positions and on both the positive and negative diagonals, requiring three all_different constraints in total.
Question 33: What is the Picat equivalent of a C-style `for(i=0; i<n; i++)` loop?
- for I := 0 to n-1 do ... end
- while I < n do I := I + 1 end
- loop I from 0 to n-1 do ... end
- foreach(I in 0..n-1) (Correct answer)
Correct answer: foreach(I in 0..n-1)
Picat uses `foreach(I in 0..n-1)` to iterate over a range, equivalent to C's for loop from 0 to n-1.
Question 34: In a `best_plan` search, what happens when two plans have the same total cost?
- It returns both plans via backtracking
- It raises an ambiguity error
- The planner returns whichever it finds first during its search (Correct answer)
- It always returns the shorter plan
Correct answer: The planner returns whichever it finds first during its search
The planner returns the first optimal-cost plan it discovers; tie-breaking among equal-cost plans is not specified and depends on search order.
Question 35: The word BENEVOLENT most nearly means:
- jealous
- kind (Correct answer)
- strict
- hostile
Correct answer: kind
Benevolent means well-meaning and kindly disposed toward others.
Question 36: Given `double(X) = 2 * X`, what does `Y = double(5) + double(3)` evaluate to?
- Y = 10
- Y = 16 (Correct answer)
- A syntax error is raised
- Y = 6
Correct answer: Y = 16
`double(5)` returns 10 and `double(3)` returns 6, so `Y = 16`.
Question 37: In the Picat `maps` module, which predicate creates a new empty map?
- new_map/1 (Correct answer)
- {}
- maps:empty/1
- maps:new/1
Correct answer: new_map/1
`new_map/1` binds a variable to a fresh, empty map data structure in Picat.
Question 38: In Picat, what does `_` (underscore) guarantee about variable binding?
- It only matches atoms
- It must match an uninstantiated variable
- It matches any value and is never bound, even if it appears multiple times (Correct answer)
- It binds to the first value it sees and reuses that binding
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 39: How does Picat handle a call to a function for which no pattern-matching rule applies?
- 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.
- The call enters an infinite loop.
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 40: In Picat's imperative mode, what does `X @= Y` mean?
- X is element-wise equal to array Y
- There is no @= operator in Picat
- 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 41: Friendly most of the time
- Friendly (Correct answer)
- Stern
- Disgruntled
- Shy
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 42: 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:read_file_to_string("config.txt") (Correct answer)
- io:read_file("config.txt")
- io:read_all("config.txt")
- io:get_file_contents("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 43: What is the pH value of a neutral solution at room temperature?
- 0
- 5
- 7 (Correct answer)
- 14
Correct answer: 7
Pure water and neutral solutions have a pH of 7, where hydrogen and hydroxide ion concentrations are equal.
Question 44: You are designing a system to represent a simple family tree. You need to store a person's name, year of birth, and a list of their children (who are also people). Which data structure is most idiomatic and efficient for representing a single person with these fixed fields?
- An array
- A map where keys are `"name"`, `"yob"`, and `"children"`
- A list like `[Name, YearOfBirth, ChildrenList]`
- A structure like `$person(Name, YearOfBirth, ChildrenList)` (Correct answer)
Correct answer: A structure like `$person(Name, YearOfBirth, ChildrenList)`
A structure (or compound term) is the most idiomatic and efficient choice in Picat for representing a fixed set of related data fields like a record. It provides a clear, named representation (`person`) and allows for efficient access to its components through unification. The dollar sign `$` is required to distinguish the structure from a function call.
Question 45: In Picat tabling, what happens when a tabled predicate is called with arguments it has already been called with?
- An exception is raised to prevent duplicate calls.
- The predicate body is re-executed to verify consistency.
- The stored result is returned without re-executing the predicate body. (Correct answer)
- 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 46: A vector can be used to represent force. A vector is indicative of
- Direction
- Magnitude and Direction (Correct answer)
- Magnitude
- 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 47: Any celestial body revolving around a massive body is referred to as
- Chemical
- Carbon atoms
- Thread
- A satellite (Correct answer)
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 48: What is the basic unit of heredity that carries genetic information?
- Chromosome
- Nucleus
- Gene (Correct answer)
- Protein
Correct answer: Gene
A gene is a specific sequence of DNA that codes for a particular trait or protein.
Question 49: In Picat, what happens when you use `=` to match a pattern inside a rule body rather than in the head?
- It performs unification at that point in execution, failing if patterns don't match (Correct answer)
- It is equivalent to `==` for comparison only
- It assigns a new value, overwriting the old binding
- It always succeeds and returns true
Correct answer: It performs unification at that point in execution, failing if patterns don't match
The `=` operator in Picat's body is unification — it tries to make both sides identical and throws an error if it fails.
Question 50: Which Picat operator is used to check structural equality without performing unification?
- :=
- =
- == (Correct answer)
- =..
Correct answer: ==
The == operator tests if two terms are identical in structure and variable bindings without unifying them.
Question 51: Which `util` module predicate removes duplicate elements from a list while preserving order?
- remove_dups/2 (Correct answer)
- list_to_set/2
- dedupe/2
- unique/2
Correct answer: remove_dups/2
`remove_dups/2` removes duplicate elements from the list while keeping the first occurrence of each element.
Question 52: What happens when no pattern in a Picat function definition matches the given arguments?
- A runtime exception is thrown (Correct answer)
- The function returns `none`
- The program silently succeeds
- The last clause always matches as a fallback
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 53: What term describes organisms that can produce their own food using sunlight?
- Autotrophs (Correct answer)
- Heterotrophs
- Decomposers
- Omnivores
Correct answer: Autotrophs
Autotrophs, such as plants and algae, use photosynthesis to convert sunlight and CO₂ into glucose.
Question 54: In a Picat function, what happens if execution reaches the end of the body without a `return`?
- The function returns the last evaluated expression (Correct answer)
- An error is raised
- The function implicitly returns true
- The function returns a free (unbound) variable
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 55: Watts serve as a measuring unit for
- Energy
- Speed
- Power (Correct answer)
- 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 56: What situation does `existence_error(procedure, F/A)` represent in Picat?
- A predicate F/A that is not defined (Correct answer)
- A predicate called with wrong arity
- A file that could not be found
- A module that was not loaded
Correct answer: A predicate F/A that is not defined
`existence_error(procedure, F/A)` is thrown when the predicate F with arity A is not defined in the program.
Question 57: In Picat, which of the following correctly swaps the values of two mutable variables A and B?
- A <=> B
- Tmp := A, A := B, B := Tmp (Correct answer)
- swap(A, B)
- A := B, B := A
Correct answer: Tmp := A, A := B, B := Tmp
A temporary variable must hold one value during the swap; the naive two-step assignment would lose A's original value.
Question 58: Which built-in feature of Picat allows a predicate to behave like a function when exactly one solution is needed?
- `forall(Goal)`
- `freeze(Goal)`
- `once(Goal)` (Correct answer)
- `assert(Goal)`
Correct answer: `once(Goal)`
`once/1` commits to the first solution of a nondeterministic predicate, discarding remaining choice points.
Question 59: Consider the following Picat code. What value will be printed to the console? main => S = 0, foreach (X in [10, 5, 3]) S := S + X end, println(S).
- 0
- 18 (Correct answer)
- 15
- 3
Correct answer: 18
The `foreach` loop iterates through each element of the list `[10, 5, 3]`. The variable `S` is initialized to 0. In each iteration, the current element `X` is added to `S`. The calculation proceeds as: `0 + 10 = 10`, then `10 + 5 = 15`, and finally `15 + 3 = 18`. The final value, 18, is printed.
Question 60: Which word most closely resembles the definition of CURIOUS?
- Inquisitive (Correct answer)
- Dexterity
- Serenity
- Infatuation
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 61: 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 #/ S2 + D2 #=< S1` (Correct answer)
- `S1 + D1 #< S2 + D2`
- `S1 + D1 #!= S2`
- `alldifferent([S1, D1, S2, D2])`
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 62: Which system does the catalytic converter belong to?
- Chemical
- Standard transmission
- Frequency
- Emission control system (Correct answer)
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 63: Which Picat construct provides a `do ... while` style loop that tests the condition at the end?
- do ... while Cond end
- repeat ... until Cond end
- loop ... end Cond
- Picat has no post-condition loop construct (Correct answer)
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 64: 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 65: What does `bp.pred_name(Args)` syntax allow in Picat?
- Calling a B-Prolog built-in predicate not natively exposed in Picat (Correct answer)
- Accessing a byte-code primitive
- Bypassing type checking for performance
- Calling a C foreign function
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 66: Honorable most nearly
- Condemn
- Discriminate
- Trust
- 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 67: Which Picat built-in decomposes a compound term into its functor and arguments?
- decompose/2
- split/3
- =../2 (univ) only
- functor/3 and arg/3 (Correct answer)
Correct answer: functor/3 and arg/3
functor(T, F, A) extracts functor F and arity A, while arg(N, T, Arg) extracts the Nth argument of T.
Question 68: The word AMBIGUOUS most nearly means:
- simple
- unclear (Correct answer)
- definite
- honest
Correct answer: unclear
Ambiguous means open to more than one interpretation; not having one obvious meaning.
Question 69: In a Picat `if-then-else` expression, what is required if the else branch is omitted?
- The condition must always be true
- Omitting else is a syntax error in function mode (Correct answer)
- An implicit else true is added
- The if expression returns a free variable on failure
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 70: Which pattern in Picat uses an anonymous variable to ignore a list element?
- [*, X | *]
- [any, X | any]
- [_, X | _] (Correct answer)
- [nil, X | nil]
Correct answer: [_, X | _]
The underscore `_` is Picat's anonymous variable that matches any value without binding it.
Question 71: Silicon chips are mostly utilized in
- amplifier
- carbon atoms
- suspension
- 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 72: When two forces act against each other on an item, the resulting force is
- the ratio of the two forces
- the product of the two forces
- the sum of the two forces
- the difference between the two forces (Correct answer)
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 73: What is the SI unit of electrical resistance?
- Ampere
- Ohm (Correct answer)
- Volt
- Watt
Correct answer: Ohm
The ohm (Ω) measures electrical resistance and is named after physicist Georg Simon Ohm.
Question 74: What does sort([X : X in [3,1,4,1,5,9,2,6]]) produce in Picat?
- [9, 6, 5, 4, 3, 2, 1]
- [3, 1, 4, 1, 5, 9, 2, 6]
- [1, 1, 2, 3, 4, 5, 6, 9]
- [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 75: How do you raise an exception in Picat?
- exception(Error)
- raise(Error)
- throw(Error) (Correct answer)
- error(Error)
Correct answer: throw(Error)
`throw(Error)` raises an exception carrying the given error term in Picat.
Question 76: What is the arity of the Picat term `foo(a)`?
- 2
- 0
- foo
- 1 (Correct answer)
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 77: What does `plan_unbounded/2` do differently from `plan/2`?
- It uses breadth-first search exclusively
- It runs on a separate thread
- It returns all possible plans instead of just one
- It searches without any cost bound, potentially exploring all reachable states (Correct answer)
Correct answer: It searches without any cost bound, potentially exploring all reachable states
`plan_unbounded/2` imposes no upper cost limit on the search, whereas `plan/2` uses iterative deepening with increasing cost bounds.
Question 78: The phrase "all the organisms living in a particular place and their interactions with each other and their environment" defines which of the following terms?
- Community
- Habitat
- Ecosystem (Correct answer)
- Population
Correct answer: Ecosystem
An ecosystem encompasses all the living organisms (biotic components) in a specific area, along with their interactions with each other and with the non-living physical and chemical factors (abiotic components) of their environment. This definition highlights the interconnectedness of life and its surroundings. A population is a group of the same species, a habitat is where an organism lives, and a community is just the interacting populations of different species.
Question 79: In Picat CP, what does the `among/4` global constraint enforce?
- That a value appears at most High times across all variables
- That between Low and High variables in a list take values from a given set (Correct answer)
- That a variable lies within a given interval
- That exactly N variables in a list are equal to each other
Correct answer: That between Low and High variables in a list take values from a given set
`among(Low, High, Vars, Values)` constrains that the number of variables in Vars whose values belong to Values is between Low and High.
Question 80: What search strategy does `[up]` specify when passed to `solve` in Picat's CP module?
- Orders variables by ascending domain size before labeling
- Assigns values starting from the upper bound of each variable's domain
- Performs search upward through the constraint hierarchy
- 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 81: Which of the following is a valid way to call a Picat predicate `greet(Name)`?
- X = greet("Alice")
- Z is greet("Alice")
- print(greet("Alice"))
- greet("Alice") (Correct answer)
Correct answer: greet("Alice")
Predicates are called as statements; they do not return values and cannot appear inside expressions.
Question 82: What is the chemical symbol for sodium?
- Na (Correct answer)
- Ni
- So
- Sd
Correct answer: Na
Sodium's symbol Na comes from the Latin word 'Natrium.'
Question 83: How do you obtain the length of a string in Picat?
- size(S)
- length(S) (Correct answer)
- string_length(S)
- len(S)
Correct answer: length(S)
`length(S)` returns the number of elements in a list or characters in a string since strings are lists.
Question 84: In Picat, what is the result of executing `X := 5, X := X + 1`?
- X is bound to 5 permanently via unification
- X becomes 6 (Correct answer)
- A runtime error is thrown because X is already bound
- X becomes 5+1 as an unevaluated term
Correct answer: X becomes 6
The := operator allows reassignment, so X is first set to 5 and then updated to 6.
Question 85: The word VIGILANT most nearly means:
- sleepy
- watchful (Correct answer)
- courageous
- reckless
Correct answer: watchful
Vigilant means keeping careful watch for possible danger or difficulties.
Question 86: In the Picat `lists` module, what does `flatten/2` do?
- Sorts a nested list
- Converts a nested list into a flat list (Correct answer)
- Reverses a list
- Removes duplicates from a list
Correct answer: Converts a nested list into a flat list
`flatten/2` recursively removes nesting from a list, producing a flat single-level list.
Question 87: Which function converts a number to its string representation in Picat?
- str(N)
- num_string(N)
- number_to_string(N)
- to_string(N) (Correct answer)
Correct answer: to_string(N)
`to_string(N)` converts any Picat term, including numbers, to its string representation.
Question 88: Which built-in in Picat CP is used to obtain the current lower bound of a variable's domain?
- lo(Var)
- domain_min(Var, Lo)
- fd_min(Var, Lo) (Correct answer)
- min_domain(Var, Lo)
Correct answer: fd_min(Var, Lo)
`fd_min(Var, Lo)` unifies Lo with the minimum value currently in Var's finite domain.
Question 89: The word TEDIOUS most nearly means:
- boring (Correct answer)
- exciting
- dangerous
- creative
Correct answer: boring
Tedious means too long, slow, or dull; tiresome and monotonous.
Question 90: In Picat, what does the `@` symbol signify when used in a term like `[H|T]@List`?
- It marks a lazy evaluation thunk
- It is not standard syntax; Picat uses [H|T] without @
- It represents string concatenation
- It aliases the whole list to List while also destructuring (Correct answer)
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 91: Picat functions can be higher-order. Which call correctly applies function `F` to value `X` and uses the result?
- Result = call(F, X) (Correct answer)
- Result = F.apply(X)
- call(F, X, Result)
- Result = apply(F, 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 92: What does it mean for a tabled predicate in Picat to have reached a 'fixpoint'?
- The predicate body has been fully unfolded without recursion.
- The recursion depth equals the number of table entries.
- The predicate has been called exactly as many times as it has answers.
- No new answers are generated by further evaluation; the table is complete. (Correct answer)
Correct answer: No new answers are generated by further evaluation; the table is complete.
Fixpoint means iterative tabled evaluation has stabilized: another pass adds no new answers.
Question 93: Which predicate reads a single character from an open stream in Picat?
- get_char(Stream, Char) (Correct answer)
- char_read(Char)
- read_char(Stream, Char)
- input_char(Char)
Correct answer: get_char(Stream, Char)
`get_char(Stream, Char)` reads one character from the stream and unifies Char with the character atom.
Question 94: Which predicate in Picat's `io` module reads a single character from standard input?
- read_char/1
- char_read/1
- read/1
- get_char/1 (Correct answer)
Correct answer: get_char/1
`get_char/1` reads the next character from the current input stream and unifies it with its argument.
Question 95: Which Picat built-in computes the length of a list?
- length(List, Len) (Correct answer)
- count(List, Len)
- size(List)
- list_length(List)
Correct answer: length(List, Len)
`length(List, Len)` unifies Len with the number of elements in List, and can also generate a list of free variables when Len is given.
Question 96: Which Picat predicate retrieves all solutions of a goal as a list?
- collect(Goal, List)
- bagof(Template, Goal, List)
- all_solutions(Goal, List)
- findall(Template, Goal, List) (Correct answer)
Correct answer: findall(Template, Goal, List)
`findall/3` collects every Template instantiation for which Goal succeeds into List, returning [] if Goal always fails.
Question 97: In Picat, what happens when unification of two terms fails during pattern matching in a clause head?
- The variable is bound to a default value
- Picat backtracks and tries the next matching clause (Correct answer)
- The predicate succeeds with a partial match
- The program throws a runtime exception
Correct answer: Picat backtracks and tries the next matching clause
When a clause head fails to unify with the call, Picat backtracks and attempts the next clause whose head can unify.
Question 98: What is the effect of placing the `table` declaration after the predicate clauses in Picat?
- It causes a compilation error or warning because `table` must precede the predicate clauses. (Correct answer)
- The declaration is silently ignored.
- Tabling is still applied but only to the last clause.
- Tabling is applied retroactively to all prior calls.
Correct answer: It causes a compilation error or warning because `table` must precede the predicate clauses.
In Picat, `table` must appear before the predicate definition; placing it after leads to an error.
Question 99: What happens when `plan/2` cannot find any plan from the given initial state?
- It throws an exception
- The call fails (Correct answer)
- It enters an infinite loop
- It returns an empty list
Correct answer: The call fails
Like most Picat predicates, `plan/2` simply fails (backtracks) when no plan exists rather than throwing an error.
Question 100: Why does Picat distinguish between pattern matching in rule heads and explicit unification (`=`), a feature that makes it different from traditional Prolog?
- To eliminate the need for the occurs check, which is computationally expensive.
- To allow for overloading of the `=` operator for different data types.
- To enforce a functional programming style where rule heads cannot modify arguments.
- To improve performance and scalability by facilitating better indexing of rules, as pattern matching is simpler than full unification. (Correct answer)
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 101: The word ANTAGONIZE most nearly means:
- follow
- support
- provoke (Correct answer)
- admire
Correct answer: provoke
Antagonize means to cause someone to become hostile; to irritate or provoke.
Question 102: The word DEPLETE most nearly means:
- increase
- preserve
- collect
- exhaust (Correct answer)
Correct answer: exhaust
Deplete means to use up the supply or resources of something.
Question 103: What does the `once/1` built-in do in Picat?
- Runs a goal in a separate thread
- Runs a goal and commits to its first solution, discarding other choice points (Correct answer)
- Runs a goal once and fails if it has no solutions
- Repeats a goal until failure
Correct answer: Runs a goal and commits to its first solution, discarding other choice points
once(Goal) succeeds at most once: it runs Goal and keeps only the first solution, cutting away alternatives.
Question 104: What is the effect of giving an overly tight Limit value in `plan/3`?
- It returns a partial plan up to the limit
- plan/3 fails even though a valid plan exists beyond the limit (Correct answer)
- It automatically increases the limit and retries
- It throws a resource_exceeded exception
Correct answer: plan/3 fails even though a valid plan exists beyond the limit
If every valid plan costs more than Limit, `plan/3` fails because no solution satisfies the bound — it does not relax the limit automatically.
Question 105: In Picat logic predicates, what is the purpose of `call/1` or `call/N`?
- Evaluates an arithmetic expression
- Defines a new predicate dynamically
- Imports a module
- Calls a goal stored in a variable at runtime (meta-call) (Correct answer)
Correct answer: Calls a goal stored in a variable at runtime (meta-call)
call/N allows a term held in a variable to be invoked as a goal, enabling higher-order programming.
Question 106: What is the role of the `module` declaration in a Picat source file?
- Sets the recursion limit
- Declares a constraint domain
- Defines a namespace for predicates and functions (Correct answer)
- Imports an external library
Correct answer: Defines a namespace for predicates and functions
A `module` declaration names the compilation unit and controls which predicates are exported as part of Picat's module system.
Question 107: The word ADHERE most nearly means:
- separate
- wander
- collapse
- 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 108: Which `best_plan` variant also enforces an upper bound on the search cost?
- best_plan/2 (best_plan(State, Plan))
- best_plan/1 (best_plan(State))
- best_plan/4 always ignores the limit
- best_plan/3 (best_plan(State, Limit, Plan)) (Correct answer)
Correct answer: best_plan/3 (best_plan(State, Limit, Plan))
`best_plan/3` takes an explicit Limit argument and returns the cheapest plan whose cost does not exceed that limit.
Question 109: What is the purpose of the `table(+, +, min)` mode declaration in Picat?
- It memoizes the predicate, keeping only the answer with the minimum value for the last argument (Correct answer)
- It enables parallel evaluation across cores
- It sorts the tabled answers by the last column
- It restricts the predicate to accept only ground inputs
Correct answer: It memoizes the predicate, keeping only the answer with the minimum value for the last argument
Mode declarations like `table(+,+,min)` instruct the tabling engine to retain only the optimal (minimum) tabled result for each input combination, enabling dynamic-programming optimizations.
Question 110: 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?
- `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}`
- `domain([X, Y, Z], 1, 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 111: Of the following, which one is NOT a fruit?
- Peppers
- Carrots (Correct answer)
- Corn
- Tomatoes
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 112: What is the correct way to define a recursive Picat function `fact(N)` for the factorial of N?
- 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).
- fact(0) = 1. fact(N) = N * fact(N-1). (Correct answer)
Correct answer: fact(0) = 1. fact(N) = N * fact(N-1).
Recursive Picat functions use `=` and pattern-match across multiple clauses.
Question 113: In the Picat `math` module, what does `gcd(12, 8)` return?
- 2
- 8
- 6
- 4 (Correct answer)
Correct answer: 4
`gcd/2` computes the greatest common divisor, and the GCD of 12 and 8 is 4.
Question 114: Which statement best describes how Picat handles a predicate that is called but immediately fails?
- The runtime returns `false` as a value
- The predicate retries indefinitely
- Control backtracks to the most recent choice point or the call fails (Correct answer)
- An exception is raised automatically
Correct answer: Control backtracks to the most recent choice point or the call fails
A failing predicate causes backtracking; if no choice point exists, the enclosing goal fails.
Question 115: The word VAGUE most nearly means:
- specific
- unclear (Correct answer)
- detailed
- honest
Correct answer: unclear
Vague means not clearly expressed or defined; uncertain or indistinct.
Question 116: In Picat, which syntax is used to define a function with multiple return clauses including a default case?
- Write multiple `= Expr` clauses with pattern matching or guards, ending with a catch-all (Correct answer)
- Picat only allows one clause per function
- Use `if-then-else` inside a single `=>` clause
- Use `switch` with `case` labels
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 117: The word INEPT most nearly means:
- clumsy (Correct answer)
- brave
- honest
- skillful
Correct answer: clumsy
Inept means having or showing no skill; clumsy or incompetent.
Question 118: The word NOTORIOUS most nearly means:
- famous for something bad (Correct answer)
- generous
- unknown
- respected
Correct answer: famous for something bad
Notorious means famous or well-known, typically for some bad quality or deed.
Question 119: The programs' *permanent* underfunding
- Massive
- Severe
- Habitual (Correct answer)
- Temporary
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 120: 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 121: 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). ```
- general (Correct answer)
- The query fails.
- An error due to ambiguity.
- 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 122: 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?
- The call implicitly returns a `fail` atom.
- The program halts with an instantiation error.
- The call simply fails, and execution backtracks. (Correct answer)
- A syntax error is reported at compile time.
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 123: What is printed when you call `writeln(Plan)` after `plan(InitState, Plan)` succeeds with a three-step plan?
- A single action term
- A list with three elements, one per action (Correct answer)
- The integer 3
- The final goal state
Correct answer: A list with three elements, one per action
Plan is a list of action terms, so `writeln` outputs something like `[action1,action2,action3]` with one element per step.
Question 124: How does Picat's tabling handle a predicate that is called recursively before its result is fully computed (i.e., a loop)?
- It returns false for all looping calls.
- It falls back to standard Prolog-style depth-first search.
- It immediately raises a loop_detected exception.
- It uses iterative computation to accumulate answers incrementally until a fixpoint is reached. (Correct answer)
Correct answer: It uses iterative computation to accumulate answers incrementally until a fixpoint is reached.
Picat's tabling supports tabled logic programs with loops via iterative fixpoint computation.
Question 125: What does `f(a, b, c) =.. L` bind L to in Picat?
- (f, a, b, c)
- [a, b, c]
- f([a, b, c])
- [f, a, b, c] (Correct answer)
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 126: What does `spy(Predicate)` do in Picat?
- Prevents a predicate from backtracking
- Sets a breakpoint on a specific predicate (Correct answer)
- Logs all calls to a log file
- Monitors memory allocation
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 127: Ascorbic acid is referred to as
- Vitamin A (Correct answer)
- Vitamin C
- Vitamin B12
- Vitamin E
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 128: What is the correct way to break out of a `foreach` loop early in Picat?
- Throw and catch an exception
- Use the `break` keyword inside the loop
- Use a boolean flag variable with a while loop instead (Correct answer)
- Call `halt`
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 129: What does the pattern `{X, Y, Z}` match in Picat?
- A tuple with exactly three elements (Correct answer)
- A set containing X, Y, and Z
- A struct named tuple
- A list of three elements
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 130: What does `maps:get(Map, Key, Default)` do when the key is not found in the map?
- Returns an empty map
- Fails silently
- Returns Default (Correct answer)
- Throws an exception
Correct answer: Returns Default
The three-argument form of `maps:get/3` returns the Default value when the Key is absent from Map.
Question 131: What does [X*2 : X in [1,2,3], X > 1] produce in Picat?
- [4, 6] (Correct answer)
- [2, 6]
- [2, 4, 6]
- [1, 4, 6]
Correct answer: [4, 6]
The condition X > 1 excludes X=1, so only X=2 (producing 4) and X=3 (producing 6) pass the filter, giving [4, 6].
Question 132: What does [X : X in [a,b,c,d,e], X \= b, X \= d] produce in Picat?
- [a, c, e] (Correct answer)
- A syntax error because \= cannot appear in comprehension conditions
- [b, d]
- [a, b, c, d, e]
Correct answer: [a, c, e]
The two inequality conditions X \= b and X \= d both use structural non-unification, excluding the atoms b and d and leaving [a, c, e].
Question 133: How do you re-throw a caught exception from inside a handler in Picat?
- rethrow(Error)
- throw(Error) (Correct answer)
- raise(Error)
- re_throw(Error)
Correct answer: throw(Error)
You re-throw a caught exception using the same `throw(Error)` predicate inside the catch handler.
Question 134: Which construct catches exceptions in Picat?
- catch(Goal, Error, Handler) (Correct answer)
- on_error(Goal, Handler)
- exception(Goal, Handler)
- try-catch
Correct answer: catch(Goal, Error, Handler)
`catch(Goal, Error, Handler)` executes Goal and runs Handler if a matching exception is raised.
Question 135: 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 136: A Picat script needs to be executed from the command line with several arguments. How can the script access these arguments?
- By reading from the `io:stdin` stream
- By calling `sys:get_args()` (Correct answer)
- By accessing the built-in `ARGS` list
- By calling `os:get_cmd_args()`
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 137: In Picat, the body of a function clause and the body of a predicate clause share which feature?
- Both must end with a `return` statement
- Both can include goals, assignments, and conditionals (Correct answer)
- Both must be deterministic
- Both use `=>` to separate head from body
Correct answer: Both can include goals, assignments, and conditionals
Both function and predicate bodies are sequences of goals and can use the same control constructs.
Question 138: What does Picat's `to_string/1` function do that a predicate could not directly accomplish?
- It binds a variable through unification
- It returns a string value usable inline in expressions like `print(to_string(42) ++ "!")` (Correct answer)
- It asserts facts into the database
- It reads input from stdin
Correct answer: It returns a string value usable inline in expressions like `print(to_string(42) ++ "!")`
As a function, `to_string/1` returns a value immediately composable with operators like `++`.
Question 139: Approximately how long does it take Earth to complete one full orbit around the Sun?
- 400 days
- 28 days
- 365.25 days (Correct answer)
- 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 140: In Picat, which loop construct can serve as an alternative to tabling for simple iterative DP problems?
- foreach loops combined with arrays (Correct answer)
- while loops with assert/retract
- between/3 with cut
- findall/3 with sort
Correct answer: foreach loops combined with arrays
Picat's imperative foreach loops over arrays can implement iterative DP directly, avoiding recursive overhead.
Question 141: Consider `foo([H|T]) => write(H).` — what does H bind to when called as `foo([1,2,3])`?
- The entire list
- [1,2,3]
- 1 (Correct answer)
- [2,3]
Correct answer: 1
In the head pattern `[H|T]`, H binds to the first element (head) of the list, which is 1.
Question 142: What is the 'depth-first search' strategy in Picat's logic programming execution model?
- Picat fully explores one clause branch before trying alternatives (Correct answer)
- Picat tries all clauses simultaneously and returns the fastest
- Picat uses breadth-first search by default
- Picat uses a heuristic to choose the best clause
Correct answer: Picat fully explores one clause branch before trying alternatives
Picat (like Prolog) uses depth-first search: it commits to the first matching clause and explores it fully before backtracking to try alternatives.
Question 143: When is it more appropriate to use a predicate instead of a function in Picat?
- When you want to embed the call directly into a mathematical formula for conciseness.
- When the primary purpose is to check if a certain condition is true or false without returning a specific value. (Correct answer)
- When you need to perform a simple, deterministic calculation that returns a single value.
- When you want to guarantee that the operation will never fail and always produce a result.
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 144: How does Picat handle arithmetic evaluation — must you use a special operator?
- Arithmetic is always lazy and evaluated on demand
- Use eval(Expr, Result) for all arithmetic
- No, = automatically evaluates arithmetic
- Yes, use X = Y evaluates; without it, expressions remain unevaluated terms (Correct answer)
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 145: In Picat's `math` module, which predicate computes the base-10 logarithm?
- log/1
- log10/1 (Correct answer)
- ln/1
- lg/1
Correct answer: log10/1
`log10/1` computes the base-10 (common) logarithm, while `log/1` computes the natural logarithm.
Question 146: What does the `cumulative/4` global constraint model in Picat CP?
- Partitioning variables into groups of equal sum
- Sequencing tasks with deadlines on a single machine
- Enforcing monotonic ordering of a variable sequence
- Resource allocation where tasks use capacity over time (Correct answer)
Correct answer: Resource allocation where tasks use capacity over time
`cumulative(Starts, Durations, Resources, Limit)` ensures that at no point in time does the total resource consumption exceed Limit.
Question 147: Which operator tests value equality (not unification) in Picat's imperative code?
- =
- == (Correct answer)
- is
- =:=
Correct answer: ==
The == operator tests structural/value equality without binding variables, while = performs unification.
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