Update and inspect interval-valued conclusions

Start with Reason over complete validity ranges for interval intersection, union, change segments and point/range agreement. Each example below defines its own program and facts and runs with the base install. No database/source identity, backend, serializer or publication permission is created by these computations.

Absence applies only where its blocker is inactive

Alice is a candidate on [0, 10) and banned on [5, 10). With banned declared complete for the supplied inputs, eligibility holds on [0, 5). Moving the ban’s start to 3 shrinks eligibility to [0, 3); the updated closure must agree with fresh evaluation, not just with a few sampled points.

Standalone example. Install with python -m pip install "gestaltdb".

 1import warnings
 2from gestaltdb.reasoning import (
 3    GenericProgram, GenericRule, Interval, IntervalSet, ReasoningLimits,
 4    TemporalFact, TemporalProofTruncatedWarning, TypedAtom, TypedFact,
 5    Variable, evaluate_range, update_range, verify_closure,
 6)
 7
 8person = Variable("person")
 9program = GenericProgram([GenericRule(
10    "eligible", [TypedAtom("candidate", [person])], [], TypedAtom("eligible", [person]),
11    negated=[TypedAtom("banned", [person])],
12)], closed=["banned"])
13candidate = TemporalFact(TypedFact("candidate", ["alice"]), IntervalSet([Interval(0, 10)]))
14ban = TemporalFact(TypedFact("banned", ["alice"]), IntervalSet([Interval(5, 10)]))
15base = [candidate, ban]
16goal = TypedFact("eligible", ["alice"])
17closure = evaluate_range(program, base, limits=ReasoningLimits())
18assert closure.answers(goal).intervals == (Interval(0, 5),)
19assert closure.evidence(goal)[0].absence[0].scope == ("banned",)
20changed = [candidate, TemporalFact(ban.fact, IntervalSet([Interval(3, 10)]))]
21updated = update_range(program, closure, changed, limits=ReasoningLimits())
22fresh = evaluate_range(program, changed, limits=ReasoningLimits())
23assert updated.closure.conclusions == fresh.conclusions
24assert updated.closure.answers(goal).intervals == (Interval(0, 3),)
25assert not verify_closure(program, updated.closure, limits=ReasoningLimits()).proofs_truncated
26
27with warnings.catch_warnings(record=True) as caught:
28    warnings.simplefilter("always")
29    partial = evaluate_range(program, base, limits=ReasoningLimits(max_proof_nodes=1))
30assert any(isinstance(item.message, TemporalProofTruncatedWarning) for item in caught)
31assert partial.answers(goal) == closure.answers(goal)
32assert partial.proofs_truncated and partial.missing_evidence()

Scoped absence is not a negative claim or a declaration that every unrecorded predicate is false. The range evaluator checks supported stratified absence on each completed segment, with its scoped evidence. This differs from the stored claim-rule service’s conservative overlap rule (Stored rules and support maintenance).

Logical results and retained explanations are separate. The warning above says evidence is incomplete, not that eligibility vanished. answers and at remain logical answers; derivations/evidence can be partial. A truncated old closure is rematerialized rather than admitted as a reusable proof cache. Malformed input, cancellation and logical-work bounds still fail without a successful partial closure (Temporal delta maintenance and interval publication).

Aggregate the rows active on each segment

One member is present on [0, 10) and another joins on [5, 10). The team size is one then two. A count does not extend beyond the members’ validity or invent a zero-count group outside the populated interval.

Standalone example. Install with python -m pip install "gestaltdb".

 1from gestaltdb.reasoning import (
 2    AggregateRule, Aggregation, GenericProgram, Interval, IntervalSet, Literal,
 3    ReasoningLimits, TemporalFact, TypedAtom, TypedFact, Variable, evaluate_range, verify_closure,
 4)
 5
 6team, member, count = Variable("team"), Variable("member"), Variable("count")
 7program = GenericProgram([], aggregates=[AggregateRule(
 8    "team-count", [TypedAtom("member", [team, member])], [team],
 9    [Aggregation("count", member, count)], TypedAtom("team_size", [team, count]),
10)])
11base = [TemporalFact(TypedFact("member", ["lab", "alice"]), IntervalSet([Interval(0, 10)])),
12        TemporalFact(TypedFact("member", ["lab", "bob"]), IntervalSet([Interval(5, 10)]))]
13closure = evaluate_range(program, base, limits=ReasoningLimits())
14one = TypedFact("team_size", ["lab", Literal("integer", 1)])
15two = TypedFact("team_size", ["lab", Literal("integer", 2)])
16assert closure.answers(one).intervals == (Interval(0, 5),)
17assert closure.answers(two).intervals == (Interval(5, 10),)
18assert not any(fact.predicate == "team_size" for fact in closure.at(10))
19assert len(closure.evidence(two)[0].aggregates[0].operands) == 2
20assert not verify_closure(program, closure, limits=ReasoningLimits()).proofs_truncated

Only the supported nonrecursive aggregate stratum is evaluated. Aggregate heads remain sinks and cannot feed another aggregate body or recursive rule. Range evaluation does not widen the typed engine’s accepted fragment. Its aggregate evidence records logical operands for a segment, not authenticated database versions or an independently recomputed arithmetic certificate.

Scope equality to one segment

Representatives from an equality policy are not globally stable aliases. This separate helper takes caller-selected active fact sets for two segments. The explicit functional-property policy equates the two mailbox values in the first segment; that evidence is absent in the second. It does not rewrite either the input facts or database nodes.

Standalone example. Install with python -m pip install "gestaltdb".

 1from gestaltdb.reasoning import TypedFact, canonicalize_segments
 2from gestaltdb.reasoning.equality import FunctionalProperty
 3
 4segments = [
 5    [TypedFact("mailbox", ["alice", "address-a"]), TypedFact("mailbox", ["alice", "address-b"])],
 6    [TypedFact("mailbox", ["alice", "address-a"])],
 7]
 8mappings = canonicalize_segments(segments, [FunctionalProperty("mailbox")], scope_prefix="example")
 9assert mappings[0].representative("address-b") == "address-a"
10assert mappings[1].representative("address-b") == "address-b"
11assert mappings[0].scope != mappings[1].scope

The policy is caller-selected, not automatic real-world identity resolution. Rebuild scoped mappings when support or the selected horizon changes. The helper does not acquire database snapshots, automatically rewrite range closure, or make equality valid beyond the fact set supplied for that segment. See Snapshot-local equality and functional identity for conflicts and representative semantics.

Computation, admission and publication are separate

Do not infer authority from a successful calculation

Stage

Provides

Does not provide

evaluate_range / update_range

Closure over explicit program/base validity

Database authentication or write authority

verify_closure

Re-segmentation, per-segment reevaluation and evidence conformance

Independent source authentication or real-world truth certification

Authenticated range admission

Explicit finite source/range/program identities, extraction and recomputation

A universal publication permit or a cheap cache hit

Bound range publication

Computation-owned guarded source re-admission, freshness/target checks and interval-batch commit

Unrestricted publication of caller-derived state or automatic mutation of current graph edges

Follow Authenticated temporal-range evaluation and re-admission and Authenticated interval-batch publication only when a database workflow requires those contracts. Raw caller-derived stage_range remains a distinct operation; capturing a staging horizon does not authenticate the computation that preceded it (Temporal delta maintenance and interval publication). Compare incremental and full evaluation on your workload rather than assuming updates always reuse most segments.