Liking cljdoc? Tell your friends :D

vaelii.impl.assert-entry

The per-sentence write entry point: what vaelii.core/assert does once it has one sentence in one context.

Three things live together here because the assert path runs them as one step and preview has to undo all three:

  • The premise mark, written to the network node and the record slot together (put-premise-mark), and resolved from content rather than arrival order (mark-premise says why a bare re-assert may not downgrade a class).
  • The rule slots, reconciled when a rule is stated twice (reconcile-rule-slots!, join-engines).
  • The dispatch a sentence takes — imperative, ist, rule, or plain fact (assert-one).

*premise-audit* is the hook a batch rollback reads (core/rollback-batch!).

assert-one takes the re-entry as an argument. An (ist Ctx S) sentence is not stored — it asserts S in Ctx — so the dispatch re-enters the caller's own entry point. That is vaelii.core/assert, and an engine namespace may not require vaelii.core, so the caller passes it in.

The per-sentence write entry point: what `vaelii.core/assert` does once it has one
sentence in one context.

Three things live together here because the assert path runs them as one step and
`preview` has to undo all three:

- **The premise mark**, written to the network node and the record slot together
  (`put-premise-mark`), and resolved from content rather than arrival order
  (`mark-premise` says why a bare re-assert may not downgrade a class).
- **The rule slots**, reconciled when a rule is stated twice
  (`reconcile-rule-slots!`, `join-engines`).
- **The dispatch** a sentence takes — imperative, `ist`, rule, or plain fact
  (`assert-one`).

`*premise-audit*` is the hook a batch rollback reads (`core/rollback-batch!`).

**`assert-one` takes the re-entry as an argument.**  An `(ist Ctx S)` sentence is not
stored — it asserts `S` in `Ctx` — so the dispatch re-enters the caller's own entry
point.  That is `vaelii.core/assert`, and an engine namespace may not require
`vaelii.core`, so the caller passes it in.
raw docstring

*premise-audit*clj

When bound to an atom, every premise mark on the assert path first records the datum's prior premise state here — {handle {:premise? bool :strength kw :spellings rec}}, first writer wins, :spellings read only for a prior premise. core/preview, core/edit! and a single core/assert bind it, and core/rollback-batch! reads it (docs/preview.md, "The mechanism").

When bound to an atom, every premise mark on the assert path first records the
datum's **prior** premise state here — `{handle {:premise? bool :strength kw
:spellings rec}}`, first writer wins, `:spellings` read only for a prior premise.
`core/preview`, `core/edit!` and a single `core/assert` bind it, and
`core/rollback-batch!` reads it (docs/preview.md, "The mechanism").
sourceraw docstring

assert-exceptWhen-meta!clj

(assert-exceptWhen-meta! kb rule-handle exc author-vm context opts)

Store one exceptWhen exception against the rule at rule-handle as a belief-following (exceptWhen <aligned-query> (sentexHandle rule-handle)) meta-sentex, and return its handle.

exc is the exception's conjunct literals in the author's variable names (as written beside the rule), and author-vm is the canonical→author varmap of the rule as written in this assert — not the rule's stored varmap, which carries whatever names the rule was first asserted with, so a re-reference under new variable names would misalign. The query is mapped to the rule's canonical variables through it, so a firing's bindings substitute straight in; an exception variable no antecedent binds is refused (:exception-not-closed), as is a quantifier binder the rule also names (:quantifier-not-local) and one that would close a cycle through negation (check-exceptWhen-stratified). Storing it posts the re-check index (index-exceptWhen-meta) and settles, so any conclusion the new exception now blocks is swept before this returns.

Store one exceptWhen exception against the rule at `rule-handle` as a
belief-following `(exceptWhen <aligned-query> (sentexHandle rule-handle))`
meta-sentex, and return its handle.

`exc` is the exception's conjunct literals in the *author's* variable names (as
written beside the rule), and `author-vm` is the canonical→author varmap of the rule
**as written in this assert** — not the rule's stored varmap, which carries whatever
names the rule was *first* asserted with, so a re-reference under new variable names
would misalign.  The query is mapped to the rule's canonical variables through it, so
a firing's bindings substitute straight in; an exception variable no antecedent binds
is refused (`:exception-not-closed`), as is a quantifier binder the rule also names
(`:quantifier-not-local`) and one that would close a cycle through
negation (`check-exceptWhen-stratified`).  Storing it posts the re-check index
(`index-exceptWhen-meta`) and settles, so any conclusion the new exception now blocks
is swept before this returns.
sourceraw docstring

assert-oneclj

(assert-one kb sentence context opts {:keys [assert-fn bulk?]})

Assert a single sentence (any conjunctive-consequent rule is split into one rule per conjunct by assert before reaching here). Returns the sentex handle.

from carries what only the caller's entry point knows: :assert-fn, re-entered for an (ist Ctx S) sentence and for nothing else, and :bulk?, the caller-guaranteed bulk-load mode that turns off the per-fact machinery which only validates or dedups. :bulk? is a value rather than a var read because the public knob is vaelii.core/*bulk-load?*, and an engine namespace may not read vaelii.core.

Assert a single sentence (any conjunctive-consequent rule is split into one rule
per conjunct by `assert` before reaching here).  Returns the sentex handle.

`from` carries what only the caller's entry point knows: `:assert-fn`, re-entered for
an `(ist Ctx S)` sentence and for nothing else, and `:bulk?`, the caller-guaranteed
bulk-load mode that turns off the per-fact machinery which only validates or dedups.
`:bulk?` is a value rather than a var read because the public knob is
`vaelii.core/*bulk-load?*`, and an engine namespace may not read `vaelii.core`.
sourceraw docstring

check-rule-sentenceclj

(check-rule-sentence kb sentence context)

Every pre-storage check a rule must pass, as a step that writes nothing — checks/check-rule!, the list both storage entry points read (the other being a generator firing, chain/place-conclusion). A generator's own three are in that list rather than beside it, because a minted rule can be a generator too (docs/generators.md) and a check only this entry point ran would be one the fixpoint could store around.

Every pre-storage check a rule must pass, as a step that writes nothing —
`checks/check-rule!`, the list both storage entry points read (the other being a generator
firing, `chain/place-conclusion`).  A generator's own three are in that list rather
than beside it, because a *minted* rule can be a generator too (docs/generators.md)
and a check only this entry point ran would be one the fixpoint could store around.
sourceraw docstring

ist-partsclj

(ist-parts sentence)

The [context sentence] an (ist Ctx S) names, or nil when the form is not one — a bare (ist Ctx) included.

assert and check both read the form here, so a malformed ist is one refusal on both paths. Reaching into it positionally is how the two would disagree: check taking a default and reporting :shape while assert takes none and throws a bare IndexOutOfBoundsException, which carries no :type for a caller to discriminate on and names nothing a writer can act on.

The `[context sentence]` an `(ist Ctx S)` names, or nil when the form is not one — a
bare `(ist Ctx)` included.

`assert` and `check` both read the form here, so a malformed `ist` is one refusal on
both paths.  Reaching into it positionally is how the two would disagree: `check`
taking a default and reporting `:shape` while `assert` takes none and throws a bare
`IndexOutOfBoundsException`, which carries no `:type` for a caller to discriminate on
and names nothing a writer can act on.
sourceraw docstring

ist-shape-problemclj

(ist-shape-problem sentence)

The :shape problem a malformed ist is refused with — a value for check, and the ex-info assert throws.

The `:shape` problem a malformed `ist` is refused with — a value for `check`, and the
`ex-info` `assert` throws.
sourceraw docstring

put-premise-markclj

(put-premise-mark kb h strength)

Write the premise mark on sentex h at exactly strength — the network's node and the record store's slot, which the assert path always moves together. One function so neither half can be marked without the other: the network is what labelling reads and the record is what recover rebuilds the network from, so a KB whose two halves disagreed would answer one thing until it restarted and another afterwards.

Callers say mark-premise instead. This is the raw write, and the only caller that wants it is the one restoring a mark it recorded — rollback-batch!, putting back a class the KB already held rather than stating one.

Write the premise mark on sentex `h` at exactly `strength` — the network's node and
the record store's slot, which the assert path always moves together.  One function so
neither half can be marked without the other: the network is what labelling reads and
the record is what `recover` rebuilds the network from, so a KB whose two halves
disagreed would answer one thing until it restarted and another afterwards.

Callers say `mark-premise` instead.  This is the raw write, and the only caller that
wants it is the one *restoring* a mark it recorded — `rollback-batch!`, putting back a
class the KB already held rather than stating one.
sourceraw docstring

storage-contextclj

(storage-context kb pred context)

The context a fact whose functor is pred is stored in when asserted in context: CxUniverse for a forced_decontextualized_predicate, context otherwise. Reads the global property on purpose: this decides where the sentex is stored, storage does not vary by the writer's visibility, and scoping the placement by what can see the declaration would be circular. assert-one places with it, and vaelii.core's fact-problems and check-reified-inputs! read with it, so a check reads the fact from the context the store would hold it in.

The context a fact whose functor is `pred` is stored in when asserted in `context`:
CxUniverse for a `forced_decontextualized_predicate`, `context` otherwise.  Reads the
**global** property on purpose: this decides where the sentex is stored, storage does
not vary by the writer's visibility, and scoping the placement by what can see the
declaration would be circular.  `assert-one` places with it, and `vaelii.core`'s
`fact-problems` and `check-reified-inputs!` read with it, so a check reads the fact
from the context the store would hold it in.
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