Admissible predicate on lazy lists 2026-10-31
A predicate on possibly partial lists is admissible when it holds at the limit of every increasing chain of finite approximations on which it holds. Increasing here means replacing a bottom value by more defined information while retaining already defined constructors and values. This closure condition permits a property established for finite approximations to pass to an infinite list. The predicate “the list is finite” lacks this closure: every finite prefix ending in an undefined tail is finite in extent, but their limit may have infinitely many constructors.
Automated deduction 2026-11-05
Automated deduction uses an algorithm to construct or check a mathematical proof from explicit assumptions and inference rules. The representation might use propositional logic, first-order logic or a specialized theory such as linear arithmetic. Soundness means the rules preserve truth; finding a proof additionally requires a search strategy.
For a small resolution example, the clauses , and yield and then the empty clause. This is a contradiction, so the original clauses cannot all hold. To prove a conclusion from assumptions, a refutation method adds its negation and searches for such a contradiction. In first-order logic, unification determines which terms can instantiate matching predicates. A procedure that eventually finds every valid proof need not terminate on every invalid claim: this distinction explains why proof search and proof checking have different computational costs.
Blocks world 2026-10-24
The blocks world is a classical planning model of movable blocks arranged in stacks on an unlimited table. Each block has one support, each block supports at most one other block, and the support relation has no directed cycle. A clear block can move onto another clear block or onto the table. In a direct-transfer STRIPS representation, an action includes the entire pickup-and-placement operation; a separate holding or empty-hand planning fluent is unnecessary unless the action model explicitly splits those operations.
The table has unlimited capacity, so its availability must not be deleted when a block is placed there. Planning state invariants connect the predicate describing a clear block to the absence of any block directly above it. Goal interaction in planning makes this small model useful for testing automated planning methods.
Data validation 2026-11-05
Data validation checks a value against stated requirements, such as an allowed data type, range or relationship between fields. Parsing establishes how input fits a syntax; an application's validation rules determine whether the resulting value is suitable for its purpose. In Python,
json.loads performs JSON deserialization, but it does not know a particular application's requirements.[ref]For an original example, suppose a program accepts an exact Python integer object from 0 through 10. Its validation predicate is
type(x) is int and 0 <= x <= 10. After JSON decoding, inputs 0, 3 and 10 pass; -1, 11, "3", true and 3.0 fail. All are valid JSON texts. The last input becomes a floating-point object, so this particular rule rejects it even though its numerical value is integral. A different application could deliberately accept it.The rule must therefore be explicit about its intended distinction. Converting every input to an integer before checking would change what is accepted and could lose information. Validating after such conversion answers a different question from checking the original decoded data type.
Suppose a predicate accepts some and rejects some . Dropping its initial accepted list prefix maps both the empty list and the singleton to the empty list, but maps the extensions by to different lists. A direct list fold cannot do this: its combining function receives the same head and the same folded-tail summary in both cases. This is an instance of the fold factorisation criterion. An auxiliary list fold retaining more information followed by projection is not ruled out.
E. F. Codd 2026-11-05
E. F. Codd introduced the relational model in his 1970 paper on large shared data banks. Data is represented by relations rather than application-visible pointers and access paths, supporting data independence: changing physical organization need not change the meaning of a query.[ref]
The distinction is operationally important. A query can request tuples satisfying a predicate while the system chooses an index or scan. Applications specify the information they need instead of navigating one fixed storage layout. Mathematical relations also expose dependencies among attributes, providing a foundation for database normalization.
Filtering a list by unfolding 2026-10-31
For a predicate , normalize the state to the first remaining passing element with
seek = dropWhile (not . p). Stop on an empty state, otherwise emit its head and continue from seek (tail state). The invariant is that every nonempty state starts with a passing element. An initial seek establishes it; removing the emitted head and seeking again preserves it. Each rejected run is traversed once, giving linear time in the examined input prefix under constant-cost predicate tests. List filter 2026-10-31
Keep exactly the elements of a list satisfying a predicate, preserving their relative order. A recursive step tests the head, prepending it to the filtered tail when it passes and otherwise returning that filtered tail alone. On a finite input, this uses one predicate evaluation per element; an infinite rejected tail cannot produce a next output under lazy evaluation.
Index the coins so that is smallest and largest. Choose as the initial stack and as the destination, assuming . The static predicate facts describing size areNo size comparison with is needed: moving onto empty ground will have a separate action schema. The initial STRIPS state isUnder the closed-world assumption, all other ground ground atoms are false. In particular, the initial state contains just one predicate fact naming the top of each stack. The predicate names the immediate support, not every coin farther below.
An explicit positive conjunctive goal is the following set of required ground atoms:A state succeeds when it contains . The static predicate facts in persist automatically. Starting from , the planning state invariants proved below make this goal exactly the desired completed stack on with all other stacks empty. If any new stack is acceptable, the choice of loses no generality because the initially empty stacks are interchangeable.
Use two STRIPS action schemas, for a destination topped by a coin and for an empty destination. In both, is a coin, are distinct stack constants, and is either a different coin or . In the first, is a coin distinct from and, when is a coin, also distinct from . These are restrictions on action grounding, so no new type or inequality predicates are needed.
For , useFor , useThe last cases are a compact notation for two ordinary action schemas, one with a coin and one with . In the second case, already holds and is left unchanged: the same ground object represents the base of every stack. Its stack identity is carried by , so moving a singleton stack to an empty location still changes two top markers even though its support remains .
Each ground action applies only if and updates the STRIPS state byThe preconditions require the moved coin to be exposed and the destination to be either exposed or empty. A coin destination additionally requires the moved coin to be smaller. The delete list removes its old support relation when that support changes, removes its old source-top marker, and removes the destination's old top marker. The add list exposes its former support and installs it as the destination top.
To prove that no incorrect plans arise, induct on the action history. Initially every coin has exactly one support; the stacks are disjoint decreasing chains ending at ; and each stack has exactly one correct top marker. An applicable action removes just the top coin from one such chain and attaches it to a different chain, or creates a singleton chain. The size precondition preserves decreasing order; distinct stack parameters prevent moving onto one's own stack; and updating both top markers preserves their accuracy. The unchanged chain segments retain their support relations. These planning state invariants therefore hold after every action. Only the named stacks can be used, enforcing the stack limit.
Conversely, every legal physical move has a source top , a uniquely determined former support , and either an empty target or a target top larger than . The corresponding ground action has exactly these preconditions and effects. Thus the encoding permits all legal moves and preserves physical legality from the initial state.[ref]
Intelligent Systems examination paper by the University of Oxford (2015). Printed p. 3, Question 2(a–b), prescribed objects and predicates
Let brick have positive integer width . Regard its horizontal occupied region as and its vertical occupied region as . These half-open interval conventions allow adjoining bricks to touch without overlapping. Since the vertical coordinates are integers, two bricks can overlap only when they are on the same row. A suitable predicate isPositive widths and nonnegative integer heights are the underlying domain conditions for a wall built on the baseplate. Distinct members of the set are compared even if their
Brick references happen to be identical: one brick specification can describe several placements. Testing object identity alone would miss two overlapping placements of the same specification.For an integer cell coordinate, occupancy is an existential predicate:The first occupied unit cell of brick is at , and its last is at . Thus the required support predicate, with the baseplate explicitly included, isFor width one, the two support cells coincide. For a wider brick, its middle may bridge an empty gap; the question only requires support beneath its two ends. Checking would incorrectly examine a cell beyond the brick's right end. The potentially infinite baseplate supplies every required support at height zero.[ref]
Write for the table. The positive initial planning fluents read from the original figure areThe static type facts are , and ; the table is not a block. With an explicit table-availability predicate, take to be permanently true. Under the closed-world assumption, all other well-typed initial planning fluents are false; in particular, is not clear.
The goal is the partial-state conjunctionIt need not redundantly prescribe every final fact. With only these three blocks and a valid blocks world state, the completed stack also places on the table and leaves clear.
Ground as distinct blocks. For , takeThus a clear block leaves its block support, makes that support clear, and joins the unlimited table. persists, and table availability is never deleted. Requiring to be a block excludes a redundant table-to-table action. The static predicates need not be stored as time-varying planning fluents.
Use for the agent, monster, gold and arrow, and abbreviate to . A physically safe STRIPS plan isEvery movement follows a listed adjacency predicate. The shot is taken from while the arrow is held, and kills the monster before entry into . The pit at is never entered. The pickup establishes possession of the gold, and the last four movements restore the exit location while preserving that possession. Thus ten actions achieve the formal goal and the intended safe return; arriving at the exit is the source model’s representation of leaving.
A prefix-dropping iterator must preserve the first satisfying element. Reading it to test the predicate physically consumes it from the source, so keep it in a one-element buffer. Once a match is found, return the entire suffix without testing subsequent elements again.Assume the source iterator is owned by the wrapper, its
trait Iter[T] {
def hasNext: Boolean
def next(): T
def copy(): Iter[T]
}
class DropUntil[T](p: T => Boolean, iter: Iter[T]) extends Iter[T] {
private var seeking = true
private var saved: Option[T] = None
private def prepare(): Unit = {
if (seeking) {
while (saved.isEmpty && iter.hasNext) {
val x = iter.next()
if (p(x)) saved = Some(x)
}
seeking = false
}
}
def hasNext: Boolean = {
prepare()
saved.nonEmpty || iter.hasNext
}
def next(): T = {
prepare()
saved match {
case Some(x) => saved = None; x
case None =>
if (!iter.hasNext) throw new NoSuchElementException("next")
iter.next()
}
}
def copy(): Iter[T] = {
val result = new DropUntil[T](p, iter.copy())
result.seeking = seeking
result.saved = saved
result
}
}copy meets the stated independent-cursor contract, and is a pure function. Before preparation, the logical remainder is the source remainder with its maximal initial failing prefix removed. After preparation, it is the buffered match followed by the source remainder, or simply the source remainder when the buffer is empty. This describes the abstraction function and proves that repeated hasNext calls neither lose the match nor skip more values.Copying preserves the phase flag and optional buffered value and independently copies the source iterator. It does not rerun the predicate on an already accepted match. A shallow copy of the wrapper alone would give shared iterator consumption, violating the specification. ThereforeWhen no element satisfies , a finite source yields an empty iterator. Seeking can diverge on an infinite source with no match; this is inherent in determining whether its required suffix begins anywhere. An element object is not deep-copied by this cursor operation.
These operations consume the receiver, as expected for this destructive iterator interface. For
exists stops immediately after the first successful test.trait RichIter[T] extends Iter[T] {
def foreach(f: T => Unit): Unit = {
while (hasNext) f(next())
}
def exists(p: T => Boolean): Boolean = {
while (hasNext) {
if (p(next())) return true
}
false
}
def foldLeft[U](x: U)(f: (U, T) => U): U = {
var acc = x
while (hasNext) acc = f(acc, next())
acc
}
}foreach, after iterations the supplied function has been applied in order to exactly the first entries. For exists, every consumed entry has failed the predicate unless the method is returning true. For the left fold, the loop invariant after consuming entries isEach iteration extends the expression by the next entry on the right. For a finite remaining sequence, its unconsumed length is a common loop variant. ThusAn empty iterator invokes no callback, gives false for exists, and returns from the left fold. On an infinite iterator, exists can terminate when it finds a match; the other two operations ordinarily do not terminate. With constant-cost callbacks, finite input of length takes time complexity and constant auxiliary space.A demand-driven filtering iterator needs one cached accepted value. Otherwise The representation invariant says that
hasNext would either lose an element or consume another accepted value every time it is queried.def filterIter[T](p: T => Boolean, it: Iter[T]): Iter[T] =
new Iter[T] {
private var buffered: Option[T] = None
private var finished = false
private def fill(): Unit = {
while (buffered.isEmpty && !finished) {
if (!it.hasNext) finished = true
else {
val x = it.next()
if (p(x)) buffered = Some(x)
}
}
}
def hasNext: Boolean = {
fill()
buffered.nonEmpty
}
def next(): T = {
fill()
require(buffered.nonEmpty)
val answer = buffered.get
buffered = None
answer
}
}buffered holds at most one accepted value. The represented sequence is the buffered value, if present, followed by the subsequence of the underlying remainder satisfying the predicate. Filling moves the next accepted value into the cache and discards only rejected values, so this abstract sequence is unchanged by hasNext. Clearing the cache in next removes its head. Thusnext works even when the client has not first called hasNext; exhaustion violates its stated precondition. As with ordinary iterator adapters, clients should give this wrapper exclusive consumption of it, and the predicate should give a stable answer for each element. One call may scan several rejected elements, but across a complete traversal each source element is consumed once. Cache storage is constant.The dot after gives it scope over the following implication: read the premise as . Choose a fresh arbitrary eigenvariable . A natural deduction proof isAt line 6, is free in no undischarged assumption, so the universal quantifier introduction rule is valid.
The proposed variant is not derivable in a sound first-order logic. For a countermodel, use the two-element domain , interpret both predicates as , and assign the free variable the value 0. Then is true, as is under the assignment, but is false at element 1. The premise's bound and the conclusion's free have different scopes.Attempting to generalize from in the variant would violate the eigenvariable condition, because remains free in the undischarged assumption .
The first matching entry must be retained, and copying an already-started prefix-dropping iterator must not restart the search. Use a private initial buffer together with the underlying iterator snapshot:Before preparation, the iterator still represents the original remaining sequence. During the search, the loop invariant says that every discarded entry fails the predicate, and
class DropUntil[T] private (
p: T => Boolean, iter: Iter[T],
saved: Option[T], alreadyStarted: Boolean) extends Iter[T] {
def this(p: T => Boolean, iter: Iter[T]) =
this(p, iter, None, false)
private var pending: Option[T] = saved
private var started: Boolean = alreadyStarted
private def prepare(): Unit = {
if (!started) {
var found = false
while (!found && iter.hasNext) {
val x = iter.next()
if (p(x)) {
pending = Some(x)
found = true
}
}
started = true
}
}
def hasNext: Boolean = {
prepare()
pending.nonEmpty || iter.hasNext
}
def next(): T = {
prepare()
pending match {
case Some(x) => pending = None; x
case None =>
if (!iter.hasNext) throw new NoSuchElementException("DropUntil.next")
iter.next()
}
}
def copy(): Iter[T] =
new DropUntil[T](p, iter.copy(), pending, started)
}pending is either empty or contains the first satisfying entry just consumed. For a finite input, the number of unread entries is a loop variant. After preparation, the abstract remaining sequence is pending.toList followed by the underlying iterator's remaining sequence. Repeated hasNext calls do not discard or test more entries after the first match.The iterator snapshot copies both the cached entry and the started flag. In particular, copying after the matching entry has been returned continues with the remaining suffix, including later entries that fail
p. Restarting new DropUntil(p, iter.copy()) at that point would wrongly drop another prefix.As usual, assume a deterministic predicate without shared mutable effects. On an infinite input having no match, the first demand cannot terminate: no finite inspection establishes absence. Independence here concerns cursor state; arbitrary mutation of shared element objects is outside the iterator contract.