Liking cljdoc? Tell your friends :D

vaelii.impl.nat

Non-atomic terms (NATs) via reification — Strategy A.

A NAT is a function-application term (F arg…) that denotes an entity — (FruitFn AppleTree), (CapitalOf France). A function splits by declaration into two kinds:

(reifiable_function F) object-denoting. A ground (F a…) is a reified NAT: it reifies to an opaque nat/-namespaced constant K before it reaches the index, so the reified NAT autoindexes exactly like a hand-minted symbol — no trie-key change, no term-index change. (unreifiable_function F) evaluated/interpreted. The NAT is a structural NAT and stays structural — (QuantityFn 5 Meter) keeps its magnitude and unit readable for a downstream prover; it is never minted.

The constant↔expression map is itself an ordinary stored fact, (termOfUnit K E) in CxUniverse, so the inverted term index makes E's constituents (and K) discoverable natively — no KV side tables. K stays STABLE across renames: a rename rewrites the expression inside the one termOfUnit sentex in place, and nested NATs referencing K need no cascade.

This namespace holds the detectors, the index-backed lookups, display expansion, and the reify — both modes: the read-mode (dedup, never mint) and the write-mode (mint a fresh constant, materialize its result types, merge rename collisions). The write-mode stores its termOfUnit and result-type facts through the full assert path, reached by vaelii.impl.wiring — which is where the reason that is not an ordinary require is written down. So all NAT reification lives here.

What sits above this and calls the reify rather than reimplementing it: vaelii.impl.skolem mints the witness an existential rule head fires to, and vaelii.impl.nat-maintenance sequences the post-assert reconciliation and drops an orphaned reified NAT when its last use is retracted (it rides the retract! sweep).

Reads the store, the taxonomy and belief directly (nat <- kb); reaches assertion only through the fns above.

Non-atomic terms (NATs) via reification — Strategy A.

A NAT is a function-application term `(F arg…)` that denotes an entity —
`(FruitFn AppleTree)`, `(CapitalOf France)`.  A function splits by declaration
into two kinds:

  (reifiable_function F)    object-denoting.  A ground `(F a…)` is a **reified NAT**: it
                           reifies to an opaque `nat/`-namespaced constant `K`
                           *before* it reaches the index, so the reified NAT autoindexes
                           exactly like a hand-minted symbol — no trie-key change,
                           no term-index change.
  (unreifiable_function F)  evaluated/interpreted.  The NAT is a **structural NAT** and stays
                           *structural* — `(QuantityFn 5 Meter)` keeps its magnitude
                           and unit readable for a downstream prover; it is never
                           minted.

The constant↔expression map is itself an ordinary stored fact, `(termOfUnit K E)`
in CxUniverse, so the inverted term index makes `E`'s constituents (and `K`)
discoverable natively — no KV side tables.  `K` stays STABLE across renames: a
rename rewrites the expression inside the one `termOfUnit` sentex in place, and
nested NATs referencing `K` need no cascade.

This namespace holds the detectors, the index-backed lookups, display expansion,
and the reify — **both** modes: the read-mode (dedup, never mint) and the
write-mode (mint a fresh constant, materialize its result types, merge rename
collisions).  The write-mode stores its `termOfUnit` and result-type facts through the
full assert path, reached by `vaelii.impl.wiring` — which is where the reason that is
not an ordinary require is written down.  So all NAT reification lives here.

What sits above this and *calls* the reify rather than reimplementing it:
`vaelii.impl.skolem` mints the witness an existential rule head fires to, and
`vaelii.impl.nat-maintenance` sequences the post-assert reconciliation and drops an
orphaned reified NAT when its last use is retracted (it rides the `retract!` sweep).

Reads the store, the taxonomy and belief directly (nat <- kb); reaches assertion only
through the fns above.
raw docstring

*withheld*clj

The reifiable_function functions whose ground applications stay as written while bound: the ones a reader does not believe the mark of (withheld-at), so the reconcile stores, and a read looks up, the spelling that reader reads (chain/reconcile-reified!).

The `reifiable_function` functions whose ground applications stay as written while
bound: the ones a reader does not believe the mark of (`withheld-at`), so the reconcile
stores, and a read looks up, the spelling that reader reads (`chain/reconcile-reified!`).
sourceraw docstring

any-corresponding-predicates?clj

(any-corresponding-predicates? kb)

Cheap gate: does the KB declare any functionCorrespondingPredicate? An O(1) functor count, so a KB that declares none pays one integer read per assert and nothing else.

Cheap gate: does the KB declare any `functionCorrespondingPredicate`?  An O(1)
functor count, so a KB that declares none pays one integer read per assert and
nothing else.
sourceraw docstring

any-reifiable-functions?clj

(any-reifiable-functions? kb)

Cheap gate: does the KB declare any reifiable_function? False ⇒ no sentence can contain a reifiable NAT, so the argument reify pass and the rename/remove NAT steps short-circuit to a no-op. One in-memory taxonomy-prop read.

Cheap gate: does the KB declare any `reifiable_function`?  False ⇒ no sentence can
contain a reifiable NAT, so the argument reify pass and the rename/remove NAT steps
short-circuit to a no-op.  One in-memory taxonomy-prop read.
sourceraw docstring

any-reified-constants?clj

(any-reified-constants? kb)

Gate for the maintenance a reified constant owes (the orphan sweep, the collision merge, the structural genlCx producer): does the KB declare a reifiable_function, or store a termOfUnit map? A context slot mints a cx/ constant with no declaration (maybe-reify-context), so the in-memory read alone misses a KB whose only constants are contexts. The in-memory read first, then one O(1) functor count.

Gate for the maintenance a reified constant owes (the orphan sweep, the collision merge,
the structural `genlCx` producer): does the KB declare a `reifiable_function`, or store
a `termOfUnit` map?  A context slot mints a `cx/` constant with no declaration
(`maybe-reify-context`), so the in-memory read alone misses a KB whose only constants
are contexts.  The in-memory read first, then one O(1) functor count.
sourceraw docstring

any-result-declarations?clj

(any-result-declarations? kb)

Cheap gate: does the KB declare any result, genlResult or resultArg? False ⇒ no mint has materialized a result type and no application can be typed by one, so both the orphan sweep's question about them and the argument checks' are answered without a probe. Three O(1) functor counts, the same shape as any-corresponding-predicates?.

Cheap gate: does the KB declare any `result`, `genlResult` or `resultArg`?  False ⇒
no mint has materialized a result type and no application can be typed by one, so both
the orphan sweep's question about them and the argument checks' are answered without a
probe.  Three O(1) functor counts, the same shape as `any-corresponding-predicates?`.
sourceraw docstring

authoritative-expressionclj

(authoritative-expression exprs)

The one expression a reified constant denotes, chosen from exprs — the content-least of them.

Normally there is nothing to choose: the map is 1:1 and exprs holds one member. A collision the repair has yet to reach holds several, and every reader of the map has to make the same choice out of them or they disagree about one constant — orphan? deciding a constant orphaned against one expression while bookkeeping-handles computes what to retract from another is a sweep that retracts the wrong records. Content, never arrival, for the reason dedup-constant elects the surviving constant the same way: which of two spellings the retrieval yielded first is not an answer about the KB.

The one expression a reified constant denotes, chosen from `exprs` — the **content-least**
of them.

Normally there is nothing to choose: the map is 1:1 and `exprs` holds one member.  A
collision the repair has yet to reach holds several, and every reader of the map has to
make the same choice out of them or they disagree about one constant — `orphan?` deciding
a constant orphaned against one expression while `bookkeeping-handles` computes what to
retract from another is a sweep that retracts the wrong records.  Content, never arrival,
for the reason `dedup-constant` elects the surviving constant the same way: which of two
spellings the retrieval yielded first is not an answer about the KB.
sourceraw docstring

bookkeeping-handlesclj

(bookkeeping-handles kb k)

The bookkeeping sentex handles of constant k — its termOfUnit and materialized result-type premises, plus its correspondence projection — the ones to retract when k is orphaned. Not belief-filtered: once k is orphaned everything it owns goes, and a bookkeeping sentex sitting OUT would otherwise stay stored, a map for a constant the sweep has already collected.

A context constant's is its termOfUnit alone, and the structural genlCx edges the producer computed off it are deliberately not listed: they are derived, so retracting the map withdraws their one premise and the dependency-directed sweep deletes them (docs/nmtms.md). Which is also what puts the far end of each edge in the next round's candidate set, so a chain of ordered contexts collapses by the rule that collapsed the first.

Realized before it returns, because the caller retracts what it hands back and minted is a read of the very sentexes being retracted: it asks k's termOfUnit which expression the mint wrote about, so a tail forced after the map's own retraction answers #{} and the materialized types and the projection stop looking like bookkeeping — left stored, naming a constant the sweep has collected. Whether that happens is decided by which sentex the term index hands back first, so a lazy answer here is a dangling nat/ symbol in some retrieval orders and not in others.

The bookkeeping sentex handles of constant `k` — its `termOfUnit` and materialized
result-type premises, plus its correspondence projection — the ones to retract when
`k` is orphaned.  Not belief-filtered: once `k` is orphaned everything it owns
goes, and a bookkeeping sentex sitting OUT would otherwise stay stored, a map for
a constant the sweep has already collected.

A **context** constant's is its `termOfUnit` alone, and the structural `genlCx` edges
the producer computed off it are deliberately not listed: they are *derived*, so
retracting the map withdraws their one premise and the dependency-directed sweep
deletes them (docs/nmtms.md).  Which is also what puts the far end of each edge in the
next round's candidate set, so a chain of ordered contexts collapses by the rule that
collapsed the first.

**Realized before it returns**, because the caller retracts what it hands back and
`minted` is a read of the very sentexes being retracted: it asks `k`'s `termOfUnit`
which expression the mint wrote about, so a tail forced after the map's own
retraction answers `#{}` and the materialized types and the projection stop looking
like bookkeeping — left stored, naming a constant the sweep has collected.  Whether
that happens is decided by which sentex the term index hands back first, so a lazy
answer here is a dangling `nat/` symbol in some retrieval orders and not in others.
sourceraw docstring

colliding-constant-groupsclj

(colliding-constant-groups kb)

Believed reified constants that share one expression — [survivor [dup …]] per collision. A rename can collapse two NATs onto one expression; restoring the 1:1 invariant means merging each group's dups into its survivor.

Reads the whole map, so this is the answer about the KB; the maintenance after a rename asks the narrower question collisions-touching instead.

Believed reified constants that share one expression — `[survivor [dup …]]` per
collision.  A rename can collapse two NATs onto one expression; restoring the 1:1
invariant means merging each group's `dup`s into its `survivor`.

Reads the whole map, so this is the answer *about the KB*; the maintenance after a
rename asks the narrower question `collisions-touching` instead.
sourceraw docstring

constant-forclj

(constant-for ns E)

The opaque reified constant expression E reifies to, in reserved namespace ns (nat for an object NAT, cx for a context NAT). Deterministic in E's content (content-name), so re-reifying E — in this process, in another, or in a KB rebuilt in another order — yields the same constant. A hash collision (two expressions, one name) can only degrade into the ordinary two-expressions-one-constant case the merge repair already reconciles by content (authoritative-expression), never into a wrong answer. A nat/ name matches the camelCase argument convention (nat-scheme-tag explains the base62 choice) and a cx/ name is exempt as a context spelling (naming/context?), so neither needs an exemption in naming/argument-problem, where a reified constant is checked — only ever as an argument, never as a functor.

The opaque reified constant expression `E` reifies to, in reserved namespace `ns`
(`nat` for an object NAT, `cx` for a context NAT).  Deterministic in `E`'s content
(`content-name`), so re-reifying `E` — in this process, in another, or in a KB rebuilt
in another order — yields the *same* constant.  A hash collision (two expressions, one
name) can only degrade into the ordinary two-expressions-one-constant case the merge
repair already reconciles by content (`authoritative-expression`), never into a wrong
answer.  A `nat/` name matches the camelCase argument convention (`nat-scheme-tag`
explains the base62 choice) and a `cx/` name is exempt as a context spelling
(`naming/context?`), so neither needs an exemption in `naming/argument-problem`, where a
reified constant is checked — only ever as an argument, never as a functor.
sourceraw docstring

context-application?clj

(context-application? form)

True iff form is a ground application headed by a symbol: what a context slot reifies to a cx/ constant, whatever is declared about the head. Decided by the form alone, so a write stores the same set in every arrival order (docs/context-nat.md).

True iff `form` is a ground application headed by a symbol: what a context slot reifies
to a `cx/` constant, whatever is declared about the head.  Decided by the form alone,
so a write stores the same set in every arrival order (docs/context-nat.md).
sourceraw docstring

context-for-checkclj

(context-for-check kb context)

The context assert stores a sentex in for the slot context, minting nothing: for a context-application?, its existing-context, else the cx/ constant constant-for names for the expression, which no stored sentex names. Any other slot passes through. vaelii.core/check reads the slot through this, so its checks read the context maybe-reify-context mints.

The context `assert` stores a sentex in for the slot `context`, minting nothing: for a
`context-application?`, its `existing-context`, else the `cx/` constant `constant-for`
names for the expression, which no stored sentex names.  Any other slot passes through.
`vaelii.core/check` reads the slot through this, so its checks read the context
`maybe-reify-context` mints.
sourceraw docstring

context-function-believed?clj

(context-function-believed? kb head)

True iff CxUniverse believes a (result head context) declaration it sees: what a read of a context slot (head a…) requires. The slot resolves through the termOfUnit map, which every reader reads in CxUniverse (dedup-constant), so the declaration is read there too: stated in a context CxUniverse sees, and hidden by no except or defeat in force at CxUniverse (res/supporter-visible?).

True iff CxUniverse believes a `(result head context)` declaration it sees: what a read
of a context slot `(head a…)` requires.  The slot resolves through the `termOfUnit` map,
which every reader reads in CxUniverse (`dedup-constant`), so the declaration is read
there too: stated in a context CxUniverse sees, and hidden by no `except` or `defeat` in
force at CxUniverse (`res/supporter-visible?`).
sourceraw docstring

context-namespaceclj

Reserved namespace for context reified-NAT constants: a ground application (F a…) in a sentex's context slot mints one, whatever is declared about F (docs/context-nat.md). A cx/ constant classifies as a context, so it can be a sentex's context slot and a genlCx node, while its structural argument stays readable in the termOfUnit map. Distinct from nat/ because role-reading is spelling-only (docs/naming.md): the namespace, not a belief, carries the context role.

Reserved namespace for **context** reified-NAT constants: a ground application `(F a…)`
in a sentex's context slot mints one, whatever is declared about `F`
(docs/context-nat.md).  A `cx/` constant classifies as a *context*, so it can be a
sentex's context slot and a `genlCx` node, while its structural argument stays readable
in the `termOfUnit` map.  Distinct from `nat/` because role-reading is spelling-only
(docs/naming.md): the namespace, not a belief, carries the context role.
sourceraw docstring

context-typeclj

The type a (result F context) declaration names: F's applications denote contexts, so a context slot written as (F a…) reads (docs/context-nat.md).

The type a `(result F context)` declaration names: `F`'s applications denote contexts,
so a context slot written as `(F a…)` reads (docs/context-nat.md).
sourceraw docstring

correspondence-ofclj

(correspondence-of kb f m)

The [predicate position] declared for function f applied to m arguments, or nil. position defaults to m + 1, the value last.

Nil when the KB believes more than one declaration for f, deliberately: two are two different claims about what (f a…) denotes, and picking between them by handle would make term identity depend on the order they were asserted in.

The `[predicate position]` declared for function `f` applied to `m` arguments, or
nil.  `position` defaults to `m + 1`, the value last.

Nil when the KB believes **more than one** declaration for `f`, deliberately: two are
two different claims about what `(f a…)` denotes, and picking between them by handle
would make term identity depend on the order they were asserted in.
sourceraw docstring

correspondence-predicateclj

The declaration relating a NAT function to the predicate stating the same thing.

The declaration relating a NAT function to the predicate stating the same thing.
sourceraw docstring

correspondence-valueclj

(correspondence-value kb E)

The term a believed corresponding fact already names as the value of the ground NAT expression E, or nil. Exactly one value, or none: several believed values mean the KB does not agree on what E denotes, and reifying to one of them would be a guess the reader could not see.

The term a believed corresponding fact already names as the value of the ground NAT
expression `E`, or nil.  Exactly one value, or none: several believed values mean the
KB does not agree on what `E` denotes, and reifying to one of them would be a guess
the reader could not see.
sourceraw docstring

corresponding-literalclj

(corresponding-literal kb E v)

The sentence the correspondence makes equivalent to E = v — the predicate applied to E's arguments with v at the declared position — or nil when E's function has no single correspondence.

The sentence the correspondence makes equivalent to `E = v` — the predicate applied
to `E`'s arguments with `v` at the declared position — or nil when `E`'s function has
no single correspondence.
sourceraw docstring

dedup-constantclj

(dedup-constant kb E)
(dedup-constant kb E ns)

The existing reified constant for the ground NAT expression E in reify namespace ns (default nat/), or nil — the E → K half of the 1:1 map, so re-reifying an expression finds the constant already minted for it rather than minting a second. More than one constant can name E in one namespace (a :bulk? load skips this probe, and an import restores whatever the dump held), and the answer is then the lexicographically smallest — the survivor group-collisions elects — so a read resolves to the constant the merge repair keeps rather than to whichever the retrieval yielded first.

The existing reified constant for the ground NAT expression `E` in reify namespace `ns`
(default `nat/`), or nil — the `E → K` half of the 1:1 map, so re-reifying an
expression finds the constant already minted for it rather than minting a second.  More
than one constant can name `E` in one namespace (a `:bulk?` load skips this probe, and
an import restores whatever the dump held), and the answer is then the
lexicographically smallest — the survivor `group-collisions` elects — so a read
resolves to the constant the merge repair keeps rather than to whichever the retrieval
yielded first.
sourceraw docstring

existing-contextclj

(existing-context kb form)

The cx/ constant (or rewriteOf target) the context application form already resolves to, or nil when none was minted — the dedup half of maybe-reify-context's write path, read without any declaration.

The `cx/` constant (or `rewriteOf` target) the context application `form` already
resolves to, or nil when none was minted — the dedup half of `maybe-reify-context`'s
write path, read without any declaration.
sourceraw docstring

expand-expressionclj

(expand-expression kb form)
(expand-expression kb form expand?)

Recursively replace every reified NAT constant in form with the functional expression it denotes — human-readable printing / export ((color (FruitFn AppleTree) Red), never a raw nat/ symbol). Returns form UNCHANGED (same identity) when it holds no reified NAT, so content holding no reified NAT is untouched; only reified NAT-bearing forms are rebuilt. A vector rebuilds as a vector — an antecedent list stays the shape its record stores. expand? narrows which constants are expanded.

Recursively replace every reified NAT constant in `form` with the functional
expression it denotes — human-readable printing / export
(`(color (FruitFn AppleTree) Red)`, never a raw `nat/` symbol).  Returns `form`
UNCHANGED (same identity) when it holds no reified NAT, so content holding no reified NAT is
untouched; only reified NAT-bearing forms are rebuilt.  A vector rebuilds as a
vector — an antecedent list stays the shape its record stores.  `expand?` narrows which
constants are expanded.
sourceraw docstring

genl-result-typesclj

(genl-result-types kb head)
(genl-result-types kb head context)

Types T with (genlResult head T) — what an application of head is a subtype of. Materialized as (genl K T) on a freshly minted reified NAT whose function is head, and read at check time for an application that is never minted. Globally, or (with context) through only the declarations visible from it. head may be given as an application, as result-types takes it.

Types `T` with `(genlResult head T)` — what an application of `head` is a *subtype*
of.  Materialized as `(genl K T)` on a freshly minted reified NAT whose function is
`head`, and read at check time for an application that is never minted.  Globally, or
(with `context`) through only the declarations visible from it.  `head` may be given as
an application, as `result-types` takes it.
sourceraw docstring

maybe-reify-contextclj

(maybe-reify-context kb context)
(maybe-reify-context kb context mint?)

Reify a context slot (CxTimeFn …) to its cx/ constant — the context-slot twin of maybe-reify-nats, which reifies a sentence. The context argument is passed to assert beside the sentence, so it is not on the sentence-reify walk (docs/context-nat.md). Minting when mint? (the write path), for every context-application?. Dedup-only when not (a read goal resolves to an existing context, never mints one), and only for a readable-context-application?. A bare symbol and any other form pass through unchanged, to be caught by the context-shape checks.

Reify a **context slot** `(CxTimeFn …)` to its `cx/` constant — the context-slot twin
of `maybe-reify-nats`, which reifies a *sentence*.  The context argument is passed to
`assert` beside the sentence, so it is not on the sentence-reify walk
(docs/context-nat.md).  Minting when `mint?` (the write path), for every
`context-application?`.  Dedup-only when not (a read goal resolves to an existing
context, never mints one), and only for a `readable-context-application?`.  A bare symbol
and any other form pass through unchanged, to be caught by the context-shape checks.
sourceraw docstring

maybe-reify-for-readclj

(maybe-reify-for-read kb sentence)
(maybe-reify-for-read kb sentence reader)

Reify every reifiable ground NAT subterm of a QUERY sentence to its existing constant (dedup, never mint) so the query matches the stored atomic form. A never-minted NAT resolves to no-match, so an unknown-NAT query matches nothing. Cheap no-op when the KB declares no reifiable_function. Given a reader, an application of a function the reader does not believe reifiable stays as written (withheld-at).

Reify every reifiable ground NAT subterm of a QUERY `sentence` to its existing
constant (dedup, never mint) so the query matches the stored atomic form.  A
never-minted NAT resolves to `no-match`, so an unknown-NAT query matches nothing.
Cheap no-op when the KB declares no `reifiable_function`.  Given a `reader`, an
application of a function the reader does not believe reifiable stays as written
(`withheld-at`).
sourceraw docstring

maybe-reify-natsclj

(maybe-reify-nats kb sentence)
(maybe-reify-nats kb sentence chain?)

Replace every ground reifiable NAT subterm of sentence with its reified constant, minting as needed. A cheap no-op when the KB declares no reifiable_function.

Replace every ground reifiable NAT subterm of `sentence` with its reified constant,
minting as needed.  A cheap no-op when the KB declares no `reifiable_function`.
sourceraw docstring

mint-nat!clj

(mint-nat! kb E)
(mint-nat! kb E ns chain?)

Mint a fresh reified constant for the ground NAT expression E: allocate an opaque constant K in reify namespace ns (cx/ for a context slot, nat/ for an argument), assert (termOfUnit K E) in CxUniverse, and — for an object NAT only — materialize the function's result types ((T K) per result, (genl K T) per genlResult) and the correspondence projection. Returns K. The bookkeeping is :monotonic — a reified NAT's identity and result types are structural, not defeasible defaults. assert stores synchronously, so a second occurrence of E in the same sentence dedups against this. A (resultArg F n) is not materialized here: the argument entailment draws its membership off the termOfUnit fact (checks/result-arg-rows, docs/argtypes.md).

A context NAT (cx/) skips the result-type and correspondence machinery: those are object-denoting concerns (a constant that is an instance of a type, or is the value a predicate names), and a context is neither — it is a place, wired into the genlCx lattice by the structural producer rather than typed (docs/context-nat.md). Its only bookkeeping is the termOfUnit map; a (result F context) is not materialized on it, since the cx/ spelling carries the role and a role is never read from belief.

The result types and the correspondence projection take the chaining the caller asked for; (termOfUnit K E) is asserted with chaining off unless a resultArg is written of F — the identity record is what the dedup probe reads, not content a rule fires on, and the resultArg membership it entails is. Minting is a step inside somebody else's assert, and a bulk load that turned chaining off did so for the whole load: on OpenCyc the two unqualified ones ran 46,346 chain fixpoints nobody wanted, most of whose conclusions were then dropped for having no placement context.

Mint a fresh reified constant for the ground NAT expression `E`: allocate an opaque
constant `K` in reify namespace `ns` (`cx/` for a context slot, `nat/` for an argument),
assert `(termOfUnit K E)` in CxUniverse, and — for an **object** NAT only —
materialize the function's result types (`(T K)` per `result`, `(genl K T)` per
`genlResult`) and the correspondence projection.  Returns `K`.  The bookkeeping is
`:monotonic` — a reified NAT's identity and result types are structural, not defeasible
defaults.  `assert` stores synchronously, so a second occurrence of `E` in the same
sentence dedups against this.  A `(resultArg F n)` is not materialized here: the
argument entailment draws its membership off the `termOfUnit` fact
(`checks/result-arg-rows`, docs/argtypes.md).

A **context** NAT (`cx/`) skips the result-type and correspondence machinery: those are
object-denoting concerns (a constant that *is an instance of* a type, or *is the value*
a predicate names), and a context is neither — it is a place, wired into the `genlCx`
lattice by the structural producer rather than typed (docs/context-nat.md).  Its only
bookkeeping is the `termOfUnit` map; a `(result F context)` is not materialized on it,
since the `cx/` spelling carries the role and a role is never read from belief.

The result types and the correspondence projection take the chaining the caller
asked for; `(termOfUnit K E)` is asserted with chaining off unless a `resultArg` is
written of `F` — the identity record is what the dedup probe reads, not content a rule
fires on, and the `resultArg` membership it entails is.
Minting is a step inside somebody else's assert, and a bulk load that turned
chaining off did so for the whole load: on OpenCyc the two unqualified ones ran
46,346 chain fixpoints nobody wanted, most of whose conclusions were then dropped
for having no placement context.
sourceraw docstring

names-reifiable-nat?clj

(names-reifiable-nat? kb s)

Does sentence s hold a ground reifiable NAT the write-mode reify would replace with a constant? The derivation path asks this of every conclusion it places, so the common answer is reached without allocating: false on a KB that declares no reifiable function (any-reifiable-functions?), and otherwise one walk that rebuilds nothing.

Does sentence `s` hold a ground reifiable NAT the write-mode reify would replace with
a constant?  The derivation path asks this of every conclusion it places, so the common
answer is reached without allocating: false on a KB that declares no reifiable
function (`any-reifiable-functions?`), and otherwise one walk that rebuilds nothing.
sourceraw docstring

nat-expressionclj

(nat-expression kb nat-sym)

The NAT expression a reified constant denotes, or nil — the authoritative one where an unrepaired collision maps it to more than one (authoritative-expression).

The NAT expression a reified constant denotes, or nil — the authoritative one where an
unrepaired collision maps it to more than one (`authoritative-expression`).
sourceraw docstring

nat-namespaceclj

Reserved namespace for object-denoting reified-NAT constants — a (reifiable_function F) application (F a…) mints one. The cheap detector the display and mutation layers key on.

Reserved namespace for **object**-denoting reified-NAT constants — a
`(reifiable_function F)` application `(F a…)` mints one.  The cheap detector the
display and mutation layers key on.
sourceraw docstring

nat-quoting-predicatesclj

Predicates whose NAT-bearing argument is a quoted expression and must NOT be reified or type-checked as a term: the arg holds the literal NAT being mapped (termOfUnit) or reified-to-a-real-term (rewriteOf).

Predicates whose NAT-bearing argument is a *quoted* expression and must NOT be
reified or type-checked as a term: the arg holds the literal NAT being mapped
(`termOfUnit`) or reified-to-a-real-term (`rewriteOf`).
sourceraw docstring

nat-scheme-tagclj

The one-letter scheme prefix on every content-named reified constant, nat/a…. A letter because a symbol whose name starts with a digit is not a readable token (nat/9x… reads back as an invalid token), so a numeric-leading hash could not round-trip through a dump. The letter is also the version: a is this scheme — SHA-256 truncated to 96 bits, base62 — and a later hash or encoding change is b, old constants keeping the names they were minted with (the whole reason a name carries its scheme). One letter covers both jobs, so there is nothing to separate and no separator.

Base62, not base64url, because a reified constant only ever stands in argument position, where it is held to the same spelling rules as any name (naming/argument-problem) — and base64url's two extra characters, - and _, are precisely the two those rules forbid (- would also make the name read as a sense). Base62 drops just those two, so nat/a… is [A-Za-z0-9] and matches the camelCase rule (naming/predicate?). The name is 18 characters: the one-letter tag and a 17-digit base62 payload.

The one-letter scheme prefix on every content-named reified constant, `nat/a…`.  A
**letter** because a symbol whose name starts with a digit is not a readable token
(`nat/9x…` reads back as an invalid token), so a numeric-leading hash could not
round-trip through a dump.  The letter is also the **version**: `a` is this scheme —
SHA-256 truncated to 96 bits, base62 — and a later hash or encoding change is `b`, old
constants keeping the names they were minted with (the whole reason a name carries its
scheme).  One letter covers both jobs, so there is nothing to separate and no separator.

Base62, not base64url, because a reified constant only ever stands in **argument**
position, where it is held to the same spelling rules as any name
(`naming/argument-problem`) — and base64url's two extra characters, `-` and `_`, are
precisely the two those rules forbid (`-` would also make the name read as a `sense`).
Base62 drops just those two, so `nat/a…` is `[A-Za-z0-9]` and matches the camelCase rule
(`naming/predicate?`).  The name is 18 characters: the one-letter tag and a 17-digit
base62 payload.
sourceraw docstring

no-matchclj

The reserved nat/ constant a read-mode reify resolves an unknown (never-minted) NAT to. It can never be a real minted constant, so a query carrying it matches nothing — an unknown-NAT query returns empty without minting. Never written, never displayed.

The reserved `nat/` constant a read-mode reify resolves an unknown (never-minted)
NAT to.  It can never be a real minted constant, so a query carrying it matches
nothing — an unknown-NAT query returns empty without minting.  Never written,
never displayed.
sourceraw docstring

orphan?clj

(orphan? kb k)

Is the reified constant k orphaned — is every stored sentex naming it one of k's own bookkeeping sentexes? False when nothing maps it: a constant with no believed termOfUnit names no expression, so there is no map left to dangle.

For a context constant the same question reaches one thing more, because a context is somewhere sentexes are as well as something sentences name: it is orphaned when its context slot holds nothing, no stored sentence names it, and no stored genlCx edge does either — bar the edges the structural producer computed from its own termOfUnit (computed-genlCx-edge?), which are the engine's wiring rather than anybody's claim. Its only bookkeeping is that map (minted-for).

Uses count by storage, not belief: a stored-but-OUT use revives when the defeat above it lifts, and an inert use (a labeling's choice head) has no TMS node at all — collecting the map from under either would leave it dangling a raw nat/ symbol, and re-reifying the expression would then mint a second constant beside the first, a collision no merge repair caused. Only the map read (mapped-expressions) follows belief, so a superseded spelling still answers nothing.

One term-index read answers the whole question. k's uses, its map and its materialized types are all sentexes naming k, so the inverted term index (docs/indexing.md) hands back the lot in the size of k's own footprint, and nothing here is a function of how many other constants the KB has minted. The index posts a sentex's context beside its content terms (kv/sentex-terms), so a cx/ context's extent is in that same answer and no second question has to be asked to be correct.

A context is asked the cheap half first. A context NAT is a place, so what is stored in it keeps it alive as surely as what names it — and a live one is the common case and the expensive one, since its extent is exactly what the term-index answer would materialize. count-in-context settles it in one O(1) read on every backend (docs/indexing.md, the secondary roots), so a context holding a million facts costs a count rather than a million record fetches, and only an empty one goes on to the term read. Stored, not believed, for the reason the uses are.

Asked of the authoritative expression alone, not of any expression that would answer yes: an unrepaired collision maps k to several, and bookkeeping-handles computes the retraction set from exactly one of them (nat-expression), so deciding orphanhood against a different one would retract E₂'s bookkeeping on E₁'s verdict.

Is the reified constant `k` orphaned — is every **stored** sentex naming it one of
`k`'s own bookkeeping sentexes?  False when nothing maps it: a constant with no
believed `termOfUnit` names no expression, so there is no map left to dangle.

For a **context** constant the same question reaches one thing more, because a context
is somewhere sentexes are as well as something sentences name: it is orphaned when its
context slot holds nothing, no stored sentence names it, and no stored `genlCx` edge
does either — bar the edges the structural producer computed from its own `termOfUnit`
(`computed-genlCx-edge?`), which are the engine's wiring rather than anybody's claim.
Its only bookkeeping is that map (`minted-for`).

Uses count by storage, not belief: a stored-but-OUT use revives when the defeat
above it lifts, and an inert use (a labeling's choice head) has no TMS node at all
— collecting the map from under either would leave it dangling a raw `nat/`
symbol, and re-reifying the expression would then mint a second constant beside
the first, a collision no merge repair caused.  Only the map read
(`mapped-expressions`) follows belief, so a superseded spelling still answers
nothing.

**One term-index read answers the whole question.**  `k`'s uses, its map and its
materialized types are all sentexes naming `k`, so the inverted term index
(docs/indexing.md) hands back the lot in the size of `k`'s own footprint, and nothing
here is a function of how many other constants the KB has minted.  The index posts a
sentex's **context** beside its content terms (`kv/sentex-terms`), so a `cx/` context's
extent is in that same answer and no second question has to be asked to be correct.

**A context is asked the cheap half first.**  A context NAT is a *place*, so what is
stored in it keeps it alive as surely as what names it — and a live one is the common
case and the expensive one, since its extent is exactly what the term-index answer
would materialize.  `count-in-context` settles it in one O(1) read on every backend
(docs/indexing.md, the secondary roots), so a context holding a million facts costs a
count rather than a million record fetches, and only an **empty** one goes on to the
term read.  Stored, not believed, for the reason the uses are.

Asked of the **authoritative** expression alone, not of any expression that would
answer yes: an unrepaired collision maps `k` to several, and `bookkeeping-handles`
computes the retraction set from exactly one of them (`nat-expression`), so deciding
orphanhood against a different one would retract `E₂`'s bookkeeping on `E₁`'s verdict.
sourceraw docstring

orphaned-constantsclj

(orphaned-constants kb)

Every reified constant in the KB that no live use references any more. Removing the fact that used a reified NAT leaves it an orphan — its termOfUnit and materialized types would dangle a raw nat/ symbol — so those are collected and removed.

Reads the whole map, so this is the answer about the KB, and its cost is the KB's whole termOfUnit population; the maintenance after a teardown asks the narrower orphaned-among instead.

Both kinds: an object constant nothing names, and a context constant nothing is stored in, names or wires (orphan?).

Every reified constant in the KB that no live use references any more.  Removing the
fact that used a reified NAT leaves it an orphan — its `termOfUnit` and materialized
types would dangle a raw `nat/` symbol — so those are collected and removed.

Reads the whole map, so this is the answer *about the KB*, and its cost is the KB's
whole `termOfUnit` population; the maintenance after a teardown asks the narrower
`orphaned-among` instead.

Both kinds: an object constant nothing names, and a context constant nothing is stored
in, names or wires (`orphan?`).
sourceraw docstring

orphans-named-byclj

(orphans-named-by kb sentexes)

The orphans among the constants the removed sentexes named — the region-scoped question a teardown's sweep asks each round, which is constants-named-by fed straight to orphaned-among.

One entry point because the two halves are one question: a constant becomes an orphan only when something referencing it goes, so the candidate set is what the departing sentexes named, and asking the second half of anything else would be asking about a constant no removal touched. The whole-KB reading is orphaned-constants.

The orphans among the constants the removed `sentexes` named — the region-scoped
question a teardown's sweep asks each round, which is `constants-named-by` fed straight
to `orphaned-among`.

One entry point because the two halves are one question: a constant becomes an orphan
only when something referencing it goes, so the candidate set *is* what the departing
sentexes named, and asking the second half of anything else would be asking about a
constant no removal touched.  The whole-KB reading is `orphaned-constants`.
sourceraw docstring

queue-split-uses!clj

(queue-split-uses! kb sentence)

Queue [:reifiable f] on :respell for each function f a ground application in sentence names whose mark some reader does not believe (split-reifiable?): the write stores the use reified, and the settle's reconcile stores the spelling each reader reads (chain/reconcile-reified!). One walk and no index read on a KB whose reifiable marks every reader believes.

Queue `[:reifiable f]` on `:respell` for each function `f` a ground application in
`sentence` names whose mark some reader does not believe (`split-reifiable?`): the
write stores the use reified, and the settle's reconcile stores the spelling each
reader reads (`chain/reconcile-reified!`).  One walk and no index read on a KB whose
reifiable marks every reader believes.
sourceraw docstring

readable-context-application?clj

(readable-context-application? kb form)

True iff form is a context-application? whose head CxUniverse believes denotes contexts (context-function-believed?): what a read admits as a context slot.

True iff `form` is a `context-application?` whose head CxUniverse believes denotes
contexts (`context-function-believed?`): what a read admits as a context slot.
sourceraw docstring

reconcile-nats!clj

(reconcile-nats! kb sentence)

The reified-constant maintenance a just-asserted sentence owes, in the order the assert path runs it: the collision merge first, then the correspondence, then a result declaration reaching the constants minted before it.

An equality assert is a rename, and its migration can collapse two reified constants onto one expression — so merge-colliding-nats! restores the 1:1 constant↔expression invariant, and only after an equality, since nothing else can break it. reconcile-correspondence! then equates an application with the value its corresponding predicate names, whichever of the application, the fact and the declaration arrived last.

Both are no-ops — one integer read each — on a KB that states no equality and declares no correspondence. vaelii.impl.nat-maintenance/reconcile-assert is the caller, and it holds the any-reifiable-functions? gate ahead of this.

The reified-constant maintenance a just-asserted `sentence` owes, in the order the
assert path runs it: the collision merge first, then the correspondence, then a result
declaration reaching the constants minted before it.

An equality assert is a rename, and its migration can collapse two reified constants
onto one expression — so `merge-colliding-nats!` restores the 1:1
constant↔expression invariant, and only after an equality, since nothing else can
break it.  `reconcile-correspondence!` then equates an application with the value its
corresponding predicate names, whichever of the application, the fact and the
declaration arrived last.

Both are no-ops — one integer read each — on a KB that states no equality and declares
no correspondence.  `vaelii.impl.nat-maintenance/reconcile-assert` is the caller, and it
holds the `any-reifiable-functions?` gate ahead of this.
sourceraw docstring

reifiable-entriesclj

(reifiable-entries kb f)

{[:prop :reifiable f] {handle context}}, the reifiable_function mark of f and its supporters, in res/mark-entries' shape.

`{[:prop :reifiable f] {handle context}}`, the `reifiable_function` mark of `f` and its
supporters, in `res/mark-entries`' shape.
sourceraw docstring

reifiable-function?clj

(reifiable-function? kb head)

True iff head reifies its ground applications in argument position: (reifiable_function head), minting nat/. A retracted declaration stops the function reifying. A function in *withheld* does not reify while it is bound.

The mark is read unscoped: the reified spelling is a stored key every reader shares, and a reader that does not believe the mark binds *withheld*.

True iff `head` reifies its ground applications in argument position:
`(reifiable_function head)`, minting `nat/`.  A retracted declaration stops the function
reifying.  A function in `*withheld*` does not reify while it is bound.

The mark is read unscoped: the reified spelling is a stored key every reader shares, and
a reader that does not believe the mark binds `*withheld*`.
sourceraw docstring

reifiable-ground-nat?clj

(reifiable-ground-nat? kb form)

True iff form is a ground (F …) whose head F is an object reifiable_function — a NAT the sentence/argument reify walk may mint to a nat/ constant. Ground because an open NAT ((F ?x)) would need an enumerating prover to mint anything, so it is left alone. sequential?, not seq?: reification runs before canon, so a vector-spelled [F …] is the same NAT as (F …) — gating on the list spelling alone would store the raw compound where the other spelling stores the constant, two handles for one canonical sentence.

The sentence walk is argument position, so it mints nat/ only. The context slot is not on it: maybe-reify-context mints that slot's cx/ constant, so one expression in both positions names two constants and no cx/ context is an argument (docs/context-nat.md).

True iff `form` is a ground `(F …)` whose head F is an **object** reifiable_function — a
NAT the sentence/argument reify walk may mint to a `nat/` constant.  Ground because an
open NAT (`(F ?x)`) would need an enumerating prover to mint anything, so it is left
alone.  `sequential?`, not `seq?`: reification runs before `canon`, so a vector-spelled
`[F …]` is the same NAT as `(F …)` — gating on the list spelling alone would store the
raw compound where the other spelling stores the constant, two handles for one canonical
sentence.

The sentence walk is argument position, so it mints `nat/` only.  The context slot is
not on it: `maybe-reify-context` mints that slot's `cx/` constant, so one expression in
both positions names two constants and no `cx/` context is an argument
(docs/context-nat.md).
sourceraw docstring

reified-context-symbol?clj

(reified-context-symbol? term)

True iff term is a reified context constant — a symbol in the cx/ namespace. The discriminant that lets a reified constant classify as a context (naming/context?) while an object nat/ constant classifies as a term, and what the orphan sweep reads to ask the context liveness question of one: a context is kept alive by what is stored in it as much as by what names it (orphan?).

True iff `term` is a reified **context** constant — a symbol in the `cx/`
namespace.  The discriminant that lets a reified constant classify as a context
(`naming/context?`) while an object `nat/` constant classifies as a term, and what the
orphan sweep reads to ask the *context* liveness question of one: a context is kept
alive by what is stored **in** it as much as by what names it (`orphan?`).
sourceraw docstring

reified-namespacesclj

The two reserved namespaces a reified constant lives in — object (nat/) and context (cx/). Everything that asks 'is this an opaque reified constant' — display, the K → E lookup, the orphan sweep — keys on membership here, since both kinds carry a termOfUnit map and reify the same way; only the mint namespace and the role differ.

The two reserved namespaces a reified constant lives in — object (`nat/`) and
context (`cx/`).  Everything that asks 'is this an opaque reified constant' — display,
the `K → E` lookup, the orphan sweep — keys on membership here, since both kinds carry
a `termOfUnit` map and reify the same way; only the mint namespace and the role differ.
sourceraw docstring

reified-nat-symbol?clj

(reified-nat-symbol? term)

True iff term is a reified constant — a symbol in one of the two reserved reified namespaces, object (nat/) or context (cx/). Despite the object-case name it recognizes both kinds: every caller wants 'is this an opaque reified constant', which both are — they share the termOfUnit map, the display expansion, and the orphan sweep.

True iff `term` is a reified constant — a symbol in one of the two reserved
reified namespaces, object (`nat/`) or context (`cx/`).  Despite the object-case name it
recognizes both kinds: every caller wants 'is this an opaque
reified constant', which both are — they share the `termOfUnit` map, the
display expansion, and the orphan sweep.
sourceraw docstring

reified-nats-inclj

(reified-nats-in form)

Every reified-NAT constant form names, at any nesting.

Descends a vector as well as a list, since a vector in a sentence is a list of forms — an exceptWhen's conjuncts, a thereExists's binders — and a constant standing in one is as much a reference as a constant in a literal.

Every reified-NAT constant `form` names, at any nesting.

Descends a vector as well as a list, since a vector in a sentence is a *list of forms*
— an `exceptWhen`'s conjuncts, a `thereExists`'s binders — and a constant standing in
one is as much a reference as a constant in a literal.
sourceraw docstring

reified-object-symbol?clj

(reified-object-symbol? term)

True iff term is a reified object constant — a symbol in the nat/ namespace. The other half of the pair: an object constant denotes a thing sentences talk about, so nothing can be stored in it and naming is the whole of its liveness.

True iff `term` is a reified **object** constant — a symbol in the `nat/` namespace.
The other half of the pair: an object constant denotes a *thing* sentences talk about,
so nothing can be stored in it and naming is the whole of its liveness.
sourceraw docstring

reify-existingclj

(reify-existing kb sentence)

Reify every reifiable ground NAT subterm of sentence that has an existing term to that term, and leave every other one as written. Never mints.

vaelii.core/check reads a sentence through this. assert would reify the same subterms, minting the ones with no term yet, and check may not write: an application with a term is read as that term, as assert reads it, and one without stays an application, which the argument checks read as the constant assert would mint (checks/*entry-mints?*). Cheap no-op when the KB declares no reifiable_function.

Reify every reifiable ground NAT subterm of `sentence` that has an existing term to
that term, and leave every other one as written.  Never mints.

`vaelii.core/check` reads a sentence through this.  `assert` would reify the same subterms,
minting the ones with no term yet, and `check` may not write: an application with a
term is read as that term, as `assert` reads it, and one without stays an application,
which the argument checks read as the constant `assert` would mint
(`checks/*entry-mints?*`).  Cheap no-op when the KB declares no `reifiable_function`.
sourceraw docstring

reify-inclj

(reify-in kb s nat-fn)

Reify every reifiable ground NAT subterm of literal/sentence s, calling nat-fn (a (fn [kb form])) at each one — it returns the NAT's constant, having reified any nested NAT args itself. Quoting-predicate arguments (termOfUnit / rewriteOf) are left opaque, as is every head predicate.

A vector is descended element by element, and every element of it. A vector in a sentence is a list of forms rather than a literal — an exceptWhen's conjuncts, a thereExists's binders — so it has no head predicate to hold opaque and no element to skip. Stopping at one would leave an exception's query spelled with the compound while the fact it is about is stored under the constant, and an exception that cannot be answered does not hold: the rule would fire, unguarded and silently.

Reify every reifiable ground NAT subterm of literal/sentence `s`, calling
`nat-fn` (a `(fn [kb form])`) at each one — it returns the NAT's constant, having
reified any nested NAT args itself.  Quoting-predicate arguments
(`termOfUnit` / `rewriteOf`) are left opaque, as is every head predicate.

**A vector is descended element by element, and every element of it.**  A vector in a
sentence is a *list of forms* rather than a literal — an `exceptWhen`'s conjuncts, a
`thereExists`'s binders — so it has no head predicate to hold opaque and no element to
skip.  Stopping at one would leave an exception's query spelled with the compound
while the fact it is about is stored under the constant, and an exception that cannot
be answered does not hold: the rule would fire, unguarded and silently.
sourceraw docstring

reify-or-mint-natclj

(reify-or-mint-nat kb form)
(reify-or-mint-nat kb form chain?)
(reify-or-mint-nat kb form ns chain?)

Reify a ground NAT form to the term it denotes in reify namespace ns (default nat/): reify any nested NAT args first, then return the existing term for the expression (existing-term: a rewriteOf target, the value its corresponding predicate already names, else a prior termOfUnit mint) or mint a fresh constant.

A real term outranks a placeholder, which is why the correspondence is consulted before the dedup probe: a constant minted while the value was unknown is folded onto that value as soon as it arrives (reconcile-correspondence!), so by the time both exist the two answers agree — and until the merge lands, resolving to the name a reader wrote beats resolving to an opaque one.

A quoting_function's argument is a mention — the term named as syntax — so its nested NATs are not reified: (Quote (FruitFn Apple)) mints against the literal (FruitFn Apple), not against that NAT's own constant, or two quoted syntaxes whose payloads' referents merged would collapse to one mention. The whole quoted expression is the identity, held opaque here the same way res/representative-term holds it opaque to a sameAs merge.

The quoting_function mark is read unscoped: whether an argument is a mention is a fact about the sentence (tax/mention-marks).

Reify a ground NAT `form` to the term it denotes in reify namespace `ns` (default
`nat/`): reify any nested NAT args first, then return the existing term for the
expression (`existing-term`: a `rewriteOf` target, the value its corresponding predicate
already names, else a prior `termOfUnit` mint) or mint a fresh constant.

A **real term outranks a placeholder**, which is why the correspondence is consulted
before the dedup probe: a constant minted while the value was unknown is folded onto
that value as soon as it arrives (`reconcile-correspondence!`), so by the time both
exist the two answers agree — and until the merge lands, resolving to the name a
reader wrote beats resolving to an opaque one.

A **`quoting_function`'s argument is a mention** — the term named as syntax — so its
nested NATs are **not** reified: `(Quote (FruitFn Apple))` mints against the literal
`(FruitFn Apple)`, not against that NAT's own constant, or two quoted syntaxes whose
payloads' referents merged would collapse to one mention.  The whole quoted expression
is the identity, held opaque here the same way `res/representative-term` holds it opaque
to a `sameAs` merge.

The `quoting_function` mark is read unscoped: whether an argument is a mention is a
fact about the sentence (`tax/mention-marks`).
sourceraw docstring

resolve-for-readclj

(resolve-for-read kb sentence)

The read-mode reify of sentence (maybe-reify-for-read: dedup, never mint) when every reifiable NAT in it already has a stored constant, else nil — the sentence names a NAT that was never minted, so it has no stored atomic form.

A read entry point hands the reified sentence with its no-match sentinels straight to the lookup, which then matches nothing; a write path that must not mint (core/assert- inert) refuses on nil instead, and an un-stored canonicalizer (core/canonical-sentex) keeps the compound. Cheap no-op returning the sentence unchanged when the KB declares no reifiable_function.

The read-mode reify of `sentence` (`maybe-reify-for-read`: dedup, never mint) when
every reifiable NAT in it already has a stored constant, else nil — the sentence names
a NAT that was never minted, so it has no stored atomic form.

A read entry point hands the reified sentence with its `no-match` sentinels straight to
the lookup, which then matches nothing; a write path that must not mint (`core/assert-
inert`) refuses on nil instead, and an un-stored canonicalizer (`core/canonical-sentex`)
keeps the compound.  Cheap no-op returning the sentence unchanged when the KB declares
no `reifiable_function`.
sourceraw docstring

respell-regionclj

(respell-region kb f)

The stored sentexes a reifiable_function mark on f moving can re-spell: each one holding an application of f, and each use of an object constant whose expression holds one, at any nesting (a constant whose expression names such a constant included). Left out: a quoting predicate's row, whose payload is a mention, a constant's own sentexes (own-sentex-test), which the orphan sweep collects once the uses have moved, and the uses of a constant an equality retired. Stored, not believed: a use sitting OUT moves as a believed one does, so its revival finds it spelled as the KB spells it.

One term-index read for f and one per constant reached, so the cost is the size of f's applications and their constants' uses.

The stored sentexes a `reifiable_function` mark on `f` moving can re-spell: each one
holding an application of `f`, and each use of an object constant whose expression
holds one, at any nesting (a constant whose expression names such a constant
included).  Left out: a quoting predicate's row, whose payload is a mention, a
constant's own sentexes (`own-sentex-test`), which the orphan sweep collects once the
uses have moved, and the uses of a constant an equality retired.  Stored, not believed: a use sitting OUT moves as a believed one does,
so its revival finds it spelled as the KB spells it.

One term-index read for `f` and one per constant reached, so the cost is the size of
`f`'s applications and their constants' uses.
sourceraw docstring

respelledclj

(respelled kb sentence)

sentence as the write path spells it under the marks believed now: every object constant expanded to the expression it maps to, then every ground reifiable application reified again (maybe-reify-nats), minting what has no term yet. Equal to sentence when no mark it depends on has moved.

`sentence` as the write path spells it under the marks believed now: every object
constant expanded to the expression it maps to, then every ground reifiable application
reified again (`maybe-reify-nats`), minting what has no term yet.  Equal to `sentence`
when no mark it depends on has moved.
sourceraw docstring

result-typesclj

(result-types kb head)
(result-types kb head context)

Types T with (result head T) — what an application of head is an instance of. Materialized as (T K) on a freshly minted reified NAT whose function is head, and read at check time for an application that is never minted (docs/argtypes.md). Globally, or (with context) through only the declarations visible from it.

Given an application (head a…) in place of head, the types its resultArg declarations name are added: the argument at each declared position. The checks read that form; the argument entailment types a minted constant by a resultArg (checks/result-arg-rows).

Types `T` with `(result head T)` — what an application of `head` is an *instance*
of.  Materialized as `(T K)` on a freshly minted reified NAT whose function is `head`,
and read at check time for an application that is never minted (docs/argtypes.md).
Globally, or (with `context`) through only the declarations visible from it.

Given an application `(head a…)` in place of `head`, the types its `resultArg`
declarations name are added: the argument at each declared position.  The checks read
that form; the argument entailment types a minted constant by a `resultArg`
(`checks/result-arg-rows`).
sourceraw docstring

rewrite-targetclj

(rewrite-target kb E)
(rewrite-target kb E ns)

The real term T a (rewriteOf T E) declaration says the NAT expression E reifies to instead of a fresh constant, or nil. A quoting-predicate declaration: E is the literal NAT payload, T an existing atomic term. Given reify namespace ns, a T outside it (in-namespace?) answers nil, so a context slot resolves only to a context.

Nil when the believed declarations name more than one target, exactly as correspondence-of answers its twin question: picking between them by whichever the retrieval yielded first would store (likes Tom Mary) or (likes Tom Maria) according to the order two rewriteOfs arrived — divergent stored state, which every later read then inherits. Two targets are a disagreement for the clash machinery, not a tie for this read to break; two declarations of one target (the engine's own reconcile writes those) are one answer.

The real term `T` a `(rewriteOf T E)` declaration says the NAT expression `E`
reifies to instead of a fresh constant, or nil.  A quoting-predicate declaration:
`E` is the literal NAT payload, `T` an existing atomic term.  Given reify namespace
`ns`, a `T` outside it (`in-namespace?`) answers nil, so a context slot resolves only
to a context.

Nil when the believed declarations name **more than one target**, exactly as
`correspondence-of` answers its twin question: picking between them by whichever
the retrieval yielded first would store `(likes Tom Mary)` or `(likes Tom Maria)`
according to the order two `rewriteOf`s arrived — divergent *stored* state, which
every later read then inherits.  Two targets are a disagreement for the clash
machinery, not a tie for this read to break; two declarations of **one** target
(the engine's own reconcile writes those) are one answer.
sourceraw docstring

split-reifiable?clj

(split-reifiable? kb f)

Does some reader not believe f's stored reifiable_function mark (res/uniform-marks?)?

Does some reader not believe `f`'s stored `reifiable_function` mark
(`res/uniform-marks?`)?
sourceraw docstring

universal-contextclj

Where every NAT bookkeeping fact lives — (reifiable_function F), (termOfUnit K E), (result F T), and a minted reified NAT's materialized types — so it is visible from every context, matching the other universal vocabulary.

Where every NAT bookkeeping fact lives — `(reifiable_function F)`, `(termOfUnit K
E)`, `(result F T)`, and a minted reified NAT's materialized types — so it is visible
from every context, matching the other universal vocabulary.
sourceraw docstring

withheld-atclj

(withheld-at kb reader)

The reifiable functions reader does not believe the mark of while another reader does, as a set: what *withheld* holds to spell a sentence as reader reads it. Empty for a variable or nil reader.

The marks are read unscoped, a superset that split-reifiable? and res/entries-at narrow to reader.

The reifiable functions `reader` does not believe the mark of while another reader
does, as a set: what `*withheld*` holds to spell a sentence as `reader` reads it.
Empty for a variable or nil `reader`.

The marks are read unscoped, a superset that `split-reifiable?` and `res/entries-at`
narrow to `reader`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close