Liking cljdoc? Tell your friends :D

vaelii.impl.naming

KB naming invariants, as predicates over symbols — and the walk that applies them to every literal of a sentence rather than to its outermost functor alone.

predicate camelCase, lowercase-initial, no underscore parentOf, genl, arg individual CapitalCamelCase Muffet, Tom type snake_case, lowercase, unary predicate dog, physical_object sense a type, plus which sense of it is meant abrasive-grit context Cx prefix, then CapitalCamelCase CxUniverse, CxCore lexeme the lex namespace; the name is parse input lex/fool's_gold

Single lowercase words (dog, genl, parentOf) satisfy both predicate? and type-symbol?; role is disambiguated by position and arity, not the symbol alone. A sense is a type too, so it is unary for the same reason, and a lexeme is the one role a namespace decides — its text is a surface form and not ours to spell. A functor carrying an underscore is a type name and nothing else, and types are used as unary predicates — (dog Muffet), not (isa Muffet Dog) — so it is legal at arity 1 and nowhere else. (lives_in penguin cold_place) is a type name doing a relation's job; admitting it fragments the vocabulary into one-off predicates (lives_in_antarctica, capable_of_swimming) that can never join a rule or match another sentence.

How hard these are enforced is the KB's to say, not this namespace's: open-kb's :naming selects :strict / :warn / :off (policies, below) and assert reads it. The predicates themselves do not move — :off stores a name nothing can classify, not one classified differently.

problems checks the functor of every literal a sentence contains — a rule's antecedents, its consequent, an exceptWhen query's conjuncts, a not body, an ist-directed sentence, a negation-as-failure query — not only the outermost one. A rule consequent is exactly where generated content lands, and the outermost functor there is implies.

KB naming invariants, as predicates over symbols — and the walk that applies them to
every **literal** of a sentence rather than to its outermost functor alone.

  predicate    camelCase, lowercase-initial, no underscore   parentOf, genl, arg
  individual   CapitalCamelCase                               Muffet, Tom
  type         snake_case, lowercase, unary predicate         dog, physical_object
  sense        a type, plus which sense of it is meant        abrasive-grit
  context      Cx prefix, then CapitalCamelCase               CxUniverse, CxCore
  lexeme       the `lex` namespace; the name is parse input   lex/fool's_gold

Single lowercase words (dog, genl, parentOf) satisfy both `predicate?` and
`type-symbol?`; role is disambiguated by position and arity, not the symbol alone.
A sense is a type too, so it is unary for the same reason, and a lexeme is the one
role a *namespace* decides — its text is a surface form and not ours to spell.
A functor carrying an **underscore** is a type name and nothing else, and types are
used as *unary* predicates — `(dog Muffet)`, not `(isa Muffet Dog)` — so it is legal at
arity 1 and nowhere else.  `(lives_in penguin cold_place)` is a type name doing a
relation's job; admitting it fragments the vocabulary into one-off predicates
(`lives_in_antarctica`, `capable_of_swimming`) that can never join a rule or match
another sentence.

How hard these are enforced is the **KB's** to say, not this namespace's: `open-kb`'s
`:naming` selects `:strict` / `:warn` / `:off` (`policies`, below) and `assert` reads
it.  The predicates themselves do not move — `:off` stores a name nothing can classify,
not one classified differently.

`problems` checks the functor of every literal a sentence contains — a rule's
antecedents, its consequent, an `exceptWhen` query's conjuncts, a `not` body, an
`ist`-directed sentence, a negation-as-failure query — not only the outermost one.
A rule consequent is exactly where generated content lands, and the outermost
functor there is `implies`.
raw docstring

adviceclj

(advice sentence)

A well-formed sentence that is nonetheless almost certainly not what was meant — or nil. Where problems reads the invariants, this reads intent, so everything here passes every check and stores cleanly.

One entry so far. (isa Muffet Dog) is the membership spelling every other KR system taught the reader, and here it stores a two-place predicate named isa relating two individuals — legal, indexed, believed, and matched by nothing anyone will ask. The reader then asks (isa? kb 'Muffet 'Dog) and gets false, with no error to search for, because the type they meant was never asserted. CxCore.txt says never to write it and docs/naming.md calls it out by name; neither is in front of someone who is typing.

The bar for a new entry is that the shape has no legitimate reading: isa is a predicate no shipped KB declares and the one the ontology names as the mistake. A shape somebody might mean stays out — a nudge that fires on correct input is one that gets tuned out, and takes the real ones with it.

A well-formed sentence that is nonetheless almost certainly not what was meant — or
nil.  Where `problems` reads the invariants, this reads *intent*, so everything here
passes every check and stores cleanly.

One entry so far.  `(isa Muffet Dog)` is the membership spelling every other KR system
taught the reader, and here it stores a two-place predicate named `isa` relating two
individuals — legal, indexed, believed, and matched by nothing anyone will ask.  The
reader then asks `(isa? kb 'Muffet 'Dog)` and gets false, with no error to search for,
because the type they meant was never asserted.  `CxCore.txt` says never to write
it and `docs/naming.md` calls it out by name; neither is in front of someone who is
typing.

The bar for a new entry is that the shape has no legitimate reading: `isa` is a
predicate no shipped KB declares and the one the ontology names as the mistake.  A
shape somebody might mean stays out — a nudge that fires on correct input is one that
gets tuned out, and takes the real ones with it.
sourceraw docstring

advise!clj

(advise! policy sentence context)

Log advice about sentence, once per process per kind of advice.

Silent under :naming :off, which asks for names not to be policed at all. Never a refusal at any policy: the sentence is well-formed, and refusing a legal shape on a guess about intent would make the front door unpredictable.

Log `advice` about `sentence`, once per process per kind of advice.

Silent under `:naming :off`, which asks for names not to be policed at all.  Never a
refusal at any policy: the sentence is well-formed, and refusing a legal shape on a
guess about intent would make the front door unpredictable.
sourceraw docstring

applied-literalsclj

(applied-literals sentence)
(applied-literals role form)

The [role literal] pairs of sentence as written — every position at which it applies something to arguments, tagged with the frame that position sits in (:sentence / :antecedent / :consequent / :exception).

Frames are descended through, arguments are not, so this is exactly the set of positions an author wrote a predicate application in — a variable functor ((?p ?x ?y), the dotted rest (?pred . ?args)) among them, which is what literals filters back out and rules/variable-functor-literals keeps.

The `[role literal]` pairs of `sentence` as written — every position at which it
applies *something* to arguments, tagged with the frame that position sits in
(`:sentence` / `:antecedent` / `:consequent` / `:exception`).

Frames are descended through, arguments are not, so this is exactly the set of
positions an author wrote a predicate application in — a variable functor
(`(?p ?x ?y)`, the dotted rest `(?pred . ?args)`) among them, which is what
`literals` filters back out and `rules/variable-functor-literals` keeps.
sourceraw docstring

argsclj

(args sentence)
source

arityclj

(arity sentence)
source

blocking-problemsclj

(blocking-problems policy sentence context)

The naming violations that stop something under policy — the messages, or nil. Empty under :warn and :off by construction, so a caller that has to yield a value rather than throw (special/definitional-violation, the assert dry run) asks this and needs no policy branch of its own.

The naming violations that **stop** something under `policy` — the messages, or nil.
Empty under `:warn` and `:off` by construction, so a caller that has to yield a value
rather than throw (`special/definitional-violation`, the `assert` dry run) asks this
and needs no policy branch of its own.
sourceraw docstring

by-print-keyclj

(by-print-key coll)

coll ordered by its elements' print-key — the guarded form of (sort-by str coll), and what a caller ordering terms, sentences or pairs wants when the printed order is the contract.

sort-by-content-key underneath, so the key is built once per element rather than once per comparison, which is what a printed key costs most in: sort-by calls its key fn from inside the comparator, and print-key opens a binding frame per call. compare because a printed key's lexicographic order is the whole reason it was printed.

`coll` ordered by its elements' `print-key` — the guarded form of `(sort-by str coll)`,
and what a caller ordering terms, sentences or pairs wants when the printed order is
the contract.

`sort-by-content-key` underneath, so the key is built **once per element** rather than
once per comparison, which is what a printed key costs most in: `sort-by` calls its key
fn from inside the comparator, and `print-key` opens a binding frame per call.  `compare`
because a printed key's lexicographic order is the whole reason it was printed.
sourceraw docstring

check!clj

(check! policy sentence context)

Enforce policy on sentence in context: throw :naming under :strict, log under :warn, do nothing under :off. The one place the three differ, so no caller spells the throw out and none can drift from another.

Past the invariants it also gives advice — for a sentence that breaks none of them and is still a mistake, which a refusal cannot reach.

Enforce `policy` on `sentence` in `context`: throw `:naming` under `:strict`, log
under `:warn`, do nothing under `:off`.  The one place the three differ, so no caller
spells the throw out and none can drift from another.

Past the invariants it also gives `advice` — for a sentence that breaks none of them
and is still a mistake, which a refusal cannot reach.
sourceraw docstring

compare-formclj

(compare-form a b)

A structural total order on sentence / context content — what a clash report's sides and a (contradicts …) sentence are ordered by — computed by walking the two forms in place rather than printing them. A drop-in Comparator for sort / sort-by.

Total and deterministic, and read from content alone: no handle enters it, so a tie it breaks is broken the same way in every arrival order. Different kinds order by form-rank; same-kind scalars by the natural compare (symbols by ns then name, numbers numerically, and so on); two sequentials element by element, then shorter first — so (a) precedes (a b). The last-resort :else is unreachable for well-formed sentence content and totalizes the order for an exotic value alone.

The order is arbitrary but stable, which is the contract a content order owes (docs/nmtms.md). It is deliberately not the lexicographic order pr-str gave — (a) before (a b) where the printed forms compared the other way — so a caller that had pinned that exact reading re-pins this one.

A structural total order on sentence / context content — what a clash report's sides
and a `(contradicts …)` sentence are ordered by — computed by walking the two forms
in place rather than printing them.  A drop-in `Comparator` for `sort` / `sort-by`.

Total and deterministic, and read from **content alone**: no handle enters it, so a
tie it breaks is broken the same way in every arrival order.  Different kinds order by
`form-rank`; same-kind scalars by the natural `compare` (symbols by ns then name,
numbers numerically, and so on); two sequentials element by element, then shorter
first — so `(a)` precedes `(a b)`.  The last-resort `:else` is unreachable for
well-formed sentence content and totalizes the order for an exotic value alone.

The order is arbitrary but stable, which is the contract a content order owes
(docs/nmtms.md).  It is deliberately **not** the lexicographic order `pr-str` gave —
`(a)` before `(a b)` where the printed forms compared the other way — so a caller that
had pinned that exact reading re-pins this one.
sourceraw docstring

context-namespaceclj

Reserved namespace of a reified context constant (vaelii.impl.nat, docs/context-nat.md) — a cx/ symbol is a context by the same spelling-only rule as a Cx… name. Duplicated here as a literal rather than required from vaelii.impl.nat (which requires this namespace) so the role predicates stay dependency-free.

Reserved namespace of a reified **context** constant (`vaelii.impl.nat`,
docs/context-nat.md) — a `cx/` symbol is a context by the same spelling-only rule as a
`Cx…` name.  Duplicated here as a literal rather than required from `vaelii.impl.nat`
(which requires *this* namespace) so the role predicates stay dependency-free.
sourceraw docstring

context?clj

(context? x)

A context: a Cx… CapitalCamelCase name, or a reified context constant in the cx/ namespace. Both decided by spelling alone — role-reading never consults belief (docs/naming.md), which is why a reified context NAT carries its own namespace rather than a (context K) mark a context? would have to look up.

A context: a `Cx…` CapitalCamelCase name, or a reified context constant in the `cx/`
namespace.  Both decided by spelling alone — role-reading never consults belief
(docs/naming.md), which is why a reified *context* NAT carries its own namespace rather
than a `(context K)` mark a `context?` would have to look up.
sourceraw docstring

empty-tallyclj

A fresh tally accumulator: records seen, records with at least one violation, and the per-class breakdown. Counts records rather than violations — one sentence can break three conventions, and what an operator is deciding is what fraction of the corpus is re-assertable.

A fresh `tally` accumulator: records seen, records with at least one violation, and
the per-class breakdown.  Counts records rather than violations — one sentence can
break three conventions, and what an operator is deciding is what fraction of the
corpus is re-assertable.
sourceraw docstring

functorclj

(functor sentence)
source

individual?clj

(individual? x)
source

lexeme-namespaceclj

The namespace marking a lexeme — a surface form exactly as a model or a person wrote it, before anything decided what it means. A namespace rather than a spelling because a lexeme's own text is unconstrained: it carries apostrophes (fool's_gold), dashes, dots and digits, so any marker written into the name would collide with the word it marks. (namespace x) is a field read and cannot.

The namespace marking a **lexeme** — a surface form exactly as a model or a person
wrote it, before anything decided what it means.  A namespace rather than a spelling
because a lexeme's own text is unconstrained: it carries apostrophes (`fool's_gold`),
dashes, dots and digits, so any marker written *into* the name would collide with the
word it marks.  `(namespace x)` is a field read and cannot.
sourceraw docstring

lexeme?clj

(lexeme? x)

A lexeme: lex/fool's_gold. Parse input, and the only role whose text this makes no claim about — what a person typed is not ours to spell.

Every other namespace stays invisible to the role checks: nm reads the name half, so agg/count and set/forwardRule are read as the predicates count and forwardRule. lex is the one namespace that decides a role.

A lexeme: `lex/fool's_gold`.  Parse input, and the only role whose text this makes no
claim about — what a person typed is not ours to spell.

Every other namespace stays invisible to the role checks: `nm` reads the name half, so
`agg/count` and `set/forwardRule` are read as the predicates `count` and `forwardRule`.
`lex` is the one namespace that decides a role.
sourceraw docstring

literalsclj

(literals sentence)
(literals role form)

The [role literal] pairs whose functor names a predicateapplied-literals without the variable-functor positions, which are patterns and name nothing these invariants can judge. This is the set of functors an author named, and what every check below reads.

The `[role literal]` pairs whose functor **names a predicate** — `applied-literals`
without the variable-functor positions, which are patterns and name nothing these
invariants can judge.  This is the set of functors an author named, and what every
check below reads.
sourceraw docstring

messageclj

(message {:keys [class role symbol literal]})

One problems* map rendered as the line a rejection carries. Every message names the offending symbol, the frame it sits in and the spelling to write instead: whoever reads it is mid-repair, and a violation reported without its fix is a second lookup.

One `problems*` map rendered as the line a rejection carries.  Every message names
the offending symbol, the frame it sits in and the spelling to write instead: whoever
reads it is mid-repair, and a violation reported without its fix is a second lookup.
sourceraw docstring

min-by-content-keyclj

(min-by-content-key keyfn coll)
(min-by-content-key keyfn cmp coll)

The sort-by-content-key-least element of coll(first (sort-by-content-key keyfn cmp coll)) in a single pass, building the key once per element where the sort would build it once and then discard all but the first. Ties keep the earliest arrival, exactly as the stable sort's first would. nil for an empty coll. cmp defaults to compare-form.

The `sort-by-content-key`-least element of `coll` — `(first (sort-by-content-key keyfn cmp coll))`
in a single pass, building the key once per element where the sort would build it once
and then discard all but the first.  Ties keep the earliest arrival, exactly as the
stable sort's `first` would.  nil for an empty `coll`.  `cmp` defaults to `compare-form`.
sourceraw docstring

name-keyclj

(name-key x)

x as an ordering key where the value is a scalar — a symbol, keyword, string or number. str on one of those cannot collapse: the print bounds elide a collection and never a name, so a scalar key is safe as it stands and this is str.

What it adds is that the scalar is a claim rather than an assumption. str honours the print vars exactly as pr-str does, so a key that turns out to be a sentence, a NAT or a binding map collapses under a REPL's *print-length* and the tie it was breaking falls back to arrival order — silently, since both readings are legal strings. A collection reaching here is handed to print-key instead, which is the guarded answer for one, so a NAT arriving where a symbol was expected is keyed safely rather than wrongly.

Cheap where print-key is not: no binding frame, no printer, so a plain sort-by over scalars needs no decorating. compare-form is still the first thing to reach for where the order may be structural; these two are for a key that must be a Comparable String.

`x` as an ordering key where the value is a **scalar** — a symbol, keyword, string or
number.  `str` on one of those cannot collapse: the print bounds elide a *collection*
and never a name, so a scalar key is safe as it stands and this is `str`.

What it adds is that the scalar is a claim rather than an assumption.  `str` honours
the print vars exactly as `pr-str` does, so a key that turns out to be a sentence, a
NAT or a binding map collapses under a REPL's `*print-length*` and the tie it was
breaking falls back to arrival order — silently, since both readings are legal strings.
A collection reaching here is handed to `print-key` instead, which is the guarded
answer for one, so a NAT arriving where a symbol was expected is keyed safely rather
than wrongly.

Cheap where `print-key` is not: no binding frame, no printer, so a plain `sort-by` over
scalars needs no decorating.  `compare-form` is still the first thing to reach for
where the order may be structural; these two are for a key that must be a `Comparable`
String.
sourceraw docstring

policiesclj

What a KB does with a naming violation, and the one line each is for.

A bulk path is not on this list because it does not consult it: a corpus import builds records directly and never asks (docs/naming.md, "The two doors"). What it does instead is report — an operator learns the refused fraction at load time, from a count rather than from a failed experiment a year later.

What a KB does with a naming violation, and the one line each is for.

A bulk path is not on this list because it does not consult it: a corpus import builds
records directly and never asks (`docs/naming.md`, "The two doors").  What it does
instead is *report* — an operator learns the refused fraction at load time, from a
count rather than from a failed experiment a year later.
sourceraw docstring

predicate?clj

(predicate? x)
source

(print-key x)

x printed as a content key: pr-str with the print bounds released.

The one home for a printed ordering key. compare-form is the cheaper answer and the one to reach for first, but a few keys are printed on purpose — a Comparable String whose lexicographic order is the contract, or a tuple mixing a form with a rank. Every one of them owes this guard, and the reason is the paragraph above: an ambient *print-length* / *print-level* — a REPL's, typically — elides two long sentences to one prefix, the key collapses, and the tie falls back to the enumeration order the content key exists to keep out. A short sentence is not safe either: *print-length* 3 prints (arg parentOf 1 person) and (arg parentOf 1 animal) as the same string.

*print-meta* is bound off with them, so a form carrying metadata keys the same as one that does not — the metadata is no part of what a sentence says.

One binding frame per call, which is why a caller ordering a large collection binds once around the whole sort instead and prints inside it. sort_by_content_key_test scans the sources for a printed key that reaches neither this fn nor such a frame.

`x` printed as a content key: `pr-str` with the print bounds released.

**The one home for a printed ordering key.**  `compare-form` is the cheaper answer
and the one to reach for first, but a few keys are printed on purpose — a
`Comparable` String whose lexicographic order is the contract, or a tuple mixing a
form with a rank.  Every one of them owes this guard, and the reason is the paragraph
above: an ambient `*print-length*` / `*print-level*` — a REPL's, typically — elides two
long sentences to one prefix, the key collapses, and the tie falls back to the
enumeration order the content key exists to keep out.  A short sentence is not safe
either: `*print-length*` 3 prints `(arg parentOf 1 person)` and `(arg parentOf 1 animal)`
as the same string.

`*print-meta*` is bound off with them, so a form carrying metadata keys the same as one
that does not — the metadata is no part of what a sentence says.

One binding frame per call, which is why a caller ordering a large collection binds
once around the whole sort instead and prints inside it.  `sort_by_content_key_test`
scans the sources for a printed key that reaches neither this fn nor such a frame.
sourceraw docstring

problem-classesclj

What a naming violation is, as a keyword, with the human line under it. A rejection reads as prose, but a caller that counts them needs to group without parsing English — an operator auditing a corpus wants five numbers, not eleven million sentences — so the class is the datum and the message is rendered from it.

What a naming violation *is*, as a keyword, with the human line under it.  A rejection
reads as prose, but a caller that counts them needs to group without parsing English —
an operator auditing a corpus wants five numbers, not eleven million sentences — so the
class is the datum and the message is rendered from it.
sourceraw docstring

problemsclj

(problems sentence context)

Checkable naming violations for a sentence in a context (seq of strings): the context's own name, then every literal's functor (outermost frame first), then every literal's atomic symbol arguments, then any ist context slot, then the dotted rest marker where it cannot appear.

This is a check on the shape of a name, not on whether the name is worth having. A unary snake_case functor is a well-formed type name, so (implies (penguin ?x) (has_black_and_white_feathers ?x)) passes here, and so would capable_of_swimming or thermoregulates_via_blubber_and_feathers — each is exactly what the invariants say a type looks like. Nothing about a symbol distinguishes a type the ontology wants from a one-off coined for a single sentence, so nothing here can refuse the second: judging that needs the KB's existing vocabulary, which is a separate question asked elsewhere. Read this as a guard against misnamed content, never as a guard against vocabulary fragmentation.

Checkable naming violations for a sentence in a context (seq of strings): the
context's own name, then every literal's functor (outermost frame first), then every
literal's atomic symbol arguments, then any `ist` context slot, then the dotted rest
marker where it cannot appear.

**This is a check on the shape of a name, not on whether the name is worth having.**
A *unary* snake_case functor is a well-formed type name, so
`(implies (penguin ?x) (has_black_and_white_feathers ?x))` passes here, and so would
`capable_of_swimming` or `thermoregulates_via_blubber_and_feathers` — each is exactly
what the invariants say a type looks like.  Nothing about a symbol distinguishes a
type the ontology wants from a one-off coined for a single sentence, so nothing here
can refuse the second: judging that needs the KB's existing vocabulary, which is a
separate question asked elsewhere.  Read this as a guard against *misnamed* content,
never as a guard against vocabulary fragmentation.
sourceraw docstring

problems*clj

(problems* sentence context)

Checkable naming violations for a sentence in a context, as data: a vector of {:class :role :symbol :literal} maps in the order problems reports them. :class is one of problem-classes, :role the frame the offending literal sits in, :symbol the name that broke the convention, and message renders the line.

Data rather than prose because the two callers want different halves of it. assert wants the sentence it refused spelled out; an audit over a whole corpus wants to group — how many violations, of which class, over how many distinct spellings — and a message that embeds the literal is unique per record, so counting them counts records. Rendering is therefore separate and paid only where a message is read.

Checkable naming violations for a sentence in a context, as **data**: a vector of
`{:class :role :symbol :literal}` maps in the order `problems` reports them.  `:class`
is one of `problem-classes`, `:role` the frame the offending literal sits in, `:symbol`
the name that broke the convention, and `message` renders the line.

Data rather than prose because the two callers want different halves of it.  `assert`
wants the sentence it refused spelled out; an audit over a whole corpus wants to
*group* — how many violations, of which class, over how many distinct spellings — and
a message that embeds the literal is unique per record, so counting them counts
records.  Rendering is therefore separate and paid only where a message is read.
sourceraw docstring

query-context?clj

(query-context? x)

Is x a query context — a reading mode wearing a context's spelling? See query-contexts for the roster and what each one reads.

Is `x` a query context — a reading mode wearing a context's spelling?  See
`query-contexts` for the roster and what each one reads.
sourceraw docstring

query-contextsclj

The query contexts: three Cx… symbols naming a reading mode rather than a place.

Cyc reifies InferencePSC / EverythingPSC as contexts you can assert into. Here scope is a property of the read (docs/from-cyc.md), so these are resolved at the read door and never reach the engine — nothing is stored in one, no genlCx edge names one, and core/contexts does not list them. Each names one of the readings the engine already had and could not spell:

symbolbeliefwhose view must hold the answer
CxEverythingignored— (not a view question at all)
CxInferencefollowedevery literal in one view, handed back as ?ctx
CxNothingfollowed (vacuously)the empty view: the provers alone

A variable context (?ctx, the default of every short arity) is none of the three. It follows belief like the last two and filters by context like none of them: it is existential per literal rather than over the derivation, so it can join two facts no single context sees (docs/contexts.md). CxInference is that reading made joint, which is why it is a fourth spelling and not a rename of the default.

These are two axes and not a ladder. CxEverything alone stops following belief, which makes it a different kind of question — its answers are not belief claims — while ?ctx, CxInference and an ordinary context all ask what the KB holds and differ only in whose view has to hold it. A reader who takes the roster for an ordered list concludes that ?ctx is a near neighbour of CxEverything, and it is not.

Spelled Cx… because they stand where a context stands, and deliberately left in context?, which is spelling alone and stays that way: a role-read asking what a symbol looks like must not have to know this roster. What refuses them is the write side, where the difference between a place and a reading is an invariant rather than a naming policy — core/assert's context slot, and the genlCx argument slots at vaelii.impl.wff.

The **query contexts**: three `Cx…` symbols naming a *reading mode* rather than a
place.

Cyc reifies `InferencePSC` / `EverythingPSC` as contexts you can assert into.
Here scope is a property of the read (docs/from-cyc.md), so these are resolved at the
read door and **never reach the engine** — nothing is stored in one, no `genlCx` edge
names one, and `core/contexts` does not list them.  Each names one of the readings the
engine already had and could not spell:

| symbol | belief | whose view must hold the answer |
|---|---|---|
| `CxEverything` | **ignored** | — (not a view question at all) |
| `CxInference` | followed | every literal in **one** view, handed back as `?ctx` |
| `CxNothing` | followed (vacuously) | the empty view: the provers alone |

A **variable** context (`?ctx`, the default of every short arity) is none of the three.
It follows belief like the last two and filters by context like none of them: it is
existential *per literal* rather than over the derivation, so it can join two facts no
single context sees (docs/contexts.md).  `CxInference` is that reading made joint, which
is why it is a fourth spelling and not a rename of the default.

These are **two axes and not a ladder**.  `CxEverything` alone stops following belief,
which makes it a different kind of question — its answers are not belief claims — while
`?ctx`, `CxInference` and an ordinary context all ask what the KB holds and differ only in
whose view has to hold it.  A reader who takes the roster for an ordered list concludes
that `?ctx` is a near neighbour of `CxEverything`, and it is not.

Spelled `Cx…` because they stand where a context stands, and deliberately left **in**
`context?`, which is spelling alone and stays that way: a role-read asking what a symbol
looks like must not have to know this roster.  What refuses them is the write side,
where the difference between a place and a reading is an invariant rather than a naming
policy — `core/assert`'s context slot, and the `genlCx` argument slots at
`vaelii.impl.wff`.
sourceraw docstring

sense?clj

(sense? x)

A disambiguated type.

A disambiguated type.
sourceraw docstring

sort-by-content-keyclj

(sort-by-content-key keyfn coll)
(sort-by-content-key keyfn cmp coll)

coll ordered by (keyfn element) under cmp — the decorate-sort-undecorate the engine's content orders share, in one place. It closes at once the three costs the scattered sort-by <expensive-key> sites each paid:

  • The key is built once per element, not once per comparison. sort-by calls its key fn from inside the comparator, so a plain (sort-by keyfn coll) rebuilds the key ~2·n·log₂n times; here one mapv decorates each element with its key, the pairs sort on the key alone, and the key is stripped. When the key is a get-sentex per antecedent, a pr-str, or a taxonomy-closure read, that is the difference between n builds and n·log n.
  • Below two there is nothing to order — a collection of zero or one is already in its own order and the key is what orders, so no key is built at all. This is the shape supporting-justifications on a one-justification fact meets on every proof hop.
  • cmp defaults to compare-form — structural, so no String is printed to compare two forms. Pass compare when the key is a pre-built Comparable tuple (a [rank …] priority vector, or a print-key whose lexicographic order is the contract). This does not bind the print vars for you: a printed key is built by the caller's keyfn, so print-key is where that guard lives.

Stable: sort-by keeps equal-keyed elements in coll's order, so a tie falls to arrival only after the content key has had its say — never onto a handle.

`coll` ordered by `(keyfn element)` under `cmp` — the decorate-sort-undecorate the
engine's content orders share, in one place.  It closes at once the three costs the
scattered `sort-by <expensive-key>` sites each paid:

* **The key is built once per element, not once per comparison.**  `sort-by` calls its
  key fn from inside the comparator, so a plain `(sort-by keyfn coll)` rebuilds the key
  ~2·n·log₂n times; here one `mapv` decorates each element with its key, the pairs sort
  on the key alone, and the key is stripped.  When the key is a `get-sentex` per
  antecedent, a `pr-str`, or a taxonomy-closure read, that is the difference between n
  builds and n·log n.
* **Below two there is nothing to order** — a collection of zero or one is already in
  its own order and the key is what orders, so no key is built at all.  This is the
  shape `supporting-justifications` on a one-justification fact meets on every proof hop.
* **`cmp` defaults to `compare-form`** — structural, so no String is printed to compare
  two forms.  Pass `compare` when the key is a pre-built `Comparable` tuple (a
  `[rank …]` priority vector, or a `print-key` whose lexicographic order is the
  contract).  This does **not** bind the print vars for you: a printed key is built by
  the caller's `keyfn`, so `print-key` is where that guard lives.

Stable: `sort-by` keeps equal-keyed elements in `coll`'s order, so a tie falls to
arrival only after the content key has had its say — never onto a handle.
sourceraw docstring

tallyclj

(tally t sentence context)

Fold one sentence's violations into t. Counts and classes only, never spellings: a corpus large enough to need a bulk path has a vocabulary large enough that holding its distinct offending names would cost more than the load (vaelii.bench.survey's naming audit is where that question is asked).

Fold one sentence's violations into `t`.  Counts and classes only, never spellings: a
corpus large enough to need a bulk path has a vocabulary large enough that holding its
distinct offending names would cost more than the load
(`vaelii.bench.survey`'s `naming` audit is where that question is asked).
sourceraw docstring

tally-lineclj

(tally-line t)

The one line a load prints about t, or nil when the front door agrees with the corpus — which is the common case and deserves no output at all.

The one line a load prints about `t`, or nil when the front door agrees with the
corpus — which is the common case and deserves no output at all.
sourceraw docstring

type-symbol?clj

(type-symbol? x)

A type: bare snake_case (dog, physical_object) or a sense (abrasive-grit). Both are unary predicates — a sense is a type that says which sense it is.

A type: bare snake_case (`dog`, `physical_object`) or a sense (`abrasive-grit`).
Both are unary predicates — a sense is a type that says which sense it is.
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